Bryan C. Mills [Wed, 8 Dec 2021 14:49:04 +0000 (09:49 -0500)]
debug/buildinfo: update test for CL 369977
As a side effect of the changes in cmd/go/internal/work in CL 369977,
binaries built in GOPATH mode now include rudimentary build metadata
for at least the package path and compiler in use.
That seems like a strict improvement, but the test needs to be updated
to reflect the newly-available metadata.
Russ Cox [Tue, 7 Dec 2021 22:09:41 +0000 (17:09 -0500)]
cmd: go get golang.org/x/tools@fd2bfb7 (Dec 7 2021)
cd src/cmd
go get golang.org/x/tools@fd2bfb7
go mod tidy
go mod vendor
Brings in fixes to cmd/vet for 'any' changes.
Change-Id: I70a48d451bd99f5d82f91fd079fbdd1b4bac2520
Reviewed-on: https://go-review.googlesource.com/c/go/+/370136
Trust: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Hana [Tue, 7 Dec 2021 22:50:50 +0000 (17:50 -0500)]
cmd/go: fix references to old `go mod editwork`
That is replaced by `go work edit`.
Change-Id: I39996c7bea0182a18edf6a1f70b6616c74099a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/370139 Reviewed-by: Michael Matloob <matloob@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Michael Pratt [Mon, 6 Dec 2021 22:26:32 +0000 (17:26 -0500)]
runtime/pprof: assert that labelHog samples are always labeled
With https://golang.org/issue/50007 resolved, there are no known issues
with pprof labels remaining. Thus, the 10% allowed error in
TestLabelSystemstack should not be required.
Drop it in favor of an explicit assertion that all samples containing
labelHog are properly labeled.
This is no flaky in my local testing. It is possible that other bugs
will appear at larger testing scale, in which case this CL will be
reverted, but then at least we will be aware of additional failure
modes.
For #50007.
Change-Id: I1ef530c303bd9a01af649b8b08d4b35505e8aada
Reviewed-on: https://go-review.googlesource.com/c/go/+/369744 Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Pratt [Mon, 6 Dec 2021 21:05:55 +0000 (16:05 -0500)]
runtime/pprof: consume tag for first CPU record
profBuf.write uses an index in b.tags for each entry, even if that entry
has no tag (that slice entry just remains 0). profBuf.read similarly
returns a tags slice with exactly as many entries as there are records
in data.
profileBuilder.addCPUData iterates through the tags in lockstep with the
data records. Except in the special case of the first record, where it
forgets to increment tags. Thus the first read of profiling data has all
tags off-by-one.
To help avoid regressions, addCPUData is changed to assert that tags
contains exactly the correct number of tags.
For #50007.
Change-Id: I5f32f93003297be8d6e33ad472c185d924a63256
Reviewed-on: https://go-review.googlesource.com/c/go/+/369741 Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Dan Scales [Tue, 7 Dec 2021 00:30:19 +0000 (16:30 -0800)]
cmd/compile: deal with unsatisfiable type assertion in some instantiations
Deal with case where a certain instantiation of a generic
function/method leads to an unsatisfiable type assertion or type case.
In that case, the compiler was causing a fatal error while trying to
create an impossible itab for the dictionary. To deal with that case,
allow ITabLsym() to create a dummy itab even when the concrete type
doesn't implement the interface. This dummy itab is analogous to the
"negative" itabs created on-the-fly by the runtime.
We will use the dummy itab in type asserts and type switches in
instantiations that use that dictionary entry. Since the dummy itab can
never be used for any real value at runtime (since the concrete type
doesn't implement the interface), there will always be a failure for the
corresponding type assertion or a non-match for the corresponding
type-switch case.
Fixes #50002
Change-Id: I1df05b1019533e1fc93dd7ab29f331a74fab9202
Reviewed-on: https://go-review.googlesource.com/c/go/+/369894 Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Katie Hockman [Wed, 1 Dec 2021 16:25:16 +0000 (11:25 -0500)]
internal/fuzz: handle unrecoverable errors during minimization
Previously, if an unrecoverable error occurred during
minimization, then the input that caused the failure
could not be retrieved by the coordinator. This was fine
if minimizing a crash, since the coordinator could simply
report the original error, and ignore the new one.
However, if an error occurred while minimizing an
interesting input, then we may lose an important error
that would be better to report.
This changes is a pretty major refactor of the minimization
logic in order to support this. It removes minimization
support of all types except []byte and string. There isn't
compelling evidence that minimizing types like int or float64
are actually beneficial, so removing this seems fine.
With this change, the coordinator requests that the worker
minimize a single value at a time. The worker updates shared
memory directly during minimzation, writing the *unmarshaled*
bytes to the shared memory region. If a nonrecoverable error occurs
during minimization, then the coordinator can get the
unmarshaled value out of shared memory for that type being
minimized.
Russ Cox [Mon, 6 Dec 2021 18:38:04 +0000 (13:38 -0500)]
cmd/link, cmd/go: make version info easier to extract
Reading the version information to date has required evaluating
two pointers to strings (which themselves contain pointers to data),
which means applying relocations, which can be very system-dependent.
To simplify the lookup, inline the string data into the build info blob.
This makes go version work on binaries built with external linking
on darwin/arm64.
Also test that at least the very basics work on a trivial binary,
even in short mode.
Jeremy Faller [Thu, 2 Dec 2021 18:47:39 +0000 (13:47 -0500)]
doc/go1.18: add docs for -count when benchmarking
CL 356669
Updates #47694
Change-Id: I49e0cdd3b34e81e9e44020a8eb1304d78249cd66
Reviewed-on: https://go-review.googlesource.com/c/go/+/368677
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Bryan C. Mills [Tue, 7 Dec 2021 03:09:12 +0000 (22:09 -0500)]
net/http: remove arbitrary timeout in TestServerHijackGetsBackgroundByte_big
This test fails with "timeout" once per couple of months.
It may be that the arbitrary timeout is too short,
or it may be that the test is detecting a real bug
(perhaps a deadlock) and reporting it without sufficient
information to debug.
Either way, the arbitrary timeout is doing only harm:
either it is too short, or it is preventing us from getting
a useful goroutine dump when the test inevitably times out.
Fixes #35498 (hopefully).
Change-Id: Ic6bbb1ef8df2c111b9888ba9903f58633e7cb95d
Reviewed-on: https://go-review.googlesource.com/c/go/+/369854
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Michael Anthony Knyszek [Tue, 7 Dec 2021 05:24:54 +0000 (00:24 -0500)]
runtime: fix comments on the behavior of SetGCPercent
Fixes for #49680, #49695, #45867, and #49370 all assumed that
SetGCPercent(-1) doesn't block until the GC's mark phase is done, but
it actually does. The cause of 3 of those 4 failures comes from the fact
that at the beginning of the sweep phase, the GC does try to preempt
every P once, and this may run concurrently with test code. In the
fourth case, the issue was likely that only *one* of the debug_test.go
tests was missing a call to SetGCPercent(-1). Just to be safe, leave a
TODO there for now to remove the extraneous runtime.GC calls, but leave
the calls in.
Updates #49680, #49695, #45867, and #49370.
Change-Id: Ibf4e64addfba18312526968bcf40f1f5d54eb3f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/369815 Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Bryan C. Mills [Mon, 6 Dec 2021 22:25:34 +0000 (17:25 -0500)]
cmd/go: fix tests broken in CL 358539
CL 358539 revised the build-stamp format, and updated the git and hg
tests to match. However, the fossil and bzr tests were missed, and
were not caught on the builders due to the fact that none of the
builder images have the necessary VCS tools installed.
Bryan C. Mills [Tue, 23 Nov 2021 15:27:30 +0000 (10:27 -0500)]
net: in (*netFD).dial, use the passed in local address if getsockname fails
'man getsockname' lists a number of possible failure modes, including
ENOBUFS (for resource exhaustion) and EBADF (which we could possibly
see in the event of a bug or race condition elsewhere in the program).
If getsockname fails for an explicit user-provided local address, the
user is probably not expecting LocalAddr on the returned net.Conn to
return nil. This may or may not fix #34611, but should at least help
us diagnose it more clearly.
While we're add it, also add more nil-checking logic in the test based
on the stack traces posted to
https://golang.org/issue/34611#issuecomment-975923748.
Cherry Mui [Mon, 6 Dec 2021 23:41:49 +0000 (18:41 -0500)]
cmd/dist: enable plugin test on Linux/ARM64
The test was skipped because with the old gold linker on the
builder it fails with an internal error in gold. The builders now
have gold 2.31 and the test passes. Enable it.
Fixes #17138.
Change-Id: Ia0054030dd12f1d003c7420bf7ed8b112715baa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/369814
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Anthony Knyszek [Mon, 6 Dec 2021 22:53:35 +0000 (17:53 -0500)]
runtime: clean up redundant calls to SetGCPercent in debug_test.go
SetGCPercent(-1) is called by several tests in debug_test.go (followed
by a call to runtime.GC) due to #49370. However, startDebugCallWorker
already actually has this, just without the runtime.GC call (allowing an
in-progress GC to still mess up the test).
This CL consolidates SetGCPercent into startDebugDebugCallWorker where
applicable.
Change-Id: Ifa12d6a911f1506e252d3ddf03004cf2ab3f4ee4
Reviewed-on: https://go-review.googlesource.com/c/go/+/369751
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Michael Anthony Knyszek [Mon, 6 Dec 2021 22:35:58 +0000 (17:35 -0500)]
runtime: call runtime.GC in several tests that disable GC
These tests disable GC because of the potential for a deadlock, but
don't consider that a GC could be in progress due to other tests. The
likelihood of this case was increased when the minimum heap size was
lowered during the Go 1.18 cycle. The issue was then mitigated by
CL 368137 but in theory is always a problem.
This change is intended specifically for #45867, but I just walked over
a whole bunch of other tests that don't take this precaution where it
seems like it could be relevant (some tests it's not, like the
UserForcedGC test, or testprogs where no other code has run before it).
Fixes #45867.
Change-Id: I6a1b4ae73e05cab5a0b2d2cce14126bd13be0ba5
Reviewed-on: https://go-review.googlesource.com/c/go/+/369747 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: David Chase <drchase@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Bryan C. Mills [Tue, 23 Nov 2021 22:02:10 +0000 (17:02 -0500)]
log/syslog: create unix sockets in unique directories
startServer was invoking os.Remove on the temporary file for a unix
socket after creating it. Since the files were created in the global
temp directory, that could cause two tests to arrive at colliding
names.
(Noticed while looking into the failure at
https://storage.googleapis.com/go-build-log/af2c83b1/solaris-amd64-oraclerel_3e01fda8.log,
but I would be surprised if this solves that failure.)
This change uses unique temporary directories, and attempts to keep
name lengths minimal to avoid accidentally running into socket-name
length limitations.
Jeremy Faller [Thu, 2 Dec 2021 18:33:18 +0000 (13:33 -0500)]
doc/go1.18: add new sync.[RW]Mutex methods
CL 319769
Updates #47694
Change-Id: I9655af0d249926617645c33617d53b73f985aa19
Reviewed-on: https://go-review.googlesource.com/c/go/+/368797
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Jeremy Faller [Thu, 2 Dec 2021 18:22:46 +0000 (13:22 -0500)]
doc/go1.18: add changes to regexp to release notes
CL 354569
Updates #47694
Change-Id: I78536c110215b3c9f247c1420bcaa5fc3d8fb930
Reviewed-on: https://go-review.googlesource.com/c/go/+/368795
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Austin Clements [Mon, 6 Dec 2021 18:33:54 +0000 (13:33 -0500)]
doc/go1.18: minor tweaks to generics section
This CL reorders the bullet points in the generics section to more
closely match what I think users will consider most important. I put
the ~ token before the mention of ~T in interfaces to avoid a forward
reference, though I wonder if we actually want to spent a couple more
sentences saying what union and ~T types are, since most people are
going to care about that a lot more than they care about the low-level
detail that there's a new token.
For #47694.
Change-Id: Ib84f096ef6346a711801268ce362b64fa423d3f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/369734
Trust: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
To prevent interleaving of output when 'go build' compiles several
packages in parallel, the output mutex in the Builder struct must
be locked around any calls to Builder.Print which could generate
arbitrary amounts of text (ie more than is guaranteed to be written
atomically to a pipe).
Michael Anthony Knyszek [Mon, 23 Aug 2021 17:27:40 +0000 (17:27 +0000)]
runtime: set iOS addr space to 40 bits with incremental pagealloc
In iOS <14, the address space is strictly limited to 8 GiB, or 33 bits.
As a result, the page allocator also assumes all heap memory lives in
this region. This is especially necessary because the page allocator has
a PROT_NONE mapping proportional to the size of the usable address
space, so this keeps that mapping very small.
However starting with iOS 14, this restriction is relaxed, and mmap may
start returning addresses outside of the <14 range. Today this means
that in iOS 14 and later, users experience an error in the page
allocator when a heap arena is mapped outside of the old range.
This change increases the ios/arm64 heapAddrBits to 40 while
simultaneously making ios/arm64 use the 64-bit pagealloc implementation
(with reservations and incremental mapping) to accommodate both iOS
versions <14 and 14+.
Once iOS <14 is deprecated, we can remove these exceptions and treat
ios/arm64 like any other arm64 platform.
This change also makes the BaseChunkIdx expression a little bit easier
to read, while we're here.
Fixes #46860.
Change-Id: I13865f799777739109585f14f1cc49d6d57e096b
Reviewed-on: https://go-review.googlesource.com/c/go/+/344401
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com>
Roi Martin [Tue, 30 Nov 2021 18:35:47 +0000 (19:35 +0100)]
cmd/go: update "go help doc" docs
This CL updates "go help doc" docs so they reflect the following
changes:
- CL 59413 modified "go doc", so the behavior of the two-args case is
consistent with the one-arg one.
- CL 141397 removed godoc's command-line interface in favor of "go doc".
Ian Lance Taylor [Sun, 5 Dec 2021 01:59:19 +0000 (17:59 -0800)]
test/ken/slicearray.go: correct type width in comment
The type was changed in https://golang.org/cl/3991043 but the comment
wasn't updated.
Change-Id: I7ba3f625c732e5e801675ffc5d4a28e1d310faa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/369374
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Robert Griesemer [Sat, 4 Dec 2021 03:24:54 +0000 (19:24 -0800)]
doc/go1.18: expand section on generics
Also, move it up in the document.
Updates #47694
Change-Id: I927c4c845089a5c22e2c5b5f3de1831c04c6d990
Reviewed-on: https://go-review.googlesource.com/c/go/+/369102
Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dan Scales [Sat, 27 Nov 2021 18:33:59 +0000 (10:33 -0800)]
test: re-enable a bunch of tests with types2
Enable a bunch of types2-related error tests to run successfully, so
they no longer have to be disabled in run.go.
- directive.go: split it into directive.go and directive2.go, since the
possible errors are now split across the parser and noder2, so they
can't all be reported in one file.
- linkname2.go: similarly, split it into linkname2.go and linkname3.go
for the same reason.
- issue16428.go, issue17645.go, issue47201.dir/bo.go: handle slightly
different wording by types2
- issue5609.go: handle slight different error (array length must be
integer vs. array bound too large).
- float_lit3.go: handle slightly different wording (overflows
float vs cannot convert to float)
I purposely didn't try to fix tests yet where there are extra or missing
errors on different lines, since that is not easy to make work for both
-G=3 and -G=0. In a later change, will flip to make the types2 version
match correctly, vs. the -G=0 version.
Change-Id: I6079ff258e3b90146335b9995764e3b1b56cda59
Reviewed-on: https://go-review.googlesource.com/c/go/+/368455
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Felix Geisendörfer [Mon, 20 Sep 2021 14:09:47 +0000 (16:09 +0200)]
runtime: fix missing pprof labels
Use gp.m.curg instead of the gp when recording cpu profiler stack
traces. This ensures profiler labels are captured when systemstack or similar
is executing on behalf of the current goroutine.
After this there are still rare cases of samples containing the labelHog
function, so more work might be needed. This patch should fix ~99% of the
problem.
Also change testCPUProfile interface a little to allow the new test to
re-run with a longer duration if it fails during a -short run.
Fixes #48577.
Change-Id: I3dbc9fd5af3c513544e822acaa43055b2e00dfa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/367200
Trust: Michael Pratt <mpratt@google.com>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Ian Lance Taylor [Thu, 2 Dec 2021 22:52:31 +0000 (14:52 -0800)]
builtin: document "any" and "comparable"
Fixes #49927
Change-Id: I8b34cf13b3bc6338309f005648ca3ee6852927f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/368954
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Cherry Mui [Fri, 3 Dec 2021 00:05:27 +0000 (19:05 -0500)]
cmd/compile: set PPC64's MAXWIDTH as other architectures
PPC64's MAXWIDTH is set as 1<<60 whereas on other 64-bit
architetures it is set as 1<<50. Set to 1<<50 for consistency. The
toolchain cannot handle such large program anyway.
May fix PPC64 build.
Change-Id: Ic3972a089b2f14a96e4ded57ef218d763c924a6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/368955
Trust: Cherry Mui <cherryyz@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Cherry Mui [Tue, 30 Nov 2021 23:58:53 +0000 (18:58 -0500)]
runtime/race: rebuild darwin syso to work around macOS 12 malloc reserved address
On macOS 12 a new malloc implementation (nano) is used by default,
and apparently it reserves address range
0x600000000000-0x600020000000, which conflicts with the address
range that TSAN uses for Go. Work around the issue by changing the
address range slightly.
The actual change is made on LLVM at https://reviews.llvm.org/D114825 .
This CL includes syso's built with the patch applied.
Ian Lance Taylor [Thu, 2 Dec 2021 19:39:38 +0000 (11:39 -0800)]
doc/go1.18: mention new -asan option
For #44853
For #47694
Change-Id: Ia76246218b1361d8bdf510bbfc5178c83cdd3eec
Reviewed-on: https://go-review.googlesource.com/c/go/+/368834
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
CL 205237 allowed SSL_CERT_DIR to be a colon delimited list of
directories. In the case that SSL_CERT_DIR is unset, the change
also made certDirectories to all be loaded rather than stopping
after successfully reading at least one file from a directory.
This update fixes code comments on the certDirectories package
level variables to reflect current behavior.
Dan Scales [Mon, 29 Nov 2021 19:45:17 +0000 (11:45 -0800)]
cmd/compile: report channel size errors correctly for -G=3
First, we need to set base.Pos in varDecl() and typeDecl(), so it will
be correct if we need to report type size errors while converting types.
Changed error calls in types/sizes.go to use Errorf, not ErrorfAt, since
we want to use base.Pos (which will set from t.Pos(), if that is
available).
Second, we need to add an extra call CalcSize(t1.Elem()) in the
TCHANARGS case of CalcSize(). We can use CalcSize() rather than
CheckSize(), since we know the top-level recursive type will have been
calculated by the time we process the fake TCHANARGS type. In -G=0 mode,
the size of the channel element has often been calculated because of
some other processing (but not in the case of #49767). But in -G=3 mode,
we just calculate sizes during the single noder2 pass, so we are more
likely to have not gotten to calculating the size of the element yet,
depending on the order of processing of the deferredTypeStack.
Fixes the tests fixedbugs/issue{42058a,42058b}.go that were
disabled for -G=3 mode.
Had to add exceptions in stdlib_test.go for go/types and types2, because
the types2 typechecker does not know about type size limits.
Fixes #49814
Fixes #49771
Updates #49767
Change-Id: I77d058e8ceff68a58c4c386a8cf46799c54b04c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/367955
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Jeremy Faller [Fri, 19 Nov 2021 21:51:47 +0000 (16:51 -0500)]
doc/go1.18: add short-circuit evaluation for text/template
This description is based on https://golang.org/cl/321490.
Updates #47694
Change-Id: I48656cd487d2fccf0b0d3390f350f1bc6f2b0080
Reviewed-on: https://go-review.googlesource.com/c/go/+/365738
Trust: Jeremy Faller <jeremy@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Michael Anthony Knyszek [Wed, 1 Dec 2021 15:26:31 +0000 (15:26 +0000)]
runtime: break out new minimum heap size into a goexperiment
The new minimum heap of 512 KiB has been the cause of some build
slowdown (~1%) and microbenchmark slowdown (usually ~0%, up to ~50%)
because of two reasons:
1. Applications with lots of small short-lived processes execute many
more GC cycles.
2. Applications with heaps <4 MiB GC up to 8x more often.
In many ways these consequences are inevitable given how GOGC works,
however we need to investigate more as to whether the apparent slowdowns
are indeed unavoidable or if the GC has issues scaling down, which it's
too late for for this release.
Given that this release is already huge, it's OK to push this back.
We'll take a closer look at it next cycle, so place block it behind a
new goexperiment to allow users and ourselves to easily experiment with
it.
Fixes #49744.
Updates #44167.
Change-Id: Ibad51f7873de7517490c89802f3c593834e77ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/368137
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com>
Dan Scales [Wed, 1 Dec 2021 18:53:17 +0000 (10:53 -0800)]
cmd/compile: fix case where g.curDecl should be saved/restored
When we set g.curDecl for the type params created during fillinMethods
for an instantiated type, we need to save/restore its value, because
fillinMethods() may be called while processing a typeDecl. We want the
value of g.curDecl to continue to be correct for type params created in
the typeDecl. Because of ordering issues, not restoring g.curDecl
happens to cause problems (which don't always show up visibly) exactly
when a type param is not actually used in a type declaration.
Cleared g.curDecl to "" at the later points in typeDecl() and
funcDecl(). This allows adding asserts that g.curDecl is always empty
("") when we set it in typeDecl() and funcDecl(), and always non-empty
when we use it in typ0().
Fixes #49893
Change-Id: Ic2fb1df791585bd257f2b86ffaae0453c31705c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/368454
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Bryan C. Mills [Wed, 1 Dec 2021 16:04:39 +0000 (11:04 -0500)]
net: remove arbitrary deadlines in PacketConn tests
When TestPacketConn was added (in CL 6501057) it included arbitrary
100ms deadlines. Those deadlines were arbitrarily increased to 500ms
in CL 4922.
If the test is actually provoking a deadlock, allowing it to deadlock
will give us a more useful goroutine dump. Otherwise, the deadlines
don't seem all that useful — they appear to increase code coverage,
but have no effect on the test in the typical case, and can only
cause flakes on particularly-slow machines.
For #43627
Change-Id: I83de5217c54c743b83adddf51d4f6f2bd5b91732
Reviewed-on: https://go-review.googlesource.com/c/go/+/368215
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Bryan C. Mills [Wed, 1 Dec 2021 19:15:08 +0000 (14:15 -0500)]
os/exec: in TestContextCancel, dump goroutines on failure
If this test fails, we want to know exactly what the os/exec
goroutines are doing. Panicking gives us a goroutine dump,
whereas t.Fatal does not.
While we're here, use exponential backoff instead of a hard-coded 1ms
sleep. We want to give the OS enough time to actually terminate the
subprocess.
For #42061
Change-Id: I3d50a71ac314853c68a935218e7f97ce18b08b5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/368317
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Robert Findley [Tue, 30 Nov 2021 22:48:51 +0000 (17:48 -0500)]
gcimporters: allow reusing empty interfaces on the RHS of type decls
We guard against caching or reusing interfaces on the RHS of a type
declaration, because for such interfaces the base type is used as the
interface method receiver type. However, we don't need to do this for
empty interfaces. By refining our guard, we can allow importing the
predeclared 'any' type on the RHS of a type declaration.
Update tests to add more coverage for importing generic export data.
Some accomodation had to be made for the unified builder, which does not
yet fully support generics in export data.
Fixes #49888
Change-Id: I51f329de464fc7309f95991b839ab55868c2924f
Reviewed-on: https://go-review.googlesource.com/c/go/+/367851
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Austin Clements [Wed, 1 Dec 2021 13:56:19 +0000 (08:56 -0500)]
runtime: fix racy allgs access on weak memory architectures
Currently, markroot is very clever about accessing the allgs slice to
find stack roots. Unfortunately, on weak memory architectures, it's a
little too clever and can sometimes read a nil g, causing a fatal
panic.
Specifically, gcMarkRootPrepare snapshots the length of allgs during
STW and then markroot accesses allgs up to this length during
concurrent marking. During concurrent marking, allgadd can append to
allgs *without synchronizing with markroot*, but the argument is that
the markroot access should be safe because allgs only grows
monotonically and existing entries in allgs never change.
This reasoning is insufficient on weak memory architectures. Suppose
thread 1 calls allgadd during concurrent marking and that allgs is
already at capacity. On thread 1, append will allocate a new slice
that initially consists of all nils, then copy the old backing store
to the new slice (write A), then allgadd will publish the new slice to
the allgs global (write B). Meanwhile, on thread 2, markroot reads the
allgs slice base pointer (read A), computes an offset from that base
pointer, and reads the value at that offset (read B). On a weak memory
machine, thread 2 can observe write B *before* write A. If the order
of events from thread 2's perspective is write B, read A, read B,
write A, then markroot on thread 2 will read a nil g and then panic.
Fix this by taking a snapshot of the allgs slice header in
gcMarkRootPrepare while the world is stopped and using that snapshot
as the list of stack roots in markroot. This eliminates all read/write
concurrency around the access in markroot.
Alternatively, we could make markroot use the atomicAllGs API to
atomically access the allgs list, but in my opinion it's much less
subtle to just eliminate all of the interesting concurrency around the
allgs access.
Fixes #49686.
Fixes #48845.
Fixes #43824.
(These are all just different paths to the same ultimate issue.)
Change-Id: I472b4934a637bbe88c8a080a280aa30212acf984
Reviewed-on: https://go-review.googlesource.com/c/go/+/368134
Trust: Austin Clements <austin@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Bryan C. Mills [Tue, 30 Nov 2021 21:10:47 +0000 (16:10 -0500)]
runtime: give the subprocess more time in TestSpuriousWakeupsNeverHangSemasleep
Issue #27250 reproduced readily enough to keep the subprocess hung
indefinitely when it occurred, so the timeout does not need to be
short to maintain test fidelity. On the other hand, on heavily loaded
systems it might take a while for the kernel to actually start the
subprocess, and it might also take a while for control flow to return
to the test after the subprocess exits.
We can reduce noise from this test in two ways:
1. Measure the timeout from closer to when the subprocess actually
starts sleeping, instead of when we started creating the subprocess.
2. Use a longer timeout, since it doesn't actually need to be short.
Fixes #38921
Updates #27250
Change-Id: I01c11ae82d0cdc6e7def2da6544b4d07201b35e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/367849
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Rhys Hiltner [Tue, 30 Nov 2021 00:48:34 +0000 (16:48 -0800)]
runtime: fix riscv64 sigaction mask field offset
The Linux kernel for riscv64 does not include an sa_restorer field on
its sigaction struct, and expects sa_mask to come immediately after the
sa_flags field. Arrange the fields of the sigaction struct that are
known to the kernel so they appear at the correct byte offsets, and so
they agree with the output of "go tool cgo -godefs".
Follow the example set by the mips/mipsle port to leave the sa_restorer
field in place, but at an offset where it won't hurt anything.
Fixes #49709
Change-Id: I9bb0d7dbd7439d07e3a204461c7d790f33fd4977
Reviewed-on: https://go-review.googlesource.com/c/go/+/367635
Run-TryBot: Rhys Hiltner <rhys@justin.tv> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Joel Sing <joel@sing.id.au>
Trust: Ian Lance Taylor <iant@golang.org>
Cherry Mui [Tue, 30 Nov 2021 22:30:57 +0000 (17:30 -0500)]
net: do not use sendfile on iOS
Apparently, on the iOS builder sendfile causes a SIGSYS signal
(instead of returning ENOSYS). Disabling it for now so we can
make progress on iOS. We can revisit if sendfile is actually
broken on iOS and whether it is beneficial.
Updates #49616.
Change-Id: I3883fad0ce35e3f0aa352301eb499a1afa0225a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/368054
Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Changkun Ou <mail@changkun.de> Reviewed-by: Roland Shoemaker <roland@golang.org>
Cuong Manh Le [Tue, 30 Nov 2021 09:58:36 +0000 (16:58 +0700)]
cmd/compile: fix identical to recognize any and interface{}
Currently, identical handles any and interface{} by checking against
Types[TINTER]. This is not always true, since when two generated
interface{} types may not use the same *Type instance.
Instead, we must check whether Type is empty interface or not.
Fixes #49875
Change-Id: I28fe4fc0100041a01bb03da795cfe8232b515fc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/367754
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Tobias Klauser [Tue, 30 Nov 2021 22:21:39 +0000 (23:21 +0100)]
runtime: skip TestSignalIgnoreSIGTRAP on all OpenBSD builders
TestSignalIgnoreSIGTRAP is flaky on OpenBSD and the cause is suspected
to be a kernel bug. This test is currently only skipped on the previous
OpenBSD 6.2 and 6.4 builders for #17496. In the meantime the OpenBSD
builders were upgraded to more recent OpenBSD versions (currently 6.8
and 7.0). It seems the issue is still present in these OpenBSD versions
and there is no obvious workaround in Go. Thus, skip the flaky test on
OpenBSD in general.
Paul E. Murphy [Fri, 19 Nov 2021 22:33:42 +0000 (16:33 -0600)]
misc/cgo/test: further reduce likeliness of hang in Test9400
As suggested by #49680, a GC could be in-progress when we
disable GC. Force a GC after we pause to ensure we don't
hang in this case.
For #49695
Change-Id: I4fc4c06ef2ac174217c3dcf7d58c7669226e2d24
Reviewed-on: https://go-review.googlesource.com/c/go/+/367874
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Paul Murphy <murp@ibm.com>
Russ Cox [Mon, 25 Oct 2021 20:02:07 +0000 (16:02 -0400)]
cmd/go: adjust BuildInfo.Settings
Make Settings more closely align with command-line flags
and environment variables.
- Change command-line flags to begin with -
- Change syntax of build lines to use Key=Value instead of Key<tab>Value.
- Change CGO_ENABLED to 0/1, matching environment variable,
instead of false/true.
- Add GOOS and GOARCH.
These are technically redundant, in that they can be extracted
from the binary in other ways most of the time, but not always:
GOOS=ios and GOOS=darwin may produce binaries that are
difficult to tell apart. In any case, it's a lot easier to have them
directly in the settings list than derive them from other parts
of the binary.
- Add GOEXPERIMENT.
These could be inferred from the tags list, but the experiments
are being removed from the tags list.
- Change the tags list to match the -tags command-line argument.
- Add msan and race, echoing the -msan and -race arguments
(always 'true' when present, omitted when false).
Paul E. Murphy [Fri, 19 Nov 2021 22:33:42 +0000 (16:33 -0600)]
misc/cgo/test: reduce likeliness of hang in Test9400
If a GC triggers while spinning in RewindAndSetgid, it may result in
this test hanging. Avoid it by disabling the collector before entering
the uninterruptable ASM conditional wait.
Fixes #49695
Change-Id: Ie0a03653481fb746f862469361b7840f4bfa8b67
Reviewed-on: https://go-review.googlesource.com/c/go/+/365836
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Bryan C. Mills [Mon, 29 Nov 2021 20:17:36 +0000 (15:17 -0500)]
net/http: eliminate arbitrary timeout in TestClientWriteShutdown
This test occasionally hangs on the darwin-arm64-11_0-toothrot
builder. When it does, it fails with the unhelpful error message
"timeout" instead of a useful goroutine dump.
This change eliminates the use of an arbitrary timeout channel, so
that if (and probably when) the test hangs again we will get more
useful logs to diagnose the root cause.
For #49860
Change-Id: I23f6f1c81209f0b2dbe565e1dfb26b1b2eff0187
Reviewed-on: https://go-review.googlesource.com/c/go/+/367615
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Jason A. Donenfeld [Mon, 29 Nov 2021 20:07:04 +0000 (15:07 -0500)]
runtime: keep //go:cgo_unsafe_args arguments alive to prevent GC
When syscall's DLL.FindProc calls into syscall_getprocaddress with a
byte slice pointer, we need to keep those bytes alive. Otherwise the GC
will collect the allocation, and we wind up calling `GetProcAddress` on
garbage, which showed up as various flakes in the builders. It turns out
that this problem extends to many uses of //go:cgo_unsafe_args
throughout, on all platforms. So this patch fixes the issue by keeping
non-integer pointer arguments alive through their invocation in
//go:cgo_unsafe_args functions.
Fixes #49731.
Change-Id: I93e4fbc2e8e210cb3fc53149708758bb33f2f9c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/367654
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Patrik Nyblom <pnyb@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Robert Findley [Mon, 29 Nov 2021 22:39:19 +0000 (17:39 -0500)]
go/types, types2: handle case of no specific target types in conversion
Avoid a panic by handling the case of no specific target type in a type
parameter to type parameter conversions.
Fixes #49864
Change-Id: I117dd80cc9d47c8c1e168f1caf0f281726270c84
Reviewed-on: https://go-review.googlesource.com/c/go/+/367616
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Robert Findley [Mon, 29 Nov 2021 19:52:54 +0000 (14:52 -0500)]
go/types: ensure that constructed type parameters are immutable
TypeParam.iface may mutate TypeParam.bound in the event that the type
parameter bound is not an interface.
Ensure that iface() is called before the type-checking pass returns, and
before NewTypeParam or TypeParam.SetConstraint exits.
Fixes #49788
Change-Id: I72279acf5f0223161671c04887bc2c3df4158927
Reviewed-on: https://go-review.googlesource.com/c/go/+/367614
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Robert Findley [Mon, 29 Nov 2021 17:21:46 +0000 (12:21 -0500)]
go/types: consider structural restrictions in Implements
Fixes #49786
Change-Id: I4559d013399deda48bcb97aef3427ecf87a3ef26
Reviewed-on: https://go-review.googlesource.com/c/go/+/367515
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>