]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
23 months agomisc/cgo/testcarchive: don't rely on an erroneous install target in tests
Bryan C. Mills [Mon, 11 Jul 2022 17:06:56 +0000 (13:06 -0400)]
misc/cgo/testcarchive: don't rely on an erroneous install target in tests

Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.

This change switches the 'go install' command in TestPIE to instead
use 'go build', and switches TestInstall and TestCachedInstall
(which appear to be explicitly testing 'go install') to explicitly
request GOPATH mode (which does have a well-defined install target).

For #37015.

Change-Id: Ifb24657d2781d1e35cf40078e8e3ebf56aab9cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/416954
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agonet/url: use EscapedPath for url.JoinPath
Sean Liao [Sat, 9 Jul 2022 17:38:45 +0000 (18:38 +0100)]
net/url: use EscapedPath for url.JoinPath

Fixes #53763

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

23 months agodatabase/sql: make TestTxContextWaitNoDiscard test more robust
Dmitri Goutnik [Sat, 9 Jul 2022 12:36:45 +0000 (07:36 -0500)]
database/sql: make TestTxContextWaitNoDiscard test more robust

Similar to CL 385934, rely on waiter trigger instead of the WAIT query
prefix and factor out the common test code.

Fixes #53222

Change-Id: I46efc85ca102b350bb4dbe8e514921e016870ffb
Reviewed-on: https://go-review.googlesource.com/c/go/+/416655
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
23 months agocmd/go: use package index for std in load.loadPackageData
Russ Cox [Tue, 5 Jul 2022 17:53:35 +0000 (13:53 -0400)]
cmd/go: use package index for std in load.loadPackageData

load.loadPackageData was only using an index for modules,
not for standard library packages. Other parts of the code were
using the index, so there was some benefit, but not as much
as you'd hope.

With the index disabled, the Script/work test takes 2.2s on my Mac.
With the index enabled before this CL, it took 2.0s.
With the index enabled after this CL, it takes 1.6s.

Before this CL, the Script/work test issued:

 429 IsDir
  19 IsDirWithGoFiles
   7 Lstat
9072 Open
 993 ReadDir
 256 Stat
   7 Walk
   3 indexModule
  24 openIndexModule
 525 openIndexPackage

After this CL, it issued:

  19 IsDirWithGoFiles
   7 Lstat
  60 Open
 606 ReadDir
 256 Stat
   7 Walk
   3 indexModule
  24 openIndexModule
 525 openIndexPackage

This speedup helps the Dragonfly builder, which has very slow
file I/O and is timing out since a recent indexing change.

Times for go test -run=Script/^work$ on the Dragonfly builder:

50s before indexing changes
31s full module indexing of std
46s per-package indexing of std

It cuts the time for go test -run=Script/^work$ from 44s to 20s.

For #53577.

Change-Id: I7189a77fc7fdf61de3ab3447efc4e84d1fc52c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/416134
Reviewed-by: Bryan Mills <bcmills@google.com>
23 months agonet/http: remove Content-Encoding in writeNotModified
Mitar [Sun, 10 Jul 2022 14:06:09 +0000 (14:06 +0000)]
net/http: remove Content-Encoding in writeNotModified

Additional header to remove if set before calling http.ServeContent.

The API of ServeContent is that one should set Content-Encoding before calling it, if the content is encoded (e.g., compressed). But then, if content has not been modified, that header should be removed, according to RFC 7232 section 4.1.

Change-Id: If51b35b7811a4dbb19de2ddb73f40c5e68fcec7e
GitHub-Last-Rev: 53df6e73c44b63f351f7aeeb45cab82d706311eb
GitHub-Pull-Request: golang/go#50903
Reviewed-on: https://go-review.googlesource.com/c/go/+/381955
Run-TryBot: hopehook <hopehook@qq.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
23 months agocmd/compile: fix libfuzzer instrumentation line number
Keith Randall [Fri, 8 Jul 2022 21:52:23 +0000 (14:52 -0700)]
cmd/compile: fix libfuzzer instrumentation line number

Set a reasonable starting line number before processing the body of
the function in the order pass.

We update base.Pos each time we process a node, but some of the
libfuzzer instrumentation is added before we process any node, so the
base.Pos used is junk.

Fixes #53688

Change-Id: I3654b805eabb8866a9a1574845ef4ff062797319
Reviewed-on: https://go-review.googlesource.com/c/go/+/416654
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go: avoid setting variables for '/' and ':' in TestScript subprocess environments
Bryan C. Mills [Fri, 8 Jul 2022 14:02:14 +0000 (10:02 -0400)]
cmd/go: avoid setting variables for '/' and ':' in TestScript subprocess environments

Also simplify platform-dependent handling of the PATH variable,
to make it more like the existing platform-dependent handling for
HOME and TMPDIR.

Fixes #53671.

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

23 months agonet/http: wait for listeners to exit in Server.Close and Shutdown
Damien Neil [Tue, 31 May 2022 21:47:33 +0000 (14:47 -0700)]
net/http: wait for listeners to exit in Server.Close and Shutdown

Avoid race conditions when a new connection is accepted just after
Server.Close or Server.Shutdown is called by waiting for the
listener goroutines to exit before proceeding to clean up active
connections.

No test because the mechanism required to trigger the race condition
reliably requires such tight coupling to the Server internals that
any test would be quite fragile in the face of reasonable refactorings.

Fixes #48642
Updates #33313, #36819

Change-Id: I109a93362680991bf298e0a95637595dcaa884af
Reviewed-on: https://go-review.googlesource.com/c/go/+/409537
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
23 months agocmd/compile: don't convert to interface{} for un-comparable types in generic switch
Cuong Manh Le [Fri, 1 Jul 2022 09:33:54 +0000 (16:33 +0700)]
cmd/compile: don't convert to interface{} for un-comparable types in generic switch

Fixes #53635

Change-Id: I41f383be8870432fc0d29fa83687911ddd8217f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/415634
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
23 months agoruntime: overestimate the amount of allocated memory in heapLive
Michael Anthony Knyszek [Thu, 7 Jul 2022 20:01:21 +0000 (20:01 +0000)]
runtime: overestimate the amount of allocated memory in heapLive

CL 377516 made it so that memory metrics are truly monotonic, but also
updated how heapLive tracked allocated memory to also be monotonic.

The result is that cached spans with allocated memory aren't fully
accounted for by the GC, causing it to make a worse assumption (the
exact mechanism is at this time unknown), resulting in a memory
regression, especially for smaller heaps.

This change is a partial revert of CL 377516 that makes heapLive a
non-monotonic overestimate again, which appears to resolve the
regression.

For #53738.

Change-Id: I5c51067abc0b8e0a6b89dd8dbd4a0be2e8c0c1b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/416417
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocrypto/x509: restrict CRL number to <=20 octets
Roland Shoemaker [Wed, 29 Jun 2022 18:30:47 +0000 (11:30 -0700)]
crypto/x509: restrict CRL number to <=20 octets

Similar to certificate serial numbers, RFC 5280 restricts the length of
the CRL number field to no more than 20 octets. Enforce this in
CreateRevocationList.

Fixes #53543

Change-Id: If392ef6b0844db716ae9ee6ef317135fceab039c
Reviewed-on: https://go-review.googlesource.com/c/go/+/415134
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>

23 months agocrypto/x509: correctly parse CRL entry extensions
Aaron Gable [Tue, 28 Jun 2022 22:28:21 +0000 (15:28 -0700)]
crypto/x509: correctly parse CRL entry extensions

When checking to see if a CRL entry has any extensions, attempt to read
them from the individual revokedCertificate, rather than from the parent
TBSCertList.

Additionally, crlEntryExtensions is not an EXPLICIT field (c.f.
crlExtension and Certificate extensions), so do not perform an extra
layer of unwrapping when parsing the field.

The added test case fails without the accompanying changes.

Fixes #53592

Change-Id: Icc00e4c911f196aef77e3248117de64ddc5ea27f
Reviewed-on: https://go-review.googlesource.com/c/go/+/414877
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocrypto/x509: populate Number and AKI of parsed CRLs
Aaron Gable [Wed, 6 Jul 2022 23:59:03 +0000 (16:59 -0700)]
crypto/x509: populate Number and AKI of parsed CRLs

The x509.RevocationList type has two fields which correspond to
extensions, rather than native fields, of the underlying ASN.1 CRL:
the .Number field corresponds to the crlNumber extension, and
the .AuthorityKeyId field corresponds to the authorityKeyIdentifier
extension.

The x509.CreateRevocationList() function uses these fields to populate
their respective extensions in the resulting CRL. However, the
x509.ParseRevocationList() function does not perform the reverse
operation: the fields retain their zero-values even after parsing a CRL
which contains the relevant extensions.

Add code which populates these fields when parsing their extensions.
Add assertions to the existing tests to confirm that the values are
populated appropriately.

Fixes #53726

Change-Id: Ie5b71081e53034e0b5b9ff3c122065c62f15cf23
Reviewed-on: https://go-review.googlesource.com/c/go/+/416354
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
23 months agocmd/link: explicitly disable PIE for windows/amd64 -race mode
Than McIntosh [Fri, 1 Jul 2022 12:39:12 +0000 (08:39 -0400)]
cmd/link: explicitly disable PIE for windows/amd64 -race mode

Turn off PIE explicitly for windows/amd64 when -race is in effect,
since at the moment the race detector runtime doesn't seem to handle
PIE binaries correctly. Note that newer C compilers on windows
produce PIE binaries by default, so the Go linker needs to explicitly
turn off PIE when invoking the external linker in this case.

Updates #53539.

Change-Id: Ib990621f22cf61a5fa383584bab81d3dfd7552e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/415676
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
23 months agocmd/go: default to "exe" build mode for windows -race
Than McIntosh [Wed, 6 Jul 2022 11:45:19 +0000 (07:45 -0400)]
cmd/go: default to "exe" build mode for windows -race

This patch changes the default build mode from "pie" to "exe" when
building programs on windows with "-race" in effect. The Go command
already issues an error if users explicitly ask for -buildmode=pie in
combination with -race on windows, but wasn't revising the default
"pie" build mode if a specific buildmode was not requested.

Updates #53539.
Updates #35006.

Change-Id: I2f81a41a1d15a0b4f5ae943146175c5a1202cbe0
Reviewed-on: https://go-review.googlesource.com/c/go/+/416174
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>

23 months agocmd/compile: only check implicit dots for method call enabled by a type bound
Cuong Manh Le [Tue, 28 Jun 2022 19:05:21 +0000 (02:05 +0700)]
cmd/compile: only check implicit dots for method call enabled by a type bound

Fixes #53419

Change-Id: Ibad64f5c4af2112deeb0a9ecc9c589b17594bd05
Reviewed-on: https://go-review.googlesource.com/c/go/+/414836
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

23 months agocmd/go: set up git identity for build_buildvcs_auto.txt
Daniel Martí [Tue, 5 Jul 2022 15:14:22 +0000 (16:14 +0100)]
cmd/go: set up git identity for build_buildvcs_auto.txt

Just like in other tests like get_dotfiles.txt or
version_buildvcs_git.txt. Without it, I get a failure on my machine:

fatal: empty ident name (for <mvdan@p14s.localdomain>) not allowed

Change-Id: I1c17c0d58c539b59154570b5438c7bd850bac5aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/416095
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
23 months agocmd/compile: rework induction variable detector
Keith Randall [Sat, 2 Jul 2022 18:07:55 +0000 (11:07 -0700)]
cmd/compile: rework induction variable detector

Induction variable detection is still not quite right. I've added
another failing test.

Redo the overflow/underflow detector so it is more obviously correct.

Update #53600
Fixes #53653
Fixes #53663

Change-Id: Id95228e282fdbf6bd80b26e1c41d62e935ba08ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/415874
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
23 months agoos/exec: clarify that Wait must be called
Ian Lance Taylor [Fri, 24 Jun 2022 21:34:28 +0000 (14:34 -0700)]
os/exec: clarify that Wait must be called

Fixes #52580

Change-Id: Ib2dd8a793b9c6fcb083abb3f7c346f6279adefc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/414056
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
23 months agocmd/internal/notsha256: add purego tag as needed
Ian Lance Taylor [Sun, 3 Jul 2022 20:34:47 +0000 (13:34 -0700)]
cmd/internal/notsha256: add purego tag as needed

This permits building the package with gccgo, when using gccgo
as a bootstrap compiler.

Fixes #53662

Change-Id: Ic7ae9323ec5954e9306a32e1160e9aa1ed3aa202
Reviewed-on: https://go-review.googlesource.com/c/go/+/415935
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
23 months agocmd/dist: use purego tag when building the bootstrap binaries
Ian Lance Taylor [Sun, 3 Jul 2022 20:32:54 +0000 (13:32 -0700)]
cmd/dist: use purego tag when building the bootstrap binaries

This is in addition to the current math_big_pure_go tag.
Using purego ensures that we can build the cmd binaries with gccgo.

For #53662

Change-Id: Ib82f8bf10659b5f94935f2b427ae8b2da875cd3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/415934
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agomisc/cgo/test: make TestSetgidStress cheaper
Cherry Mui [Fri, 1 Jul 2022 16:56:39 +0000 (12:56 -0400)]
misc/cgo/test: make TestSetgidStress cheaper

TestSetgidStress spawns 1000 threads, which can be expensive on
some platforms or slow builders. Run with 50 threads in short
mode instead.

This makes the failure less reproducible even with buggy code. But
one can manually stress test it (e.g. when a flaky failure appear
on the builder).

Fixes #53641.

Change-Id: I33b5ea5ecaa8c7a56f59c16f9171657ee295db47
Reviewed-on: https://go-review.googlesource.com/c/go/+/415677
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>

23 months agotest: recognize new gofrontend error message
Ian Lance Taylor [Mon, 4 Jul 2022 20:16:46 +0000 (13:16 -0700)]
test: recognize new gofrontend error message

The new gofrontend message matches other gofrontend error messages,
so adjust the test to accept it.

For #27938
For #51237

Change-Id: I29b536f83a0cf22b1dbdae9abc2f5f6cf21d522d
Reviewed-on: https://go-review.googlesource.com/c/go/+/416014
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
23 months agocmd/compile: drop "buildcfg" from no instrument packages
Michael Pratt [Tue, 28 Jun 2022 18:47:49 +0000 (14:47 -0400)]
cmd/compile: drop "buildcfg" from no instrument packages

Package buildcfg was added to this list by CL 403851, but package
buildcfg does not exist.

This was probably intended to refer to internal/buildcfg, but
internal/buildcfg is only used by the compiler so it is not clear why it
couldn't be instrumented.

For #44853.

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

23 months agocmd/go: make module@nonexistentversion failures reusable
Russ Cox [Fri, 1 Jul 2022 20:10:19 +0000 (16:10 -0400)]
cmd/go: make module@nonexistentversion failures reusable

CL 411398 added the -reuse flag for reusing cached JSON output
when the remote Git repository has not changed. One case that was
not yet cached is a lookup of a nonexistent version.

This CL adds caching of failed lookups of nonexistent versions,
by saving a checksum of all the heads and tags refs on the remote
server (we never consider other kinds of refs). If none of those have
changed, then we don't need to download the full server.

Fixes #53644.

Change-Id: I428bbc8ec8475bd7d03788934d643e1e2be3add0
Reviewed-on: https://go-review.googlesource.com/c/go/+/415678
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go: add -reuse flag to make proxy invocations more efficient
Russ Cox [Fri, 10 Jun 2022 16:03:06 +0000 (12:03 -0400)]
cmd/go: add -reuse flag to make proxy invocations more efficient

The go list -m and go mod download commands now have a -reuse flag,
which is passed the name of a file containing the JSON output from a
previous run of the same command. (It is up to the caller to ensure
that flags such as -versions or -retracted, which affect the output,
are consistent between the old and new run.)

The new run uses the old JSON to evaluate whether the answer is
unchanged since the old run. If so, it reuses that information,
avoiding a costly 'git fetch', and sets a new Reuse: true field in its
own JSON output.

This dance with saving the JSON output and passing it back to -reuse
is not necessary on most systems, because the go command caches
version control checkouts in the module cache. That cache means that a
new 'git fetch' would only download the commits that are new since the
previous one (often none at all).

The dance becomes important only on systems that do not preserve the
module cache, for example by running 'go clean -modcache' aggressively
or by running in some environment that starts with an empty file
system.

For #53644.

Change-Id: I447960abf8055f83cc6dbc699a9fde9931130004
Reviewed-on: https://go-review.googlesource.com/c/go/+/411398
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
23 months agocmd/go: record origin metadata during module download
Russ Cox [Thu, 9 Jun 2022 03:56:28 +0000 (23:56 -0400)]
cmd/go: record origin metadata during module download

This change adds an "Origin" JSON key to the output of
go list -json -m and go mod download -json. The associated value is a
JSON object with metadata about the source control system. For Git,
that metadata is sufficient to evaluate whether the remote server has
changed in any interesting way that might invalidate the cached data.
In most cases, it will not have, and a fetch could then avoid
downloading a full repo from the server.

This origin metadata is also now recorded in the .info file for a
given module@version, for informational and debugging purposes.

This change only adds the metadata. It does not use it to optimize
away unnecessary git fetch operations. (That's the next change.)

For #53644.

Change-Id: I4a1712a2386d1d8ab4e02ffdf0f72ba75d556115
Reviewed-on: https://go-review.googlesource.com/c/go/+/411397
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
23 months agobuild/constraint: update doc to mention a feature added in Go 1.17
Cristian Greco [Sun, 3 Jul 2022 11:04:04 +0000 (11:04 +0000)]
build/constraint: update doc to mention a feature added in Go 1.17

The pkg documentation mentions that the "//go:build" syntax "will be"
added in Go 1.17. In fact, it has been added in that Go release, so the
documentation can now be updated.

Change-Id: I72f24063c3be62d97ca78bf724d56599f5f19460
GitHub-Last-Rev: 4371886f6ce9f2c2a370df047a5baa1f122c681f
GitHub-Pull-Request: golang/go#53647
Reviewed-on: https://go-review.googlesource.com/c/go/+/415774
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agoruntime: pass correct string to exits on Plan 9
Ori Bernstein [Sun, 3 Jul 2022 16:26:30 +0000 (12:26 -0400)]
runtime: pass correct string to exits on Plan 9

In CL 405901 the definition of exit in the Plan 9 go runtime
was changed like so:

-               status = append(itoa(tmp[:len(tmp)-1], uint64(e)), 0)
+               sl := itoa(tmp[:len(tmp)-1], uint64(e))
+               // Don't append, rely on the existing data being zero.
+               status = tmp[:len(sl)+1]

However, itoa only puts the converted number "somewhere" in the buffer.
Specifically, it builds it from the end of the buffer towards the start,
meaning the first byte of the buffer is a 0 byte, and the resulting string
that's passed to exits is empty, leading to a falsely successful exit.

This change uses the returned value from itoa, rather than the buffer
that was passed in, so that we start from the correct location in the
string.

Fixes #53669

Change-Id: I63f0c7641fc6f55250857dc17a1eeb12ae0c2e10
Reviewed-on: https://go-review.googlesource.com/c/go/+/415680
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agonet/http: omit invalid header value from error message
Alexander Yastrebov [Thu, 14 Oct 2021 22:01:49 +0000 (22:01 +0000)]
net/http: omit invalid header value from error message

Updates #43631

Change-Id: I0fe3aafdf7ef889fed1a830128721393f8d020e6
GitHub-Last-Rev: c359542d741b17f4e2cb0d50982bf341246233b0
GitHub-Pull-Request: golang/go#48979
Reviewed-on: https://go-review.googlesource.com/c/go/+/355929
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go, go/build: clarify build constraint docs
Ian Lance Taylor [Fri, 10 Jun 2022 22:58:22 +0000 (15:58 -0700)]
cmd/go, go/build: clarify build constraint docs

Clarify that the //go:build line is an expression of constraints,
not a constraint itself.

Fixes #53308

Change-Id: Ib67243c6ee5cfe3b688c12b943b5e7496f686035
Reviewed-on: https://go-review.googlesource.com/c/go/+/411697
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
23 months agoflag: highlight support for double dashes in docs
Sebastian Gassner [Thu, 30 Jun 2022 13:37:04 +0000 (13:37 +0000)]
flag: highlight support for double dashes in docs

Updating examples, to show that double dashes are also permitted. This has been easy to miss previously.

Change-Id: Ib67b4e39fea90ef4cb9e894709c53baedfc18fc2
GitHub-Last-Rev: f7df57b646d6412c1346e85c3a7353a8df41afc6
GitHub-Pull-Request: golang/go#53628
Reviewed-on: https://go-review.googlesource.com/c/go/+/415374
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

23 months agogo/types, types2: document that exported predicates are unspecified for invalid type...
Robert Griesemer [Thu, 30 Jun 2022 23:41:31 +0000 (16:41 -0700)]
go/types, types2: document that exported predicates are unspecified for invalid type arguments

Per discussion on the issue.

For #53595.

Change-Id: Iefd161e5c7e792d454652cbe831a0c2d769f748e
Reviewed-on: https://go-review.googlesource.com/c/go/+/415574
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agogo/types, types2: re-enable a couple of commented out tests
Robert Griesemer [Thu, 30 Jun 2022 01:21:32 +0000 (18:21 -0700)]
go/types, types2: re-enable a couple of commented out tests

Change-Id: Ibb27012b18fc0f0f9f9ef74cc120e7ef981e6d43
Reviewed-on: https://go-review.googlesource.com/c/go/+/415156
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

23 months agogo/doc/comment: support links in lists in comments
Ben Sarah Golightly [Wed, 29 Jun 2022 18:42:46 +0000 (19:42 +0100)]
go/doc/comment: support links in lists in comments

The proposed (#51082) new go doc comment additions supports lists,
links, and doc links, but does not support links and doc links inside
lists, so implemnent this.

Fixes #53610

Change-Id: I4fa17d204fc9efa8f3633133e4a49e56cf1aa9bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/415174
Reviewed-by: Ben Golightly <golightly.ben@googlemail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agoos: fix a typo in path_windows.go
AndreasHGK [Thu, 30 Jun 2022 15:59:30 +0000 (15:59 +0000)]
os: fix a typo in path_windows.go

I believe the path_windows.go file has a typo, which is fixed in this PR

Change-Id: Ibf1a7189a6312dbb3b1e6b512beeb6d99da5b5bc
GitHub-Last-Rev: cedac7eaa07d26667e6800c5ac96239d5ccf6ba8
GitHub-Pull-Request: golang/go#53629
Reviewed-on: https://go-review.googlesource.com/c/go/+/415434
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

23 months agoos: simplify deadline fluctuation tests
Ian Lance Taylor [Wed, 29 Jun 2022 20:11:33 +0000 (13:11 -0700)]
os: simplify deadline fluctuation tests

This applies the net package CL 365334, CL 366176, CL 372215 to the os
package.

CL 365334:

    These tests were checking for fairly narrow timing windows, but were
    running in parallel and heavily dependent on timer and goroutine
    scheduling. This change eliminates unnecessary goroutines, runs the
    tests sequentially (dramatically shortening the timeouts to reduce the
    penalty of doing so), and uses timestamp comparison instead of
    background timers to hopefully gain some robustness from monotonic
    timestamps.

    Many of the other tests from this package would benefit from similar
    simplifications, which we can apply if and when we notice flaky
    failures or want to improve the latency of running the test.

CL 366176:

    It appears that at least the OpenBSD kernel gets sloppier the longer
    the timeout we give it, up to an observed overhead of around 25%.
    Let's give it a little more than that (33%) in the comparison, and
    also increase the growth curve to match the actual observed times
    instead of exponential initial growth.

CL 372215:

    Decrease the slop everywhere else, since NetBSD and OpenBSD seem to be
    the only ones that miss by that much.

For #36108
For #50189
Fixes #50725 (we hope)

Change-Id: I0854d27af67ca9fcf0f9d9e4ff67acff4c2effc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/415234
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agocmd/go/internal/modindex: remove spurious field from index_format documentation
Bryan C. Mills [Thu, 30 Jun 2022 18:18:02 +0000 (14:18 -0400)]
cmd/go/internal/modindex: remove spurious field from index_format documentation

The 'path' field was removed in an earlier revision to the format.

While auditing the format, I also cleaned up a couple of minor
typographical issues.

For #53586.

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

23 months agocmd/go: include module root in package index key
Bryan C. Mills [Thu, 30 Jun 2022 17:39:57 +0000 (13:39 -0400)]
cmd/go: include module root in package index key

The package index format includes the directory relative to the module
root. The module root for a given directory can change even if the
contents of the directory itself do not (by adding or removing a
go.mod file in some parent directory).

Thus, we need to invalidate the index for a package when its module
root location changes.

Fixes #53586 (I think).

Change-Id: I2d9f4de80e16bce75b3106a2bad4a11d8378d037
Reviewed-on: https://go-review.googlesource.com/c/go/+/415475
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go: add a 'sleep' command for script tests
Bryan C. Mills [Thu, 30 Jun 2022 17:30:48 +0000 (13:30 -0400)]
cmd/go: add a 'sleep' command for script tests

Due to mtime skew we don't index mutable packages with an mtime
younger than 2 seconds. In order to test indexed packages reliably, we
want to be able to sleep long enough for the files in the package to be cached.

(As an alternative we could instead use os.Chtimes to fake old enough
timestamps, but sleeping keeps the tests more realistic.)

For #53586.

Change-Id: I1873f47c55a72d928451593b8c989f0092a557db
Reviewed-on: https://go-review.googlesource.com/c/go/+/415474
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/compile: fix prove pass when upper condition is <= maxint
Keith Randall [Wed, 29 Jun 2022 20:22:59 +0000 (13:22 -0700)]
cmd/compile: fix prove pass when upper condition is <= maxint

When the terminating condition is <= X, we need to make sure that
X+step doesn't overflow.

Fixes #53600

Change-Id: I36e5384d05b4d7168e48db6094200fcae409bfe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/415219
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

23 months agospec: retitle section on "Assignments" to "Assignment statements"
Robert Griesemer [Wed, 22 Jun 2022 18:58:06 +0000 (11:58 -0700)]
spec: retitle section on "Assignments" to "Assignment statements"

This permits a clear distinction between an individual assignment
and an assignment statement which may assign more than one value.
It also makes this section title consistent with all other section
titles about statements. Adjust internal links and prose where
appropriate. (Note that the spec already referred to assignment
statements in a couple of places, even before this change.)

Add an introductory paragraph to the section on assignment statements.

Preparation for adding a section on value vs reference types
(issue #5083).

Change-Id: Ie140ac296e653c67da2a5a203b63352b3dc4f9f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/413615
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agotest: add regress test for #53619
Matthew Dempsky [Wed, 29 Jun 2022 22:39:01 +0000 (15:39 -0700)]
test: add regress test for #53619

Works with cmd/compile, but fails with gccgo currently.

Updates #53619.

Change-Id: I787faa9584cc33bd851c9cc8f146c91f4eb36fc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/415238
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

23 months agodebug/pe: add IMAGE_FILE_MACHINE_LOONGARCH{64,32}
Guoqi Chen [Fri, 10 Jun 2022 11:53:27 +0000 (19:53 +0800)]
debug/pe: add IMAGE_FILE_MACHINE_LOONGARCH{64,32}

Related: https://github.com/MicrosoftDocs/win32/pull/1067

Change-Id: I946253f217a5c616ae4a19be44634000cba5020e
Reviewed-on: https://go-review.googlesource.com/c/go/+/411616
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
23 months agonet/http: preserve nil values in Header.Clone
Damien Neil [Fri, 17 Jun 2022 17:09:45 +0000 (10:09 -0700)]
net/http: preserve nil values in Header.Clone

ReverseProxy makes a distinction between nil and zero-length header values.
Avoid losing nil-ness when cloning a request.

Thanks to Christian Mehlmauer for discovering this.

Fixes #53423
Fixes CVE-2022-32148

Change-Id: Ice369cdb4712e2d62e25bb881b080847aa4801f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/412857
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
23 months agocmd/internal/obj/arm64: save LR and SP in one instruction for small frames
Cherry Mui [Wed, 15 Jun 2022 19:09:24 +0000 (15:09 -0400)]
cmd/internal/obj/arm64: save LR and SP in one instruction for small frames

When we create a thread with signals blocked. But glibc's
pthread_sigmask doesn't really allow us to block SIGSETXID. So we
may get a signal early on before the signal stack is set. If we
get a signal on the current stack, it will clobber anything below
the SP. This CL makes it to save LR and decrement SP in a single
MOVD.W instruction for small frames, so we don't write below the
SP.

We used to use a single MOVD.W instruction before CL 379075.
CL 379075 changed to use an STP instruction to save the LR and FP,
then decrementing the SP. This CL changes it back, just this part
(epilogues and large frame prologues are unchanged). For small
frames, it is the same number of instructions either way.

This decreases the size of a "small" frame from 0x1f0 to 0xf0.
For frame sizes in between, it could benefit from using an
STP instruction instead of using the prologue for the "large"
frame case. We don't bother it for now as this is a stop-gap
solution anyway.

This only addresses the issue with small frames. Luckily, all
functions from thread entry to setting up the signal stack have
samll frames.

Other possible ideas:
- Expand the unwind info metadata, separate SP delta and the
  location of the return address, so we can express "SP is
  decremented but the return address is in the LR register". Then
  we can always create the frame first then write the LR, without
  writing anything below the SP (except the frame pointer at SP-8,
  which is minor because it doesn't really affect program
  execution).
- Set up the signal stack immediately in mstart in assembly.

For Go 1.19 we do this simple fix. We plan to do the metadata fix
in Go 1.20 ( #53609 ).

Other LR architectures are addressed in CL 413428.

Fix #53374.

Change-Id: I9d6582ab14ccb06ac61ad43852943d9555e22ae5
Reviewed-on: https://go-review.googlesource.com/c/go/+/412474
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
23 months agogo/token: use atomics not Mutex for last file cache
Alan Donovan [Wed, 29 Jun 2022 17:08:11 +0000 (13:08 -0400)]
go/token: use atomics not Mutex for last file cache

Previously, FileSet would cache the last *File found by a lookup,
using a full (exclusive) mutex within FileSet.File, turning a logical
read operation into an update. This was one of the largest sources
of contention in gopls.  This change uses atomic load/store on the
'last' field without a mutex.

Also, in FileSet.AddFile, allocate the File outside the critical
section; all the other operations are typically cheap.

Fixes #53507

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

23 months agonet/http: don't strip whitespace from Transfer-Encoding headers
Damien Neil [Wed, 1 Jun 2022 18:17:07 +0000 (11:17 -0700)]
net/http: don't strip whitespace from Transfer-Encoding headers

Do not accept "Transfer-Encoding: \rchunked" as a valid TE header
setting chunked encoding.

Thanks to Zeyu Zhang (https://www.zeyu2001.com/) for identifying
the issue.

Fixes #53188
Fixes CVE-2022-1705

Change-Id: I1a16631425159267f2eca68056b057192a7edf6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/409874
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
23 months agoruntime: add race annotations to cbs.lock
Michael Pratt [Tue, 28 Jun 2022 20:32:50 +0000 (16:32 -0400)]
runtime: add race annotations to cbs.lock

cbs.lock protects a map. The map implementation is race instrumented
regardless of which package is it called from.

lock/unlock are not automatically race instrumented, so we can trigger
race false positives without manually annotating our lock acquire and
release.

compileCallback is used during initialization before the P is available,
at which point raceacquire will crash during a racecallback to get the
race proc. Thus we skip instrumentation until scheduler initialization
is complete.

Fixes #50249.

Change-Id: Ie49227c9e9210ffbf0aee65f86f2b7b6a2f64638
Reviewed-on: https://go-review.googlesource.com/c/go/+/414518
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

23 months agocrypto/x509/pkix: move crl deprecation message
Roland Shoemaker [Tue, 28 Jun 2022 01:04:56 +0000 (18:04 -0700)]
crypto/x509/pkix: move crl deprecation message

There was a deprecation message on RevokedCertificate which was
intended to be on CertificateList.

Change-Id: Ia378935afc75c36702e64cf33ea5c8a24c1488ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/414754
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
23 months agocmd/internal/obj/mips,s390x,riscv: save LR after decrementing SP
Cherry Mui [Wed, 22 Jun 2022 20:28:41 +0000 (16:28 -0400)]
cmd/internal/obj/mips,s390x,riscv: save LR after decrementing SP

Following CL 412474, for the rest of the LR architectures. On
MIPS(32/64), S390X, and RISCV, there is no single instruction that
saves the LR and decrements the SP, so we need to insert an
instruction to save the LR after decrementing the SP.

On ARM(32) and PPC64 we already use a single instruction to save
the LR and decrement the SP.

Updates #53374.

Change-Id: I5a2e211026d95edb0e0f7d084ddb784f8077b86d
Reviewed-on: https://go-review.googlesource.com/c/go/+/413428
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

23 months agoruntime: add race annotations to metricsSema
Michael Pratt [Tue, 28 Jun 2022 19:17:12 +0000 (15:17 -0400)]
runtime: add race annotations to metricsSema

metricsSema protects the metrics map. The map implementation is race
instrumented regardless of which package is it called from.

semacquire/semrelease are not automatically race instrumented, so we can
trigger race false positives without manually annotating our lock
acquire and release.

See similar instrumentation on trace.shutdownSema and reflectOffs.lock.

Fixes #53542.

Change-Id: Ia3fd239ac860e037d09c7cb9c4ad267391e70705
Reviewed-on: https://go-review.googlesource.com/c/go/+/414517
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
23 months agocrypto/x509: improve RevocationList documentation
Roland Shoemaker [Mon, 27 Jun 2022 23:23:37 +0000 (16:23 -0700)]
crypto/x509: improve RevocationList documentation

Adds documentation for a handful of RevocationList fields.

Updates #50674

Change-Id: I26b838553d870b631deaf8b9a5b4d0b251fdef20
Reviewed-on: https://go-review.googlesource.com/c/go/+/414635
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
23 months agocmd/internal/obj/arm64: fix BITCON constant printing error
eric fang [Sun, 26 Jun 2022 09:39:09 +0000 (09:39 +0000)]
cmd/internal/obj/arm64: fix BITCON constant printing error

For some 32-bit instructions whose first operand is a constant, we
copy the lower 32 bits of the constant into the upper 32 bits in progedit,
which leads to the wrong value being printed in -S output.

The purpose of this is that we don't need to distinguish between 32-bit
and 64-bit constants when checking C_BITCON, this CL puts the modified
value in a temporary variable, so that the constant operand of the
instruction will not be modified.

Fixes #53551

Change-Id: I40ee9223b4187bff1c0a1bab7eb508fcb30325f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/414374
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
23 months agocmd/go: pass --no-decorate when listing git tags for a commit
hidu [Thu, 3 Mar 2022 05:33:38 +0000 (13:33 +0800)]
cmd/go: pass --no-decorate when listing git tags for a commit

This avoids a parse error when the user's global .gitconfig sets
log.decorate to true.

Fixes #51312.

Change-Id: Ic47b0f604c0c3a404ec50d6e09f4e138045ac2f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/387835
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
23 months agoos/exec: on Windows, suppress ErrDot if the implicit path matches the explicit one
Bryan C. Mills [Fri, 24 Jun 2022 19:36:25 +0000 (15:36 -0400)]
os/exec: on Windows, suppress ErrDot if the implicit path matches the explicit one

If the current directory is also listed explicitly in %PATH%,
this changes the behavior of LookPath to prefer the explicit name for it
(and thereby avoid ErrDot).

However, in order to avoid running a different executable from what
would have been run by previous Go versions, we still return the
implicit path (and ErrDot) if it refers to a different file entirely.

Fixes #53536.
Updates #43724.

Change-Id: I7ab01074e21a0e8b07a176e3bc6d3b8cf0c873cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/414054
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/compile: fix generic inter-inter comparisons from value switch statements
Cuong Manh Le [Tue, 28 Jun 2022 17:07:37 +0000 (00:07 +0700)]
cmd/compile: fix generic inter-inter comparisons from value switch statements

If value is a non-empty interface and has shape, we still need to
convert it to an interface{} first.

Fixes #53477

Change-Id: I516063ba4429a6cc24c483758387ec13815fc63e
Reviewed-on: https://go-review.googlesource.com/c/go/+/414834
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

23 months agocmd/go/internal/modfetch: cache latest revinfo in Versions func
Baokun Lee [Sun, 1 May 2022 06:32:02 +0000 (14:32 +0800)]
cmd/go/internal/modfetch: cache latest revinfo in Versions func

The responses have been cached by the web2 package before removed
it in CL 170879. This change add latest revinfo cache in Versions
func.

Fixes #51391

Change-Id: I73597e0a6b4938238e69d85e1cbbaa9007776db3
Reviewed-on: https://go-review.googlesource.com/c/go/+/403335
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Lee Baokun <bk@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
23 months agotest: add more tests for const decls with ommitted RHS expressions
Robert Griesemer [Tue, 28 Jun 2022 17:51:53 +0000 (10:51 -0700)]
test: add more tests for const decls with ommitted RHS expressions

Add analogous tests to go/types and types2 test suites.
Make sure "assert" built-in is available in type-checker
tests.

For #49157.
For #53585.

Change-Id: I092901ecb43eb4833c09bd8f5e38efbe0285babe
Reviewed-on: https://go-review.googlesource.com/c/go/+/414795
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agotest: add test that gofrontend failed to compile
Ian Lance Taylor [Tue, 28 Jun 2022 05:11:38 +0000 (22:11 -0700)]
test: add test that gofrontend failed to compile

For #51475

Change-Id: Ie1b27304687225194a323dc8305e5d62578fff4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/414755
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
23 months agoruntime: clean up unused function gosave on loong64
Guoqi Chen [Mon, 30 May 2022 10:44:57 +0000 (18:44 +0800)]
runtime: clean up unused function gosave on loong64

Change-Id: I28960a33d251a36e5e364fa6e27c5b2e13349f6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/409354
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: David Chase <drchase@google.com>

23 months agocmd/go: omit build metadata that may contain system paths when -trimpath is set
Bryan C. Mills [Fri, 27 May 2022 19:54:44 +0000 (15:54 -0400)]
cmd/go: omit build metadata that may contain system paths when -trimpath is set

CGO flag variables often include system paths for header files and
compiled libraries. The point of -trimpath is to avoid dependending on
system paths, so stamping these variables is counterproductive.

Moreover, the point of stamping build information is to improve
reproducibility. Since we don't also stamp the versions of C
compilers, headers, and libraries used in a cgo build, only the most
trivial cgo programs can be faithfully reproduced from the stamped
information.

Likewise, the -ldflags flag may include system-specific paths,
particularly if external linking is in use. For now, we omit -ldflags
entirely; however, in the future we may instead want to parse and
redact the individual flags.

Fixes #52372.

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

23 months agoapi: correct debug/pe issue number for Go 1.19 changes
Russ Cox [Mon, 27 Jun 2022 21:48:57 +0000 (17:48 -0400)]
api: correct debug/pe issue number for Go 1.19 changes

It was #51868 not #51686.

For #53310.

Change-Id: I2cf28ca4de65e7030fdbd05e7f32fe42c8f3ca0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/414515
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
23 months agocmd/go/internal/modload: fix doc comment
Russ Cox [Thu, 9 Jun 2022 12:51:11 +0000 (08:51 -0400)]
cmd/go/internal/modload: fix doc comment

Change-Id: Ib7f47c7fc2fa5db3adbe51612b1e7a9bb49647b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/411105
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agogo/printer: report allocs and set bytes
Daniel Martí [Wed, 15 Jun 2022 20:19:04 +0000 (21:19 +0100)]
go/printer: report allocs and set bytes

We now get more than just time/op.

name      time/op
Print-16    6.29ms ± 3%

name      speed
Print-16  8.25MB/s ± 3%

name      alloc/op
Print-16     483kB ± 0%

name      allocs/op
Print-16     17.8k ± 0%

Change-Id: I6b5e9a30a826ff8603724bd5983e6b7f5ec12708
Reviewed-on: https://go-review.googlesource.com/c/go/+/412554
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agonet: really skip Windows PTR tests if we say we are skipping them
Ian Lance Taylor [Mon, 27 Jun 2022 21:10:08 +0000 (14:10 -0700)]
net: really skip Windows PTR tests if we say we are skipping them

For #38111

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

23 months agonet: avoid darwin/arm64 platform bug in TestCloseWrite
Bryan C. Mills [Mon, 27 Jun 2022 17:58:55 +0000 (13:58 -0400)]
net: avoid darwin/arm64 platform bug in TestCloseWrite

On darwin_arm64, reading from a socket at the same time as the other
end is closing it will occasionally hang for 60 seconds before
returning ECONNRESET. (This is a macOS issue, not a Go issue.)

Work around this condition by adding a brief sleep before the read.

Fixes #49352 (we hope).
Updates #37795.

Change-Id: I4052aec21d311d7370550aea9dd7941f39141133
Reviewed-on: https://go-review.googlesource.com/c/go/+/414534
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agohtml/template: fix typo in content_test.go
SemihBKGR [Sun, 26 Jun 2022 03:27:08 +0000 (03:27 +0000)]
html/template: fix typo in content_test.go

esacped -> escaped

Change-Id: I253c46b30bb1cf7cdfb4668628907d16428fefb9
GitHub-Last-Rev: accd0e089f35b93c7e26725fcac5c048799db022
GitHub-Pull-Request: golang/go#53553
Reviewed-on: https://go-review.googlesource.com/c/go/+/414274
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@google.com>

23 months agocmd/link: link against libsynchronization.a for -race on windows
Than McIntosh [Fri, 24 Jun 2022 19:31:35 +0000 (15:31 -0400)]
cmd/link: link against libsynchronization.a for -race on windows

As of LLVM rev 41cb504b7c4b18ac15830107431a0c1eec73a6b2, the
race detector runtime now refers to things in the windows
synchronization library, hence when doing windows internal
linking, at that library to the list of host archives that
we visit. The tsan code that makes the reference is here:

https://github.com/llvm/llvm-project/blob/41cb504b7c4b18ac15830107431a0c1eec73a6b2/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp#L48
https://github.com/llvm/llvm-project/blob/41cb504b7c4b18ac15830107431a0c1eec73a6b2/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp#L834

Note that libsynchronization.a is not guaranteed to be available on
all windows systems, so in the external linking case, check for its
existence before adding "-lsynchronization" to the external linker
args.

Updates #53539.

Change-Id: I433c95c869915693d59e9c1082d5b8a11da1fc8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413817
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

23 months agotest: add test that caused gofrontend crash
Ian Lance Taylor [Sun, 26 Jun 2022 22:17:23 +0000 (15:17 -0700)]
test: add test that caused gofrontend crash

For #52871

Change-Id: Id6102222a8b1ec8a84b716425bed0e349c65dbc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/414336
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
23 months agotest: add test that caused gofrontend crash
Ian Lance Taylor [Sat, 25 Jun 2022 00:13:30 +0000 (17:13 -0700)]
test: add test that caused gofrontend crash

The gofrontend crashed importing a complex 0 constant.

For #52862

Change-Id: Ia87d8eadb9c5ddf51e1cd65c1a626f05f0d068d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/413980
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
23 months agocmd/go: compile runtime/internal/syscall as a runtime package
Michael Pratt [Fri, 24 Jun 2022 20:50:59 +0000 (16:50 -0400)]
cmd/go: compile runtime/internal/syscall as a runtime package

runtime/internal/syscall is a runtime package, so it should be built
with -+.

Specifically, we don't want libfuzzer instrumentation in Go functions
defined in runtime/internal/syscall, which is disabled with -+.

For #53190.

Change-Id: I9f16f5c7c7ce10b98371e9de82fcea6da854e163
Reviewed-on: https://go-review.googlesource.com/c/go/+/413818
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocrypto/internal/boring: factor Cache into crypto/internal/boring/bcache
Russ Cox [Wed, 11 May 2022 19:11:29 +0000 (15:11 -0400)]
crypto/internal/boring: factor Cache into crypto/internal/boring/bcache

Requested by the maintainers of the OpenSSL-based fork of Go+BoringCrypto,
to make maintaining that fork easier.

Change-Id: I770e70ecc12b589034da31edecf59c73b2c6e1dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/407135
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

23 months agoruntime: avoid fma in mkfastlog2table
Ian Lance Taylor [Fri, 24 Jun 2022 20:22:02 +0000 (13:22 -0700)]
runtime: avoid fma in mkfastlog2table

This lets us generate identical copies of fastlog2table.go on all hosts.

Tested by regenerating fastlog2table.go on linux-amd64 and darwin-arm64.

Fixes #49891

Change-Id: I279d6b5abb5a5290c049d9658050fd9c8d0c0190
Reviewed-on: https://go-review.googlesource.com/c/go/+/413976
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agotest: add test that gofrontend gets wrong
Ian Lance Taylor [Sat, 25 Jun 2022 22:40:11 +0000 (15:40 -0700)]
test: add test that gofrontend gets wrong

For #52856

Change-Id: Iab3e8352f64d774058391f0422cd01c53c3e711d
Reviewed-on: https://go-review.googlesource.com/c/go/+/414235
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

23 months agocmd/compile: do branch/label checks only once
Robert Griesemer [Sat, 25 Jun 2022 02:11:52 +0000 (19:11 -0700)]
cmd/compile: do branch/label checks only once

The previous change implemented the missing fallthrough checking
in the parser. Therefore we can now disable the duplicate check
in the type checker:

- rename (types2.Config.)IngoreLabels to IgnoreBranches to more
  accurately reflect its functionality

- now also ignore break/continue/fallthroughs, not just labels

The IgnoreBranches flag only exists for types2, for use with
the compiler. There's no need to port this code to go/types.

Note: An alternative (and perhaps better) approach would be
to not use the the parser's CheckBranches mode and instead
enable (i.e. not disable) the branch/label checking in the
type checker. However, this requires a bit more work because
the type checker's error messages about goto's jumping over
variables don't have access to the variable names, which are
desired in the error messages.

Fixes #51456.

Change-Id: Ib2e71e811d4e84e4895b729646e879fd43b12dcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/414135
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
23 months agocmd/compile/internal/syntax: check fallthrough in CheckBranches mode
Robert Griesemer [Fri, 24 Jun 2022 22:55:30 +0000 (15:55 -0700)]
cmd/compile/internal/syntax: check fallthrough in CheckBranches mode

The parser CheckBranches mode checked correct use of break, continue,
and labels, but not of fallthrough statements.

This CL adds checking of fallthrough statements as well.

For #51456.

Change-Id: I5000388011973724f80c59a6aaf015e3bb70faea
Reviewed-on: https://go-review.googlesource.com/c/go/+/414134
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agoruntime: mark string comparison hooks as no split
Khaled Yakdan [Sat, 25 Jun 2022 05:17:45 +0000 (05:17 +0000)]
runtime: mark string comparison hooks as no split

These functions can be inserted by the compiler into the code to be
instrumented. This may result in these functions having callers that
are nosplit. That is why they must be nosplit.

This is a followup for CL 410034 in order to fix #53190.

Change-Id: I03746208a2a302a581a1eaad6c9d0672bb1e949a
GitHub-Last-Rev: 6506d86f221d745de083fad862bba7ba04a80455
GitHub-Pull-Request: golang/go#53544
Reviewed-on: https://go-review.googlesource.com/c/go/+/413978
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

23 months agoio: clarify SeekEnd offset value
HowJMay [Fri, 24 Jun 2022 04:02:10 +0000 (04:02 +0000)]
io: clarify SeekEnd offset value

fixes #53474

Change-Id: I14c3dc800dc27233630a54592328bb0df1bbaa5d
GitHub-Last-Rev: 46f93cfbd41c1b3274b570744f18d08e7759eb1e
GitHub-Pull-Request: golang/go#53505
Reviewed-on: https://go-review.googlesource.com/c/go/+/413614
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agocmd/go: prepend builtin prolog when checking for preamble errors
qmuntal [Thu, 20 Jan 2022 11:46:38 +0000 (12:46 +0100)]
cmd/go: prepend builtin prolog when checking for preamble errors

Fixes #50710

Change-Id: I62feddbe3eaae9605d196bec60d378614436603a
Reviewed-on: https://go-review.googlesource.com/c/go/+/379754
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
23 months agostrconv: avoid panic on invalid call to FormatFloat
Rémy Oudompheng [Fri, 29 Apr 2022 09:54:13 +0000 (11:54 +0200)]
strconv: avoid panic on invalid call to FormatFloat

Calling FormatFloat with an invalid value of fmt is expected
to return a string containing '%' and the input fmt character.
Since even before Go 1.0, the code has been panicking in the
case where prec=0.

Fixes #52187

Change-Id: I74fec601eedb7fe28efc5132c4253674661452aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/402817
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agointernal/trace: add Go 1.19 test data
Rhys Hiltner [Thu, 23 Jun 2022 16:43:47 +0000 (09:43 -0700)]
internal/trace: add Go 1.19 test data

Update instructions to match what seems to be the historical practice:
to generate canned traces when a version is finalized, rather than
waiting until it is superseded.

Follow rename of trace-internal tests from "Span" to "Region". Update
the net/http test invocation to match the apparent intent and the actual
http_1_5_good behavior (about 7ms of total run time and trace file size
under 50kB).

Change-Id: Ifd4c85882159478852e0b8f0d771b6f16b8f3c1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/413776
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
23 months agocmd/internal/archive: don't rely on an erroneous install target in tests
Bryan C. Mills [Fri, 24 Jun 2022 21:02:24 +0000 (17:02 -0400)]
cmd/internal/archive: don't rely on an erroneous install target in tests

Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.
This change switches the 'go install' command to instead use
'go build -buildmode=archive' with an explicit archive path.

For #37015.

Change-Id: Ib0c8f213100b6473a7657af96f31395703e28493
Reviewed-on: https://go-review.googlesource.com/c/go/+/414055
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

23 months agocmd/go: add per-package indexing for modules outside mod cache
Michael Matloob [Thu, 23 Jun 2022 19:46:29 +0000 (15:46 -0400)]
cmd/go: add per-package indexing for modules outside mod cache

Packages outside the module cache including the standard library will be
indexed individually rather than as a whole module.

For #52876

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

23 months agocmd/go/internal/list: update help info with Deprecated field
Sean Liao [Tue, 22 Mar 2022 22:00:22 +0000 (22:00 +0000)]
cmd/go/internal/list: update help info with Deprecated field

Also align Retracted documentation with actual type of []string

Fixes #51876

Change-Id: I3b34e53424aa7ee5330eb71adac23510fff91798
Reviewed-on: https://go-review.googlesource.com/c/go/+/394677
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
23 months agogo/types, types2: print qualified object names in cycle errors
Robert Griesemer [Fri, 24 Jun 2022 00:53:01 +0000 (17:53 -0700)]
go/types, types2: print qualified object names in cycle errors

Fixes #50788.

Change-Id: Id1ed7d9c0687e3005e28598373fd5634178c78ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/413895
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
23 months agogo/types, types2: better errors for == when type sets are empty
Robert Griesemer [Fri, 24 Jun 2022 03:54:52 +0000 (20:54 -0700)]
go/types, types2: better errors for == when type sets are empty

For #51525.

Change-Id: I3762bc4a48a1aaab3b006b1ad1400f866892243c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413934
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
23 months agodoc/go1.19: Linux race detector now requires glibc 2.17
Ian Lance Taylor [Fri, 24 Jun 2022 00:23:39 +0000 (17:23 -0700)]
doc/go1.19: Linux race detector now requires glibc 2.17

Fixes #53522

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

23 months agodebug/dwarf: handle malformed line table with bad program offset
Than McIntosh [Thu, 23 Jun 2022 18:11:59 +0000 (14:11 -0400)]
debug/dwarf: handle malformed line table with bad program offset

Touch up the line table reader to ensure that it can detect and reject
an invalid program offset field in the table header.

Fixes #53329.

Change-Id: Ia8d684e909af3aca3014b4a3d0dfd431e3f5a9f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/413814
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agoembed: document additional file name restrictions
tulip [Tue, 21 Jun 2022 16:42:29 +0000 (00:42 +0800)]
embed: document additional file name restrictions

For #44486

Change-Id: I66af9f7a9f95489a41fd6710e50bdd7878f78b85
Reviewed-on: https://go-review.googlesource.com/c/go/+/413494
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agotest: add test that causes gofrontend crash
Ian Lance Taylor [Wed, 22 Jun 2022 23:02:45 +0000 (16:02 -0700)]
test: add test that causes gofrontend crash

For #52846

Change-Id: I763f81def97b53277396c123c524f7b8193ea35e
Reviewed-on: https://go-review.googlesource.com/c/go/+/413694
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agocmd/compile: don't use dictionary convert to shaped empty interface
Wayne Zuo [Tue, 7 Jun 2022 01:12:21 +0000 (09:12 +0800)]
cmd/compile: don't use dictionary convert to shaped empty interface

Fixes: #53254
Change-Id: I3153d6ebb9f25957b09363f45c5cd4651ee84c2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/410655
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
23 months agocmd/go: make module .zip files group/world readable
Dmitri Goutnik [Sat, 7 May 2022 21:10:16 +0000 (16:10 -0500)]
cmd/go: make module .zip files group/world readable

os.CreateTemp in downloadZip leaves downloaded .zip files readable only
by the owner. Make them group/world readable.

Fixes #52765

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

23 months agocmd/go, cmd/link: support failure to create _cgo_import.go
Ian Lance Taylor [Wed, 22 Jun 2022 01:11:32 +0000 (18:11 -0700)]
cmd/go, cmd/link: support failure to create _cgo_import.go

For a package that uses cgo, the file _cgo_import.go is created to
record information required for internal linking: the non-Go dynamic
symbols and libraries that the package depends on. Generating this
information sometimes fails, because it can require recreating all the
dependencies of all transitively imported packages. And the
information is rarely needed, since by default we use external linking
when there are packages outside of the standard library that use cgo.

With this CL, if generating _cgo_import.go fails, we don't report an
error. Instead, we mark the package as requiring external linking, by
adding an empty file named "dynimportfail" into the generated archive.
If the linker sees a file with that name, it rejects an attempt to use
internal linking.

Fixes #52863

Change-Id: Ie586e6753a5b67e49bb14533cd7603d9defcf0ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/413460
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go: avoid indexing modules in GOROOT
Bryan C. Mills [Wed, 22 Jun 2022 19:19:54 +0000 (15:19 -0400)]
cmd/go: avoid indexing modules in GOROOT

Scanning GOROOT modules for changes appears to be causing Windows
builders to time out in x/tools tests. We may try a per-package index
instead, but for now just skip GOROOT modules (as we do for main
modules).

Fixes #53493.

Change-Id: Ic5bb90b4ce173a24fc6564e85fcde96e1f9b975f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413634
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
23 months agoall: update to current golang.org/x/sys revision
Guoqi Chen [Wed, 15 Jun 2022 11:07:24 +0000 (19:07 +0800)]
all: update to current golang.org/x/sys revision

go get -d golang.org/x/sys@6c1b26c55098eae66ce95ab7c3712ab6cbfff2b7
go mod tidy
go mod vendor

This fixes the problem of the second return value in syscall on linux/loong64.

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

23 months agocmd/compile: fix assert condition in generic method call
Wayne Zuo [Thu, 16 Jun 2022 03:05:39 +0000 (11:05 +0800)]
cmd/compile: fix assert condition in generic method call

Fixes #53406.

Change-Id: If7ae39ec1042a792d82a0a2de96d168c22d8ab71
Reviewed-on: https://go-review.googlesource.com/c/go/+/412614
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
Auto-Submit: Alex Rakoczy <alex@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>

23 months agocompress/gzip: always close bodyReader in Example_compressingReader
Ian Lance Taylor [Fri, 17 Jun 2022 20:38:07 +0000 (13:38 -0700)]
compress/gzip: always close bodyReader in Example_compressingReader

For #53362
Fixes #53414

Change-Id: I352164e70c136eed210c7ee4ceba5dc631f81f94
Reviewed-on: https://go-review.googlesource.com/c/go/+/412955
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agoencoding/xml: check nil pointer in DecodeElement
shaoliming [Fri, 17 Jun 2022 05:01:26 +0000 (05:01 +0000)]
encoding/xml: check nil pointer in DecodeElement

Fixes #53350

Change-Id: Id5e1f4016db5f1d4349ee1a76a9dfe3aeae83cee
GitHub-Last-Rev: 45add121612a8144c2525828bd7386c4adb05174
GitHub-Pull-Request: golang/go#53407
Reviewed-on: https://go-review.googlesource.com/c/go/+/412634
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
23 months agocmd/cgo: dont override declared struct type
kkHAIKE [Wed, 11 May 2022 02:27:21 +0000 (02:27 +0000)]
cmd/cgo: dont override declared struct type

Fixes #52611

Change-Id: I835df8d6a98a37482446ec00af768c96fd8ee4fe
GitHub-Last-Rev: ea54dd69eef90eaf1641889039344fff70158ece
GitHub-Pull-Request: golang/go#52733
Reviewed-on: https://go-review.googlesource.com/c/go/+/404497
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dexter Ouyang <kkhaike@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>