]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agoruntime: call fflush before exiting in C test
Austin Clements [Mon, 24 Jan 2022 14:27:31 +0000 (09:27 -0500)]
runtime: call fflush before exiting in C test

Very, very rarely TestVectoredHandlerDontCrashOnLibrary fails because
the C subprocess exits with a 0 status code and no output. This
appears to happen because C does not actually guarantee that stdout
will be flushed on exit and somehow, very rarely, it is not flushed.

Add explicit fflushes to fix this. This reduces the failure rate of
TestVectoredHandlerDontCrashOnLibrary from 0.0013% to 0% in 250,000
iterations.

Fixes #49959.

Change-Id: I892cf49a165ac91134c5da37588a2ab11e1f3f8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/380494
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
3 years agoRevert "cmd/go: evaluate root symlink in matchPackages"
Bryan Mills [Sat, 22 Jan 2022 03:42:40 +0000 (03:42 +0000)]
Revert "cmd/go: evaluate root symlink in matchPackages"

This reverts CL 380057.

Reason for revert: appears to have broken x/tools tests on macOS.

Change-Id: If1340bcb9b78f7271798c4dd923553e33db7f72e
Reviewed-on: https://go-review.googlesource.com/c/go/+/380294
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agospec: minor formatting and link cleanups
Ian Lance Taylor [Fri, 21 Jan 2022 22:30:39 +0000 (14:30 -0800)]
spec: minor formatting and link cleanups

Mostly from CL 367954.

Change-Id: Id003b0f785a286a1a649e4d6e8c87d0418a36545
Reviewed-on: https://go-review.googlesource.com/c/go/+/379920
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/go: evaluate root symlink in matchPackages
Michael Matloob [Fri, 21 Jan 2022 21:05:02 +0000 (16:05 -0500)]
cmd/go: evaluate root symlink in matchPackages

This fixes checks for crossing module boundaries when the root of
the module is a symlink. We're comparing paths by string, so we need
to follow the symlink to get the proper path to compare.

Change-Id: Idf5f0dd5c49bcae5fffb5372e99a7fab89169a9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/380057
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime/pprof: TestLabelSystemstack parallelLabelHog.func1 must be labeled
Michael Pratt [Fri, 21 Jan 2022 16:07:52 +0000 (11:07 -0500)]
runtime/pprof: TestLabelSystemstack parallelLabelHog.func1 must be labeled

The closure in parallelLabelHog should be labeled in a addition to
parallelLabelHog itself. Generally samples on that goroutine land on
labelHog, but there is a small portion of the closure outside of
labelHog.

Fixes #50740.

Change-Id: I363b6d8eec2e6920c215686e2039fce6d5b29a98
Reviewed-on: https://go-review.googlesource.com/c/go/+/380055
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Michael Pratt <mpratt@google.com>

3 years agoRevert "doc/go1.18: document type parameter name restriction"
Robert Griesemer [Fri, 21 Jan 2022 00:20:33 +0000 (16:20 -0800)]
Revert "doc/go1.18: document type parameter name restriction"

This reverts CL 376414.

For #47694.
For #50481.

Change-Id: Ie73961046e52e6e5d3262ef0aeaa24bec7eaa937
Reviewed-on: https://go-review.googlesource.com/c/go/+/379835
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: make sure multiple blank typeparams remain unique
Dan Scales [Tue, 18 Jan 2022 20:55:17 +0000 (12:55 -0800)]
cmd/compile: make sure multiple blank typeparams remain unique

In a method declaration "func (f *Foo[_, _]) String() string { ... }",
the two blank typeparams have the same name, but our current design with
types1 needs unique names for type params. Similarly, for export/import,
we need unique names to keep the type params straight in generic types
and connect the proper type param with the proper constraint. We make
blank type params unique by changing them to $1, $2, etc in noder.typ0()
via typecheck.TparamExportName(). We then revert $<num> back to _ during
type2 import via typecheck.TparamName(). We similarly revert
during gcimporter import. We don't need/want to revert in the types1
importer, since we want unique names for type params.

Rob Findley has made a similar change to x/tools (and we tried to make
the source code changes similar for the gcimporter and types2 importer
changes).

Fixes #50419

Change-Id: I855cc3d90d06bcf59541ed0c879e9a0e4ede45bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/379194
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>

3 years agoruntime: remove -tags=threadprof in tests
Ian Lance Taylor [Wed, 19 Jan 2022 02:46:00 +0000 (18:46 -0800)]
runtime: remove -tags=threadprof in tests

Use an enviroment variable rather than a build tag to control starting
a busy loop thread when testprogcgo starts. This lets us skip another
build that invokes the C compiler and linker, which should avoid
timeouts running the runtime tests.

Fixes #44422

Change-Id: I516668d71a373da311d844990236566ff63e6d72
Reviewed-on: https://go-review.googlesource.com/c/go/+/379294
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
3 years agocmd/go: ignore replaces of main modules in workspace modules
Michael Matloob [Wed, 19 Jan 2022 18:38:05 +0000 (13:38 -0500)]
cmd/go: ignore replaces of main modules in workspace modules

And disallow replaces of any main modules in the go.work file itself.

Change-Id: Ifa9ba9eaed047e6a75fcde230d96c7c450c1a1ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/379534
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime/pprof: allow labels on racecall in TestLabelSystemstack
Michael Pratt [Thu, 20 Jan 2022 16:17:51 +0000 (11:17 -0500)]
runtime/pprof: allow labels on racecall in TestLabelSystemstack

Fixes #50705.

Change-Id: I85857f836cbe58447625df6cd56756d3a69880ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/379834
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agogo/types, types2: use Identical rather than unification in missingMethod
Robert Findley [Thu, 20 Jan 2022 03:00:42 +0000 (22:00 -0500)]
go/types, types2: use Identical rather than unification in missingMethod

Now that we instantiate methods on instantiated types, there is no need
to use unification to match signatures inside of missingMethod.

Generally, we should never encounter uninstantiated signatures within
statements. If we do encounter signatures that contain type parameters,
it is because the signatures are themselves defined or instantiated
using type parameters declared in the function scope (see example
below). The current unification logic would not handle this.

type S[T any] struct{}
func (S[T]) m(T)

func _[P any]() bool {
var v interface{m(int)}
_, ok = v.(S[P])
return ok
}

Change-Id: I754fb5535bba2fc7a209dc7419fd4015c413c9a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/379540
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile/internal/importer, gcimporter: use *TypeParam as tparamIndex map value
Robert Griesemer [Wed, 19 Jan 2022 23:48:17 +0000 (15:48 -0800)]
cmd/compile/internal/importer, gcimporter: use *TypeParam as tparamIndex map value

This is a map from identifiers to type parameters, use *TypeParam
as map value instead of Type.

Change-Id: Ib006393418c6352bcffc1c6796c5e002c33d9f4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/379634
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoregexp: add the missing is
luochuanhang [Tue, 18 Jan 2022 01:59:20 +0000 (01:59 +0000)]
regexp: add the missing is

Change-Id: I23264972329aa3414067cd0e0986b69bb39bbeb5
GitHub-Last-Rev: d1d668a3cbe852d9a06f03369e7e635232d85139
GitHub-Pull-Request: golang/go#50650
Reviewed-on: https://go-review.googlesource.com/c/go/+/378935
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>

3 years agoruntime: print error if mmap fails
Ian Lance Taylor [Wed, 19 Jan 2022 03:44:34 +0000 (19:44 -0800)]
runtime: print error if mmap fails

Fixes #49687

Change-Id: Ife7f64f4c98449eaff7327e09bc1fb67acee72c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/379354
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
3 years agocmd/compile: add early a CONVIFACE normally created in the order phase
Dan Scales [Mon, 17 Jan 2022 21:24:06 +0000 (13:24 -0800)]
cmd/compile: add early a CONVIFACE normally created in the order phase

Most CONVIFACEs are created in the transform phase (or old typechecker,
in -G=0 mode). But if the main result of a multi-value assignment (map,
channel, or dot-type) must be converted to an interface during the
assignment, that CONVIFACE is not created until (*orderState).as2ok in
the order phase (because the AS2* ops and their sub-ops are so tightly
intertwined). But we need to create the CONVIFACE during the
stenciling/transform phase to enable dictionary lookups. So, in
transformAssign(), if we are doing a special multi-value assignment
involving a type-param-derived type, assign the results first to temps,
so that we can manifest the CONVIFACE during the transform in assigning
the first temp to lhs[0].

Added a test for both AS2RECV (channel receives) and AS2MAPR (maps). I
don't think we can have a type assertion on a type-param-derived type.

Fixes #50642

Change-Id: I4d079fc46c93d8494d7db4ea8234d91522edb02a
Reviewed-on: https://go-review.googlesource.com/c/go/+/379054
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agogo/types, types2: use orig. compiler error message for a shift error
Robert Griesemer [Wed, 19 Jan 2022 01:52:16 +0000 (17:52 -0800)]
go/types, types2: use orig. compiler error message for a shift error

Slightly better for cases such as string(1 << s).
Leaves type-checker tests alone for now because
there are multiple dozens.

For #45117.

Change-Id: I47b314c713fabe424c2158674bf965416a8a6f5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/379274
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agodoc/go1.18: don't mention -buildinfo flag
Ian Lance Taylor [Wed, 19 Jan 2022 03:14:25 +0000 (19:14 -0800)]
doc/go1.18: don't mention -buildinfo flag

It was removed in CL 378576.

For #50501

Change-Id: I26b8f0e99a40fa5c616aa4849a6ab15dd0d072f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/379314
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
3 years agoruntime/pprof: compare all samples vs rusage in TestCPUProfileMultithreadMagnitude
Michael Pratt [Wed, 19 Jan 2022 19:25:12 +0000 (14:25 -0500)]
runtime/pprof: compare all samples vs rusage in TestCPUProfileMultithreadMagnitude

TestCPUProfileMultithreadMagnitude compares pprof results vs OS rusage
to verify that pprof is capturing all CPU usage. Presently it compares
the sum of cpuHog1 samples vs rusage. However, background usage from the
scheduler, GC, etc can cause additional CPU usage causing test failures
if rusage is too far off from the cpuHog1 samples.

That said, this test doesn't actually need to care about cpuHog1
samples. It simply cares that pprof samples match rusage, not what the
breakdown of usage was. As a result, we can compare the sum of _all_
pprof samples vs rusage, which should implicitly include any background
CPU usage.

Fixes #50097.

Change-Id: I649a18de5b3dcf58b62be5962fa508d14cd4dc79
Reviewed-on: https://go-review.googlesource.com/c/go/+/379535
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 years agogo/types, types2: explicitly check for non-nil type in LookupFieldOrMethod
Robert Griesemer [Wed, 19 Jan 2022 03:58:14 +0000 (19:58 -0800)]
go/types, types2: explicitly check for non-nil type in LookupFieldOrMethod

Document and enforce API expectation. Add a test so we don't
inadvertently change the function behavior with respect to nil
type arguments.

Fixes #50620.

Change-Id: Ic000bff7504a03006bd248a319c7a2d49dcf09c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/379374
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime/pprof: assert that labels never appear on unexpected samples
Michael Pratt [Tue, 7 Dec 2021 17:01:04 +0000 (12:01 -0500)]
runtime/pprof: assert that labels never appear on unexpected samples

This makes TestLabelSystemstack much more strict, enabling it to detect
any misplacement of labels.

Unfortunately, there are several edge cases where we may not have an
obviously correct stack trace, so we generally except the runtime
package, with the exception of background goroutines that we know should
not be labeled.

For #50007
For #50032

Change-Id: I8dce7e7da04f278ce297422227901efe52782ca0
Reviewed-on: https://go-review.googlesource.com/c/go/+/369984
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
3 years agoruntime: do not inherit labels on system goroutines
Michael Pratt [Tue, 7 Dec 2021 20:59:14 +0000 (15:59 -0500)]
runtime: do not inherit labels on system goroutines

GC background mark worker goroutines are created when the first GC is
triggered (or next GC after GOMAXPROCS increases). Since the GC can be
triggered from a user goroutine, those workers will inherit any pprof
labels from the user goroutine.

That isn't meaningful, so avoid it by excluding system goroutines from
inheriting labels.

Fixes #50032

Change-Id: Ib425ae561a3466007ff5deec86b9c51829ab5507
Reviewed-on: https://go-review.googlesource.com/c/go/+/369983
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>

3 years agoruntime: eliminate arbitrary timeout in TestStackGrowth
Bryan C. Mills [Wed, 12 Jan 2022 15:26:04 +0000 (10:26 -0500)]
runtime: eliminate arbitrary timeout in TestStackGrowth

Instead, allow the test to run up until nearly the test's deadline,
whatever that may be, and then crash with a panic (instead of calling
t.Errorf) to get a useful goroutine dump.

With the arbitrary timeout removed, we can now also run this test in
short mode, reducing its impact on test latency.

Fixes #19381

Change-Id: Ie1fae321a2973fcb9b69a012103363f16214f529
Reviewed-on: https://go-review.googlesource.com/c/go/+/378034
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: don't elide extension for LoadReg to FP register on MIPS64
Cherry Mui [Tue, 18 Jan 2022 23:36:00 +0000 (18:36 -0500)]
cmd/compile: don't elide extension for LoadReg to FP register on MIPS64

For an extension operation like MOWWreg, if the operand is already
extended, we optimize the second extension out. Usually a LoadReg
of a proper type would come already extended, as a MOVW/MOVWU etc.
instruction does. But for a LoadReg to a floating point register,
the instruction does not do the extension. So we cannot elide the
extension.

Fixes #50671.

Change-Id: Id8991df78d5acdecd3fd6138c558428cbd5f6ba3
Reviewed-on: https://go-review.googlesource.com/c/go/+/379236
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 years agoruntime: deflake TestPreemptionAfterSyscall
Austin Clements [Tue, 18 Jan 2022 21:27:40 +0000 (16:27 -0500)]
runtime: deflake TestPreemptionAfterSyscall

This test occasionally takes very slightly longer than the 3 second
timeout on slow builders (especially windows-386-2008), so increase
the timeout to 5 seconds. It fails with much longer timeouts on Plan
9, so skip it as flaky there.

Updates #41015.

Change-Id: I426a7adfae92c18a0f8a223dd92762b0b91565e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/379214
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
3 years agocmd/go: fix TestScript/version_buildvcs_git_gpg
Bryan C. Mills [Fri, 14 Jan 2022 16:15:28 +0000 (11:15 -0500)]
cmd/go: fix TestScript/version_buildvcs_git_gpg

This test was missed in CL 358539, presumably because the 'longtest'
builders lack a 'gpg' executable.

Updates #49168
Fixes #50675

Change-Id: Ie3bfc761a5e4304531119625742f3def9df8af3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/378575
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>
3 years agospec: add another example for an invalid shift case
Robert Griesemer [Wed, 19 Jan 2022 02:04:30 +0000 (18:04 -0800)]
spec: add another example for an invalid shift case

Fixes #45114.

Change-Id: I969e5f1037254fc0ffbba2fc07a81a3987e6b05f
Reviewed-on: https://go-review.googlesource.com/c/go/+/379275
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agogo/types, types2: report error for invalid string(1 << s)
Robert Griesemer [Tue, 18 Jan 2022 23:21:37 +0000 (15:21 -0800)]
go/types, types2: report error for invalid string(1 << s)

For #45114.
Fixes #45117.

Change-Id: I71d6650ae2c4c06952fce19959120f15f13c08a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/379256
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types, types2: avoid field/method lookup error on invalid types
Robert Griesemer [Wed, 12 Jan 2022 22:01:44 +0000 (14:01 -0800)]
go/types, types2: avoid field/method lookup error on invalid types

Fixes #49541.

Change-Id: I27a52d0722a7408758682e7ddcd608c0a6c4881b
Reviewed-on: https://go-review.googlesource.com/c/go/+/378175
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile: add missing copyright notice
Dan Scales [Tue, 18 Jan 2022 21:45:05 +0000 (13:45 -0800)]
cmd/compile: add missing copyright notice

Also, simplify one expression (missed comment on previous review).

Change-Id: Ic2d212442c2738e03c733336bb990e28c8912ca4
Reviewed-on: https://go-review.googlesource.com/c/go/+/379254
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>
3 years agocmd/compile, go/types: restore 'too many return values' error for func with no results
Russ Cox [Tue, 18 Jan 2022 15:31:59 +0000 (10:31 -0500)]
cmd/compile, go/types: restore 'too many return values' error for func with no results

Currently the code handles the case of returning values from
a function with no result parameters as a special case.
Consider this input:

package p

func f0_2()            { return 1, 2 }
func f0_1()            { return 1 }
func f1_0() int        { return }
func f1_2() int        { return 1, 2 }
func f2_0() (int, int) { return }
func f2_1() (int, int) { return 1 }

The errors are:

x.go:3:33: no result values expected   <<<
x.go:4:33: no result values expected   <<<
x.go:5:26: not enough return values
have ()
want (int)
x.go:6:36: too many return values
have (number, number)
want (int)
x.go:7:26: not enough return values
have ()
want (int, int)
x.go:8:33: not enough return values
have (number)
want (int, int)

There are two problems with the current special case emitting the
errors on the marked line:

1. It calls them 'result values' instead of 'return values'.
2. It doesn't show the type being returned, which can be useful to programmers.

Using the general case solves both these problems,
so this CL removes the special case and calls the general case instead.

Now those two errors read:

x.go:3:33: too many return values
have (number, number)
want ()
x.go:4:33: too many return values
have (number)
want ()

Fixes #50653.

Change-Id: If6b47dcece14ed4febb3a2d3d78270d5be1cb24d
Reviewed-on: https://go-review.googlesource.com/c/go/+/379116
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agodoc/go1.18: add a release note for 'go mod tidy' checksum changes
Bryan C. Mills [Fri, 14 Jan 2022 16:46:42 +0000 (11:46 -0500)]
doc/go1.18: add a release note for 'go mod tidy' checksum changes

Updates #47738
Fixes #49598

Change-Id: I708dcb880a701699116227a9eaca994cf460fef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/378577
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile, go/types: fix checking of bad type switch
Russ Cox [Tue, 18 Jan 2022 15:49:57 +0000 (10:49 -0500)]
cmd/compile, go/types: fix checking of bad type switch

Consider the following program:

package p

func f() {
x := 1
v := 2
switch v.(type) {
case int:
println(x)
println(x / 0)
case 1:
}
}

Before this CL, the compiler prints:

x.go:4:2: x declared but not used
x.go:6:9: v (variable of type int) is not an interface

x is in fact used, and other errors in the switch go undiagnosed.

This commit fixes that problem by processing the switch statement
even when the 'not an interface' error is reported.

Now the compiler drops the spurious 'declared but not used'
and adds two previously undiagnosed problems:

x.go:6:9: v (variable of type int) is not an interface
x.go:9:15: invalid operation: division by zero
x.go:10:7: 1 is not a type

go/types was printing roughly the same thing the compiler did before,
and now still prints roughly the same thing the compiler does after.
(The only differences are in the exact reported columns.)

Fixes #50493.

Change-Id: I317883f29077b1b4bbd0e8793617fd3bb31aa0f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/379117
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agonet/http: skip TestClientTimeout_Headers_h{1,2} on windows/arm and windows/arm64
Bryan C. Mills [Tue, 18 Jan 2022 17:21:18 +0000 (12:21 -0500)]
net/http: skip TestClientTimeout_Headers_h{1,2} on windows/arm and windows/arm64

This extends the skip added in CL 375635 to the "_Headers" variant of
the test, since we have observed similar failures in that variant on
the builders.

For #43120

Change-Id: Ib1c97fbb776b576271629272f3194da77913a941
Reviewed-on: https://go-review.googlesource.com/c/go/+/379156
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agocmd/compile: support field access for typeparam with structural constraint
Dan Scales [Fri, 7 Jan 2022 00:51:10 +0000 (16:51 -0800)]
cmd/compile: support field access for typeparam with structural constraint

In the compiler, we need to distinguish field and method access on a
type param. For field access, we avoid the dictionary access (to create
an interface bound) and just do the normal transformDot() (which will
create the field access on the shape type).

This field access works fine for non-pointer types, since the shape type
preserves the underlying type of all types in the shape. But we
generally merge all pointer types into a single shape, which means the
field will not be accessible via the shape type. So, we need to change
Shapify() so that a type which is a pointer type is mapped to its
underlying type, rather than being merged with other pointers.

Because we don't want to change the export format at this point in the
release, we need to compute StructuralType() directly in types1, rather
than relying on types2. That implementation is in types/type.go, along
with the helper specificTypes().

I enabled the compiler-related tests in issue50417.go, added an extra
test for unnamed pointer types, and added a bunch more tests for
interesting cases involving StructuralType(). I added a test
issue50417b.go similar to the original example, but also tests access to
an embedded field.

I also added a unit test in
cmd/compile/internal/types/structuraltype_test.go that tests a bunch of
unusual cases directly (some of which have no structural type).

Updates #50417

Change-Id: I77c55cbad98a2b95efbd4a02a026c07dfbb46caa
Reviewed-on: https://go-review.googlesource.com/c/go/+/376194
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/go: remove the -buildinfo flag
Bryan C. Mills [Fri, 14 Jan 2022 16:23:59 +0000 (11:23 -0500)]
cmd/go: remove the -buildinfo flag

Fixes #50501
(in a sense, by removing a flag that looks like it should do something
it does not)

Change-Id: I69ae4862706a6283cda4016fd43b361bb21557f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/378576
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
3 years agocmd/dist: avoid lapsing into x86 builds on ARM64 Macs
Russ Cox [Sun, 16 Jan 2022 17:58:45 +0000 (12:58 -0500)]
cmd/dist: avoid lapsing into x86 builds on ARM64 Macs

We use uname -m to decide the GOHOSTARCH default,
and on my ARM64 Mac laptop, uname -m prints x86_64.

uname -a prints:

Darwin p1.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 x86_64

(Note the x86_64 at the end, consistent with uname -m.)

The effect of this is that make.bash builds an x86 toolchain
even when I start with an ARM64 bootstrap toolchain!
Avoid being tricked by looking for RELEASE_ARM64 instead.

Fixes #50643.

Change-Id: I76eded84bde8009d29419d5982bf964a0bf1c8fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/378894
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/internal/obj/arm64: adjust rule for VMOVQ instruction
eric fang [Wed, 5 Jan 2022 09:20:06 +0000 (09:20 +0000)]
cmd/internal/obj/arm64: adjust rule for VMOVQ instruction

The VMOVQ instruction stores a 128-bit number into a V register, for
example:
    VMOVQ $0x1122334455667788, $0x99aabbccddeeff00, V2
From a documentation (https://pkg.go.dev/cmd/internal/obj/arm64) point
of view, the value in V2 should be 0x112233445566778899aabbccddeeff00,
however the value is actually 0x99aabbccddeeff001122334455667788. The
reason is that we misplaced the high 64-bit and the low 64-bit in the
literal pool. To maintain backward compatibility, this CL adjusts the
rule of VMOVQ instruction to make the documentation consistent with the
code.

Fixes #50528

Change-Id: Ib51f59e97c55252ab2a50bbc6ba4d430732a7a04
Reviewed-on: https://go-review.googlesource.com/c/go/+/377055
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Trust: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime/race: be less picky about test run time
Austin Clements [Fri, 14 Jan 2022 18:11:36 +0000 (13:11 -0500)]
runtime/race: be less picky about test run time

Currently, there are two regexps in the race detector output tests
that assume subtests will complete in < 1 second. This isn't necessary
and very occasionally fails (on builders that are probably very
loaded). Make these tests less picky about timing.

Fixes #50612.

Change-Id: Ib3f94d6c5dc37541dbeb06de71cf462a74af844b
Reviewed-on: https://go-review.googlesource.com/c/go/+/378581
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoRevert "cmd/dist: log CPU model when testing"
Michael Pratt [Fri, 14 Jan 2022 20:22:51 +0000 (15:22 -0500)]
Revert "cmd/dist: log CPU model when testing"

Fails TestRepeatBootstrap.

This reverts CL 371474.

For #50146.

Change-Id: Ie4adda4e0229e153471301ca00fe2c1c694b4b2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/378587
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoRevert "cmd/dist: log OS version when testing"
Michael Pratt [Fri, 14 Jan 2022 20:22:10 +0000 (15:22 -0500)]
Revert "cmd/dist: log OS version when testing"

Fails TestAllDependencies.

This reverts CL 371475.

For #50146.

Change-Id: I1feccd772d92d80e57c6327a4ac7b8af753a8c05
Reviewed-on: https://go-review.googlesource.com/c/go/+/378586
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/dist: log OS version when testing
Michael Pratt [Mon, 13 Dec 2021 22:34:16 +0000 (17:34 -0500)]
cmd/dist: log OS version when testing

As a follow-up to https://golang.org/cl/371474, add the OS version to
the metadata printed for each test.

Fixes #50146.

Change-Id: I3b7e47983d0e85feebce8e424881b931882d53bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/371475
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>
Reviewed-by: Austin Clements <austin@google.com>
3 years agocmd/dist: log CPU model when testing
Michael Pratt [Mon, 13 Dec 2021 22:32:07 +0000 (17:32 -0500)]
cmd/dist: log CPU model when testing

Knowing whether test failures are correlated with specific CPU models on
has proven useful on several issues. Log it for prior to testing so it
is always available.

internal/sysinfo provides the CPU model, but it is not available in the
bootstrap toolchain, so we can't access this unconditionally in
cmd/dist. Instead use a build-tagged file, as the final version of
cmd/dist will use the final toolchain.

The addition of new data to the beginning of cmd/dist output will break
x/build/cmd/coordinator's banner parsing, leaving extra lines in the log
output, though information will not be lost.
https://golang.org/cl/372538 fixes up the coordinator and should be
submitted and deployed before this CL is submitted.

For #46272.
For #49209.
For #50146.

Change-Id: I515d2ec58e4c0034b76bf624ecaab38f16146074
Reviewed-on: https://go-review.googlesource.com/c/go/+/371474
Trust: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
3 years agodebug/elf: do not read unrelated bytes for SHT_NOBITS sections
Alessandro Arzilli [Tue, 4 Jan 2022 14:47:02 +0000 (15:47 +0100)]
debug/elf: do not read unrelated bytes for SHT_NOBITS sections

SHT_NOBITS sections do not occupy space in the file and their offset is
"conceptual", reading their data should return all zeroes instead of
reading bytes from the section that follows them.

Change-Id: Iaa9634792c1909c3e87dab841dd646cd6dcf9027
Reviewed-on: https://go-review.googlesource.com/c/go/+/375216
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoruntime: skip known TestSegv failure mode on linux-mips64le-mengzhuo
Bryan C. Mills [Fri, 14 Jan 2022 14:23:25 +0000 (09:23 -0500)]
runtime: skip known TestSegv failure mode on linux-mips64le-mengzhuo

Also adjust other skips to actually call t.Skip, so that the test
correctly shows as skipped instead of passing.

For #50605

Change-Id: Ied482f231a879224c5a92e2c47a6b21c1593a7da
Reviewed-on: https://go-review.googlesource.com/c/go/+/378554
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime: fix net poll races
Russ Cox [Wed, 12 Jan 2022 22:22:09 +0000 (17:22 -0500)]
runtime: fix net poll races

The netpoll code was written long ago, when the
only multiprocessors that Go ran on were x86.
It assumed that an atomic store would trigger a
full memory barrier and then used that barrier
to order otherwise racy access to a handful of fields,
including pollDesc.closing.

On ARM64, this code has finally failed, because
the atomic store is on a value completely unrelated
to any of the racily-accessed fields, and the ARMv8
hardware, unlike x86, is clever enough not to do a
full memory barrier for a simple atomic store.
We are seeing a constant background rate of trybot
failures where the net/http tests deadlock - a netpollblock
has clearly happened after the pollDesc has begun to close.

The code that does the racy reads is netpollcheckerr,
which needs to be able to run without acquiring a lock.
This CL fixes the race, without introducing unnecessary
inefficiency or deadlock, by arranging for every updater
of the relevant fields to publish a summary as a single
atomic uint32, and then having netpollcheckerr use a
single atomic load to fetch the relevant bits and then
proceed as before.

Fixes #45211 (until proven otherwise!).

Change-Id: Ib6788c8da4d00b7bda84d55ca3fdffb5a64c1a0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/378234
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: add call to ImportedBody() when exporting shape inst body
Dan Scales [Thu, 13 Jan 2022 21:20:19 +0000 (13:20 -0800)]
cmd/compile: add call to ImportedBody() when exporting shape inst body

When we export a shape instantiation, because a particular
fully-instantiated type is needed by an inlineable function, we possibly
export the body of the instantiation, if it is inlineable. In this case,
we should have been calling ImportedBody() to make sure that the
function body had already been read in (if it is actually imported from
another package).

Fixes #50598

Change-Id: I512d2bcc745faa6ff3a97e25bc8f46e2c2643d23
Reviewed-on: https://go-review.googlesource.com/c/go/+/378494
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: stop interface conversions for generic method calls from allocating
Keith Randall [Thu, 13 Jan 2022 00:11:35 +0000 (16:11 -0800)]
cmd/compile: stop interface conversions for generic method calls from allocating

Let T be a type parameter, and say we instantiate it with S, a type
that isn't pointer-like (e.g. a pair of ints, or as in 50182, a
slice). Then to call a method m on a variable of type T, the compiler
does essentially:

var v T = ...
i := (interface{m()})(v)
i.m()

The conversion at that second line allocates, as we need to make the
data word for an interface. And in the general case, that interface
may live an arbitrarily long time. But in this case, we know it
doesn't.

The data word of i has type *S.  When we call i.m, we can't call S.m
directly. It is expecting an S, not a *S. We call through a wrapper
defined on *S, which looks like:

func (p *S) m() {
   var s S = *p
   s.m()
}

The value passed in for p is exactly the data word mentioned above. It
never escapes anywhere - the wrapper copies a type S variable out of
*p and p is dead after that. That means that in the situation where we
build an interface for the explicit purpose of calling a method on it,
and use that built interface nowhere else, the allocation of the data
word for that interface is known to die before the call returns and
thus can be stack allocated.

One tricky case is that although the allocation of the backing store
of the interface conversion doesn't escape, pointers we store *inside*
that allocation might escape (in fact they definitely will, unless we
can devirtualize the receiver).

Fixes #50182

Change-Id: I40e893955c2e6871c54ccecf1b9f0cae17871b0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/378178
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agotesting: skip flaky TestRaiseException on windows-amd64-2012
Patrik Nyblom [Thu, 13 Jan 2022 01:50:55 +0000 (17:50 -0800)]
testing: skip flaky TestRaiseException on windows-amd64-2012

This is in relation to #49681

Change-Id: I32ad8b506cf8fb0a94b15c3cc8b1eaf5af728c59
Reviewed-on: https://go-review.googlesource.com/c/go/+/378254
Run-TryBot: Patrik Nyblom <pnyb@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Patrik Nyblom <pnyb@google.com>

3 years agocmd/compile: descend through types to find fully-instantiated types
Dan Scales [Wed, 12 Jan 2022 19:30:57 +0000 (11:30 -0800)]
cmd/compile: descend through types to find fully-instantiated types

In order to make sure we export the dictionaries/shape methods for all
fully-instantiated types in inlineable functions, we need to descend
fully into types. For example, we may have a map type (e.g.
map[transactionID]Promise[*ByteBuffer]), where the key or value is a new
fully-instantiated type. So, I add a new checkFullyInst() traversal
function, which traverses all encountered types, but maintains a map, so
it only traverse it type once. We need to descend fully into interfaces,
structs, and methods, since a fully-instantiated type make occur in any
fields or arguments/results of methods, etc.

Fixes #50561

Change-Id: I88681a30384168539ed7229eed709f4e73ff0666
Reviewed-on: https://go-review.googlesource.com/c/go/+/378154
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>

3 years agocmd/compile: unique LinkString for renamed, embedded fields
Matthew Dempsky [Thu, 16 Dec 2021 20:55:15 +0000 (12:55 -0800)]
cmd/compile: unique LinkString for renamed, embedded fields

Using type aliases, it's possible to create structs with embedded
fields that have no corresponding type literal notation. However, we
still need to generate a unique name for these types to use for linker
symbols. This CL introduces a new "struct{ Name = Type }" syntax for
use in LinkString formatting to represent these types.

Reattempt at CL 372914, which was rolled back due to race-y
LocalPkg.Lookup call that isn't safe for concurrency.

Fixes #50190.

Change-Id: I0b7fd81e1b0b3199a6afcffde96ade42495ad8d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/378434
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agodatabase/sql: consolidate test polling loops
Bryan C. Mills [Thu, 13 Jan 2022 18:57:47 +0000 (13:57 -0500)]
database/sql: consolidate test polling loops

Also eliminate some arbitrary deadlines and sleeps.

Fixes #49958

Change-Id: I999b39a896e430e3bb93aa8b8c9444f28bbaa9d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/378395
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
3 years agocmd/go: run go install in workspace mode
Michael Matloob [Mon, 10 Jan 2022 17:58:20 +0000 (12:58 -0500)]
cmd/go: run go install in workspace mode

It's too confusing to users to run go install in module mode, so run
it in workspace mode instead.

Fixes #50036

Change-Id: Ia99927bd98f54be4c42224a247543892045e3464
Reviewed-on: https://go-review.googlesource.com/c/go/+/377334
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/go: reset modfetch state between modules in go work sync
Michael Matloob [Fri, 7 Jan 2022 21:52:53 +0000 (16:52 -0500)]
cmd/go: reset modfetch state between modules in go work sync

go work sync resets the state in the modload package before each
iteration where it updates the workspace modules' go.mod files. But
before this change it wasn't resetting the global state in the modfetch
package. This is necessary because the modfetch package keeps track of
the sums that will be written to go.sum. Further, the fetch caches
will update information about which modules are used when fetching
packages, and so those caches need to be cleared between each workspace
module.

Thanks bcmills for helping me debug!

Fixes #50038

Change-Id: I5679c18a80feb7c5194c4a5f7e7129c7d198ef7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/376655
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoall: add a handful of fuzz targets
Roland Shoemaker [Wed, 25 Aug 2021 20:50:24 +0000 (13:50 -0700)]
all: add a handful of fuzz targets

Adds simple fuzz targets to archive/tar, archive/zip, compress/gzip,
encoding/json, image/jpeg, image/gif, and image/png.

Second attempt, this time we don't use the archives in testdata when
fuzzing archive/tar, since those are rather memory intensive, and
were crashing a number of builders.

Change-Id: I4828d64fa4763c0d8c980392a6578e4dfd956e13
Reviewed-on: https://go-review.googlesource.com/c/go/+/378174
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agodoc: mention that GOAMD64 is a compile-time setting
Keith Randall [Thu, 13 Jan 2022 00:27:14 +0000 (16:27 -0800)]
doc: mention that GOAMD64 is a compile-time setting

Fixes #50589

Change-Id: Ic260a6edd9af5c9c6dd8b40f0830f88644c907f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/378179
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/go: enable fuzz testing for FreeBSD
Ayan George [Tue, 11 Jan 2022 21:37:46 +0000 (16:37 -0500)]
cmd/go: enable fuzz testing for FreeBSD

Add "freebsd" to GOOS for which sys.FuzzSupported() returns true
and add freebsd to the build tags to fuzz test source.

Fixes #46554
Change-Id: I5f695ecc8f09c0ab4279ced23b4715b788fcade0
Reviewed-on: https://go-review.googlesource.com/c/go/+/377855
Trust: Bryan Mills <bcmills@google.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
3 years agogo/types, types2: fix tracing output for type and expr lists
Robert Griesemer [Wed, 12 Jan 2022 06:19:56 +0000 (22:19 -0800)]
go/types, types2: fix tracing output for type and expr lists

- support printing of expression and type lists in sprintf
- simplified some code in go/types/exprstring.go
- fixed a typo in syntax package

Change-Id: Ic4bc154200aad95958d5bc2904a9ea17cf518388
Reviewed-on: https://go-review.googlesource.com/c/go/+/377974
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types, types2: prevent unification from recursing endlessly
Robert Griesemer [Wed, 12 Jan 2022 04:55:56 +0000 (20:55 -0800)]
go/types, types2: prevent unification from recursing endlessly

This is a stop gap solution to avoid panics due to stack overflow
during type unification. While this doesn't address the underlying
issues (for which we are still investigating the correct approach),
it prevents a panic during compilation and reports a (possibly not
quite correct) error message.

If the programs are correct in the first place, manually providing
the desired type arguments is a viable work-around, resulting in
code that will continue to work even when the issues here are fixed
satisfactorily.

For #48619.
For #48656.

Change-Id: I13bb14552b38b4170b5a1b820e3172d88ff656ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/377954
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types, types2: make function type inference argument-order independent
Robert Griesemer [Tue, 11 Jan 2022 23:36:38 +0000 (15:36 -0800)]
go/types, types2: make function type inference argument-order independent

If we have more than 2 arguments, we may have arguments with named and
unnamed types. If that is the case, permutate params and args such that
the arguments with named types are first in the list. This doesn't affect
type inference if all types are taken as is. But when we have inexact
unification enabled (as is the case for function type inference), when
a named type is unified with an unnamed type, unification proceeds with
the underlying type of the named type because otherwise unification would
fail right away. This leads to an asymmetry in type inference: in cases
where arguments of named and unnamed types are passed to parameters with
identical type, different types (named vs underlying) may be inferred
depending on the order of the arguments.
By ensuring that named types are seen first, order dependence is avoided
and unification succeeds where it can.

This CL implements the respectice code but keeps it disabled for now,
pending decision whether we want to address this issue in the first
place.

For #43056.

Change-Id: Ibe3b08ec2afe90a24a8c30cd1875d504bcc2ef39
Reviewed-on: https://go-review.googlesource.com/c/go/+/377894
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/ast: mention that FieldLists can now be enclosed by brackets
Robert Findley [Wed, 12 Jan 2022 14:54:19 +0000 (09:54 -0500)]
go/ast: mention that FieldLists can now be enclosed by brackets

Type parameter lists are stored using ast.FieldLists. Update the
documentation to reflect that the enclosing delimiter may be a bracket.

Change-Id: Id103e7b38975e94a1b521f75695edc10408ad3dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/378014
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoRevert "all: add a handful of fuzz targets"
Bryan Mills [Wed, 12 Jan 2022 02:22:10 +0000 (02:22 +0000)]
Revert "all: add a handful of fuzz targets"

This reverts CL 352109.

Reason for revert: causing OOM failures on several builders, and may cause OOMs for end users with small machines as well.

Change-Id: I58308d09919969d5a6512ee5cee6aa5c4af6769b
Reviewed-on: https://go-review.googlesource.com/c/go/+/377934
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>

3 years agogo/types, types2: do not run CTI before FTI
Robert Griesemer [Tue, 11 Jan 2022 01:29:21 +0000 (17:29 -0800)]
go/types, types2: do not run CTI before FTI

Until now, CTI (constraint type inference) was run before
FTI (function type inference). This lead to situations
where CTI infered a type that is missing necessary methods
even though a function argument of correct type was given.
This can happen when constraint type inference produces a
inferred type that is the structural type of multiple types,
which then is an underlying type, possibly without methods.

This CL removes the initial CTI step; it is only applied
after FTI with type arguments is run, and again after FTI
with untyped arguments is run.

Various comments are adjusted to reflect the new reality.

Fixes #50426.

Change-Id: I700ae6e762d7aa00d742943a2880f1a1db33c2b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/377594
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agospec: adjust rules for specific types once more
Robert Griesemer [Sat, 8 Jan 2022 02:20:22 +0000 (18:20 -0800)]
spec: adjust rules for specific types once more

Introduce a (local) notion of a set of representative types,
which serves as a representation/approximation of an
interface's actual type set. If the set of representative
types is is non-empty and finite, it corresponds to the set
of specific types of the interface.

In the implementation, the set of representative types serves
as a finite representation of an interface's type set, together
with the set of methods.

Change-Id: Ib4c6cd5e17b81197672e4247be9737dd2cb6b56f
Reviewed-on: https://go-review.googlesource.com/c/go/+/376834
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoall: add a handful of fuzz targets
Roland Shoemaker [Wed, 25 Aug 2021 20:50:24 +0000 (13:50 -0700)]
all: add a handful of fuzz targets

Adds simple fuzz targets to archive/tar, archive/zip, compress/gzip,
encoding/json, image/jpeg, image/gif, and image/png.

Change-Id: Ide1a8de88a9421e786eeeaea3bb93f41e0bae347
Reviewed-on: https://go-review.googlesource.com/c/go/+/352109
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile/types2, go/types: add position for "have" in failed interface satisfaction
Emmanuel T Odeke [Tue, 11 Jan 2022 07:04:22 +0000 (23:04 -0800)]
cmd/compile/types2, go/types: add position for "have" in failed interface satisfaction

With this change, we shall now see:

    *myS does not implement S (wrong type for DoSomething method)
        have DoSomething() (string, error) at ./main.go:9:14
want DoSomething() (int, error)

instead of previously:

    *myS does not implement S (wrong type for DoSomething method)
        have DoSomething() (string, error)
want DoSomething() (int, error)

Fixes #42841
Fixes #45813

Change-Id: I66990929e39b0d36f2e91da0d92f60586a9b84e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/373634
Trust: Robert Findley <rfindley@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile: fix the names of methods created during type substitution
Dan Scales [Sat, 8 Jan 2022 18:33:35 +0000 (10:33 -0800)]
cmd/compile: fix the names of methods created during type substitution

The names given to methods of types created during type substitution
were possible incorrect when the type parameters themselves were nested
types.

Fixes #50485

Change-Id: I7e0043ed22c26406a5f9d8d51d9e928770a678f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/377494
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>

3 years agocmd/compile: in typ0(), load base type before checking s.Def
Dan Scales [Fri, 7 Jan 2022 20:22:24 +0000 (12:22 -0800)]
cmd/compile: in typ0(), load base type before checking s.Def

The loading of the base type in typ0() may cause s.Def to be defined for
the instantiated type, so load the base type before checking s.Def.

Fixes #50486

Change-Id: Ic039bc8f774dda534f4ccd1f920220b7a10dede6
Reviewed-on: https://go-review.googlesource.com/c/go/+/377094
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>
3 years agocmd/compile: resolve dictionaries/shape methods in markInlBody, if needed
Dan Scales [Tue, 11 Jan 2022 17:14:38 +0000 (09:14 -0800)]
cmd/compile: resolve dictionaries/shape methods in markInlBody, if needed

Issue #50552 is due to a problem with my recent improvement in the
interaction between generics and inlining. In markInlBody(), we now mark
dictionaries and shape methods for export, so they will be available for
any package that inlines the current inlineable function. But we need to
make sure that the dictionary and method symbols have actually been
resolved into Nodes (looked up in the import data), if they are not
already defined, so we can then mark them for export.

Improved header comment on Resolve().

Fixes #50552

Change-Id: I89e52d39d3b9894591d2ad6eb3a8ed3bb5f1e0a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/377714
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

3 years agogo/types, types2: mention type decl scopes in Info.Scopes documentation
Robert Findley [Tue, 11 Jan 2022 17:53:25 +0000 (12:53 -0500)]
go/types, types2: mention type decl scopes in Info.Scopes documentation

We now may have a scope associated with a type declaration, so need to
update our API documentation accordingly.

Change-Id: Ic66dc3b7cd1969b25fb7c4bee986d76ab3544042
Reviewed-on: https://go-review.googlesource.com/c/go/+/377655
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: print "internal compiler error" message for all compiler panics
Dan Scales [Wed, 5 Jan 2022 23:20:50 +0000 (15:20 -0800)]
cmd/compile: print "internal compiler error" message for all compiler panics

Change hidePanic (now renamed handlePanic) to print out the "internal
compiler error" message for all panics and runtime exceptions, similar
to what we already do for the SSA backend in ssa.Compile().

Previously, hidePanic would not catch panics/exceptions unless it wanted
to completely hide the panic because there had already been some
compiler errors.

Tested by manually inserting a seg fault in the compiler, and verifying
that the seg fault is cause and "internal compiler error" message (with
stack trace) is displayed proeprly.

Updates #50423

Change-Id: Ibe846012e147fcdcc63ac147aae4bdfc47bf5a58
Reviewed-on: https://go-review.googlesource.com/c/go/+/376057
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
3 years agoruntime: improve asanread/asanwrite nosplit comment
Austin Clements [Thu, 6 Jan 2022 20:25:01 +0000 (15:25 -0500)]
runtime: improve asanread/asanwrite nosplit comment

Explain the conditions under which they are called on stacks that
cannot grow.

Change-Id: I08ee5480face7fbedeccc09e55b8149c5a793c2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/376036
Trust: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
3 years agotest: workaround SIGILL on issue11656 on aix
Paul E. Murphy [Mon, 10 Jan 2022 16:57:16 +0000 (10:57 -0600)]
test: workaround SIGILL on issue11656 on aix

For some reason, aix sometimes executes the bogus function body. This
should never happen as it lives in a no-execute section. It might be
a transient permission blip as the heap grows.

Add a small function to cleanup and synchronize the icache before
jumping to the bogus function to ensure it causes a panic, not SIGILL.

Fixes #44583

Change-Id: Iadca62d82bfb70fc62088705dac42a880a1208fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/377314
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/go: skip TestScript/test_fuzz_test_race on !race
Tobias Klauser [Tue, 11 Jan 2022 09:22:40 +0000 (10:22 +0100)]
cmd/go: skip TestScript/test_fuzz_test_race on !race

Skip the test on targets which don't support the race detector. This
fixes the linux-386-longtest builder after CL 376554.

Updates #50488

Change-Id: I08bf6f72cc0731761d49121eb7cfaa8b53906d37
Reviewed-on: https://go-review.googlesource.com/c/go/+/377634
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>

3 years agotest: re-enable most go/tests that were disabled because of types2 differences
Dan Scales [Sat, 4 Dec 2021 00:10:10 +0000 (16:10 -0800)]
test: re-enable most go/tests that were disabled because of types2 differences

I made the default be that, where there are differences between types2
and -G=0 error messages, we want errorcheck tests to pass types2.
Typically, we can get errorcheck to pass on types2 and -G=0 if they give
the same number of error messages on the same lines, just different
wording. If they give a different number of error messages, then I made
types2 pass. I added an exception list for -G=0 to cover those cases
where -G=0 and types give different numbers of error messages.

Because types2 does not run if there are syntax errors, for several
tests, I had to split the tests into two parts in order to get all the
indicated errors to be reported in types2 (bug228.go, bug388.go,
issue11610.go, issue14520.go)

I tried to preserve the GCCGO labeling correctly (but may have gotten
some wrong). When types2 now matches where a GCCGO error previously
occurred, I transformed GCCGO_ERROR -> ERROR. When types2 no longer
reports an error in a certain place, I transformed ERROR -> GCCGO_ERROR.
When types2 reports an error in a new place, I used GC_ERROR.

The remaining entries in types2Failures are things that I think we
probably still need to fix - either actually missing errors in types2,
or cases where types2 gives worse errors than -G=0.

Change-Id: I7f01e82b322b16094096b67d7ed2bb39b410c34f
Reviewed-on: https://go-review.googlesource.com/c/go/+/372854
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agogo/types, types2: refer to type parameter if so for interface pointer errors
Robert Griesemer [Mon, 10 Jan 2022 18:33:16 +0000 (10:33 -0800)]
go/types, types2: refer to type parameter if so for interface pointer errors

Follow-up on comment in CL 376914.

Also:
- add missing check != nil test in assignableTo
- use check.sprintf rather than fmt.Sprintf in missingMethodReason

For #48312.

Change-Id: Ie209b4101a7f2c279e42a59987d0068079c8b69f
Reviewed-on: https://go-review.googlesource.com/c/go/+/377375
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types, types2: better error message for type parameter field access
Robert Griesemer [Sat, 8 Jan 2022 22:39:43 +0000 (14:39 -0800)]
go/types, types2: better error message for type parameter field access

Fixes #50516.

Also call DefPredeclaredTestFuncs in TestFixedbugs so it can be
run independently again.

Change-Id: I78d4cc11790b1543a2545a7ab297a223b3d5e3c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/376954
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types, types2: better error message when using *interface instead of interface
Robert Griesemer [Sat, 8 Jan 2022 21:01:37 +0000 (13:01 -0800)]
go/types, types2: better error message when using *interface instead of interface

- detect *interface case and report specific error
- replaced switch with sequence of if's for more clarity
- fixed isInterfacePtr: it applies to all interfaces, incl.
  type parameters
- reviewed/fixed all uses of isInterfacePtr
- adjusted error messages to be consistently of the format
  "type %s is pointer to interface, not interface"

Fixes #48312.

Change-Id: Ic3c8cfcf93ad57ecdb60f6a727cce9e1aa4afb5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/376914
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agotesting: only snapshot coverage during fuzzing
Roland Shoemaker [Fri, 7 Jan 2022 20:18:30 +0000 (12:18 -0800)]
testing: only snapshot coverage during fuzzing

Only snapshot/reset coverage counters when we are actually fuzzing.
This prevents a race when running corpus/seed values during the testing
phase.

Fixes #50488

Change-Id: I7dd5a0353a296c0b13eede29ad9af7c78814fa2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/376554
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: use exact constant in go_asm.h
Ian Lance Taylor [Mon, 10 Jan 2022 04:20:43 +0000 (20:20 -0800)]
cmd/compile: use exact constant in go_asm.h

Fixes #50523

Change-Id: Idab1b44d106250e9301d90ee6571f0ea51242dd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/377074
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Liz Fong-Jones <lizf@honeycomb.io>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agoRevert "cmd/compile: unique LinkString for renamed, embedded fields"
Matthew Dempsky [Mon, 10 Jan 2022 19:18:39 +0000 (19:18 +0000)]
Revert "cmd/compile: unique LinkString for renamed, embedded fields"

This reverts CL 372914.

Reason for revert: missing synchronization

Change-Id: I7ebb6de082cebb73741d803ff00e3465bbafab81
Reviewed-on: https://go-review.googlesource.com/c/go/+/377379
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>

3 years agocmd/compile, test: updated comments in crawler.go, added test
Dan Scales [Wed, 29 Dec 2021 02:40:12 +0000 (18:40 -0800)]
cmd/compile, test: updated comments in crawler.go, added test

Added a test to make sure that the private methods of a local generic
type are properly exported, if there is a global variable with that
type.

Added comments in crawler.go, to give more detail and to give more about
the overall purpose.

Fixed one place where t.isFullyInstantiated() should be replaced by
isPtrFullyInstantiated(t), so that we catch pointers to generic types
that may be used as a method receiver.

Change-Id: I9c42d14eb6ebe14d249df7c8fa39e889f7cd3f22
Reviewed-on: https://go-review.googlesource.com/c/go/+/374754
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: unique LinkString for renamed, embedded fields
Matthew Dempsky [Thu, 16 Dec 2021 20:55:15 +0000 (12:55 -0800)]
cmd/compile: unique LinkString for renamed, embedded fields

Using type aliases, it's possible to create structs with embedded
fields that have no corresponding type literal notation. However, we
still need to generate a unique name for these types to use for linker
symbols. This CL introduces a new "struct{ Name = Type }" syntax for
use in LinkString formatting to represent these types.

Fixes #50190.

Change-Id: I025ceb09a86e00b7583d3b9885d612f5d6cb44fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/372914
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: expand TestGdbPythonCgo skip to include mips64le
Bryan C. Mills [Fri, 7 Jan 2022 21:35:31 +0000 (16:35 -0500)]
runtime: expand TestGdbPythonCgo skip to include mips64le

The failure mode in #37794 does not match the failure mode described
in #18784. However, since the test is currently skipped on all other
MIPS variants, it may be that they suffer from the same underlying GDB
bug. Ideally one of the Go MIPS maintainers should file an upstream
bug and remove the skip once it is fixed; in the meantime, there is no
point in continuing to let the test fail on just one of the four MIPS
variants.

For #37794

Change-Id: I570f51cc04cbb7ef1ed7efd526e26886af53bfb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/376654
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: fix interaction between generics and inlining
Dan Scales [Wed, 29 Dec 2021 15:08:55 +0000 (07:08 -0800)]
cmd/compile: fix interaction between generics and inlining

Finally figured out how to deal with the interaction between generics
and inlining. The problem has been: what to do if you inline a function
that uses a new instantiated type that hasn't been seen in the current
package? This might mean that you need to do another round of
function/method instantiatiations after inlining, which might lead to
more inlining, etc. (which is what we currently do, but it's not clear
when you can stop the inlining/instantiation loop).

We had thought that one solution was to export instantiated types (even
if not marked as exportable) if they are referenced in exported
inlineable functions. But that was quite complex and required changing
the export format. But I realized that we really only need to make sure
the relevant dictionaries and shape instantiations for the instantiated
types are exported, not the instantiated type itself and its wrappers.
The instantiated type is naturally created as needed, and the wrappers
are generated automatically while writing out run-time type (making use
of the exported dictionaries and shape instantiations).

So, we just have to make sure that those dictionaries and shape
instantiations are exported, and then they will be available without any
extra round of instantiations after inlining. We now do this in
crawler.go. This is especially needed when the instantiated type is only
put in an interface, so relevant dictionaries/shape instantiations are
not directly referenced and therefore exported, but are still needed for
the itab.

This fix avoids the phase ordering problem where we might have to keep
creating new type instantiations and instantiated methods after each
round of inlining we do.

Removed the extra round of instantiation/inlining that were added in the
previous fix. The existing tests
test/typeparam{geninline.go,structinit.go} already test this situation
of inlining a function referencing a new instantiated type.

Added the original example from issue 50121 as test (has 5 packages),
since it found a problem with this code that the current simpler test
for 50121 did not find.

Change-Id: Iac5d0dddf4be19376f6de36ee20a83f0d8f213b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/375494
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

3 years agoruntime/pprof: run TestCPUProfileMultithreadMagnitude subtests separately
Michael Pratt [Thu, 16 Dec 2021 20:30:47 +0000 (15:30 -0500)]
runtime/pprof: run TestCPUProfileMultithreadMagnitude subtests separately

Currently TestCPUProfileMultithreadMagnitude runs two CPU consumption
functions in a single profile and then analyzes the results as separate
subtests.

This works fine, but when debugging failures it makes manual analysis of
the profile dump a bit annoying.

Refactor the test to collect separate profiles for each subtest for
easier future analysis.

For #50097.
For #50232.

Change-Id: Ia1c8bb86aaaf652e64c5e660dcc2da47d2194c2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/372800
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Bryan Mills <bcmills@google.com>
3 years agonet/http: map FS Open errors just like Dir
Jonathan Amsterdam [Sat, 8 Jan 2022 14:18:24 +0000 (09:18 -0500)]
net/http: map FS Open errors just like Dir

When an http.FileServer is given a path like file1/file2 where file1
exists but file2 does not, the proper HTTP status should be
NotFound. Some OSes return a "not a directory" error instead, so this
must be mapped to NotFound.

That mapping was already being done for the Dir FileSystem
implementation, as discussed in #18984. But it wasn't for the
FS implementation.

This CL does the same mapping for FS, by generalizing the function
that did it for Dir.

Fixes #49552

Change-Id: I61d6aa8ef101158e9674707d44e653f5dedbd040
Reviewed-on: https://go-review.googlesource.com/c/go/+/376874
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agogo/types, types2: better error message for invalid == on type parameters
Robert Griesemer [Thu, 16 Dec 2021 05:25:50 +0000 (21:25 -0800)]
go/types, types2: better error message for invalid == on type parameters

Fixes #48712.

Change-Id: I6f214cdfdd1815493f2a04828e8f0097f1d8c124
Reviewed-on: https://go-review.googlesource.com/c/go/+/372734
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agonet/http/internal/testcert: use FIPS-compliant certificate
Damien Neil [Mon, 4 Oct 2021 17:20:22 +0000 (10:20 -0700)]
net/http/internal/testcert: use FIPS-compliant certificate

Upgrade the test certificate from RSA 1024 (not FIPS-approved)
to RSA 2048 (FIPS-approved), allowing tests to pass when
the dev.boringcrypto branch FIPS-only mode is enabled.

Fixes #48674.

Change-Id: I613d2f8d0207bf3683fd0df256bf0167604996c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353869
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
3 years agoruntime: skip TestSegv traceback check on 386
Michael Pratt [Fri, 7 Jan 2022 22:11:41 +0000 (17:11 -0500)]
runtime: skip TestSegv traceback check on 386

The VDSO (__kernel_vsyscall) is reachable via
asmcgocall(cgo_start_thread) on linux-386, which causes traceback to
throw.

Fixes #49182.
For #50504.

Change-Id: Idb78cb8de752203ce0ed63c2dbd2d12847338688
Reviewed-on: https://go-review.googlesource.com/c/go/+/376656
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

3 years agocmd/compile: accept string|[]byte-constrained 2nd argument in append
Robert Griesemer [Fri, 7 Jan 2022 02:02:30 +0000 (18:02 -0800)]
cmd/compile: accept string|[]byte-constrained 2nd argument in append

Similarly to what we do for the built-in function `copy`,
where we allow a string as 2nd argument to append, also
permit a type parameter constrained by string|[]byte.

While at it, change date in the manual.go2 test files so
that we don't need to constantly correct it when copying
a test case from that file into a proper test file.

Fixes #50281.

Change-Id: I23fed66736aa07bb3c481fe97313e828425ac448
Reviewed-on: https://go-review.googlesource.com/c/go/+/376214
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agosyscall: in TestDirent, make as many ReadDirent calls as are needed
Bryan C. Mills [Fri, 7 Jan 2022 14:54:44 +0000 (09:54 -0500)]
syscall: in TestDirent, make as many ReadDirent calls as are needed

ReadDirent returns only as many directory entries as will fit in the
buffer, and each entry is variable-length — so we have no guarantee in
general that a buffer of a given arbitrary size can hold even one
entry, let alone all ten entries expected by the test.

Instead, iterate calls to ReadDirent until one of the calls returns
zero entries and no error, indicating that the directory has been read
to completion.

Fixes #37323

Change-Id: I7f1cedde7666107256604e4ea1ac13c71f22151a
Reviewed-on: https://go-review.googlesource.com/c/go/+/376334
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: fix conv of slice of user-define byte type to string
Dan Scales [Thu, 6 Jan 2022 20:39:37 +0000 (12:39 -0800)]
cmd/compile: fix conv of slice of user-define byte type to string

types2 allows the conversion of a slice of a user-defined byte type B
(not builtin uint8 or byte) to string. But runtime.slicebytetostring
requires a []byte argument, so add in a CONVNOP from []B to []byte if
needed. Same for the conversion of a slice of user-defined rune types to
string.

I made the same change in the transformations of the old typechecker, so
as to keep tcConv() and transformConv() in sync. That fixes the bug for
-G=0 mode as well.

Fixes #23536

Change-Id: Ic79364427f27489187f3f8015bdfbf0769a70d69
Reviewed-on: https://go-review.googlesource.com/c/go/+/376056
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
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>

3 years agodoc/go1.18: document type parameter name restriction
Robert Griesemer [Fri, 7 Jan 2022 18:06:53 +0000 (10:06 -0800)]
doc/go1.18: document type parameter name restriction

For #47694.

Change-Id: I00862f987a0ff9f71e0295ce4320e6f9a6a4332f
Reviewed-on: https://go-review.googlesource.com/c/go/+/376414
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: fix instantiation of types referenced during inlining
Cuong Manh Le [Wed, 5 Jan 2022 09:19:19 +0000 (16:19 +0700)]
cmd/compile: fix instantiation of types referenced during inlining

CL 352870 added extra phase for instantiation after inlining, to take
care of the new fully-instantiated types. However, when fetching inlined
body of these types's methods, we need to allow OADDR operations on
untyped expressions, the same as what main inlining phase does.

The problem does not show up, until CL 371554, which made the compiler
do not re-typecheck while importing, thus leaving a OXDOT node to be
marked as address taken when it's not safe to do that.

Fixes #50437

Change-Id: I20076b872182c520075a4f8b84230f5bcb05b341
Reviewed-on: https://go-review.googlesource.com/c/go/+/375574
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 years ago.github: remove duplicate security link
Dmitri Shuralyov [Fri, 7 Jan 2022 17:50:37 +0000 (17:50 +0000)]
.github: remove duplicate security link

Since a SECURITY.md file is present in the main Go repository,
GitHub already shows a "Report a security vulnerability" link
in the issue template list. Remove the duplicate custom link.

Fixes #49962.

Change-Id: Ifdf7e93b76ebd9258d907aa9cb4915c0dbc4f93e
Reviewed-on: https://go-review.googlesource.com/c/go/+/376357
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
3 years agotest/typeparam: adjust test preamble (fix longtests)
Robert Griesemer [Fri, 7 Jan 2022 04:06:40 +0000 (20:06 -0800)]
test/typeparam: adjust test preamble (fix longtests)

For #50481.

Change-Id: I27e6c6499d6abfea6e215d8aedbdd5074ff88291
Reviewed-on: https://go-review.googlesource.com/c/go/+/376216
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
3 years agospec: be more precise with rules on specific types
Robert Griesemer [Thu, 6 Jan 2022 05:37:04 +0000 (21:37 -0800)]
spec: be more precise with rules on specific types

Problem pointed out on golang-nuts mailing list.

Change-Id: If1c9b22e1ed7b4ec7ebcaadc80fa450333e6856c
Reviewed-on: https://go-review.googlesource.com/c/go/+/375799
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agodoc/go1.18: point to spec in same directory for release notes
Robert Griesemer [Sat, 18 Dec 2021 01:17:41 +0000 (17:17 -0800)]
doc/go1.18: point to spec in same directory for release notes

The release notes explicitly refer to sections updated
for generics in the spec but then point to the old spec
which is very confusing for beta users.

For #47694

Change-Id: I5b555db3543cc32f088a8b267ec3f1195a52a812
Reviewed-on: https://go-review.googlesource.com/c/go/+/373174
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agotest/typeparam: adjust test preamble (fix longtests)
Robert Griesemer [Fri, 7 Jan 2022 02:23:01 +0000 (18:23 -0800)]
test/typeparam: adjust test preamble (fix longtests)

For #50317.

Change-Id: I24ccf333c380283a36b573ef8fc3e7fcd71bd17f
Reviewed-on: https://go-review.googlesource.com/c/go/+/376215
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>

3 years agotest/typeparam: adjust test preamble (fix longtests)
Robert Griesemer [Fri, 7 Jan 2022 00:50:49 +0000 (16:50 -0800)]
test/typeparam: adjust test preamble (fix longtests)

For #50417.

Change-Id: Ic55727c454ec342354f7fbffd22aa350e0d392c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/376174
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>