1
0
mirror of https://github.com/golang/go synced 2024-07-05 09:50:19 +00:00
Commit Graph

50860 Commits

Author SHA1 Message Date
Dan Scales
29483b3dae 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>
2021-12-03 16:24:32 +00:00
Felix Geisendörfer
9b0de0854d 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>
2021-12-03 16:11:38 +00:00
Bryan C. Mills
a174638a5c os: test that LookupEnv reports all keys found in Environ
For #49886

Change-Id: Ie3a7f12a0d30ec719caf375e7be30cc4a5796c3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/367850
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-03 14:28:11 +00:00
Ian Lance Taylor
098599003b 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>
2021-12-03 01:09:21 +00:00
Cherry Mui
8da66a35ca 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>
2021-12-03 00:46:20 +00:00
Cherry Mui
5f6552018d 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.

Fixes #49138.

Change-Id: I7b367d6e042b0db39a691c71601c98e4f8728a70
Reviewed-on: https://go-review.googlesource.com/c/go/+/367916
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-12-02 23:34:26 +00:00
Ian Lance Taylor
8835343280 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>
2021-12-02 23:02:33 +00:00
Shang Jian Ding
fd4b391849 crypto/x509: fix comments on certDirectories
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.

Fixes #48808

Change-Id: Id92f875545272fc6205d9955d03ea7bf844f15eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/354140
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Katie Hockman <katie@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Katie Hockman <katie@golang.org>
2021-12-02 22:53:18 +00:00
Jeremy Faller
06dbf6121a doc/go1.18: remove some TODOs for changes we aren't mentioning
Updates #47694

Change-Id: I8fdbded4aaf974425ee317a1cdd940a5ac88c0b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/368794
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-02 22:06:27 +00:00
Jeremy Faller
48e4284e55 doc/go1.18: add docs on FieldByIndexErr
From:
https://go-review.googlesource.com/c/go/+/357962/

Updates #47694

Change-Id: I2d43dcbd28c03457b55eada26e87f7710a113b0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/368364
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-02 22:06:10 +00:00
Jeremy Faller
e533b5793f doc/go1.18: add docs on new reflect.Value methods
From:

https://go-review.googlesource.com/c/go/+/352131/

Updates #47694

Change-Id: I7c7811c49900049f5ef7fc906fe25d2ffd73c7b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/368363
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Fabio Falzoi <fabio.falzoi84@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-02 22:05:56 +00:00
Jeremy Faller
f9b2733e3a doc/go1.18: add docs on MapIter.Reset
From:

https://go-review.googlesource.com/c/go/+/321891

Updates #47694

Change-Id: I2cdd5d9f3da62a5690cd2ef921ed48957c602d64
Reviewed-on: https://go-review.googlesource.com/c/go/+/368360
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-02 22:05:01 +00:00
Jeremy Faller
bcb98f126b doc/go1.18: add docs on User.GroupIds
Cobbled up some release notes from:

https://go-review.googlesource.com/c/go/+/330753/

Updates #47694

Change-Id: I249e4b96b7d51185b07c11a734505677e9e36315
Reviewed-on: https://go-review.googlesource.com/c/go/+/368358
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-02 22:04:50 +00:00
Jeremy Faller
c8c89d20ce doc/go1.18: add docs on Cookie.Valid
Updates #47694

Change-Id: Ibf3e25fbccf82e4abd7bd76b2ea6ceb4b05d4664
Reviewed-on: https://go-review.googlesource.com/c/go/+/368357
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-02 22:04:23 +00:00
Jeremy Faller
25f06cb71f doc/go1.18: add deprecation note for net.Error.Temporary
Updates #47694

Change-Id: Ia25ad49f688efa3d60d83290095648711704b478
Reviewed-on: https://go-review.googlesource.com/c/go/+/368316
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-02 22:03:54 +00:00
Jeremy Faller
94e22fa03e doc/go1.18: add Conn.NetConn documentation to crypto/tls section
Updates #47694

Change-Id: Iead44baa8b2a06ecf7b92d343ed9117f0fc0793e
Reviewed-on: https://go-review.googlesource.com/c/go/+/368315
Trust: Jeremy Faller <jeremy@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
2021-12-02 22:03:34 +00:00
Jeremy Faller
d3bf627bc1 doc/go1.18: add constraints package documentation
Updates #47694

Change-Id: I3239023dad194c317e271e6093eff2cfbed1a4b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/368314
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-02 22:03:11 +00:00
Jeremy Faller
d514411625 doc/go1.18: add information on new pacer.
This is based off Michael's notes.

Updates #47694

Change-Id: I6e7944f85b776e8481829a2fafd177a49557c6ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/368156
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-12-02 22:02:54 +00:00
Dan Scales
bbe1be5c19 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>
2021-12-02 20:49:56 +00:00
Jeremy Faller
3c6295d272 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>
2021-12-02 20:45:47 +00:00
Robert Findley
469f030dca all: update vendored golang.org/x/tools
Update the vendored x/tools to pick up CL 364678, which updates vet
analyzers following a change to the underlying of type parameters.

This also pulls in significant changes to the typeutil package to
support new constructs in typeutil.Map, but this is not used by vet.

The following commands were used:

  go get -d golang.org/x/tools@e212aff8fd146c44ddb0167c1dfbd5531d6c9213
  go mod tidy
  go mod vendor

Fixes #49855

Change-Id: I3ffc59f3693710c83b81d390999aeabc8043723b
Reviewed-on: https://go-review.googlesource.com/c/go/+/368774
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-02 20:21:16 +00:00
Michael Anthony Knyszek
c5c1955077 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>
2021-12-02 18:02:46 +00:00
Changkun Ou
36be0beb05 misc/ios: bump min version
For #48076

Change-Id: I5edaa43af82c3478555c309a001a3d1b16de3d64
Reviewed-on: https://go-review.googlesource.com/c/go/+/368615
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-02 16:48:07 +00:00
Austin Clements
28ec0fdeb5 runtime: print errno on clock_gettime failure on OpenBSD
For #49532.

Change-Id: I5afc64c987f0519903128550a7dac3a0f5e592cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/368334
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-12-02 15:48:58 +00:00
Dan Scales
d34051bf16 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>
2021-12-02 07:04:05 +00:00
Bryan C. Mills
1b2930d70c 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>
2021-12-02 05:26:57 +00:00
Bryan C. Mills
00dbcb33f8 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>
2021-12-02 05:25:23 +00:00
Cherry Mui
c3a7fb2074 doc/go1.18: mention stack trace change
For #47694.

Change-Id: I06cac88d5328c8c0e38212ad801d70bc36cdfc6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/368234
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-12-01 22:20:39 +00:00
Robert Findley
0103fd2b8b 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>
2021-12-01 19:00:50 +00:00
Baokun Lee
6c4bf8fb8a cmd/go/internal/modfetch: remove legacy code
ReadFileRevs function is no longer used.

Change-Id: Ibac6319dca4cf8010195e7c2fb502655494fb728
Reviewed-on: https://go-review.googlesource.com/c/go/+/367756
Run-TryBot: Baokun Lee <bk@golangcn.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Baokun Lee <bk@golangcn.org>
2021-12-01 18:48:35 +00:00
Austin Clements
08ecdf7c2e 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>
2021-12-01 17:13:34 +00:00
Bryan C. Mills
8ebb8c9ecb 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>
2021-12-01 17:01:41 +00:00
Rhys Hiltner
2c5d2083e4 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>
2021-12-01 16:55:04 +00:00
Cherry Mui
029dfbcc83 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>
2021-12-01 15:58:46 +00:00
Bryan C. Mills
ab7905540b cmd/go/internal/modload: fix up main-module checks from CL 334932
Some critical Version == "" checks were missing in mvs.go, causing
mvs.Req to fail to retain requirements provided by older versions of
main modules.

A few checks also ought to be rotated to put the less expensive
string-equality checks before the more expensive map lookups.

Fixes #48511

Change-Id: Ib8de9d49a6413660792c003866bfcf9ab7f82ee2
Reviewed-on: https://go-review.googlesource.com/c/go/+/368136
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-12-01 15:43:08 +00:00
Cuong Manh Le
0e1d553b4d 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>
2021-12-01 10:19:34 +00:00
Tobias Klauser
a412b5f0d8 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.

Updates #17496
Updates #49725

Change-Id: I3577d287dcfaad7a81679db2e71540854fce065a
Reviewed-on: https://go-review.googlesource.com/c/go/+/367115
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-12-01 06:03:27 +00:00
Paul E. Murphy
7ccbcc9056 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>
2021-11-30 20:04:58 +00:00
Chaoqun Han
5f63f168da runtime: add invalidptr=0 for TestGcZombieReporting
pointers in zombies slice may cross-span, add invalidptr=0 for avoiding the badPointer check

Fixes #49613

Change-Id: Ifb1931922170e87e799e2e6081dc85dab3890205
Reviewed-on: https://go-review.googlesource.com/c/go/+/367044
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-11-30 18:49:39 +00:00
Russ Cox
931d80ec17 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).

- Add GO$GOARCH when set.

Change-Id: Icb59ef4faa5c22407eadd94147b7e53cf4344ce6
Reviewed-on: https://go-review.googlesource.com/c/go/+/358539
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-30 18:09:02 +00:00
Paul E. Murphy
682435dd99 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>
2021-11-30 15:28:46 +00:00
Bryan C. Mills
18934e11ba 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>
2021-11-30 03:39:57 +00:00
Jason A. Donenfeld
f463b20789 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>
2021-11-30 03:11:18 +00:00
Dan Scales
f90a42b410 cmd/compile: change iexportVersionGeneric to 2
Don't expect/allow generics-related info in iexportVersion 1, now that
we increased the export version to 2.

Fixes #49853

Change-Id: I9bacee7f8e7cb9bb3b02a00084fad77edd220121
Reviewed-on: https://go-review.googlesource.com/c/go/+/367634
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>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2021-11-30 01:25:55 +00:00
Robert Findley
3ca57c7fb8 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>
2021-11-29 22:57:42 +00:00
Robert Findley
186f375ecf 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>
2021-11-29 22:25:04 +00:00
Robert Findley
c402d64f37 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>
2021-11-29 22:24:47 +00:00
Robert Griesemer
ebd0b778c9 go/types: better error message for missing ~ in constraint
This is a port of CL 366758 from types2 to go/types.

For #49179.

Change-Id: I7e1c6ffb392d5c535cf901004b7acbe8c3be9b0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/367199
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-29 22:02:51 +00:00
Robert Griesemer
bc32dd1b69 go/types: better error position for instantiation failure
This is a port of CL 366757 from types2 to go/types,
adjusted for the different handling of index expressions
in go/types.

For #49179.

Change-Id: Ic859eb09683134d055e28c8e0cb1f3814a87dc5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/367198
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-29 22:02:50 +00:00
Robert Griesemer
1ab677a797 go/types: produce empty type set for invalid ~T
This is a clean port of CL 366278 from types2 to go/types.

For #49739.

Change-Id: I2e2cb739c02fcc07e012499c7b65b13b057875ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/367197
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-29 22:02:49 +00:00