Commit graph

53420 commits

Author SHA1 Message Date
Robert Griesemer 7ec0ec3645 go/types, types2: skip comparison for operands with invalid types
Fixes #54405.

Change-Id: Ia7b2709b83966fa080e41e3d4818527d1e8b49f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/424054
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-08-16 01:11:27 +00:00
Damien Neil e3c2e4cb7d net/http: make Request.WithContext documentation less prescriptive
WithContext makes a shallow copy of a Request, and Clone makes a
deep copy. Both set the context of the new request. The distinction
between the two is clear, and it doesn't seem useful or necessary
to say that "it's rare to need WithContext".

Also update a couple locations that mention WithContext to mention
Clone as well.

Fixes #53413.

Change-Id: I89e6ddebd7d5ca6573e522fe48cd7f50cc645cdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/412778
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2022-08-15 21:54:27 +00:00
Robert Findley de0f4d190f go/types, types2: don't build unnecessary error strings in implements
When accessing (*Checker).implements from types.AssignableTo or
types.ComparableTo, we don't need to build error strings -- they won't
be used.

This string manipulation showed up as a hot spot in gopls completion,
which checks a lot of type predicates when searching for candidate
completions.

This CL yields the following results for gopls' completion benchmarks:

StructCompletion-8         24.7ms ±34%  26.0ms ±17%     ~     (p=0.447 n=10+9)
ImportCompletion-8         1.41ms ± 2%  1.45ms ± 4%   +2.42%  (p=0.027 n=8+9)
SliceCompletion-8          27.0ms ±18%  25.2ms ± 3%   -6.67%  (p=0.008 n=9+8)
FuncDeepCompletion-8       57.6ms ± 4%  22.4ms ± 4%  -61.18%  (p=0.000 n=8+9)
CompletionFollowingEdit-8   157ms ±13%   103ms ±15%  -34.70%  (p=0.000 n=10+10)

Notably, deep completion (which searches many candidates) is almost 3x
faster after this change.

Fixes #54172

Change-Id: If8303a411aed3a20bd91f7b61e346d703084166c
Reviewed-on: https://go-review.googlesource.com/c/go/+/423360
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-15 20:41:00 +00:00
Martin Möhrmann 7b45edb450 bytes: add Clone function
The new Clone function returns a copy of b[:len(b)]
for the input byte slice b.
The result may have additional unused capacity.
Clone(nil) returns nil.

Fixes #45038

Change-Id: I0469a202d77a7b491f1341c08915d07ddd1f0300
Reviewed-on: https://go-review.googlesource.com/c/go/+/359675
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-15 19:17:20 +00:00
Martin Möhrmann 69a8954282 runtime: document GODEBUG=cpu.* in runtime package
So far was only documented in doc/diagnostics.

Fixes: #54183

Change-Id: Iab67a1500547f30325453c614a2f2f6621dfadb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/423275
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2022-08-15 19:15:11 +00:00
Amit Saha 95c125a44a net/http: allow zero-valued Expires in Cookie.Valid
The value of Expires is only checked when a value is set.

This fixes the bug that a cookie with a zero-valued Expire
was considered invalid, even though Expires is an optional
field.

Fixes #52989

Change-Id: I206c50e9b6ea2744a92c74673d589ce2aaa62670
Reviewed-on: https://go-review.googlesource.com/c/go/+/407654
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-15 18:58:51 +00:00
Alexander Yastrebov 05ff045dfe net/http: add Server.DisableOptionsHandler for custom handling of OPTIONS *
Fixes #41773

Change-Id: I432ad5410d5e3bb0aff3a6e0eea6906ab1b214e2
GitHub-Last-Rev: 57d1ee249d
GitHub-Pull-Request: golang/go#49014
Reviewed-on: https://go-review.googlesource.com/c/go/+/356410
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: hopehook <hopehook@qq.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-15 18:57:35 +00:00
xiongwy12 f7e6986d6b cmd/internal/obj: remove redundant code in genFuncInfoSyms
The length of slice hashedsyms is always 0, because it's not used after defined

Change-Id: Iba8e263aedfa403d5688678a1b37c2be3119eb7f
GitHub-Last-Rev: c236c4a482
GitHub-Pull-Request: golang/go#53450
Reviewed-on: https://go-review.googlesource.com/c/go/+/413234
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: guangyuan zhou <zhouguangyuan@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-15 18:52:17 +00:00
Tobias Klauser 8ec1aa889f net: use testenv.SkipIfOptimizationOff in TestAllocs
Use the helper added by CL 422038 instead of manually detecting the
noopt builder.

Change-Id: I353f1a9d5f0184d73869520eb1ae8d0bdbbe2006
Reviewed-on: https://go-review.googlesource.com/c/go/+/423855
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-15 18:44:19 +00:00
Russ Cox 1d66144bfd build: update comments about Go 1.4 in make.bash, make.bat, make.rc
A few lingering references to Go 1.4 remain.
Fix them, and document the ones that should stay.

For #44505.
Fixes #54301.

Change-Id: Ieb9c0f08e4d1890ea3fdfd9c8df5493934ae7493
Reviewed-on: https://go-review.googlesource.com/c/go/+/423354
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-08-15 18:40:54 +00:00
cuiweixie a13903562d cmd/compile/internal/ssagen: gofmt -w -s ssa.go
Change-Id: Ie169c226e8973c8b504412cc0ac1f14abcdfdb1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/423755
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-08-15 17:51:36 +00:00
Cuong Manh Le 4a4e206884 test: fix issue53702.go for noopt builder
The test requires inlining happens.

Updates #53702

Change-Id: I0d93b5e29e271ace4098307b74c40c0e06d975e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/423834
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-15 17:50:32 +00:00
Cuong Manh Le e99f285d52 cmd/compile: fix ICE when checking implicit dot for method call
CL 414836 limited the check for implicit dot for method call enabled by
a type bound. However, the checking condition for ODOTMETH only is not
right. For example, for promoted method, we have a OXDOT node instead,
and we still have to check for implicit dot in this case.

However, if the base type and embedded types have the same method name,
e.g in issue #53419, typecheck.AddImplicitDots will be confused and
result in an ambigus selector.

To fix this, we ensure methods for the base type are computed, then only
do the implicit dot check if we can find a matched method.

Fixes #54348

Change-Id: Iefe84ff330830afe35c5daffd499824db108da23
Reviewed-on: https://go-review.googlesource.com/c/go/+/422274
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-08-15 17:49:19 +00:00
Alan Donovan 1f833e4a1b go/constant: share the empty string
This saves 11,000 allocations when loading the standard library
in golang.org/x/tools/go/ssa form.

Change-Id: I8aa32b0641c1a3dde29e6ee76c760006035dd56d
Reviewed-on: https://go-review.googlesource.com/c/go/+/423934
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2022-08-15 17:42:12 +00:00
Wayne Zuo c8000a18d6 cmd/compile,math: remove all sqrt assembly code
This CL make math.sqrt an intrinsic function, math.Sqrt is not affected
since compiler can inline it. With this change, we can remove all assembly
code for math.Sqrt that aims to speed up indirect call. The go compiler can
generate same or faster code (with regabi) for indirect call.

Benchmark on amd64:
name                 old time/op  new time/op  delta
SqrtIndirect         2.60ns ± 3%  1.03ns ± 4%  -60.24%  (p=0.000 n=10+10)
SqrtLatency          3.40ns ± 1%  3.32ns ± 1%   -2.26%  (p=0.000 n=10+8)
SqrtIndirectLatency  6.09ns ± 0%  3.31ns ± 0%  -45.67%  (p=0.000 n=10+10)
SqrtGoLatency        36.1ns ± 6%  34.6ns ± 1%     ~     (p=0.101 n=10+10)
SqrtPrime            2.53µs ± 2%  2.55µs ± 6%     ~     (p=0.398 n=9+9)

Change-Id: If4be0f242c1d9d4feca7d269fc9cd6e6066f163d
Reviewed-on: https://go-review.googlesource.com/c/go/+/421074
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-15 17:07:57 +00:00
Wayne Zuo 09932f95f5 cmd/compile: combine more constant stores on amd64
Fixes #53324

Change-Id: I06149d860f858b082235e9d80bf0ea494679b386
Reviewed-on: https://go-review.googlesource.com/c/go/+/411614
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-15 16:19:21 +00:00
Cuong Manh Le 8adc63b3eb Revert "runtime/trace: add missing events for the locked g in extra M."
This reverts commit ea9c3fd42d.

Reason for revert: break linux/ricsv64, openbsd/arm, illumos/amd64 builders

Change-Id: I98479a8f63e76eed89a0e8846acf2c73e8441377
Reviewed-on: https://go-review.googlesource.com/c/go/+/423437
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-15 15:22:28 +00:00
ted f1b1557cf3 internal/cpu: detect sha-ni instruction support for AMD64
addresses proposal #53084
    required by sha-256 change list developed for #50543

Change-Id: I5454d746fce069a7a4993d70dc5b0a5544f8eeaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/408794
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@google.com>
2022-08-15 15:15:10 +00:00
WANG Xuerui 2c5b174616 cmd/link: recognize the new R_LARCH_32_PCREL type on loong64
Due to the latest binutils change [1], at least for certain 32-bit
relocs in .eh_frame section, this new type of relocation record is
emitted, leading to breakage on systems with bleeding-edge toolchain
when trying to link with object(s) with such new-style relocs.

Simply treating it the same as the existing reloc types seems enough.

Fixes #54222

[1]: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f09482a8747b6fd4c2d59a6a64677d3a3fe1e092

Change-Id: I876d6711d5d4a674bead37e57f9503f1622d1136
Reviewed-on: https://go-review.googlesource.com/c/go/+/420983
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-08-15 13:11:25 +00:00
Mike Faraponov 03fb5d7574 crypto/tls: remove unused hashForClientCertificate param
Change-Id: I86af2508a31ea1e79d362c22ff4fac8900536761
GitHub-Last-Rev: d2a1ddccbd
GitHub-Pull-Request: golang/go#52328
Reviewed-on: https://go-review.googlesource.com/c/go/+/399829
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2022-08-14 00:26:03 +00:00
djdv beaa5717ba make.bat: handle spaces in path when determining bootstrap version
Single quotes don't account for whitespace in this context, which causes
output to look like this:

$ ./make.bat
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Building Go cmd/dist using C:\Program Files\Go. (go version =)

When it should look like this:

Building Go cmd/dist using C:\Program Files\Go. (go1.19 windows/amd64)

For #44505.

Change-Id: I71328add5c74bd2829c0e23224cfa6252395ff2c
GitHub-Last-Rev: a01fda6b52
GitHub-Pull-Request: golang/go#54270
Reviewed-on: https://go-review.googlesource.com/c/go/+/421356
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-14 00:22:21 +00:00
Cuong Manh Le 45c748f7e6 test: add test case for issue 53702
The issue is expected to be fixed when Unified IR is enabled by default,
so adding a test to make sure thing works correctly.

Updates #53702

Change-Id: Id9d7d7ca4506103df0d10785ed5ee170d69988ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/423434
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-14 00:14:04 +00:00
Ian Lance Taylor 7acbbbee94 net: ignore edns0 option in resolv.conf
We use EDNS(0) by default. No need to fall back to netdns=cgo if we
see a explicit request for EDNS(0) in resolv.conf.

For #51153

Change-Id: I135363112e3de43ce877aad45aba71d1448068b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/415579
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2022-08-14 00:13:15 +00:00
Pure White 59865f1420 internal/cpu: fix cpu cacheLineSize for arm64 darwin(a.k.a. M1)
The existing value for M1 is 64, which is the same as other arm64 cpus.
But the correct cacheLineSize for M1 should be 128, which can be
verified using the following command:

$ sysctl -a hw | grep cachelinesize
hw.cachelinesize: 128

Fixes #53075

Change-Id: Iaa8330010a4499b9b357c70743d55aed6ddb8588
GitHub-Last-Rev: df87eb9c50
GitHub-Pull-Request: golang/go#53076
Reviewed-on: https://go-review.googlesource.com/c/go/+/408576
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Martin Möhrmann <martin@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@google.com>
2022-08-14 00:06:23 +00:00
Andy Pan 2f6783c098 runtime: fix a comment typo in runqget()
Change-Id: I79695e1cfda3b4cd911673f6e14dc316c451e2ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/423436
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-12 20:40:05 +00:00
doujiang24 ea9c3fd42d runtime/trace: add missing events for the locked g in extra M.
Extra Ms may lead to the "no consistent ordering of events possible" error when parsing trace file with cgo enabled, since:
1. The gs in the extra Ms may be in `_Gdead` status while starting trace by invoking `runtime.StartTrace`,
2. and these gs will trigger `traceEvGoSysExit` events in `runtime.exitsyscall` when invoking go functions from c,
3. then, the events of those gs are under non-consistent ordering, due to missing the previous events.

Add two events, `traceEvGoCreate` and `traceEvGoInSyscall`, in `runtime.StartTrace`, will make the trace parser happy.

Fixes #29707

Change-Id: I7cc4b80822d2c46591304a59c9da2c9fc470f1d0
GitHub-Last-Rev: 445de8eaf3
GitHub-Pull-Request: golang/go#53284
Reviewed-on: https://go-review.googlesource.com/c/go/+/411034
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-12 18:26:31 +00:00
zhangjian b6f87b0755 test: remove unused code in run.go
Change-Id: Ie2a77a9643697cfda4376db606711c09da220405
GitHub-Last-Rev: ff1cf0b9d8
GitHub-Pull-Request: golang/go#53902
Reviewed-on: https://go-review.googlesource.com/c/go/+/417734
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-08-12 18:15:28 +00:00
Matthew Dempsky 7f3569c33a cmd/compile/internal/ssa: include "ppc64" in has-regabi arches list
While here, rename helper function to follow Go naming idioms:
https://github.com/golang/go/wiki/CodeReviewComments#initialisms

Fixes #53456.

Change-Id: I041dd25968e192ea2b430d58e3348626a970f92b
Reviewed-on: https://go-review.googlesource.com/c/go/+/422957
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-08-12 17:54:26 +00:00
Damien Neil ebbf2b44c5 net/http: add a test to verify form tempfiles are deleted
The HTTP/1 server deletes multipart form tempfiles after ServeHTTP
returns, but the HTTP/2 server does not. Add a test to verify
cleanup happens in both cases, temporarily disabled for the
HTTP/2 path.

For #20253
Updates #25965

Change-Id: Ib753f2761fe73b29321d9d4337dbb5090fd193c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/423194
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2022-08-12 17:25:47 +00:00
Ludi Rehak f3c39a83a3 all: replace hand-rolled atomicBool types with atomic.Bool
Two packages construct atomic booleans from atomic integers.
Replace these implementations with the new atomic.Bool type.
Indeed, these packages were the impetus for the new atomic.Bool
type, having demonstrated a need to access boolean values
atomically.

Change-Id: I6a0314f8e7d660984a6daf36a62ed05a0eb74b2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/411400
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2022-08-12 16:41:47 +00:00
Damien Neil f001df540b net/http/httputil: don't insert default User-Agent header in proxied requests
When ReverseProxy forwards a request with no User-Agent header, leave
the header in the forwarded request blank rather than inserting the
default Go HTTP clent User-Agent.

We already did this for NewSingleHostReverseProxy; generalize it to
every ReverseProxy.

Change-Id: Id81a230cb8d384acdfae190b78a4265d80720388
Reviewed-on: https://go-review.googlesource.com/c/go/+/407375
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-12 16:38:52 +00:00
Damien Neil 1513e57b70 net/http/httputil: add X-Forwarded-{Host,Proto} headers in ReverseProxy
X-Forwarded-Host contains the original request's host.

X-Forwarded-Proto contains "http" or "https", depending on whether the
original request was made on a TLS-secured connection.

Setting either header to nil in Director disables adding the header,
same as for X-Forwarded-For.

Fixes #50465.

Change-Id: If8ed1f48d83f8ea0389c53519bc7994cb53891db
Reviewed-on: https://go-review.googlesource.com/c/go/+/407414
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2022-08-12 16:38:28 +00:00
darmiel 2cf49a76b6 net/http: trim cookie names
The current implementation ignores cookies where the
cookie name starts or ends with a space. For example,

name =value

is ignored.

I have come across pages that send cookies in this weird format.
I tested with the latest versions of Firefox, Safari and Chrome,
all of which accept cookies in this format.

To do this, I remove leading and trailing spaces from the
cookie name after cutting at '='.

Change-Id: I8fd0c37a2113b6ce75712dd43607d1ea55e86c68
GitHub-Last-Rev: 368f50fcb4
GitHub-Pull-Request: golang/go#52121
Reviewed-on: https://go-review.googlesource.com/c/go/+/397734
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2022-08-12 16:22:39 +00:00
Cuong Manh Le 57c1edcaec runtime: mark atomic methods which call nosplit functions as nosplit
Fixes #54411

Change-Id: I482ebca7365862bfb82a9daf8111c6f395aa1170
Reviewed-on: https://go-review.googlesource.com/c/go/+/423255
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12 15:47:04 +00:00
Cuong Manh Le a2af095699 runtime: run "gofmt -s -w"
Change-Id: I7eb3de35d1f1f0237962735450b37d738966f30c
Reviewed-on: https://go-review.googlesource.com/c/go/+/423254
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-12 15:45:17 +00:00
Andy Pan f67c766069 cmd/internal/obj/ppc64: eliminate dead code from asm9.go
Change-Id: Ie59703ea7315a3f8efa1f543a8ca0afecff014d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/421754
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-08-12 12:26:45 +00:00
Michael Pratt 8cb350d69a runtime: synchronize P wakeup and dropping Ps
CL 310850 dropped work re-checks on non-spinning Ms to fix #43997.

This introduced a new race condition: a non-spinning M may drop its P
and then park at the same time a spinning M attempts to wake a P to
handle some new work. The spinning M fails to find an idle P (because
the non-spinning M hasn't quite made its P idle yet), and does nothing
assuming that the system is fully loaded. This results in loss of work
conservation. In the worst case we could have a complete deadlock if
injectglist fails to wake anything just as all Ps are going idle.

sched.needspinning adds new synchronization to cover this case. If work
submission fails to find a P, it sets needspinning to indicate that a
spinning M is required. When non-spinning Ms prepare to drop their P,
they check needspinning and abort going idle to become a spinning M
instead. This addresses the race without extra spurious wakeups. In the
normal (non-racing case), an M will become spinning via the normal path
and clear the flag.

injectglist must change in addition to wakep because it is a similar
form of work submission, notably used following netpoll at a point when
we might not have a P that would guarantee the work runs.

Fixes #45867

Change-Id: Ieb623a6d4162fb8c2be7b4ff8acdebcc3a0d69a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/389014
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2022-08-12 03:22:59 +00:00
Michael Pratt 54cf1b107d runtime: convert prof.hz to atomic type
This converts several unsynchronized reads (reads without holding
prof.signalLock) into atomic reads.

For #53821.
For #52912.

Change-Id: I421b96a22fbe26d699bcc21010c8a9e0f4efc276
Reviewed-on: https://go-review.googlesource.com/c/go/+/420196
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12 01:53:44 +00:00
Michael Pratt 3121c2bf64 runtime: convert prof.signalLock to atomic type
For #53821.

Change-Id: I3e757fc6a020be10ee69459c395cb7eee49b0dfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/420195
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-08-12 01:53:29 +00:00
Michael Pratt b04e4637db runtime: convert timeHistogram to atomic types
I've dropped the note that sched.timeToRun is protected by sched.lock,
as it does not seem to be true.

For #53821.

Change-Id: I03f8dc6ca0bcd4ccf3ec113010a0aa39c6f7d6ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/419449
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-08-12 01:53:11 +00:00
Michael Pratt 09cc9bac72 runtime: convert schedt.sysmonwait to atomic type
This converts a few unsynchronized accesses.

For #53821.

Change-Id: Ie2728779111e3e042696f15648981c5d5a86ca6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/419448
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2022-08-12 01:52:46 +00:00
Michael Pratt 88ef50e662 runtime: convert schedt.gcwaiting to atomic type
Note that this replaces numerous unsynchronized loads throughout the
scheduler.

For #53821.

Change-Id: Ica80b04c9e8c184bfef186e549526fc3f117c387
Reviewed-on: https://go-review.googlesource.com/c/go/+/419447
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12 01:52:29 +00:00
Michael Pratt 1eeef5d5b4 runtime: convert schedt.nmspinning to atomic type
Note that this converts nmspinning from uint32 to int32 for consistency
with the other count fields in schedt.

For #53821.

Change-Id: Ia6ca7a2b476128eda3b68e9f0c7775ae66c0c744
Reviewed-on: https://go-review.googlesource.com/c/go/+/419446
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2022-08-12 01:52:18 +00:00
Michael Pratt 58a1dabfd1 runtime: convert schedt.npidle to atomic type
Note that this converts npidle from uint32 to int32 for consistency with
the other count fields in schedt and the type of p.id.

Note that this changes previously unsynchronized operations to
synchronized operations in:
  * handoffp
  * injectglist
  * schedtrace
  * schedEnableUser
  * sync_runtime_canSpin

For #53821.

Change-Id: I36d1b3b4a28131c9d47884fade6bc44439dd6937
Reviewed-on: https://go-review.googlesource.com/c/go/+/419445
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-08-12 01:52:06 +00:00
Michael Pratt 449691b3ef runtime: convert schedt.ngsys to atomic type
Note that this converts ngsys from uint32 to int32 to match the other
(non-atomic) counters.

For #53821.

Change-Id: I3acbfbbd1dabc59b0ea5ddc86a97e0d0afa9f80c
Reviewed-on: https://go-review.googlesource.com/c/go/+/419444
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2022-08-12 01:51:51 +00:00
Michael Pratt 0fc774a68f runtime: convert schedt.pollUntil to atomic type
Note that this converts pollUntil from uint64 to int64, the type used by
nanotime().

For #53821.

Change-Id: Iec9ec7e09d3350552561d0708ba6ea9e8a8ae7ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/419443
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12 01:49:13 +00:00
Michael Pratt 5d7d50111f runtime: convert schedt.lastpoll to atomic type
Note that this changes the type from uint64 to int64, the type used by
nanotime(). It also adds an atomic load in pollWork(), which used to use
a non-atomic load.

For #53821.

Change-Id: I6173c90f20bfdc0e0a4bc3a7b1c798d1c429fff5
Reviewed-on: https://go-review.googlesource.com/c/go/+/419442
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12 01:49:02 +00:00
Michael Pratt 98e1648823 runtime: print irrelevant IDs as nil in schedtrace
We currently print these as -1, but some are technically uint64. We can
be more explicit about their irrelevance by printing 'nil' rather than
-1.

Change-Id: I267fd8830564c75032bfe9176af59047f5a90202
Reviewed-on: https://go-review.googlesource.com/c/go/+/419441
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-08-12 01:39:40 +00:00
Michael Pratt dd8cb66d0b runtime: convert g.goid to uint64
schedt.goidgen and p.goidcache are already uint64, this makes all cases
consistent.

The only oddball here is schedtrace which prints -1 as an equivalent for
N/A or nil. A future CL will make this more explicit.

Change-Id: I489626f3232799f6ca333d0d103b71d9d3aa7494
Reviewed-on: https://go-review.googlesource.com/c/go/+/419440
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12 01:39:28 +00:00
Michael Pratt b464708b46 runtime: convert schedt.goidgen to atomic type
For #53821.

Change-Id: I84c96ade5982b8e68d1d1787bf1bfa16a17a4fb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/419439
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12 01:39:14 +00:00