1
0
mirror of https://github.com/golang/go synced 2024-09-29 07:24:32 -06:00
Commit Graph

51394 Commits

Author SHA1 Message Date
Dan Scales
eb8198d2f6 cmd/compile: deal with constructed types that have shapes in them
We convert type args to shape types inside instantiations. If an
instantiation constructs a compound type based on that shape type and
uses that as a type arg to another generic function being called, then
we have a type arg with a shape type embedded inside of it. In that
case, we need to substitute out those embedded shape types with their
underlying type.

If we don't do this, we may create extra unneeded shape types that
have these other shape types embedded in them. This may lead to
generating extra shape instantiations, and a mismatch between the
instantiations that we used in generating dictionaries and the
instantations that are actually called.

Updates #51303

Change-Id: Ieef894a5fac176cfd1415f95926086277ad09759
Reviewed-on: https://go-review.googlesource.com/c/go/+/387674
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>
2022-02-28 19:38:22 +00:00
Matthew Dempsky
b33592dcfd spec: the -'s possessive suffix is English, not code
Change-Id: I2debcf926ef116c632c7366646d37de8686b7c9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/388174
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2022-02-28 19:00:23 +00:00
Cherry Mui
57e3809884 runtime: avoid cgo_unsafe_args for syscall.syscall functions on darwin/arm64
Currently, syscall.syscall-like functions are defined as
cgo_unsafe_args, which makes them ABI0, as it takes the address of
the argument area based on ABI0 layout. Those functions are
linkname'd to the syscall package. When compiling the syscall
package, the compiler doesn't know they are ABI0 therefore
generate an ABIInternal call, which will use the wrapper. As some
of the functions (e.g. syscall6) has many arguments, the wrapper
would take a good amount of stack space. And those functions must
be nosplit. This causes nosplit overflow when building with -N -l
and -race.

Avoid that by rewriting the functions to not use cgo_unsafe_args.
Instead, make a struct locally and pass the address of that
struct. This way the functions are ABIInternal and the call will
not use the wrapper.

Fixes #51247.

Change-Id: I76c1ab86b9d28664fa7d5b9c7928fbb2fd8d1417
Reviewed-on: https://go-review.googlesource.com/c/go/+/386719
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-02-28 17:51:12 +00:00
Dan Scales
06a43e4ab6 cmd/compile: fix case for structural types where we should be looking at typeparams
In getInstantiation, we were not computing tparams correctly for the
case where the receiver of a method was a fully-instantiated type. This
wasn't affecting later parts of the function, since method
instantiations of fully-instantiated types were already being calculated
in an earlier path. But it did give us a non-typeparam when trying to
see if a shape was associated with a type param with a structural type.
The fix is just to get the typeparams associated with the base generic
type. Then we can eliminate a conditional check later in the code.
The tparam parameter of Shapify should always be non-nil

Fixes #51367

Change-Id: I6f95fe603886148b2dad0c581416c51373c85009
Reviewed-on: https://go-review.googlesource.com/c/go/+/388116
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>
2022-02-28 15:58:07 +00:00
Keith Randall
0907d57abf cmd/compile: emit types of constants which are instantiated generic types
Normally types of constants are emitted when the type is defined (an
ODCLTYPE). However, the types of constants where the type is an
instantiated generic type made inside the constant declaration, do not
normally get emitted. But the DWARF processor in the linker wants
to see those types. So we emit them during stenciling.

Fixes #51245

Change-Id: I59f20f1d7b91501c9ac760cf839a354356331fc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/388117
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-02-28 15:50:51 +00:00
Dmitri Shuralyov
9c4a8620c8 CONTRIBUTORS: update for the Go 1.18 release
This update was created using the updatecontrib command:

	go install golang.org/x/build/cmd/updatecontrib@latest
	cd gotip
	updatecontrib

With manual changes based on publicly available information
to canonicalize letter case and formatting for a few names.

For #12042.

Change-Id: If08b7e798cff6ec4248011bdadcc524b510aaff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/388394
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
2022-02-28 15:43:07 +00:00
Dan Scales
57dda9795d test: add new test case for 51219 that triggers the types2 issue
The existing test for 51219 didn't actually trigger the types2 issue - I
hadn't been able to minimize the test case yet properly. This new test
case issue51219b.go now does trigger the types2 issue (it's only
slightly different).

Updates #51219

Change-Id: Iaba8144b4702ff4fefec86c899b8acef127b10dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/387814
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-28 14:59:04 +00:00
Keith Randall
a064a4f29a cmd/compile: ensure dictionary assignment statements are defining statements
The problem in 51355 is that escape analysis decided that the
dictionary variable was captured by reference instead of by value. We
want dictionaries to always be captured by value.

Escape analysis was confused because it saw what it thought was a
reassignment of the dictionary variable. In fact, it was the only
assignment, it just wasn't marked as the defining assignment. Fix
that.

Add an assert to make sure this stays true.

Fixes #51355

Change-Id: Ifd9342455fa107b113f5ff521a94cdbf1b8a7733
Reviewed-on: https://go-review.googlesource.com/c/go/+/388115
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-26 01:16:03 +00:00
Robert Griesemer
286e3e61aa go/types, types2: report an error for x.sel where x is a built-in
In case of a selector expression x.sel where x is a built-in
we didn't report an error because the type of built-ins is
invalid and we surpress errors on operands of invalid types,
assuming that an error has been reported before.

Add a corresponding check for this case.

Review all places where we call Checker.exprOrType to ensure
(invalid) built-ins are reported.

Adjusted position for index error in types2.

Fixes #51360.

Change-Id: I24693819c729994ab79d31de8fa7bd370b3e8469
Reviewed-on: https://go-review.googlesource.com/c/go/+/388054
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-26 00:21:50 +00:00
Robert Findley
01e522a973 go/types,types2: revert documentation for Type.Underlying
In the dev.typeparams branch, the documentation for Type.Underlying was
updated with commentary about forwarding chains. This aspect of
Underlying should not be exposed to the user. Revert to the
documentation of Go 1.16.

Fixes #51036

Change-Id: I4b73d3908a88606314aab56540cca91c014dc426
Reviewed-on: https://go-review.googlesource.com/c/go/+/388036
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-02-25 23:38:11 +00:00
Cherry Mui
26999cfd84 runtime/internal/atomic: set SP delta correctly for 64-bit atomic functions on ARM
64-bit atomic functions on ARM have the following structure:
- check if the address is 64-bit aligned, if not, prepare a frame
  and call panicUnaligned
- tail call armXXX or goXXX depending on GOARM

The alignment check calls panicUnaligned after preparing a frame,
so the stack can be unwound. The call never returns, so the SP is
not set back. However, the assembler assigns SP delta following
the instruction stream order, not the control flow. So it leaves
a nonzero SP delta after the check, to the tail call instructions,
which is wrong because when they are executed the SP is not
decremented. This CL fixes this by adding the SP back (the
instruction never executes, just tells the assembler to set the
SP delta back).

Should fix #51353.

Change-Id: I976cb1cfb0e9008b13538765cbc7eea0c19c7130
Reviewed-on: https://go-review.googlesource.com/c/go/+/388014
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-02-25 19:54:17 +00:00
Robert Griesemer
7c694fbad1 go/types, types2: delay receiver type validation
Delay validation of receiver type as it may cause premature expansion
of types the receiver type is dependent on. This was actually a TODO.

While the diff looks large-ish, the actual change is small: all the
receiver validation code has been moved inside the delayed function
body, and a couple of comments have been adjusted.

Fixes #51232.
Fixes #51233.

Change-Id: I44edf0ba615996266791724b832d81b9ccb8b435
Reviewed-on: https://go-review.googlesource.com/c/go/+/387918
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>
2022-02-25 15:55:34 +00:00
Bryan C. Mills
55e5b03cb3 doc/go1.18: note changes to automatic go.mod and go.sum updates
Fixes #51242
Updates #45551

Change-Id: Iba6e6acd9a94d24e26fcdd125f1022430723ada7
Reviewed-on: https://go-review.googlesource.com/c/go/+/387920
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Bryan Mills <bcmills@google.com>
2022-02-25 14:32:41 +00:00
Tobias Klauser
6d810241eb doc/go1.18: document minimum Linux kernel version
For #45964

Change-Id: Ic66502c50ca328e944c91e710dca6c8dbc168e4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/387855
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-25 08:02:46 +00:00
Robert Griesemer
b8b3196375 doc/go1.18: document method set limitation for method selectors
For #51183.
For #47694.

Change-Id: If47ae074c3cd9f73b2e7f6408749d9a7d56bd8d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/387924
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-25 00:25:34 +00:00
Robert Griesemer
c0840a7c72 go/types, types2: method recv type parameter count must match base type parameter count
Check receiver type parameter count when type checking the method
signature and report a suitable error (don't rely on delayed
instantiation and possibly constraint type inference).

While at it, simplify blank name recoding and type bound rewriting.

Stop-gap measure to avoid crashes in the compiler.

Fixes #51339.
For #51343.

Change-Id: Idbe2d32d69b66573ca973339f8924b349d2bc9cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/387836
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-24 22:11:25 +00:00
Robert Griesemer
c15527f0b0 go/types, types2: implement adjCoreType using TypeParam.is
TypeParam.is also provides ~ (tilde) information which is needed
to fix #51229. Delete all code related to singleType as it's not
used anymore.

Also, remove TypeParam.hasTerms as it was not used.

For #51229.

Change-Id: Ie49b19d157230beecb17a444d1f17cf24aa4f6ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/387774
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-24 22:11:21 +00:00
Bryan C. Mills
5a9fc946b4 cmd/go: avoid +incompatible major versions if a go.mod file exists in a subdirectory for that version
Previous versions of the 'go' command would reject a pseudo-version
passed to 'go get' if that pseudo-version had a mismatched major
version and lacked a "+incompatible" suffix. However, they would
erroneously accept a version *with* a "+incompatible" suffix even if
the repo contained a vN/go.mod file for the same major version, and
would generate a "+incompatible" pseudo-version or version if the user
requested a tag, branch, or commit hash.

This change uniformly rejects "vN.…" without "+incompatible", and also
avoids resolving to "vN.…+incompatible", when vN/go.mod exists.
To maintain compatibility with existing go.mod files, it still accepts
"vN.…+incompatible" if the version is requested explicitly as such
and the repo root lacks a go.mod file.

Fixes #51324
Updates #36438

Change-Id: I2b16150c73fc2abe4d0a1cd34cb1600635db7139
Reviewed-on: https://go-review.googlesource.com/c/go/+/387675
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2022-02-24 22:09:17 +00:00
Dan Scales
4edefe9568 cmd/compile: delay all call transforms if in a generic function
We changed to delaying all transforms of generic functions, since there
are so many complicated situations where type params can be used. We
missed changing so that all Call expressions(not just some) are delayed
if in a generic function. This changes to delaying all transforms on
calls in generic functions. Had to convert Call() to g.callExpr() (so we
can access g.delayTransform()). By always delaying transforms on calls
in generic functions, we actually simplify the code a bit both in
g.CallExpr() and stencil.go.

Fixes #51236

Change-Id: I0342c7995254082c4baf709b0b92a06ec14425e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/386220
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>
2022-02-24 17:35:40 +00:00
Felix Geisendörfer
8c5904f149 doc/go1.18: mention runtime/pprof improvements
For #47694.

Change-Id: Ib49145a58b8388d35267cf4b0caa730d7e436d06
Reviewed-on: https://go-review.googlesource.com/c/go/+/387574
Reviewed-by: Michael Pratt <mpratt@google.com>
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>
Trust: Bryan Mills <bcmills@google.com>
2022-02-24 17:31:07 +00:00
Tobias Klauser
b2dfec100a doc/go1.18: fix typo in AMD64 port section
Change-Id: I234ae7988fd3c7a41c08e72664f8db811eb23bb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/387854
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-02-24 15:38:08 +00:00
Robert Griesemer
78e99761fc go/types, types2: don't crash if comp. literal element type has no core type
Instead, report a suitable error.

Fixes #51335.

Change-Id: Ifce90cb7487b1e99c6b4221c0d43bacc0c39dca8
Reviewed-on: https://go-review.googlesource.com/c/go/+/387676
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>
2022-02-24 00:04:18 +00:00
Robert Griesemer
e94f7df957 go/types, types2: generalize cleanup phase after type checking
Use a cleanup method and simple registration mechanism
for types that need some final processing before the end
of type checking.

Use cleanup mechanism instead of expandDefTypes mechanism
for *Named types. There is no change in functionality here.

Use cleanup mechanism also for TypeParam and Interface types
to ensure that their check fields are nilled out at the end.

Introduce a simple constructor method for Interface types
to ensure that the cleanup method is always registered.

In go/types, add tracing code to Checker.checkFiles to match
types2.

Minor comment adjustments.

Fixes #51316.
Fixes #51326.

Change-Id: I7b2bd79cc419717982f3c918645af623c0e80d5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/387417
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>
2022-02-23 20:51:28 +00:00
Robert Griesemer
163da6feb5 go/types, types2: add "dynamic" flag to comparable predicate
A type implements a comparable interface only if the type
is statically known to be comparable. Specifically, a type
cannot contain (component) interfaces that are not statically
known to be comparable.

This CL adds a flag "dynamic" to the comparable predicate to
control whether interfaces are always (dynamically) comparable.
Set the flag to true when testing for (traditional) Go comparability;
set the flag to false when testing whether a type implements the
comparable interface.

Fixes #51257.

Change-Id: If22bc047ee59337deb2e7844b8f488d67e5c5530
Reviewed-on: https://go-review.googlesource.com/c/go/+/387055
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>
2022-02-23 20:51:26 +00:00
Robert Findley
e534907f65 go/types: delete unnecessary slice construction
CL 374294 made our check for incorrect type parameters constraints
eager, but failed to remove the construction of the bounds slice, which
was no longer used.

Change-Id: Ib8778fba947ef8a8414803e95d72c49b8f75c204
Reviewed-on: https://go-review.googlesource.com/c/go/+/386717
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-02-23 19:46:34 +00:00
Michael Pratt
d0c3b01162 doc/go1.18: drop misplaced period
Change-Id: Id29f352c8d2e61672f55294120058b1f585f7aeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/387655
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-23 18:00:06 +00:00
Martin Sucha
35170365c8 net: document methods of Buffers
There is code in the wild that copies the Buffers slice,
but not the contents.
Let's document explicitly that it is not safe to do so.

Updates #45163

Change-Id: Id45e27b93037d4e9f2bfde2558e7869983b60bcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/387434
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2022-02-22 23:35:31 +00:00
Cherry Mui
3140625606 doc/go1.18: correct "go build -asan" HTML tag
The tag was "go-mod-vendor", which doesn't match the content.

Also move that section later, so "go mod" sections stay together.

For #47694.

Change-Id: Id4fa7ee0768682a9aadfeb1b2f1d723e7521896b
Reviewed-on: https://go-review.googlesource.com/c/go/+/387354
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-22 18:06:06 +00:00
Russ Cox
d17b65ff54 crypto/x509, runtime: fix occasional spurious “certificate is expired”
As documented in #51209, we have been seeing a low-rate failure
on macOS builders caused by spurious x509 “certificate is expired” errors.

The root cause is that CFDateCreate takes a float64, but it is being
passed a uintptr instead. That is, we're not even putting CFDateCreate's
argument in the right register during the call. Luckily, having just
computed the argument by calling time.Duration.Seconds, which
returns a float64, most of the time the argument we want is still
in the right floating point register, somewhat accidentally.

The only time the lucky accident doesn't happen is when the goroutine
is rescheduled between calling time.Duration.Seconds and calling
into CFDateCreate *and* the rescheduling smashes the floating point
register, which can happen during various block memory moves,
since the floating point registers are also the SIMD registers.

Passing the float64 through explicitly eliminates the problem.
It is difficult to write a test for this that is suitable for inclusion
in the standard library. We will have to rely on the builders to
start flaking again if somehow this problem is reintroduced.

For future reference, there is a standalone test that used to fail
every few seconds at https://go.dev/play/p/OWfDpxgnW9g.

Fixes #51209.

Change-Id: I8b334a51e41f406b13f37270e9175c64fe6f55ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/387255
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-22 15:23:59 +00:00
Alberto Donizetti
c9fe126c8b doc/go1.18: fix a few small typos, add a few commas
Updates #47694

Change-Id: I6c1c3698fdd55fe83c756f28776d1d26dba0a9df
Reviewed-on: https://go-review.googlesource.com/c/go/+/386974
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-21 21:28:40 +00:00
hopehook
851ecea4cc encoding/xml: embedded reference to substruct causes XML marshaller to panic on encoding
When encoding a xml attribute is zero value (IsValid == false), we need
a `continue` to jump over the attribute. If not, followed marshalAttr
function will panic.

Fixes: #50164
Change-Id: I42e064558e7becfbf47728b14cbf5c7afa1e8798
Reviewed-on: https://go-review.googlesource.com/c/go/+/385514
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-20 20:58:11 +00:00
hopehook
0261fa616a testdata: fix typo in comment
Change-Id: If3d5884d9f3f32606c510af5597529b832a8f4a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/386934
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2022-02-19 16:23:54 +00:00
Nick Sherron
903e7cc699 doc/go1.18: fix grammar error
sed 's/the/that/g'

Change-Id: I3f539817b055d54b0ec99346555ac91b756d9ed6
GitHub-Last-Rev: 2e7df1c346
GitHub-Pull-Request: golang/go#51267
Reviewed-on: https://go-review.googlesource.com/c/go/+/386854
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2022-02-19 00:03:22 +00:00
George Looshch
e002cf4df7 strings: fix typo in comment
Remove unnecessary whitespace in noescape comment

Fixes #50634

Change-Id: I1c8d16c020b05678577d349470fac7e7ab8a10b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/378815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2022-02-19 00:00:52 +00:00
Russ Cox
61b5c866a9 doc/go1.18: document Go 1.17 bootstrap and //go:build fix
For #44505 and #41184.

Change-Id: I9503292dace1aa60de167ca5807bf131554465b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/386774
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2022-02-18 20:32:59 +00:00
Cherry Mui
d27248c52f runtime: save some stack space for racecall on ARM64
To avoid nosplit overflow in -race -N -l build.

For #51247.

Change-Id: I48426bbd4adefd18eaf26ed51b4113c6a28305b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/386716
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-02-18 18:47:47 +00:00
Cherry Mui
d93cc8cb96 runtime: define racefuncenter and racefuncexit as ABIInternal
They are called from compiler instrumented code as ABIInternal.
Define them as ABIInternal to avoid the wrappers and save some
stack space, to avoid nosplit overflow in -race -N -l build.

For #51247.

Change-Id: Iadad7d6da8ac03780a7b02b03b004c52d34e020a
Reviewed-on: https://go-review.googlesource.com/c/go/+/386715
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-02-18 18:46:44 +00:00
Cherry Mui
20b177268f reflect: call ABIInternal moveMakeFuncArgPtrs on ARM64
Save some stack space, to avoid nosplit overflow in
-race -N -l build.

For #51247.

Change-Id: I7357d6227f816a612a64f55f7ca1b1384e9268e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/386714
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-02-18 18:46:19 +00:00
Dan Scales
d35ed09486 cmd/compile: fix importers to deal with recursion through type constraints
The code for issue #51219 reveals bugs in the types1 and types2
importers that can occur for recursive types that are recursive through
the type constraint.

The crash in the issue is caused by the types1 bug, which leads to the
production of a type1 type which is incomplete and improperly has the
HasTParam flag set. The bug in the types1 importer is that we were not
deferring type instantiations when reading the type parameters, but we
need to do that exactly to correctly handle recursion through the type
constraint. So, the fix is to move the start of the deferrals (in the
'U' section of doDecl in typecheck/iimport.go) above the code that reads
the type params.

Once that bug is fixed, the test still crashes due to a related types2
importer issues. The problem is that t.SetConstraint(c) requires c to be
fully constructed (have its underlying type set). Since that may not be
done yet in the 'U' case in (*importReader).obj() in
importer/iimport.go, we need to defer the call to SetConstraint() in
that case, until we are done importing all the types.

I added a test case with recursion through a type constraint that causes
a problem that is fixed by the types1 importer change, though the error
is not the same as in the issue. I added more types in the test case
(which try to imitate the issue types more closely) the types2 bug, but
wasn't able to cause it yet with the smaller test case.

Fixes #51219

Change-Id: I85d860c98c09dddc37f76ce87a78a6015ec6fd20
Reviewed-on: https://go-review.googlesource.com/c/go/+/386335
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-18 16:56:42 +00:00
Bryan C. Mills
eaf040502b os: eliminate arbitrary sleep in Kill tests
The test spawned a subprocess that arbitrarily slept for one second.
However, on some platforms, longer than one second may elapse between
starting the subprocess and sending the termination signal.

Instead, the subprocess now closes stdout and reads stdin until EOF,
eliminating the need for an arbitrary duration. (If the parent test
times out, the stdin pipe will break, so the subprocess still won't
leak forever.)

This also makes the test much faster in the typical case: since it
uses synchronization instead of sleeping, it can run as quickly as the
host OS can start and kill the process.

Fixes #44131

Change-Id: I9753571438380dc14fc3531efdaea84578a47fae
Reviewed-on: https://go-review.googlesource.com/c/go/+/386174
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>
2022-02-16 21:34:51 +00:00
Bryan C. Mills
c016133c50 cmd/go/internal/modload: set errors for packages with invalid import paths
Prior to CL 339170, relative errors in module mode resulted in a
base.Fatalf from the module loader, which caused unrecoverable errors
from 'go list -e' but successfully rejected relative imports (which
were never intended to work in module mode in the first place).

After that CL, the base.Fatalf is no longer present, but some errors
that had triggered that base.Fatalf were no longer diagnosed at all:
the module loader left them for the package loader to report, and the
package loader assumed that the module loader would report them.

Since the module loader already knows that the paths are invalid,
it now reports those errors itself.

Fixes #51125

Change-Id: I70e5818cfcfeea0ac70e17274427b08a74fd7c13
Reviewed-on: https://go-review.googlesource.com/c/go/+/386176
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>
2022-02-16 19:10:58 +00:00
Daniel Theophanes
a289e9ce75 database/sql: make WAIT tests more robust, rely on waiter trigger
Replace the WAIT query prefix with a function callback.
This fixes timing issues when the testing on loaded servers.

Fixes #51208

Change-Id: I5151b397b7066c27ce6bc02c160dde0b584934bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/385934
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Daniel Theophanes <kardianos@gmail.com>
2022-02-16 18:05:27 +00:00
Bryan C. Mills
f985833dec testing: panic in Fuzz if the function returns a value
Otherwise, the behavior of a fuzz target that returns an error could
be confusing.

Fuzz is already documented to require a function “with no return
value”, so this fixes the implementation to match the existing
documentation.

Fixes #51222

Change-Id: I44ca7ee10960214c92f5ac066ac8484c8bb9cd6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/386175
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Nooras Saba‎ <saba@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-16 16:06:39 +00:00
Michael Matloob
5d8d387849 cmd/go: set go.work path using GOWORK, and remove -workfile flag
This change removes the -workfile flag and allows the go.work file path
to be set using GOWORK (which was previously read-only). This removes
the potential discrepancy and confusion between the flag and environment
variable.

GOWORK will still return the actual path of the go.work file found if it
is set to '' or 'auto'. GOWORK will return 'off' if it is set to 'off'.

For #45713
Fixes #51171

Change-Id: I72eed65d47c63c81433f2b54158d514daeaa1ab3
Reviewed-on: https://go-review.googlesource.com/c/go/+/385995
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-02-16 15:58:47 +00:00
Ian Lance Taylor
293ecd87c1 time: document that Parse truncates to nanosecond precision
For #48685
Fixes #50806

Change-Id: Ie8be40e5794c0998538890a651ef8ec92cb72d3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/381155
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-02-15 22:54:38 +00:00
Ian Lance Taylor
6e82ff83cf net: increase maximum accepted DNS packet to 1232 bytes
The existing value of 512 bytes as is specified by RFC 1035.
However, the WSL resolver reportedly sends larger packets without
setting the truncation bit, which breaks using the Go resolver.
For 1.18 and backports, just increase the accepted packet size.
This is what GNU glibc does (they use 65536 bytes).

For 1.19 we plan to use EDNS to set the accepted packet size.
That will give us more time to test whether that causes any problems.

No test because I'm not sure how to write one and it wouldn't really
be useful anyhow.

Fixes #6464
Fixes #21160
Fixes #44135
Fixes #51127
For #51153

Change-Id: I0243f274a06e010ebb714e138a65386086aecf17
Reviewed-on: https://go-review.googlesource.com/c/go/+/386015
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-15 22:30:13 +00:00
Ian Lance Taylor
d3c9ef57ce Revert "net: send EDNS(0) packet length in DNS query"
This reverts https://go.dev/cl/385035. For 1.18 we will use a simple
change to increase the accepted DNS packet size, to handle what appear
to be broken resolvers that don't honor the 512 byte limit. For 1.19
we will restore CL 385035 to make a proper EDNS request, so that it
has more testing time before it goes out in a release.

For #6464
For #21160
For #44135
For #51127
For #51153

Change-Id: Ie4a0eb85ca0a6a73bee5cd4cfc6b7d2a15ef259f
Reviewed-on: https://go-review.googlesource.com/c/go/+/386014
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-02-15 22:29:37 +00:00
Bryan C. Mills
d199ceffa8 cmd/go: in workspace mode, resolve replacements relative to their go.mod files
Fixes #51204

Change-Id: I41106b7d04120be5ba68573bd25fd33e985688de
Reviewed-on: https://go-review.googlesource.com/c/go/+/385994
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-15 22:28:43 +00:00
alex.schade
08ed4882aa cmd/go/internal/modfetch: avoid leaking a lockedfile.File in case of write errors
The go modules download command has a method called hashZip which checks the
hash of a zipped directory versus an expected value, and then writes it out
to a file. In the event that the write operation is not successful, we do
not close the file, leading to it being leaked. This could happen if the
user runs out of disk space, causing the underlying OS write command to
return an error. Ultimately, this led to a panic in lockfile.OpenFile which
was invoked from a finalizer garbage collecting the leaked file. The result
was a stack trace that didn't show the call stack from where the write
operation actually failed.

Fixes #50858

Change-Id: I4a24d2ab13dc903d623bbf8252b37bb9d724b8de
GitHub-Last-Rev: 354ef1d29e
GitHub-Pull-Request: golang/go#51058
Reviewed-on: https://go-review.googlesource.com/c/go/+/383915
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-15 21:18:59 +00:00
Michael Pratt
b5af5c0834 runtime: enable sigPerThreadSyscall handling on android
CL 383434 forgot to enable these paths for android, which is still linux
just not via GOOS.

Fixes #51213.

Change-Id: I102e53e8671403ded6edb4ba04789154d7a0730b
Reviewed-on: https://go-review.googlesource.com/c/go/+/385954
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-15 19:04:00 +00:00