Carlos Amedee [Wed, 11 Jan 2023 23:01:17 +0000 (18:01 -0500)]
[release-branch.go1.20] all: merge master (245e95d) into release-branch.go1.20
Merge List:
+ 2023-01-11 245e95dfab go/types, types2: don't look up fields or methods when expecting a type
+ 2023-01-11 18625d9bec runtime: fix incorrect comment
+ 2023-01-11 6ad27161f8 cmd/compile: better error message for when a type is in a constraint but not the type set
+ 2023-01-10 76d39ae349 cmd/link, runtime: Apple libc atfork workaround take 3
+ 2023-01-10 0a0de0fc42 runtime: revert use of __fork to work around Apple atfork bugs
+ 2023-01-10 82f09b75ca os/exec: avoid leaking an exec.Cmd in TestWaitInterrupt
+ 2023-01-09 0202ad0b3a cmd/compile: prevent IsNewObject from taking quadratic time
+ 2023-01-09 64519baf38 cmd/compile/internal/pgo: add hint to missing start_line error
+ 2023-01-09 376076f3c6 runtime: skip TestCgoPprofCallback in short mode, don't run in parallel
+ 2023-01-09 0bbd67e52f runtime/pprof: document possibility of empty stacks
+ 2023-01-09 d9f23cfe78 runtime/pprof: improve output of TestLabelSystemstack
+ 2023-01-09 8232a09e3e sync/atomic: fix the note of atomic.Store
+ 2023-01-09 841c3eb166 all: fix typos in go file comments
+ 2023-01-06 f721fa3be9 syscall: skip TestUseCgroupFD if cgroupfs not mounted
+ 2023-01-06 76ec919237 net: fix typo in hosts.go
+ 2023-01-06 660d4815ea cmd/compile: describe how Go maps to wasm implementation
+ 2023-01-05 119f679a3b crypto/tls: fix typo in cacheEntry godoc
+ 2023-01-05 d50ea217f6 cmd/cover: fix problems with "go test -covermode=atomic sync/atomic"
+ 2023-01-04 bae7d772e8 doc/go1.20: fix links to new strings functions
+ 2023-01-04 4e7c838483 crypto/internal/boring: add dev.boringcrypto README.md text
+ 2023-01-04 46e3d9d12a cmd/compile: use "satisfies" (not "implements") for constraint errors
+ 2023-01-04 79cdecc852 cmd/gofmt: fix a typo in a comment
+ 2023-01-03 9955a7e9bb README.vendor: minor updates
+ 2023-01-03 d03231d9ce doc/go1.20: fix http.ResponseController example
+ 2023-01-03 cdc73f0679 .github: suggest using private browsing in pkgsite template
Robert Findley [Wed, 11 Jan 2023 19:41:03 +0000 (14:41 -0500)]
go/types, types2: don't look up fields or methods when expecting a type
As we have seen many times, the type checker must be careful to avoid
accessing named type information before the type is fully set up. We
need a more systematic solution to this problem, but for now avoid one
case that causes a crash: checking a selector expression on an
incomplete type when a type expression is expected.
For golang/go#57522
Change-Id: I7ed31b859cca263276e3a0647d1f1b49670023a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/461577
Run-TryBot: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
Robert Griesemer [Wed, 4 Jan 2023 01:05:53 +0000 (17:05 -0800)]
cmd/compile: better error message for when a type is in a constraint but not the type set
While at it, also remove the word "constraint" in the detail explanation
of an unsatisfied constraint.
Fixes #57500.
Change-Id: I55dae1694de2cfdb434aeba9d4a3530af7aca8f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/460455 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
Russ Cox [Wed, 4 Jan 2023 14:21:14 +0000 (09:21 -0500)]
cmd/link, runtime: Apple libc atfork workaround take 3
CL 451735 worked around bugs in Apple's atfork handlers by calling
notify_is_valid_token and xpc_atfork_child at startup, so that init
code that wouldn't be safe in the child process would be warmed up in
the parent process instead, but xpc_atfork_child broke use of the xpc
library in Go programs, and xpc is internally used by various macOS
frameworks (#57263).
CL 459175 reverted that change, and then CL 459176 tried a new
approach: use __fork, which doesn't call any of the atfork handlers at all.
That worked, but an Apple engineer reviewing the change in private
email suggests that since __fork is not public API, it should be avoided.
The same engineer (with access to the source code for the xpc library)
suggests that the breakage in #57263 is caused by xpc_atfork_child
marking the library as unusable, expecting an imminent call to exec,
and that calling xpc_date_create_from_current instead would do the
necessary initialization without marking xpc as unusable.
CL 460475 reverted that change, to prepare for this one.
This CL goes back to the original “call functions to warm things up”
approach, replacing xpc_atfork_child with xpc_date_create_from_current.
The CL also updates cmd/link to use OS and SDK version 10.13.0 for
x86 macOS binaries, up from 10.9.0, also suggested by the Apple engineer.
Combined with the two warmup calls, this makes the fork hangs go away.
The minimum macOS version has been 10.13 High Sierra since Go 1.17,
so there should be no problem with writing that in the binaries too.
Russ Cox [Wed, 4 Jan 2023 14:18:02 +0000 (09:18 -0500)]
runtime: revert use of __fork to work around Apple atfork bugs
An Apple engineer suggests that since __fork is not public API,
it would be better to use a different fix. With the benefit of source code,
they suggest using xpc_date_create_from_current instead of
xpc_atfork_child. The latter sets some flags that disable certain
functionality for the remainder of the process lifetime (expecting exec),
while the former should do the necessary setup.
Reverting the __fork fix in order to prepare a clean fix based
on CL 451735 using xpc_date_create_from_current.
Bryan C. Mills [Tue, 10 Jan 2023 16:29:25 +0000 (11:29 -0500)]
os/exec: avoid leaking an exec.Cmd in TestWaitInterrupt
In CL 436655 I added a GODEBUG setting to this test process to verify
that Wait is eventually called for every exec.Cmd before it becomes
unreachable. However, the cmdHang test helpers in
TestWaitInterrupt/Exit-hang and TestWaitInterrupt/SIGKILL-hang
intentially leak a subprocess in order to simulate a leaky third-party
program, as Go users might encounter in practical use.
To avoid tripping over the leak check, we call Wait on the leaked
subprocess in a background goroutine. Since we expect the process
running cmdHang to exit before its subprocess does, the call to Wait
should have no effect beyond suppressing the leak check.
Keith Randall [Mon, 9 Jan 2023 17:49:32 +0000 (09:49 -0800)]
cmd/compile: prevent IsNewObject from taking quadratic time
As part of IsNewObject, we need to go from the SelectN[0] use of
a call to the SelectN[1] use of a call. The current code does this
by just looking through the block. If the block is very large,
this ends up taking quadratic time.
Instead, prepopulate a map from call -> SelectN[1] user of that call.
That lets us find the SelectN[1] user in constant time.
Fixes #57657
Change-Id: Ie2e0b660af5c080314f4f17ba2838510a1147f9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/461080
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Michael Pratt [Mon, 9 Jan 2023 18:59:54 +0000 (13:59 -0500)]
cmd/compile/internal/pgo: add hint to missing start_line error
Profiles only began adding Function.start_line in 1.20. If it is
missing, add a hint to the error message that they may need to profile a
build of the application built with a newer version of the toolchain.
Technically profiles are not required to come from Go itself (e.g., they
could be converted from perf), but in practice they most likely are.
Fixes #57674.
Change-Id: I87eca126d3fed0cff94bbb8dd748bd4652f88b12
Reviewed-on: https://go-review.googlesource.com/c/go/+/461195
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Ian Lance Taylor [Thu, 5 Jan 2023 02:03:46 +0000 (18:03 -0800)]
runtime: skip TestCgoPprofCallback in short mode, don't run in parallel
Fixes #54778
Change-Id: If9aef0c06b993ef2aedbeea9452297ee9f11fa06
Reviewed-on: https://go-review.googlesource.com/c/go/+/460461 Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Austin Clements [Thu, 5 Jan 2023 14:08:25 +0000 (09:08 -0500)]
runtime/pprof: document possibility of empty stacks
I spent quite a while determining the cause of empty stacks in
profiles and reasoning out why this is okay. There isn't a great place
to record this knowledge, but a documentation comment on
appendLocsForStack is better than nothing.
Updates #51550.
Change-Id: I2eefc6ea31f1af885885c3d96199319f45edb4ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/460695 Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Austin Clements [Wed, 4 Jan 2023 17:31:23 +0000 (12:31 -0500)]
runtime/pprof: improve output of TestLabelSystemstack
The current output of TestLabelSystemstack is a bit cryptic. This CL
improves various messages and hopefully simplifies the logic in the
test.
Simplifying the logic leads to three changes in possible outcomes,
which I verified by running the logic before and after this change
through all 2^4 possibilities (https://go.dev/play/p/bnfb-OQCT4j):
1. If a sample both must be labeled and must not be labeled, the test
now reports that explicitly rather than giving other confusing output.
2. If a sample must not be labeled but is, the current logic will
print two identical error messages. The new logic prints only one.
3. If the test finds no frames at all that it recognizes, but the
sample is labeled, it will currently print a confusing "Sample labeled
got true want false" message. The new logic prints nothing. We've seen
this triggered by empty stacks in profiles.
Fixes #51550. This bug was caused by case 3 above, where it was
triggered by a profile label on an empty stack. It's valid for empty
stacks to appear in a profile if we sample a goroutine just as it's
exiting (and that goroutine may have a profile label), so the test
shouldn't fail in this case.
Change-Id: I1593ec4ac33eced5bb89572a3ba7623e56f2fb3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/460516
Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com> Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Change-Id: I56281eda3b178968fbf104de1f71316c1feac64f
GitHub-Last-Rev: e91c7cee340fadfa32b0c1773e4e5cd1ca567638
GitHub-Pull-Request: golang/go#57669
Reviewed-on: https://go-review.googlesource.com/c/go/+/460767
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Shengjing Zhu [Thu, 5 Jan 2023 07:00:25 +0000 (15:00 +0800)]
syscall: skip TestUseCgroupFD if cgroupfs not mounted
When building in schroot (for building Debian package),
the cgroupfs is not mounted in schroot (only sysfs is mounted).
Change-Id: Ieddac7b2f334d58d832f5d84d81af812badf3720
Reviewed-on: https://go-review.googlesource.com/c/go/+/460539
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Change-Id: I656ea210d8ef6eaa85245cb8f463f6b4fd67e1a2
GitHub-Last-Rev: 5a93045add2f2a6885b46377c784f665ab465cfd
GitHub-Pull-Request: golang/go#57633
Reviewed-on: https://go-review.googlesource.com/c/go/+/460756 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> Reviewed-by: Damien Neil <dneil@google.com>
Than McIntosh [Thu, 22 Dec 2022 19:10:12 +0000 (14:10 -0500)]
cmd/cover: fix problems with "go test -covermode=atomic sync/atomic"
This patch fixes an elderly bug with "go test -covermode=atomic
sync/atomic". Change the cover tool to avoid adding an import of
sync/atomic when processing "sync/atomic" itself in atomic mode;
instead make direct calls to AddUint32/StoreUint32. In addition,
change the go command to avoid injecting an artificial import of
"sync/atomic" for sync/atomic itself.
Robert Griesemer [Wed, 4 Jan 2023 00:01:49 +0000 (16:01 -0800)]
cmd/compile: use "satisfies" (not "implements") for constraint errors
Per the latest spec, we distinguish between interface implementation
and constraint satisfaction. Use the verb "satisfy" when reporting
an error about failing constraint satisfaction.
This CL only changes error messages. It has no impact on correct code.
Fixes #57564.
Change-Id: I6dfb3b2093c2e04fe5566628315fb5f6bd709f17
Reviewed-on: https://go-review.googlesource.com/c/go/+/460396 Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Roland Illig [Wed, 4 Jan 2023 06:59:03 +0000 (06:59 +0000)]
cmd/gofmt: fix a typo in a comment
Change-Id: I34b2b9f9b70e39c872d5edbbda4de0fe330211f5
GitHub-Last-Rev: 723e36e11ee011c54d3ffc8125d0477c8eed25a0
GitHub-Pull-Request: golang/go#57566
Reviewed-on: https://go-review.googlesource.com/c/go/+/460457
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Dan Peterson [Mon, 5 Sep 2022 17:18:40 +0000 (14:18 -0300)]
.github: suggest using private browsing in pkgsite template
I opened #54872 without considering my browser's extensions and one of
them ended up being the cause of my issue. This seems to be a common
error.
To help that, add a suggestion to use a private/incognito tab/window
to the pkgsite issue template when reproducing issues. This probably
would have been enough for me to figure things out before opening my
issue.
Updates #54872, #47213
Change-Id: Ic61a3462cb902c91554cf9432aaae1222c6a991e
Reviewed-on: https://go-review.googlesource.com/c/go/+/427962
Run-TryBot: Dan Peterson <danp@danp.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Xiao Cui [Thu, 29 Dec 2022 00:35:13 +0000 (19:35 -0500)]
doc/go1.20: fix typos
Change-Id: Ie2e583cba9e9bec7d642e323e77fb2d9b05dc7bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/459780 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Robert Griesemer [Wed, 28 Dec 2022 22:21:50 +0000 (14:21 -0800)]
go/types, types2: use strict comparability for type set intersection
Fixes #57486.
Change-Id: I4b71199a724718886ce6d7a49e96a9ebdcbcf737
Reviewed-on: https://go-review.googlesource.com/c/go/+/459816
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Cherry Mui [Tue, 27 Dec 2022 22:29:28 +0000 (17:29 -0500)]
misc/cgo/testsanitizers: run libfuzzer tests in temp directory
The libFuzzer generated binary by default writes failure input
into the current directory. Set cmd.Dir to the temporary directory
so it won't write to GOROOT when running the test.
Change-Id: I3e4ce7e3f845be5c9f09511c36e7a9a396eafad2
Reviewed-on: https://go-review.googlesource.com/c/go/+/459556 Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Andrey Bozhko [Wed, 21 Dec 2022 22:24:05 +0000 (22:24 +0000)]
testing: rephrase the sentence about naming test files
This updates the explanation about
naming test files to be a little more clear.
Fixes #57389
Change-Id: I9b3a8e2dae5e3ad398b55624e183809b7d90864c
GitHub-Last-Rev: 9ff81b74b201ca032fd373424aa02a3fedaec008
GitHub-Pull-Request: golang/go#57399
Reviewed-on: https://go-review.googlesource.com/c/go/+/458435 Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Fahad King <fahadking750@gmail.com> Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
Cherry Mui [Wed, 21 Dec 2022 21:35:57 +0000 (16:35 -0500)]
cmd/link, runtime: use a different section for Go libfuzzer counters
Currently in libfuzzer mode, we put our counters in section
__sancov_cntrs. When linking with C/C++ code that also has fuzzer
counters, apparently the C linker combines our counters and their
counters and registers them together. But in the Go runtime we
also have code to register our counters. So the Go counters ended
up registered twice, causing problems.
Since we already have code to register our counters, put them in
a Go-specific section so it won't be combined with the C counters.
Fixes #57449.
Change-Id: If3d41735124e7e301572d4b7aecf7d057ac134c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/459055 Reviewed-by: Nicolas Hillegeer <aktau@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Russ Cox [Thu, 22 Dec 2022 14:44:56 +0000 (09:44 -0500)]
runtime: call __fork instead of fork on darwin
Issues #33565 and #56784 were caused by hangs in the child process
after fork, while it ran atfork handlers that ran into slow paths that
didn't work in the child.
CL 451735 worked around those two issues by calling a couple functions
at startup to try to warm up those child paths. That mostly worked,
but it broke programs using cgo with certain macOS frameworks (#57263).
CL 459175 reverted CL 451735.
This CL introduces a different fix: bypass the atfork child handlers
entirely. For a general fork call where the child and parent are both
meant to keep executing the original program, atfork handlers can be
necessary to fix any state that would otherwise be tied to the parent
process. But Go only uses fork as preparation for exec, and it takes
care to limit what it attempts to do in the child between the fork and
exec. In particular it doesn't use any of the things that the macOS
atfork handlers are trying to fix up (malloc, xpc, others). So we can
use the low-level fork system call (__fork) instead of the
atfork-wrapped one.
The full list of functions that can be called in a child after fork in
exec_libc2.go is:
I disassembled all of these while attached to a hung exec.test binary
and confirmed that nearly all of them are making direct kernel calls,
not using anything that the atfork handler needs to fix up.
The exceptions are ioctl, fcntl, and exit.
The ioctl and fcntl implementations do some extra work around the
kernel call but don't call any other functions, so they should still
be OK. (If not, we could use __ioctl and __fcntl instead, but without
a good reason, we should keep using the standard entry points.)
The exit implementation calls atexit handlers. That is almost
certainly inappropriate in a failed fork child, so this CL changes
that call to __exit on darwin. To avoid making unnecessary changes at
this point in the release cycle, this CL leaves OpenBSD calling plain
exit, even though that is probably a bug in the OpenBSD port
(filed #57446).
Fixes #33565.
Fixes #56784.
Fixes #57263.
Change-Id: I26812c26a72bdd7fcf72ec41899ba11cf6b9c4ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/459176 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Russ Cox [Thu, 22 Dec 2022 14:21:03 +0000 (09:21 -0500)]
runtime: revert Apple libc atfork workaround
Revert CL 451735 (1f4394a0c926), which fixed #33565 and #56784
but also introduced #57263.
I have a different fix to apply instead. Since the first fix was
never backported, it will be easiest to backport the new fix
if the new fix is done in a separate CL from the revert.
Cherry Mui [Tue, 20 Dec 2022 22:26:18 +0000 (17:26 -0500)]
runtime/internal/startlinetest: work around shared buildmode linking issue
The runtime/internal/startlinetest package contains a call to a
function defined in runtime_test. Generally this is fine as this
package is only linked in for runtime_test. Except that for "go
install -buildmode=shared std", which include all packages in std,
including this test-only internal package. In this mode, the
caller is included in the linking but the callee is not, causing
linking error. Work around it by calling
runtime_test.callerStartLine via a function pointer. The function
pointer is only set in runtime_test. In the shared std build, the
function pointer will not be set, and this is fine.
Fixes #57334.
Change-Id: I7d871c50ce6599c6ea2802cf6e14bb749deab220
Reviewed-on: https://go-review.googlesource.com/c/go/+/458696
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Cherry Mui [Tue, 20 Dec 2022 22:19:09 +0000 (17:19 -0500)]
runtime/race: add build tag to internal amd64vN packages
Only one of the runtime/race/internal/amd64vN packages should be
included in a build. Generally this is true because the
runtime/race package would import only one of them depending on
the build configuration. But for "go install -buildmode=shared std"
it includes all Go packages in std, which includes both, which
then causes link-time failure due to duplicated symbols. To avoid
this, we add build tags to the internal packages, so, depending on
the build configuation, only one package would contain buildable
go files therefore be included in the build.
For #57334.
Change-Id: I52ddc3a40e16c7d04b4dd861e9689918d27e8509
Reviewed-on: https://go-review.googlesource.com/c/go/+/458695
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Tobias Klauser [Wed, 21 Dec 2022 12:27:04 +0000 (13:27 +0100)]
doc/go1.20: fix typo
Change-Id: Ia0ce728ca18eefd835220b2076c4aa8ba00cda6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/458815
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> 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>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: David Chase <drchase@google.com>
Than McIntosh [Wed, 21 Dec 2022 16:03:16 +0000 (11:03 -0500)]
runtime/coverage: add missing file close in test support helper
The processPod() helper (invoked by processCoverTestDir, which is in
turn called by _testmain.go) was opening and reading counter data
files, but never closing them. Add a call to close the files after
they have been read.
Fixes #57407.
Change-Id: If9a489f92e4bab72c5b2df8697e14420a6f7b8f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/458835 Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Damien Neil [Wed, 21 Dec 2022 17:50:48 +0000 (09:50 -0800)]
archive/tar, archive/zip: revert documentation of ErrInsecurePath
CL 452616 disables path security checks by default, enabling them
only when GODEBUG=tarinsecurepath=0 or GODEBUG=zipinsecurepath=0
is set. Remove now-obsolete documenation of the path checks.
Damien Neil [Wed, 14 Dec 2022 17:55:06 +0000 (09:55 -0800)]
net/http/httputil: don't add X-Forwarded-{Host,Proto} after invoking Director funcs
This reverts CL 407414.
When forwarding an inbound request that contains an existing
X-Forwarded-Host or X-Forwarded-Proto header, a proxy might want
to preserve the header from the inbound request, replace it with
its own header, or not include any header at all.
CL 407414 replaces inbound X-Forwarded-{Host,Proto} headers by default,
and allows a Director func to disable sending these headers at all.
However, the Director hook API isn't sufficiently flexible to permit the
previous behavior of preserving inbound values unchanged.
The new Rewrite API does have this flexibility; users of Rewrite can
easily pick the exact behavior they want.
Revert the change to ReverseProxy when using a Director func.
Users who want a convenient way to set X-Forwarded-* headers to
reasonable values can migrate to Rewrite at their convenience,
and users depending on the current behavior will be unaffected.
For #50465.
Fixes #57132.
Change-Id: Ic42449c1bb525d6c9920bf721efbc519697f4f20
Reviewed-on: https://go-review.googlesource.com/c/go/+/457595
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
Mateusz Poliwczak [Tue, 20 Dec 2022 15:24:06 +0000 (15:24 +0000)]
net: use correct dns msg size
Set bufSize to the actual dns message size, so that the p.Start (below) gets a fully valid dns message.
Change-Id: I585e8a3d71f88db93e09bd0dbbc0875ee6de9a97
GitHub-Last-Rev: 0967be35012d2e28366e6d47eee4968c7e8d5e4a
GitHub-Pull-Request: golang/go#57392
Reviewed-on: https://go-review.googlesource.com/c/go/+/458375
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Guoqi Chen [Sun, 18 Dec 2022 21:04:48 +0000 (05:04 +0800)]
cmd/compile: sign-extend the 2nd argument of the LoweredAtomicCas32 on loong64,mips64x,riscv64
The function LoweredAtomicCas32 is implemented using the LL-SC instruction pair
on loong64, mips64x, riscv64. However,the LL instruction on loong64, mips64x,
riscv64 is sign-extended, so it is necessary to sign-extend the 2nd parameter
"old" of the LoweredAtomicCas32, so that the instruction BNE after LL can get
the desired result.
The function prototype of LoweredAtomicCas32 in golang:
func Cas32(ptr *uint32, old, new uint32) bool
When using an intrinsify implementation:
case 1: (*ptr) <= 0x80000000 && old < 0x80000000
E.g: (*ptr) = 0x7FFFFFFF, old = Rarg1= 0x7FFFFFFF
After run the instruction "LL (Rarg0), Rtmp": Rtmp = 0x7FFFFFFF
Rtmp ! = Rarg1(old) is false, the result we expect
case 2: (*ptr) >= 0x80000000 && old >= 0x80000000
E.g: (*ptr) = 0x80000000, old = Rarg1= 0x80000000
After run the instruction "LL (Rarg0), Rtmp": Rtmp = 0xFFFFFFFF_80000000
Rtmp ! = Rarg1(old) is true, which we do not expect
When using an non-intrinsify implementation:
Because Rarg1 is loaded from the stack using sign-extended instructions
ld.w, the situation described in Case 2 above does not occur
Benchmarks on linux/loong64:
name old time/op new time/op delta
Cas 50.0ns ± 0% 50.1ns ± 0% ~ (p=1.000 n=1+1)
Cas64 50.0ns ± 0% 50.1ns ± 0% ~ (p=1.000 n=1+1)
Cas-4 56.0ns ± 0% 56.0ns ± 0% ~ (p=1.000 n=1+1)
Cas64-4 56.0ns ± 0% 56.0ns ± 0% ~ (p=1.000 n=1+1)
Than McIntosh [Mon, 12 Dec 2022 15:53:17 +0000 (10:53 -0500)]
os/user,net: add -fno-stack-protector to CFLAGS
Some compilers default to having -fstack-protector on, which breaks
when using internal linking because the linker doesn't know how to
find the support functions.
Updates #52919.
Updates #54313.
Fixes #57261.
Change-Id: Iaae731851407af4521fff2dfefc5b7e3e92cf284
Reviewed-on: https://go-review.googlesource.com/c/go/+/456855
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Damien Neil [Wed, 14 Dec 2022 23:49:58 +0000 (15:49 -0800)]
net/http: improve errors in TestCancelRequestWhenSharingConnection
Provide more information about why this test might be hanging waiting
for PutIdleConn to be called (#56587): If the round trip that should
result in PutIdleConn being invoked completes, report that to the
goroutine waiting for PutIdleConn.
For #56587
Change-Id: Ie476ea0ce4a48d2bda6b9b109f89d675a10e7e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/457775
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Ian Lance Taylor [Thu, 15 Dec 2022 21:54:33 +0000 (13:54 -0800)]
syscall, internal/poll: fall back to accept on linux-arm
Our minimum Linux version is 2.6.32, and the accept4 system call was
introduced in 2.6.28, so we use accept4 everywhere. Unfortunately,
it turns out that the accept4 system call was only added to
linux-arm in 2.6.36, so for linux-arm only we need to try the accept4
system call and then fall back to accept if it doesn't work.
The code we use on linux-arm is the code we used in Go 1.17.
On non-arm platforms we continue using the simpler code introduced
in Go 1.18.
Bryan C. Mills [Thu, 15 Dec 2022 22:09:00 +0000 (17:09 -0500)]
os/exec: retry ETXTBSY errors in TestFindExecutableVsNoexec
I made this test parallel in CL 439196, which exposed it to the
fork/exec race condition described in #22315. The ETXTBSY errors from
that race should resolve on their own, so we can simply retry the call
to get past them.
Robert Griesemer [Thu, 15 Dec 2022 17:10:20 +0000 (09:10 -0800)]
doc/go1.20: fix typo
Change-Id: Icddf980e533b86ca955660ad028f5ad04b6aecbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/457916
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Robert Griesemer [Thu, 15 Dec 2022 16:15:06 +0000 (08:15 -0800)]
spec: fix typo
Fixes #57323.
Change-Id: I77d3d747aa4746bb9a8cca0c0500ff8fa6ae33a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/457915 Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Robert Griesemer [Wed, 14 Dec 2022 05:16:09 +0000 (21:16 -0800)]
spec: document which recursive arrays and structs are valid/invalid
Fixes #5069.
Change-Id: I4bc0f52a9cd1e64a49846dffeb4be5cbecc29a96
Reviewed-on: https://go-review.googlesource.com/c/go/+/457342
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
Matthew Dempsky [Wed, 14 Dec 2022 19:48:02 +0000 (11:48 -0800)]
cmd/compile: desugar OCALLMETH->OCALLFUNC within devirtualization
Devirtualization can turn OCALLINTER into OCALLMETH, but then we want
to actually desugar into OCALLFUNC instead for later phases. Just
needs a missing call to typecheck.FixMethodCall.
Fixes #57309.
Change-Id: I331fbd40804e1a370134ef17fa6dd501c0920ed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/457715
Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Robert Griesemer [Wed, 14 Dec 2022 01:41:19 +0000 (17:41 -0800)]
spec: document illegal recursive type parameter lists
Fixes #40882.
Change-Id: I90f99d75e6d66f857b6ab8789c6d436f85d20993
Reviewed-on: https://go-review.googlesource.com/c/go/+/457515
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
Robert Griesemer [Tue, 13 Dec 2022 21:59:12 +0000 (13:59 -0800)]
spec: describe new semantics for comparable and constraint satisfaction
For #56548.
Fixes #57012.
Change-Id: I44f850522e52b1811025fb31bcef289da8f8089d
Reviewed-on: https://go-review.googlesource.com/c/go/+/457437
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Robert Griesemer [Tue, 13 Dec 2022 00:30:42 +0000 (16:30 -0800)]
spec: introduce notion of strict comparability
- Rephrase the notion of "comparability" from a property
of values (operands) to a property of types and adjust
dependent prose.
- Introduce the notion of "strict comparability".
- Fix the definitions of comparability for type interfaces
and type parameters.
- Define the predeclared identifier "comparable" as stricly
comparable.
These changes address existing problems in the spec as outlined
in the section on "Related spec issues" in issue #56548.
For #56548.
Change-Id: Ibc8c2f36d92857a5134eadc18358624803d3dd21
Reviewed-on: https://go-review.googlesource.com/c/go/+/457095 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
miller [Tue, 13 Dec 2022 10:43:23 +0000 (10:43 +0000)]
syscall: fix closing of reordered FDs in plan9 ForkExec
After dup'ing file descriptors in syscall.ProcAttr.Files to pass
to the exec'ed process, the logic for closing the old descriptors
was incorrect and could close the new descriptor instead.
Fixes #57180
Change-Id: I7725f21a465ffba57050fe4e36f3d36ba181cfb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/457115
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Robert Griesemer [Mon, 12 Dec 2022 21:36:44 +0000 (13:36 -0800)]
go/types, types2: report type mismatch error when conversion is impossible
Rather than reporting an impossible conversion error when mixing an
untyped value with a pointer type in an operation, report a type
mismatch error. This fixes a regression in error quality compared
to pre-1.18.
For the fix, clean up the implementation of canMix, add documentation,
and give it a better name.
Adjust test case for corresponding error code bacause we now get a
better error message (and error code) for the old error code example.
Fixes #57160.
Change-Id: Ib96ce7cbc44db6905fa2f1c90a3769af609e101b
Reviewed-on: https://go-review.googlesource.com/c/go/+/457055 Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
Oleg Zaytsev [Fri, 9 Dec 2022 12:05:34 +0000 (13:05 +0100)]
cmd/gc: test temp string comparison with all ops
The comment on `slicebytetostringtmp` mention that `==` operator does
not allocate []byte to string conversion, but the test was testing only
`==` and `!=` and the compiler actually optimizes all comparison
operators.
Also added a test for concatenation comparison, which also should not
allocate.
Change-Id: I6f4c5c4f238808138fa901732e1fd5b6ab25f725
Reviewed-on: https://go-review.googlesource.com/c/go/+/456415
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Alexander Frolov [Fri, 9 Dec 2022 07:56:21 +0000 (07:56 +0000)]
doc/go1.20: fix typo
Change-Id: Id0319a9cc9acc549022fdcd6b7d71c7343afd245
GitHub-Last-Rev: 2b84d25763c3f8a03663d4ba75cefa4a372fefbd
GitHub-Pull-Request: golang/go#57187
Reviewed-on: https://go-review.googlesource.com/c/go/+/456395
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Nikola Jokic [Fri, 2 Dec 2022 16:42:48 +0000 (17:42 +0100)]
debug/buildinfo: check pointer size on buildinfo.Read
Previous implementation has a check on pointer size but only if ptrSize
is 4. but it does not check on ptrSize 8 causing the panic on read for
some inputs.
The explicit check for pointer size 8 is added and error is returned if
ptrSize is not 4 and not 8.
Keith Randall [Sat, 10 Dec 2022 03:49:53 +0000 (19:49 -0800)]
cmd/compile: fix conditional move rule on PPC64
Similar to CL 456556 but for ppc64 instead of arm64.
Change docs about how booleans are stored in registers for ppc64.
We now don't promise to keep the upper bits zeroed; they might be junk.
To test, I changed the boolean generation instructions (MOVBZload* and ISEL*
with boolean type) to OR in 0x100 to the result. all.bash still passed,
so I think nothing else is depending on the upper bits of booleans.
Update #57184
Change-Id: Ie66f8934a0dafa34d0a8c2a37324868d959a852c
Reviewed-on: https://go-review.googlesource.com/c/go/+/456437
Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: KAMPANAT THUMWONG (KONG PC) <1992kongpc.kth@gmail.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
Ian Lance Taylor [Fri, 9 Dec 2022 19:22:32 +0000 (11:22 -0800)]
os: skip size test in TestLstat if the file is a symlink
Tested by temporarily changing sysdir to use a directory where
the expected files were all symlinks. We should consider using
a different approach that doesn't rely on sysdir, but for now
do a minimal fix.
Fixes #57210
Change-Id: Ifb1becef03e014ceb48290ce13527b3e103c0e07
Reviewed-on: https://go-review.googlesource.com/c/go/+/456557 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Keith Randall [Fri, 9 Dec 2022 18:55:28 +0000 (10:55 -0800)]
cmd/compile: fix conditional select rule
ARM64 maintains booleans in the low byte of registers. Upper parts
of that register are junk.
This rule is using all 32 bits of a boolean-containing register, which
is wrong. Change the rule to only look at the low bit.
Fixes #57184
Change-Id: Ibbef86b2be859df3d06d993db00e1231c481c428
Reviewed-on: https://go-review.googlesource.com/c/go/+/456556
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Bryan C. Mills [Thu, 8 Dec 2022 15:47:03 +0000 (10:47 -0500)]
os/user: zero-initialize C structs returned to Go
In the wrappers for getgrnam_r and similar, the structs to be returned
are allocated on the C stack and may be uninitialized. If the call to
the wrapped C function returns an error (such as ERANGE), it may leave
the struct uninitialized, expecting that the caller will not read it.
However, when that struct is returned to Go, it may be read by the Go
garbage collector. If the uninitialized struct fields happen to
contain wild pointers, the Go garbage collector will throw an error.
(Prior to CL 449335, the Go runtime would not scan the struct fields
because they did not reside in Go memory.)
Fix this by always zeroing the struct before the C call.
Robert Findley [Thu, 8 Dec 2022 15:03:03 +0000 (10:03 -0500)]
go/types, types2: always rename type parameters during inference
Type inference uses a trick of "renaming" type parameters in the type
parameter list to avoid cycles during unification. This separates the
identity of type parameters from type arguments. When this trick was
introduced in CL 385494, we restricted its application to scenarios
where inference is truly self-recursive: the type parameter list being
inferred was the same as the type parameter list of the outer function
declaration. Unfortunately, the heuristic used to determine
self-recursiveness was flawed: type-checking function literals clobbers
the type-checker environment, losing information about the outer
signature.
We could fix this by introducing yet more state into the type-checker
(e.g. a 'declSig' field that would hold the signature of the active
function declaration), but it is simpler to just avoid this optimization
and always perform type parameter renaming. We can always optimize
later.
This CL removes the check for true self-recursion, always performing the
renaming.
Fixes golang/go#57155
Change-Id: I34c7617005c1f0ccfe2192da0e5ed104be6b92c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/456236
Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Dmitri Shuralyov [Thu, 8 Dec 2022 17:53:26 +0000 (12:53 -0500)]
doc/go1.20: correct test binary -v flag value for test2json
The -v flag value is "test2json", not "json", since it emits output
in a custom format that the cmd/test2json tool interprets.
The cmd/test2json documentation and implementation have this right.
For #54202.
Change-Id: I2b52861d926e14488aa9fc89fff8c26da32ca710
Reviewed-on: https://go-review.googlesource.com/c/go/+/456124 Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Fix a buglet in cmd/cover in how we handle package name/path for the
"go build -o foo.exe *.go" and "go run *.go" cases.
The go command assigns a dummy import path of "command-line-arguments"
to the main package built in these cases; rather than expose this
dummy to the user in coverage reports, the cover tool had a special
case hack intended to rewrite such package paths to "main". The hack
was too general, however, and was rewriting the import path of all
packages with (p.name == "main") to an import path of "main". The hack
also produced unexpected results for cases such as
go test -cover foo.go foo_test.go
This patch removes the hack entirely, leaving the package path for
such cases as "command-line-arguments".
Bryan C. Mills [Thu, 8 Dec 2022 13:24:57 +0000 (08:24 -0500)]
runtime: remove arbitrary timeouts in finalizer tests
These short timeouts can overrun due to system scheduling delay
(or GC latency) on a slow or heavily-loaded host.
Moreover, if the test deadlocks we will probably want to know what the
GC goroutines were doing at the time. With an arbitrary timeout, we
never get that information; however, if we allow the test to time out
completely we will get a goroutine dump (and, if GOTRACEBACK is
configured in the environment, that may even include GC goroutines).
Bryan C. Mills [Wed, 7 Dec 2022 21:33:42 +0000 (16:33 -0500)]
cmd/go: deflake TestScript/test2json_interrupt
- Start handling signals in 'go test' just before starting the test
subprocess instead of just after. (It is unlikely that starting the
process will cause cmd/go to hang in a way that requires signals to
debug, and it is possible that something the test does — such as
sending os.Interrupt to its parent processes — will immediately
send a signal that needs to be handled.)
- In the test-test, don't try to re-parse the parent PIDs after
sending signals, and sleep for a much shorter time interval.
(Overrunning the sleep caused the next call to strconv.Atoi — which
shouldn't even happen! — to fail with a parse error, leading to the
failure mode observed in
https://build.golang.org/log/f0982dcfc6a362f9c737eec3e7072dcc7ef29e32.)
Ian Lance Taylor [Wed, 7 Dec 2022 21:27:22 +0000 (13:27 -0800)]
os/user: on AIX getpwuid_r seems to return -1 on overflow
The getpwuid_r function is expected to return ERANGE on overflow.
Accept -1 on AIX as we see that in practice.
This problem was uncovered by, but not caused by, CL 455815,
which introduced a test that forced a buffer overflow.
Change-Id: I3ae94faf1257d2c73299b1478e49769bb807fc4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/456075
Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
David du Colombier [Wed, 7 Dec 2022 14:20:25 +0000 (15:20 +0100)]
internal/safefilepath: fix TestFromFS on Plan 9
CL 455716 added TestFromFS. This test was failing on Plan 9
because fromFS didn't return an empty string in case of error.
This change fixes TestFromFS by returning an empty string
in case of error.
Fixes #57142.
Change-Id: Ie50dfba5e70154d641f762fa43f1c26c3d12b6f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/455835
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
Russ Cox [Wed, 7 Dec 2022 14:18:11 +0000 (09:18 -0500)]
os/user: fix buffer retry loop on macOS
getpwnam_r and friends return the errno as the result,
not in the global errno. The code changes in CL 449316
inadvertently started using the global errno.
So if a lookup didn't fit in the first buffer size,
it was treated as not found instead of growing the buffer.
Matthew Dempsky [Thu, 18 Aug 2022 20:47:43 +0000 (13:47 -0700)]
go/internal/gcimporter: simplify unified IR importer
CL 424854 changed the unified IR writer's handling of type
declarations to write the underlying type rather than the RHS type
expression's type. This in turn allows us to simplify the go/types
importer, because now there's no need to delay caling SetUnderlying.
Fixes #57015.
Change-Id: I80caa61f6cad5b7f9d829939db733a66cfca621c
Reviewed-on: https://go-review.googlesource.com/c/go/+/424876 Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Matthew Dempsky [Thu, 18 Aug 2022 18:04:21 +0000 (11:04 -0700)]
cmd/compile: restore test/nested.go test cases
[Re-land of CL 424854, which was reverted as CL 425214.]
When handling a type declaration like:
```
type B A
```
unified IR has been writing out that B's underlying type is A, rather
than the underlying type of A.
This is a bit awkward to implement and adds complexity to importers,
who need to handle resolving the underlying type themselves. But it
was necessary to handle when A was declared like:
```
//go:notinheap
type A int
```
Because we expected A's not-in-heap'ness to be conferred to B, which
required knowing that A was on the path from B to its actual
underlying type int.
However, since #46731 was accepted, we no longer need to support this
case. Instead we can write out B's actual underlying type.
One stumbling point though is the existing code for exporting
interfaces doesn't work for the underlying type of `comparable`, which
is now needed to implement `type C comparable`. As a bit of a hack, we
we instead export its underlying type as `interface{ comparable }`.
Fixes #54512.
Change-Id: I9aa087e0a277527003195ebc7f4fbba6922e788c
Reviewed-on: https://go-review.googlesource.com/c/go/+/455279
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
Damien Neil [Thu, 10 Nov 2022 20:16:27 +0000 (12:16 -0800)]
os, net/http: avoid escapes from os.DirFS and http.Dir on Windows
Do not permit access to Windows reserved device names (NUL, COM1, etc.)
via os.DirFS and http.Dir filesystems.
Avoid escapes from os.DirFS(`\`) on Windows. DirFS would join the
the root to the relative path with a path separator, making
os.DirFS(`\`).Open(`/foo/bar`) open the path `\\foo\bar`, which is
a UNC name. Not only does this not open the intended file, but permits
reference to any file on the system rather than only files on the
current drive.
Make os.DirFS("") invalid, with all file access failing. Previously,
a root of "" was interpreted as "/", which is surprising and probably
unintentional.
Roland Shoemaker [Tue, 6 Dec 2022 19:58:10 +0000 (11:58 -0800)]
archive/zip: only consider UncompressedSize when checking dirs
CL 454475 switched from checking CompressedSize to UncompressedSize
when determining if we should consider an archive malformed because
it contains data and added a test for an example of this (a JAR). We
should also remove the hasDataDescriptor check, since that is basically
an alias for CompressedSize > 0. The test didn't catch this because we
didn't actually attempt to read from the returned reader.
Change-Id: Ibc4c1aa9c3a733f3ebf4a956d1e2f8f4900a29cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/455523
Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Julie Qiu <julieqiu@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Dmitri Shuralyov [Fri, 2 Dec 2022 18:30:06 +0000 (13:30 -0500)]
run.bash, cmd/dist: document GO_TEST_SHORT and GO_TEST_TIMEOUT_SCALE
These environment variables affect cmd/dist, and in turn run.bash.
They exist primarily for the Go build system, but are still needed
sometimes when investigating problems. Document them in one place.
Fixes #46054.
Change-Id: I5dea2ac79b0d203d2f3c9ec2980382f62bead5cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/455517
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>