]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
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>

23 months agonet: don't set netGo = true on Windows with no cgo
Ian Lance Taylor [Tue, 21 Jun 2022 22:17:22 +0000 (15:17 -0700)]
net: don't set netGo = true on Windows with no cgo

Windows can call the C DNS lookup routines even without cgo,
so don't force it to use the Go routines in that scenario.

No test because the test requires building the tools with CGO_ENABLED=0.

For #33097
Fixes #53490

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

23 months agocmd/trace: add basic documentation to main page
Alan Donovan [Fri, 17 Jun 2022 14:32:52 +0000 (10:32 -0400)]
cmd/trace: add basic documentation to main page

This change adds rudimentary explanation of the various
visualizations to main page of the trace server.
There is clearly a vast amount one could write here,
especially in the form of tutorials, but I've tried to
restrict it to just basic conceptual overview.

Change-Id: Id4dfe9d47f9b31ed5f8fe39f8b3a7c60c0ae8d5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/412876
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agogo/types, types2: fix parameter order dependence in type inference
Robert Griesemer [Tue, 21 Jun 2022 22:56:16 +0000 (15:56 -0700)]
go/types, types2: fix parameter order dependence in type inference

If we have more than two function arguments to a generic function,
we may have arguments with named and unnamed types. If that is the
case, permutate params and args such that the arguments with named
types are first in the list. This way, independent of parameter
ordering, the type inference will produce the same result.

This extra step is not explicitly outlined in the spec yet but we
all agree that (parameter) order independence is an invariant that
we should uphold for type inference. As we move towards less
operational and more descriptive rules for type inference, we will
incorporate this property as well.

The actual fix for this bug existed before 1.18 but was not enabled.
This CL merely enables the fix (switches a flag) and adjusts some
tests.

Fixes #43056.

Change-Id: Ie4e40cf8438dfd82fa94b78068e4f6f6f53f83e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/413459
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
23 months agospec: document operations which accept []byte|string constrained types
Robert Griesemer [Wed, 15 Jun 2022 01:30:44 +0000 (18:30 -0700)]
spec: document operations which accept []byte|string constrained types

Pre-1.18, as special cases, the built-in operations append and copy
accepted strings as second arguments if the first argument was a byte
slice. With Go 1.18, these two built-ins as well as slice expressions
rely on the notion of core types in their specification.

Because we want to permit slice expressions, append, and copy to
operate on (1st or 2nd operands) that are type parameters restricted
by []byte | string (and variations thereof), the simple notion of
core type is not sufficient for these three operations. (The compiler
already permits such more relaxed operations).

In the section on core types, add a paragraph and examples introducing
the (artificial) core type "bypestring", which describes the core type
of type sets whose underlying types are []byte or string. Adjust the
rules for slice expressions, append, and copy accordingly.

Also (unrelated): Adjust prose in the only paragraph where we used
personal speech ("we") to impersonal speech, to match the rest of
the spec.

Fixes #52859.

Change-Id: I1cbda3095a1136fb99334cc3a62a9a349a27ce1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/412234
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
23 months agoruntime/trace: ignore fallback stacks in test
Rhys Hiltner [Tue, 21 Jun 2022 19:28:48 +0000 (12:28 -0700)]
runtime/trace: ignore fallback stacks in test

When runtime.sigprof encounters a stack that gentraceback is unable to
process, it synthesizes a call stack with a sentinel function (such as
runtime._System) at the leaf.

The test to confirm that runtime/trace and runtime/pprof have similar
views of CPU profile samples has trouble with those stacks. The test
confirms that the samples match by confirming that their symbolized
forms match, and the symbolization procedure is very different for the
two packages.

Skip the samples that the CPU profiler's view symbolizes to include one
of runtime.sigprof's sentinel functions at the leaf. (The test design
expects the CPU profiler to under-report samples relative to the
execution tracer.)

Fixes #53378

Change-Id: I60c27de4c69b454057d28a3b6e12d70369de4c4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413457
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
23 months agodoc/go1.19: use correct link to sync/atomic docs
Ian Lance Taylor [Mon, 20 Jun 2022 05:57:10 +0000 (22:57 -0700)]
doc/go1.19: use correct link to sync/atomic docs

For #51400
Fixes #53453

Change-Id: Ie11182a16299cf26d03970d6aa9bfe03caa56ea4
Reviewed-on: https://go-review.googlesource.com/c/go/+/413235
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@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 agoruntime: convert flaky semaphore linearity test into benchmark
Michael Anthony Knyszek [Fri, 17 Jun 2022 19:56:27 +0000 (19:56 +0000)]
runtime: convert flaky semaphore linearity test into benchmark

Also, add a benchmark for another case that was originally tested.

Also also, remove all the dead code this now creates.

Fixes #53428.

Change-Id: Idbba88d3d31d38a8854fd5ed99001e394da27300
Reviewed-on: https://go-review.googlesource.com/c/go/+/412878
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

23 months agocmd/go/internal/modindex: avoid walking modules when not needed
Bryan C. Mills [Thu, 16 Jun 2022 22:02:11 +0000 (18:02 -0400)]
cmd/go/internal/modindex: avoid walking modules when not needed

Due to a missed condition in CL 412394, we were walking all modules
(instead of just the ones contained in GOROOT) at each invocation of a
devel version of cmd/go.

Moreover, while we were running cmd/go tests, we were re-walking
GOROOT at each 'go' invocation in the test even though we expect
GOROOT to be stable within a test run.

This change always avoids walking non-GOROOT modules, and also adds a
salt (configurable via GODEBUG) and uses it to avoid walking GOROOT
modules when GOROOT is known to be stable (such as over the course of
a 'cmd/go' test run).

This should fix the cmd/go test timeouts that are currently occurring
on the dragonfly-amd64 builder, such as this one:
https://build.golang.org/log/21c01c3ae5490d387d84abeaf872b3a0a76ab8e5

Updates #53290.

Change-Id: Ic807d215831a3cd21c63e0bccd3d7acd10d8f2b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/412779
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
23 months agocmd/compile: allow 128-bit values to be spilled
Keith Randall [Tue, 21 Jun 2022 00:06:09 +0000 (17:06 -0700)]
cmd/compile: allow 128-bit values to be spilled

We sometimes use 16-byte load+store to move values around in memory.
In rare circumstances, the loaded value must be spilled because the
store can't happen yet.

In that case, we need to be able to spill the 16-byte value.

Fixes #53454

Change-Id: I09fd08e11a63c6ba3ef781d3f5ede237e9b0132e
Reviewed-on: https://go-review.googlesource.com/c/go/+/413294
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
23 months agotest: add regress test for #53477
Matthew Dempsky [Tue, 21 Jun 2022 14:15:33 +0000 (07:15 -0700)]
test: add regress test for #53477

This test already passes for GOEXPERIMENT=unified; add regress test to
ensure it stays that way.

Updates #53477.

Change-Id: Ib7aa7428260595077052207899edcc044a6ab1c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/413394
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
23 months agodoc/go1.19: fix HTML validation issues
Tobias Klauser [Mon, 20 Jun 2022 09:42:07 +0000 (11:42 +0200)]
doc/go1.19: fix HTML validation issues

Avoid duplicating tag ID runtime and remove a superflous </dd> tag.

Found by https://validator.w3.org

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

23 months agocmd/compile: skip substituting closures in unsafe builtins arguments
Cuong Manh Le [Thu, 16 Jun 2022 16:04:25 +0000 (23:04 +0700)]
cmd/compile: skip substituting closures in unsafe builtins arguments

For unsafe.{Alignof,Offsetof,Sizeof}, subster will transform them them
to OLITERAL nodes, and discard their arguments. However, any closure in
their children nodes were already processed and added to declaration
queue. Thus, we lack of information for generating instantiation for
the closure.

To fix it, just skip substituting the closures if we are going to edit
the children nodes of unsafe builtins.

Fixes #53390

Change-Id: Ia815cd05af9dc0491f10faac4399f378ac53dec6
Reviewed-on: https://go-review.googlesource.com/c/go/+/412794
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
23 months agotest: add regress test for #53419
Matthew Dempsky [Fri, 17 Jun 2022 22:19:59 +0000 (15:19 -0700)]
test: add regress test for #53419

This currently works with GOEXPERIMENT=unified. Add a regress test to
make sure it stays that way.

Updates #53419.

Change-Id: I2ea1f9039c59807fbd497d69a0420771f8d6d035
Reviewed-on: https://go-review.googlesource.com/c/go/+/413014
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go/internal/modfetch: prevent duplicate hashes in go.sum
Josh Powers [Fri, 17 Jun 2022 18:22:12 +0000 (18:22 +0000)]
cmd/go/internal/modfetch: prevent duplicate hashes in go.sum

To write go.sum, each module and then each hash is looped through. The
hashes are kept in a slice and there is no check to ensure that hashes
were not added or already exist in the file. Therefore, unique the
hashes of each module before writing to prevent duplicates.

Fixes: #28456
Change-Id: I1cf7e7cdee3e7530a0ee605cd76d738627be1e0d
GitHub-Last-Rev: 0ed02e9591e966fe5f6ba275635c3974daa2656e
GitHub-Pull-Request: golang/go#53291
Reviewed-on: https://go-review.googlesource.com/c/go/+/411154
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosync: add more notes about Cond behavior
Kevin Burke [Wed, 15 Jun 2022 04:29:36 +0000 (21:29 -0700)]
sync: add more notes about Cond behavior

Cond is difficult to use correctly (I was just bitten by it in
a production app that I inherited). While several proposals have come
up to improve or remove sync.Cond, no action has so far been taken.

Update the documentation to discourage use of sync.Cond, and point
people in the direction of preferred alternatives. I believe this will
help encourage behavior we want (less use of sync.Cond and more use of
channels), while also paving the way for, potentially, removing Cond
in a future version of the language.

Thanks very much to Bryan Mills and Sean Liao for discussion and
recommendations.

Updates #20491.
Updates #21165.

Change-Id: Ib4d0631c79d4c4d0a30027255cd43bc47cddebd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/412237
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/go/internal/work: log clearer detail for subprocess errors in (*Builder).toolID
Bryan C. Mills [Fri, 17 Jun 2022 16:34:30 +0000 (12:34 -0400)]
cmd/go/internal/work: log clearer detail for subprocess errors in (*Builder).toolID

For #52647.

Change-Id: Ic12123769d339c2df677500ed59f15a4ee5037d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/412954
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet: fix flaky *TimeoutMustNotReturn tests
Dmitri Goutnik [Fri, 17 Jun 2022 17:10:09 +0000 (12:10 -0500)]
net: fix flaky *TimeoutMustNotReturn tests

The tester goroutine doesn't always gets a chance to run before the
timeout expires. Wait for the goroutine to start and set deadlines
before staring the timer.

Fixes #36796

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

2 years agogo/token: delete unused File.set field
Alan Donovan [Wed, 1 Jun 2022 16:54:00 +0000 (12:54 -0400)]
go/token: delete unused File.set field

This field is only used for a sanity check in a test.

Change-Id: I868ed10131ec33994ebb1b1d88f6740956824bd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/409834
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agocmd/dist: add package . to 'go test' commands
Bryan C. Mills [Thu, 16 Jun 2022 19:45:25 +0000 (15:45 -0400)]
cmd/dist: add package . to 'go test' commands

This suppresses verbose output if the test passes,
eliminating some "hello from C" noise for the ../misc/cgo test.

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

2 years agoruntime: write much more direct test for semaphore waiter scalability
Michael Anthony Knyszek [Thu, 16 Jun 2022 20:33:35 +0000 (20:33 +0000)]
runtime: write much more direct test for semaphore waiter scalability

This test originally existed as two tests in test/locklinear.go, but
this checked against actual locks and was flaky. The test was checking
a property of a deep part of the runtime but from a much higher level,
and it's easy for nondeterminism due to scheduling to completely mess
that up, especially on an oversubscribed system.

That test was then moved to the sync package with a more rigorous
testing methodology, but it could still flake pretty easily.

Finally, this CL makes semtable more testable, exports it in
export_test.go, then writes a very direct scalability test for exactly
the situation the original test described. As far as I can tell, this is
much, much more stable, because it's single-threaded and is just
checking exactly the algorithm we need to check.

Don't bother trying to bring in a test that checks for O(log n) behavior
on the other kind of iteration. It'll be perpetually flaky because the
underlying data structure is a treap, so it's only _expected_ to be
O(log n), but it's very easy for it to get unlucky without a large
number of iterations that's too much for a simple test.

Fixes #53381.

Change-Id: Ia1cd2d2b0e36d552d5a8ae137077260a16016602
Reviewed-on: https://go-review.googlesource.com/c/go/+/412875
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agocmd/go: add more tracing
Michael Matloob [Tue, 5 Apr 2022 22:47:23 +0000 (18:47 -0400)]
cmd/go: add more tracing

Change-Id: I26ed64c097533ee9276e598653db72efc053c4e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/403156
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agocmd/go: pass GOEXPERIMENT through to subtests
Russ Cox [Thu, 16 Jun 2022 19:43:57 +0000 (15:43 -0400)]
cmd/go: pass GOEXPERIMENT through to subtests

This fixes:

export GOEXPERIMENT=unified
go install cmd
go install std cmd
go install std cmd
go test -short cmd/go -run=TestScript/test_relative_import_dash_i

That script test checks that runtime is non-stale, but whether it's stale
depends on the setting of GOEXPERIMENT. Stop filtering that variable out.

Change-Id: I71bdbca495c16981cdcddf4ab4d87a38ca72a389
Reviewed-on: https://go-review.googlesource.com/c/go/+/412874
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

2 years agoexpvar: don't crash if map value set to nil
Ian Lance Taylor [Sat, 28 May 2022 14:51:56 +0000 (07:51 -0700)]
expvar: don't crash if map value set to nil

Fixes #52719

Change-Id: Ib032193d00664090c47ae92e7d59674ec2d0165a
Reviewed-on: https://go-review.googlesource.com/c/go/+/408677
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2 years agogo/parser: remove unused method checkBinaryExpr
Robert Griesemer [Thu, 16 Jun 2022 18:10:54 +0000 (11:10 -0700)]
go/parser: remove unused method checkBinaryExpr

Change-Id: Ica981657e50e30cbfa1757e8457819a479f11c7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/412775
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agocmd/go: parallelize matchPackages work in each module
Michael Matloob [Wed, 4 May 2022 21:11:35 +0000 (17:11 -0400)]
cmd/go: parallelize matchPackages work in each module

In each module matchPackages looks in, when doing the walk, do the
scanDir call in a par.Queue so all the read work can be done in
parallel.

Change-Id: I27153dbb3a2ed417ca24972f47134e9e914a55d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/404097
Reviewed-by: 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>
2 years agocmd/link: consider alignment in carrier symbol size calculation
Cherry Mui [Thu, 16 Jun 2022 15:35:40 +0000 (11:35 -0400)]
cmd/link: consider alignment in carrier symbol size calculation

Currently, when we calculate the size of a carrier symbol, we use
the previous symbol's end address as the start. But the symbol
actually starts after applying the alignment. Do this in the
size calculation.

Should fix AIX build.

Updates #53372.

Change-Id: I17942b1fe8027dce12b78c8e8c80ea6cebcee240
Reviewed-on: https://go-review.googlesource.com/c/go/+/412734
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agospec: adjust incorrect sentence in section on rune literals
Robert Griesemer [Wed, 15 Jun 2022 05:08:31 +0000 (22:08 -0700)]
spec: adjust incorrect sentence in section on rune literals

Add an additional example.

Fixes #53217.

Change-Id: I899376b9c1fa8dc5d475d8d3d6c8788ab79b0847
Reviewed-on: https://go-review.googlesource.com/c/go/+/412238
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agotest: add test that gofrontend fails
Ian Lance Taylor [Wed, 15 Jun 2022 22:42:47 +0000 (15:42 -0700)]
test: add test that gofrontend fails

For #52870

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

2 years agointernal/goarch, internal/goos: update generators for syslist.go
Ian Lance Taylor [Wed, 8 Jun 2022 23:33:45 +0000 (16:33 -0700)]
internal/goarch, internal/goos: update generators for syslist.go

Update the generator programs for the changes to syslist.go in CL
390274 and the changes to the generated files in CL 344955.

Tested by running the programs and verifying that the files did not
change.

Fixes #53299

Change-Id: I2b2c5769f7e9283aa05c803256d2ea1eb9ad1547
Reviewed-on: https://go-review.googlesource.com/c/go/+/411334
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoreflect: fix reference comment to runtime/map.go
Koichi Shiraishi [Thu, 26 May 2022 20:49:07 +0000 (05:49 +0900)]
reflect: fix reference comment to runtime/map.go

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

2 years agosyscall: clarify Pdeathsig documentation on Linux
Vojtěch Boček [Wed, 15 Jun 2022 09:36:27 +0000 (09:36 +0000)]
syscall: clarify Pdeathsig documentation on Linux

This is a rather large footgun, so let's mention that it sends the signal on thread termination and not process termination in the documentation.

Updates #27505

Change-Id: I489cf7136e34a1a7896067ae24187b0d523d987e
GitHub-Last-Rev: c8722b25d1fb8b0b3696257ec7e955eb421f15a6
GitHub-Pull-Request: golang/go#53365
Reviewed-on: https://go-review.googlesource.com/c/go/+/412114
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agogo/types, types2: add test case for issue for coverage
Robert Griesemer [Wed, 15 Jun 2022 02:01:04 +0000 (19:01 -0700)]
go/types, types2: add test case for issue for coverage

The specific error doesn't occur anymore.
Add a test to prevent regressions.

For #50729.

Change-Id: Ibf6ef6009b3d226b4f345b5a5657939915f19633
Reviewed-on: https://go-review.googlesource.com/c/go/+/412235
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agodoc/go1.19: use matching closing tag in unix build constraint heading
Tobias Klauser [Wed, 15 Jun 2022 12:40:13 +0000 (14:40 +0200)]
doc/go1.19: use matching closing tag in unix build constraint heading

Change-Id: Idb990eac60e334a5901b2d6cdc2380225d011dd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/412294
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agosyscall, runtime/internal/syscall: always zero the higher bits of return value on...
Guoqi Chen [Fri, 10 Jun 2022 11:08:14 +0000 (19:08 +0800)]
syscall, runtime/internal/syscall: always zero the higher bits of return value on linux/loong64

All loong64 syscalls return values only via R4/A0, and R5/A1 may contain unrelated
content. Always zero the second return value.

Change-Id: I62af59369bece5bd8028b937c74f4694150f7a55
Reviewed-on: https://go-review.googlesource.com/c/go/+/411615
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2 years agonet/netip: add missing ) in ParsePrefix errors
subham sarkar [Wed, 8 Jun 2022 09:38:33 +0000 (15:08 +0530)]
net/netip: add missing ) in ParsePrefix errors

The existing error messages didn't add right parenthesis ')' properly
leading to improper formation of error messages.

Fixes #53283

Change-Id: Iadf9b8059403efa07e39716a81fab68cd10b7f87
Reviewed-on: https://go-review.googlesource.com/c/go/+/411015
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agocmd/link: set alignment for carrier symbols
Cherry Mui [Tue, 14 Jun 2022 20:47:57 +0000 (16:47 -0400)]
cmd/link: set alignment for carrier symbols

For carrier symbols like type.*, currently we don't set its
alignment. Normally it doesn't actually matter as we still align
the inner symbols. But in some cases it does make the symbol table
a bit weird, e.g. on darwin/arm64,

0000000000070000 s _runtime.types
0000000000070001 s _type.*

The address of the symbol _type.* is a bit weird. And the new
darwin linker from Xcode 14 beta doesn't like that (see issue
53372).

This CL aligns them.

Fixes #53372.

Change-Id: I1cb19dcf172e9a6bca248d85a7e54da76cbbc8a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/411912
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go/internal/modindex: disable indexing for modules outside GOROOT and the module...
Bryan C. Mills [Wed, 15 Jun 2022 15:50:27 +0000 (11:50 -0400)]
cmd/go/internal/modindex: disable indexing for modules outside GOROOT and the module cache

Since CL 410821 we were indexing these modules with a cache key based
on the mtimes of the files within the module. However, that seems to
be causing test failures (#53269 and maybe #53371).

In addition, indexing these modules caused a potentially-expensive
operation (re-indexing a whole module) whenever any individual file
within the module is changed, even if it isn't relevant to the
package(s) being loaded from that module. In some cases, that could
cause a significant performance regression for 'go' commands invoked
on a small subset of the packages in the module (such as running 'go
test' on a single changed package — a common case during development).

Instead, we now index only those modules found within the module cache
and within GOROOT.

In addition, we now check mtimes when indexing GOROOT modules if the
Go version begins with the string "devel ", which indicates a
non-released Go version that may include local file edits within GOROOT.

For #53371.
For #53269.

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

2 years agotest: add tests for string/[]byte/[]rune conversions
Robert Griesemer [Tue, 14 Jun 2022 05:15:25 +0000 (22:15 -0700)]
test: add tests for string/[]byte/[]rune conversions

Matches examples in spec section on string conversions.

For #23814.

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

2 years agonet: avoid infinite recursion in Windows Resolver.lookupTXT
Ian Lance Taylor [Tue, 14 Jun 2022 22:53:59 +0000 (15:53 -0700)]
net: avoid infinite recursion in Windows Resolver.lookupTXT

For #33097

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

2 years agospec: clarify "slice of bytes" and "slice of runes" through examples
Robert Griesemer [Tue, 14 Jun 2022 01:44:44 +0000 (18:44 -0700)]
spec: clarify "slice of bytes" and "slice of runes" through examples

The spec section on conversions uses the terms "slice of bytes" and
"slice of runes". While not obviously clear, what is meant are slice
types whose element types are byte or rune types; specifically the
underlying types of the slices' element types must be byte or rune.

Some of this was evident from the examples, but not all of it. Made
this clearer by adding more examples illustrating various permitted
conversions.

Note that the 1.17 compiler did not accept the following conversions:

        string([]myByte{...})
        string([]myRune{...})
        myString([]myByte{...})
        myString([]myRune{...})

(where myByte, myRune, and myString have underlying types of byte,
rune, and string respectively) - it reported an internal error.
But it did accept the inverse conversions:

        []myByte("...")
        []myRune("...")
        []myByte(myString("..."))
        []myRune(myString("..."))

The 1.18 compiler made those conversions symmetric and they are now
permitted in both directions.

The extra examples reflect this reality.

Fixes #23814.

Change-Id: I5a1c200b45ddd0e8c0dc0d11da3a6c39cb2dc848
Reviewed-on: https://go-review.googlesource.com/c/go/+/412094
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoreflect: when StructOf overflows computing size/offset, panic
Keith Randall [Tue, 14 Jun 2022 21:38:56 +0000 (14:38 -0700)]
reflect: when StructOf overflows computing size/offset, panic

Fixes #52740

Change-Id: I849e585deb77cfcfc1b517be4a171eb29b30c5f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/412214
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 years agocmd/compile,runtime,reflect: move embedded bit from offset to name
Keith Randall [Tue, 14 Jun 2022 20:38:02 +0000 (13:38 -0700)]
cmd/compile,runtime,reflect: move embedded bit from offset to name

Previously we stole a bit from the field offset to encode whether
a struct field was embedded.

Instead, encode that bit in the name field, where we already have
some unused bits to play with. The bit associates naturally with
the name in any case.

This leaves a full uintptr to specify field offsets. This will make
the fix for #52740 cleaner.

Change-Id: I0bfb85564dc26e8c18101bc8b432f332176d7836
Reviewed-on: https://go-review.googlesource.com/c/go/+/412138
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agocmd/go: quote package directory when calling glob
Ian Lance Taylor [Fri, 10 Jun 2022 22:46:43 +0000 (15:46 -0700)]
cmd/go: quote package directory when calling glob

Fixes #53314

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

2 years agocpu: fix typos in test case
ag9920 [Tue, 14 Jun 2022 02:09:10 +0000 (02:09 +0000)]
cpu: fix typos in test case

Change-Id: Id6a27d0b3f3fc4181a00569bacc578e72b04ce09
GitHub-Last-Rev: 85c063d1a2d62181d16044592a60acf970fe3c86
GitHub-Pull-Request: golang/go#53359
Reviewed-on: https://go-review.googlesource.com/c/go/+/411916
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Zhang <binbin36520@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

2 years agoruntime: add HACKING section on nosplit functions
Austin Clements [Mon, 18 Apr 2022 17:20:54 +0000 (13:20 -0400)]
runtime: add HACKING section on nosplit functions

Change-Id: I247874d5c49d2c0d8db2a3d227aa848093551d9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/401759
Reviewed-by: Michael Pratt <mpratt@google.com>