]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
10 months agotest: add test cases for index value with range array clear
Cuong Manh Le [Fri, 7 Jul 2023 02:21:58 +0000 (09:21 +0700)]
test: add test cases for index value with range array clear

Updates #61127

Change-Id: I5fb032c990b64bb4f455a7c0345cfb556bf263bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/508335
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

10 months agocmd/compile: fix clear on slice with zero size elem
Cuong Manh Le [Sat, 1 Jul 2023 00:01:11 +0000 (07:01 +0700)]
cmd/compile: fix clear on slice with zero size elem

Fixed #61127

Change-Id: If07b04ebcc98438c66f273c0c94bea1f230dc2e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/507535
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

10 months agocmd/compile: don't ICE on unaligned offsets for pointer writes
Keith Randall [Sat, 8 Jul 2023 15:46:37 +0000 (08:46 -0700)]
cmd/compile: don't ICE on unaligned offsets for pointer writes

User code is unlikely to be correct, but don't crash the compiler
when the offset of a pointer in an object is not a multiple of the
pointer size.

Fixes #61187

Change-Id: Ie56bfcb38556c5dd6f702ae4ec1d4534c6acd420
Reviewed-on: https://go-review.googlesource.com/c/go/+/508555
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>
10 months agoos: support reading empty root directories on Windows
qmuntal [Tue, 4 Jul 2023 11:39:41 +0000 (13:39 +0200)]
os: support reading empty root directories on Windows

GetFileInformationByHandleEx can return `ERROR_FILE_NOT_FOUND` when no
files were found in a root directory, as per MS-FSA 2.1.5.6.3 [1].

This error code should not be treated as an error, but rather as an
indication that no files were found, in which case `readdir` should
return an empty slice.

This CL doesn't add any test as it is difficult to trigger this error
code. Empty root directories created using Windows utilities such as
`net use` always report at least the optional `.` and `..` entries.
A reproducer is provided in #61159, but it requires WinFSP to be
installed.

Fixes #61159

[1] https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/fa8194e0-53ec-413b-8315-e8fa85396fd8

Change-Id: Id46452030f5355c292e5b0abbf5e22af434a84d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/507775
Reviewed-by: Nick Craig-Wood <nickcw@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agosrc/database/sql: run gofmt
Than McIntosh [Fri, 7 Jul 2023 20:33:39 +0000 (16:33 -0400)]
src/database/sql: run gofmt

Run gofmt on a source file.

Change-Id: I180d5cc7425fc5d8e9cf63005ac692f361beb1ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/508497
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agogo/types, types2: do not mutate arguments in NewChecker
Robert Findley [Fri, 7 Jul 2023 15:20:16 +0000 (11:20 -0400)]
go/types, types2: do not mutate arguments in NewChecker

CL 507975 resulted in new data races (as reported in #61212), because
the pkg argument to NewChecker was mutated.

Fix this by deferring the recording of the goVersion in pkg until type
checking is actually initiated via a call to Checker.Files.
Additionally, modify types2/check.go to bring it in sync with the
changes in go/types/check.go, and generate the new version_test.go from
the types2 file.

Also move parsing the version into checkFiles, for simplicity.

Fixes #61212

Change-Id: I15edb6c2cff3085622fe7c6a3b0dab531d27bd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/508439
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
10 months agomath: add test that covers riscv64 fnm{add,sub} codegen
Michael Munday [Wed, 28 Jun 2023 22:12:33 +0000 (23:12 +0100)]
math: add test that covers riscv64 fnm{add,sub} codegen

Adds a test that triggers the RISC-V fused multiply-add code
generation bug fixed by CL 506575.

Change-Id: Ia3a55a68b48c5cc6beac4e5235975dea31f3faf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/507035
Auto-Submit: M Zhuo <mzh@golangcn.org>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
10 months agolog/slog: handle recursively empty groups
Jonathan Amsterdam [Thu, 6 Jul 2023 16:30:39 +0000 (12:30 -0400)]
log/slog: handle recursively empty groups

Handlers should not display empty groups.

A group with no attributes is certainly empty. But we also want to
consider a group to be empty if all its attributes are empty groups.
The built-in handlers did not handle this second case properly.
This CL fixes that.

There are two places in the implementation that we need to consider.

For Values of KindGroup, we change the GroupValue constructor to omit
Attrs that are empty groups. A Group is then empty if and only if it
has no Attrs. This avoids a recursive check for emptiness.
It does require allocation, but that doesn't worry us because Group
values should be relatively rare.

For groups established by WithGroup, we avoid opening such groups
unless the Record contains non-empty groups. As we did for values, we
avoid adding empty groups to records in the first place, so we only
need to check that the record has at least one Attr.

We are doing extra work, so we need to make sure we aren't slowing
things down unduly. Benchmarks before and after this change show
minimal differences.

Fixes #61067.

Change-Id: I684c7ca834bbf69210516faecae04ee548846fb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/508436
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoos: do not skip directory entries with zero inodes on wasip1
Achille Roussel [Wed, 5 Jul 2023 01:15:58 +0000 (18:15 -0700)]
os: do not skip directory entries with zero inodes on wasip1

When building programs to GOOS=wasip1, the program does not have the
guarantees that the underlying directories will come from a file system
where a zero inode value indicates that the entry was deleted but not
yet removed from the directory. The host runtime may be running on
windows or may be exposing virtual user-space file systems that do not
have the concept of inodes. In those setup, we assume that the host
runtime is in charge of dealing with edge cases such as skipping
directory entries with zero inodes when needed, and the guest
application should trust the list of entries that it sees;
therefore, we disable skipping over zero inodes on wasip1.

Change-Id: I99aa562441cdb4182965f270af054cf3cf7f8f20
Reviewed-on: https://go-review.googlesource.com/c/go/+/507915
Reviewed-by: Ian Lance Taylor <iant@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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
10 months agoruntime: print output on failure in TestMemPprof
Cherry Mui [Wed, 5 Jul 2023 20:03:55 +0000 (16:03 -0400)]
runtime: print output on failure in TestMemPprof

If running testprog fails, print the output.

For #60901.

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

10 months agonet: only build cgo_stub.go on unix or wasip1
Ian Lance Taylor [Mon, 3 Jul 2023 12:05:55 +0000 (05:05 -0700)]
net: only build cgo_stub.go on unix or wasip1

We were building it for Windows, although Windows code never calls
any of these functions. When using -tags netgo that cause a multiple
definition of cgoAvailable.

Fixes #61153

Change-Id: Ib9e1de7720a8c0dacd6f12002917bf305dfa5405
Reviewed-on: https://go-review.googlesource.com/c/go/+/507655
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
10 months agocmd/go: pass GoVersion in vet config
Russ Cox [Wed, 5 Jul 2023 16:12:35 +0000 (12:12 -0400)]
cmd/go: pass GoVersion in vet config

When invoking a vet tool with -vettool (or vet itself),
we need to pass the package's GoVersion to use when
analyzing the package.

The test of this behavior is in the x/tools/go/analysis CL 507880.

For #61176.

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

10 months agogo/types: record Config.GoVersion for reporting in Package.GoVersion method
Russ Cox [Wed, 5 Jul 2023 16:08:51 +0000 (12:08 -0400)]
go/types: record Config.GoVersion for reporting in Package.GoVersion method

Clients of go/types, such as analyzers, may need to know which
specific Go version a package is written for. Record that information
in the Package and expose it using the new GoVersion method.

Update parseGoVersion to handle the new Go versions that may
be passed around starting in Go 1.21.0: versions like "go1.21.0"
and "go1.21rc2". This is not strictly necessary today, but it adds some
valuable future-proofing.

While we are here, change NewChecker from panicking on invalid
version to saving an error for returning later from Files.
Go versions are now likely to be coming from a variety of sources,
not just hard-coded in calls to NewChecker, making a panic
inappropriate.

For #61174.
Fixes #61175.

Change-Id: Ibe41fe207c1b6e71064b1fe448ac55776089c541
Reviewed-on: https://go-review.googlesource.com/c/go/+/507975
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
10 months agolog/slog: fix faulty test
Merrick Clay [Wed, 5 Jul 2023 21:06:39 +0000 (15:06 -0600)]
log/slog: fix faulty test

Adds an optional close quote in the expected log message regex for TestConnections to prevent failing when the source filepath is surrounded in quotes due to it containing one or more spaces.

Fixes #61161

Change-Id: I0dd71fb4389bff963bbfdc668ef4e4dfe787eafc
Reviewed-on: https://go-review.googlesource.com/c/go/+/508055
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: fix FMA negative commutativity of riscv64
Meng Zhuo [Tue, 27 Jun 2023 15:22:04 +0000 (23:22 +0800)]
cmd/compile: fix FMA negative commutativity of riscv64

According to RISCV manual 11.6:

FMADD x,y,z computes x*y+z and
FNMADD x,y,z => -x*y-z
FMSUB x,y,z => x*y-z
FNMSUB x,y,z => -x*y+z respectively

However our implement of SSA convert FMADD -x,y,z to FNMADD x,y,z which
is wrong and should be convert to FNMSUB according to manual.

Change-Id: Ib297bc83824e121fd7dda171ed56ea9694a4e575
Reviewed-on: https://go-review.googlesource.com/c/go/+/506575
Run-TryBot: M Zhuo <mzh@golangcn.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agomath: fix portable FMA when x*y < 0 and x*y == -z
Michael Munday [Fri, 30 Jun 2023 23:01:26 +0000 (00:01 +0100)]
math: fix portable FMA when x*y < 0 and x*y == -z

When x*y == -z the portable implementation of FMA copied the sign
bit from x*y into the result. This meant that when x*y == -z and
x*y < 0 the result was -0 which is incorrect.

Fixes #61130.

Change-Id: Ib93a568b7bdb9031e2aedfa1bdfa9bddde90851d
Reviewed-on: https://go-review.googlesource.com/c/go/+/507376
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
10 months agodatabase/sql: prevent internal context error from being returned from Rows.Err()
zikaeroh [Fri, 23 Jun 2023 00:09:21 +0000 (17:09 -0700)]
database/sql: prevent internal context error from being returned from Rows.Err()

CL 497675 modified Rows such that context errors are propagated through
Rows.Err(). This caused an issue where calling Close meant that an
internal cancellation error would (eventually) be returned from Err:

1. A caller makes a query using a cancellable context.
2. initContextClose sees that either the query context or the
   transaction context can be canceled, so will need to spawn a
   goroutine to capture their errors.
3. initContextClose derives a context from the query context via
   WithCancel and sets rs.cancel.
4. When a user calls Close, rs.cancel is called. awaitDone's ctx is
   cancelled, which is good, since we don't want it to hang forever.
5. This internal cancellation (after CL 497675) has its error saved on
   contextDone.
6. Later, calling Err will return the error in contextDone if present.

This leads to a race condition depending on how quickly Err is called
after Close.

The docs for Close and Err state that calling Close should have no
affect on the return result for Err. So, a potential fix is to ensure
that awaitDone does not save the error when the cancellation comes from
a Close via rs.cancel.

This CL does that, using a new context not derived from the query
context, whose error is ignored as the query context's error used to be
before the original bugfix.

The included test fails before the CL, and passes afterward.

Fixes #60932

Change-Id: I2bf4c549efd83d62b86e298c9c45ebd06a3ad89a
Reviewed-on: https://go-review.googlesource.com/c/go/+/505397
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 months agoruntime,runtime/metrics: clarify OS stack metrics
Michael Anthony Knyszek [Fri, 9 Jun 2023 19:14:55 +0000 (19:14 +0000)]
runtime,runtime/metrics: clarify OS stack metrics

There are some subtle details here about measuring OS stacks in cgo
programs. There's also an expectation about magnitude in the MemStats
docs that isn't in the runtime/metrics docs. Fix both.

Fixes #54396.

Change-Id: I6b60a62a4a304e6688e7ab4d511d66193fc25321
Reviewed-on: https://go-review.googlesource.com/c/go/+/502156
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
10 months agoruntime: have ReadMemStats do a nil check before switching stacks
Keith Randall [Mon, 3 Jul 2023 20:16:59 +0000 (13:16 -0700)]
runtime: have ReadMemStats do a nil check before switching stacks

This gives the user a better stack trace experience. No need to
expose them to runtime.systemstack and friends.

Fixes #61158

Change-Id: I4f423f82e54b062773067c0ae64622e37cb3948b
Reviewed-on: https://go-review.googlesource.com/c/go/+/507755
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
10 months agoos, syscall: update unreachable link about =C: envs
Oleksandr Redko [Thu, 29 Jun 2023 13:06:19 +0000 (16:06 +0300)]
os, syscall: update unreachable link about =C: envs

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

10 months agotest/codegen: enable Mul2 DivPow2 test for riscv64
Meng Zhuo [Sun, 25 Jun 2023 03:20:35 +0000 (11:20 +0800)]
test/codegen: enable Mul2 DivPow2 test for riscv64

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

11 months agoruntime: check GOFLAGS not GCFLAGS
Michael Pratt [Fri, 30 Jun 2023 18:32:39 +0000 (14:32 -0400)]
runtime: check GOFLAGS not GCFLAGS

GCFLAGS doesn't have any defined meaning. cmd/dist enables
mayMoreStackPreempt with GOFLAGS.

For #55160.

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

11 months agonet: enable pure Go resolver for wasip1
Chris O'Hara [Sat, 3 Jun 2023 01:51:02 +0000 (11:51 +1000)]
net: enable pure Go resolver for wasip1

Top-level functions in the net package that only read files,
for example LookupPort(...), or LookupIP(host) where host resides
in /etc/hosts, now work on wasip1.

If the application has the ability to create sockets (for example,
when using a sockets extension to WASI preview 1), it's now
possible to do name resolution by passing a custom Dial function
to a Resolver instance.

Change-Id: I923886f67e336820bc89f09ea1855387c8dac61a
Reviewed-on: https://go-review.googlesource.com/c/go/+/500579
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: Randy Reddig <ydnar@shaderlab.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
11 months agosyscall: stub Getrlimit on wasip1
Chris O'Hara [Sat, 3 Jun 2023 01:49:48 +0000 (11:49 +1000)]
syscall: stub Getrlimit on wasip1

This is a prerequisite to enabling the pure Go resolver for
wasip1.

Change-Id: Iecd8a18ce4c9eb69a697d29930bedb7175b4f0ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/500577
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/asm/internal/lex: fix comment, remove the first "has"
Jes Cok [Thu, 29 Jun 2023 14:17:00 +0000 (14:17 +0000)]
cmd/asm/internal/lex: fix comment, remove the first "has"

Change-Id: I429f0fa6c99ef576fe83c7bd0d1c1e176ecbb179
GitHub-Last-Rev: fb581b7f271f026182de0737c4fe5c360d5dea96
GitHub-Pull-Request: golang/go#61066
Reviewed-on: https://go-review.googlesource.com/c/go/+/507097
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

11 months agocmd/compile/internal/types2: make TestIssue43124 match the go/types version
Robert Griesemer [Thu, 29 Jun 2023 16:48:52 +0000 (09:48 -0700)]
cmd/compile/internal/types2: make TestIssue43124 match the go/types version

Replace the (flaky) types2.TestIssue43124 with the code of the
(stable) go/types version of this test.

While at it, replace a handful of syntax.Pos{} with the equivalent
nopos, to further reduce differences between the two versions of
the issues_test.go file.

For #61064.

Change-Id: I69f3e4627a48c9928e335d67736cb875ba3835fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/507215
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

11 months agonet/http: validate Host header before sending
Damien Neil [Wed, 28 Jun 2023 20:20:08 +0000 (13:20 -0700)]
net/http: validate Host header before sending

Verify that the Host header we send is valid.
Avoids surprising behavior such as a Host of "go.dev\r\nX-Evil:oops"
adding an X-Evil header to HTTP/1 requests.

Add a test, skip the test for HTTP/2. HTTP/2 is not vulnerable to
header injection in the way HTTP/1 is, but x/net/http2 doesn't validate
the header and will go into a retry loop when the server rejects it.
CL 506995 adds the necessary validation to x/net/http2.

For #60374

Change-Id: I05cb6866a9bead043101954dfded199258c6dd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/506996
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>

11 months agocmd/{go,compile}: run gofmt
Than McIntosh [Thu, 29 Jun 2023 15:44:04 +0000 (11:44 -0400)]
cmd/{go,compile}: run gofmt

Ran gofmt on a couple of Go source files that needed it.

Change-Id: I0e9f78831f531a728b892a63c6e0c517d92b11a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/507156
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agoruntime: run wasip1 tests with wazero
Chris O'Hara [Wed, 14 Jun 2023 02:16:38 +0000 (12:16 +1000)]
runtime: run wasip1 tests with wazero

The latest wazero release supports non-blocking I/O and pre-opened
sockets. Unmask the relevant wasip1 tests so that there are multiple
WebAssembly runtimes exercising these code paths.

Change-Id: I8506ab35186f98fde2cd3ce84634d5fcb7b053f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/503595
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
11 months agoslices, maps: add examples; doc comment fixes
Ben Hoyt [Thu, 22 Jun 2023 12:35:45 +0000 (00:35 +1200)]
slices, maps: add examples; doc comment fixes

There are currently no examples in the new slices and maps package, so
add some. This adds examples for most functions in the slices package
except the very obvious ones, and adds examples for the DeleteFunc and
EqualFunc functions in the maps package.

Also clarify/correct a few doc comments:

* EqualFunc takes an "equality" function, not a "comparison" function
* It's confusing for Delete and DeleteFunc to say they "do not create a
  new slice", as they do return a new slice. They already say they
  "return the modified slice" which is enough.
* Similar for Compact, and mention that it returns the modified slice
  (and say why)
* Note that CompactFunc keeps the first element in equal runs
* Say what cmp is in SortStableFunc and IsSortedFunc
* Say that MinFunc and MaxFunc return the first value

Change-Id: I59c7bb1c7cabc4986d81018a5aaf5b712d3310f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/505095
Reviewed-by: Carlos Amedee <carlos@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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agointernal/bytealg: fix alignment code in equal_riscv64.s
Mark Ryan [Fri, 2 Jun 2023 11:13:29 +0000 (13:13 +0200)]
internal/bytealg: fix alignment code in equal_riscv64.s

The riscv64 implementation of equal has an optimization that is
applied when both pointers share the same alignment but that alignment
is not 8 bytes.  In this case it tries to align both pointers to an 8 byte boundaries,
by individually comparing the first few bytes of each buffer.  Unfortunately,
the existing code is incorrect.  It adjusts the pointers by the wrong number
of bytes resulting, in most cases, in pointers that are not 8 byte aligned.

This commit fixes the issue by individually comparing the first
(8 - (pointer & 7)) bytes of each buffer rather than the first
(pointer & 7) bytes.

This particular optimization is not covered by any of the existing
benchmarks so a new benchmark, BenchmarkEqualBothUnaligned,
is provided.  The benchmark tests the case where both pointers have
the same alignment but may not be 8 byte aligned.  Results of the
new benchmark along with some of the existing benchmarks generated on
a SiFive HiFive Unmatched A00 with 16GB of RAM running Ubuntu 23.04
are presented below.

Equal/0-4                                 3.356n ± 0%    3.357n ± 0%        ~ (p=0.840 n=10)
Equal/1-4                                 63.91n ± 7%    65.97n ± 5%   +3.22% (p=0.029 n=10)
Equal/6-4                                 72.94n ± 5%    76.09n ± 4%        ~ (p=0.075 n=10)
Equal/9-4                                 84.61n ± 7%    85.83n ± 3%        ~ (p=0.315 n=10)
Equal/15-4                                103.7n ± 2%    102.9n ± 4%        ~ (p=0.739 n=10)
Equal/16-4                                89.14n ± 3%   100.40n ± 4%  +12.64% (p=0.000 n=10)
Equal/20-4                                107.8n ± 3%    106.8n ± 3%        ~ (p=0.725 n=10)
Equal/32-4                                63.95n ± 8%    67.79n ± 7%        ~ (p=0.089 n=10)
Equal/4K-4                                1.256µ ± 1%    1.254µ ± 0%        ~ (p=0.925 n=10)
Equal/4M-4                                1.231m ± 0%    1.230m ± 0%   -0.04% (p=0.011 n=10)
Equal/64M-4                               19.77m ± 0%    19.78m ± 0%        ~ (p=0.052 n=10)
EqualBothUnaligned/64_0-4                 43.70n ± 4%    44.40n ± 5%        ~ (p=0.529 n=10)
EqualBothUnaligned/64_1-4                6957.5n ± 0%    105.9n ± 1%  -98.48% (p=0.000 n=10)
EqualBothUnaligned/64_4-4                 100.1n ± 2%    101.5n ± 4%        ~ (p=0.149 n=10)
EqualBothUnaligned/64_7-4               6965.00n ± 0%    95.60n ± 4%  -98.63% (p=0.000 n=10)
EqualBothUnaligned/4096_0-4               1.233µ ± 1%    1.225µ ± 0%   -0.65% (p=0.015 n=10)
EqualBothUnaligned/4096_1-4             584.226µ ± 0%    1.277µ ± 0%  -99.78% (p=0.000 n=10)
EqualBothUnaligned/4096_4-4               1.270µ ± 1%    1.268µ ± 0%        ~ (p=0.105 n=10)
EqualBothUnaligned/4096_7-4             584.944µ ± 0%    1.266µ ± 1%  -99.78% (p=0.000 n=10)
EqualBothUnaligned/4194304_0-4            1.241m ± 0%    1.236m ± 0%   -0.38% (p=0.035 n=10)
EqualBothUnaligned/4194304_1-4          600.956m ± 0%    1.238m ± 0%  -99.79% (p=0.000 n=10)
EqualBothUnaligned/4194304_4-4            1.239m ± 0%    1.241m ± 0%   +0.22% (p=0.007 n=10)
EqualBothUnaligned/4194304_7-4          601.036m ± 0%    1.239m ± 0%  -99.79% (p=0.000 n=10)
EqualBothUnaligned/67108864_0-4           19.79m ± 0%    19.78m ± 0%        ~ (p=0.393 n=10)
EqualBothUnaligned/67108864_1-4         9616.61m ± 0%    19.82m ± 0%  -99.79% (p=0.000 n=10)
EqualBothUnaligned/67108864_4-4           19.82m ± 0%    19.82m ± 0%        ~ (p=0.971 n=10)
EqualBothUnaligned/67108864_7-4         9616.34m ± 0%    19.86m ± 0%  -99.79% (p=0.000 n=10)
geomean                                   38.38µ         7.194µ       -81.26%

Change-Id: I4caab6c3450bd7e2773426b08b70bbc37fbe4e5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/500855
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
11 months agocmd/compile: handle min/max correctly in mayCall
Cuong Manh Le [Wed, 28 Jun 2023 16:15:35 +0000 (23:15 +0700)]
cmd/compile: handle min/max correctly in mayCall

CL 500575 changed mayCall to return "false" for min/max builtin.

However, with string or float, min/max requires runtime call, so mayCall
should return true instead. This's probably not a big problem, because
CL 506115 makes order pass handle min/max correctly. But it's still
better to do it the right way.

Updates #60582

Change-Id: I9779ca62bebd0f95e52ad5fa55b9160dc35b33aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/506855
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/compile/internal/ssagen: fix min/max codegen, again
Matthew Dempsky [Tue, 27 Jun 2023 23:51:24 +0000 (16:51 -0700)]
cmd/compile/internal/ssagen: fix min/max codegen, again

The large-function phi placement algorithm evidently doesn't like the
same pseudo-variable being used to represent expressions of varying
types.

Instead, use the same tactic as used for "valVar" (ssa.go:6585--6587),
which is to just generate a fresh marker node each time.

Maybe we could just use the OMIN/OMAX nodes themselves as the key
(like we do for OANDAND/OOROR), but that just seems needlessly risky
for negligible memory savings. Using fresh marker values each time
seems obviously safe by comparison.

Fixes #61041.

Change-Id: Ie2600c9c37b599c2e26ae01f5f8a433025d7fd08
Reviewed-on: https://go-review.googlesource.com/c/go/+/506679
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
11 months agocmd/go: enable slog vet check during 'go test'
Russ Cox [Sat, 24 Jun 2023 15:00:37 +0000 (11:00 -0400)]
cmd/go: enable slog vet check during 'go test'

The slog check is new and no existing code uses slog (it's new too),
so there are no concerns about false positives in existing code.
Enable it by default.

Change-Id: I4fc1480eeb5a3acc9e5e095e9d5428f5ce04b121
Reviewed-on: https://go-review.googlesource.com/c/go/+/505915
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/dist, internal/abi: support bootstrapping with gccgo
Ian Lance Taylor [Wed, 21 Jun 2023 22:27:20 +0000 (15:27 -0700)]
cmd/dist, internal/abi: support bootstrapping with gccgo

The required gc bootstrap compiler, 1.17, has an internal/lazyregexp
package. It permits that package to be imported by internal/profile
while bootstrapping. The gccgo compiler also has an internal/lazyregexp
package, but it does not permit the gc compiler to import it.

Permit bootstrapping with gccgo by adding internal/lazyregexp to the
list of bootstrap directories.

The gccgo compiler recognizes the magic functions internal/abi.FuncPCABI0
and FuncPCABIInternal, but only in the internal/abi package, not
in the bootstrapping internal/abi package.

Permit bootstrapping with gccgo by adding definitions of those functions
with build tags so that they are only used by gccgo.

Fixes #60913

Change-Id: I3a78848d545db13314409d170d63f4cc737ca12e
Reviewed-on: https://go-review.googlesource.com/c/go/+/505036
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@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>

11 months agoruntime: fix trace.Stop deadlock when built with faketime
Hiro [Wed, 21 Jun 2023 23:33:51 +0000 (23:33 +0000)]
runtime: fix trace.Stop deadlock when built with faketime

For #60806

Change-Id: I1ac18a6c7c703a1d6c4cd80f220059ba0be51e09
GitHub-Last-Rev: d300ca3f316d34f5013be43d01a9a473fe3000b2
GitHub-Pull-Request: golang/go#60834
Reviewed-on: https://go-review.googlesource.com/c/go/+/503356
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/compile: fix bad order of evaluation for min/max builtin
Cuong Manh Le [Mon, 26 Jun 2023 04:30:48 +0000 (11:30 +0700)]
cmd/compile: fix bad order of evaluation for min/max builtin

For float or string, min/max builtin performs a runtime call, so we need
to save its result to temporary variable. Otherwise, the runtime call
will clobber closure's arguments currently on the stack when passing
min/max as argument to closures.

Fixes #60990

Change-Id: I1397800f815ec7853182868678d0f760b22afff2
Reviewed-on: https://go-review.googlesource.com/c/go/+/506115
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
11 months agoencoding: document that base32 and base64 do not use UTF-8
Joe Tsai [Thu, 22 Jun 2023 18:10:18 +0000 (11:10 -0700)]
encoding: document that base32 and base64 do not use UTF-8

The invention of base32 and base64 predates the invention of UTF-8
and was never meant to output valid UTF-8.
By default, the output is always valid ASCII (and thus valid UTF-8)
except when the user specifies an alphabet or padding value
that is larger than '\x7f'. If that is done,
then the exact byte symbol is used rather than the UTF-8 encoding.

Fixes #60689

Change-Id: I4ec88d974ec0658ad1a578bbd65a809e27c73ea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/505237
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agosyscall: clarify which handles are affected by SysProcAttr.NoInheritHandles
qmuntal [Fri, 23 Jun 2023 10:44:15 +0000 (12:44 +0200)]
syscall: clarify which handles are affected by SysProcAttr.NoInheritHandles

SysProcAttr.NoInheritHandles doc comment is not clear about which
handles are affected by it. This CL clarifies that it not only affects
the ones passed in AdditionalInheritedHandles, but also the ones
passed in ProcAttr.Files, which are required to be stderr, stdin and
stdout when calling syscall.StartProcess.

Updates #60942

Change-Id: I5bc5b3604b6db04b83f6764d5c5ffbdafeeb22fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/505515
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agosyscall: try non-blocking stdio on wasip1
Chris O'Hara [Thu, 25 May 2023 02:07:48 +0000 (12:07 +1000)]
syscall: try non-blocking stdio on wasip1

Try to set stdio to non-blocking mode before the os package
calls NewFile for each fd. NewFile queries the non-blocking flag
but doesn't change it, even if the runtime supports non-blocking
stdio. Since WebAssembly modules are single-threaded, blocking
system calls temporarily halt execution of the module. If the
runtime supports non-blocking stdio, the Go runtime is able to
use the WASI net poller to poll for read/write readiness and is
able to schedule goroutines while waiting.

Change-Id: I1e3ce68a414e3c5960ce6a27fbfd38556e59c3dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/498196
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agogo/types, types2: replace TODO with clarifying comment
Robert Griesemer [Mon, 26 Jun 2023 20:52:37 +0000 (13:52 -0700)]
go/types, types2: replace TODO with clarifying comment

This resolves an open question.
No non-comment code changes.

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

11 months agoslices: add godoc links
Tobias Klauser [Mon, 26 Jun 2023 08:56:55 +0000 (10:56 +0200)]
slices: add godoc links

Change-Id: I79d2bab2275f123636b63e87533ae9dad69ee00f
Reviewed-on: https://go-review.googlesource.com/c/go/+/506135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agogo/types, types2: fix interface unification
Robert Griesemer [Thu, 22 Jun 2023 23:40:46 +0000 (16:40 -0700)]
go/types, types2: fix interface unification

When unification of two types succeeds and at least one of them
is an interface, we must be more cautious about when to accept
the unification, to avoid order dependencies and unexpected
inference results.

The changes are localized and only affect matching against
interfaces; they further restrict what are valid unifications
(rather than allowing more code to pass). We may be able to
remove some of the restriotions in a future release.

See comments in code for a detailed description of the changes.

Also, factored out "asInterface" functionality into a function
to avoid needless repetition in the code.

Fixes #60933.
Fixes #60946.

Change-Id: I923f7a7c1a22e0f4fd29e441e016e7154429fc5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/505396
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
11 months agotypes2, go/types: record final type for min/max arguments
Cuong Manh Le [Sun, 25 Jun 2023 15:59:33 +0000 (22:59 +0700)]
types2, go/types: record final type for min/max arguments

Fixes #60991

Change-Id: I6130ccecbdc209996dbb376491be9df3b8988327
Reviewed-on: https://go-review.googlesource.com/c/go/+/506055
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agogo/types, types2: more readable inference trace
Robert Griesemer [Thu, 22 Jun 2023 23:07:29 +0000 (16:07 -0700)]
go/types, types2: more readable inference trace

Print the unification mode in human-readable form.
Use a tab and // instead of ()'s to show unification mode
and whether operands where swapped.

These changes only affect inference trace output, which is
disabled by default. For easier debugging.

For #60933.

Change-Id: I95299c6e09b90670fc45addc4f9196b6cdd3b59f
Reviewed-on: https://go-review.googlesource.com/c/go/+/505395
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
11 months agodoc/go1.21: document changes in crypto/x509
Kota [Mon, 26 Jun 2023 13:33:42 +0000 (13:33 +0000)]
doc/go1.21: document changes in crypto/x509

RevocationList.RevokedCertificates has been deprecated and
replaced with the new RevocationList.RevokedCertificateEntries field,
not RevocationList.Entries.

Change-Id: I36053e0d67a9997264483d1e04e31774fbab8702
GitHub-Last-Rev: a9f6949b05d73e3ed7a7ca8c83e4df1310954db6
GitHub-Pull-Request: golang/go#60984
Reviewed-on: https://go-review.googlesource.com/c/go/+/505935
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>

11 months agodoc/go1.21: context.Background and TODO may now appear equal
Ian Lance Taylor [Fri, 23 Jun 2023 20:23:01 +0000 (13:23 -0700)]
doc/go1.21: context.Background and TODO may now appear equal

Fixes #60978

Change-Id: I3e4bd366dc30ac435698b8f17170695330034683
Reviewed-on: https://go-review.googlesource.com/c/go/+/505795
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agocmd/compile: fix min/max builtin code generation
Keith Randall [Fri, 23 Jun 2023 22:29:36 +0000 (15:29 -0700)]
cmd/compile: fix min/max builtin code generation

Our large-function phi placement algorithm is incompatible with phi
opcodes already existing in the SSA representation. Instead, use simple
variable assignments and have the phi placement algorithm place the phis
we need for min/max.

Turns out the small-function phi placement algorithm doesn't have this
sensitivity, so this bug only occurs in large functions (>500 basic blocks).

Maybe we should document/check that no phis are present when we start
phi placement (regardless of size).  Leaving for a potential separate CL.

We should probably also fix the placement algorithm to handle existing
phis correctly.  But this CL is probably a lot smaller/safer than
messing with phi placement.

Fixes #60982

Change-Id: I59ba7f506c72b22bc1485099a335d96315ebef67
Reviewed-on: https://go-review.googlesource.com/c/go/+/505756
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
11 months agoslices: clarify MinFunc/MaxFunc result for equal elements
Ian Lance Taylor [Fri, 23 Jun 2023 21:23:31 +0000 (14:23 -0700)]
slices: clarify MinFunc/MaxFunc result for equal elements

They should return the first of equal elements. No such clarification
is required for Min/Max as for them equal elements are indistinguishable.

For #60091

Change-Id: Iad58115d482add852c811e993131702b5b3bec5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/505796
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Eli Bendersky <eliben@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>

11 months agocrypto/x509: rename duplicated test
Roland Shoemaker [Fri, 23 Jun 2023 19:07:19 +0000 (12:07 -0700)]
crypto/x509: rename duplicated test

Rename the old TestPlatformVerifier to TestPlatformVerifierLegacy, and
add TODO about removing it once the synthetic root is widely deployed on
builders.

Updates #52108

Change-Id: I6cdba268e4738804c7f76ea18c354470b3e0318c
Reviewed-on: https://go-review.googlesource.com/c/go/+/505755
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
11 months agoruntime: set raceignore to zero when starting a new goroutine
Jelle van den Hooff [Thu, 22 Jun 2023 01:28:05 +0000 (18:28 -0700)]
runtime: set raceignore to zero when starting a new goroutine

When reusing a g struct the runtime did not reset
g.raceignore. Initialize raceignore to zero when initially
setting racectx.

A goroutine can end with a non-zero raceignore if it exits
after calling runtime.RaceDisable without a matching
runtime.RaceEnable. If that goroutine's g is later reused
the race detector is in a weird state: the underlying
g.racectx is active, yet g.raceignore is non-zero, and
raceacquire/racerelease which check g.raceignore become
no-ops. This causes the race detector to report races when
there are none.

Fixes #60934

Change-Id: Ib8e412f11badbaf69a480f03740da70891f4093f
Reviewed-on: https://go-review.googlesource.com/c/go/+/505055
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

11 months agocrypto: document non-determinism of GenerateKey
Filippo Valsorda [Thu, 22 Jun 2023 15:57:22 +0000 (17:57 +0200)]
crypto: document non-determinism of GenerateKey

Fixes #58637

Change-Id: I9eb3905d5b35ea22e22e1d8eb8c33594eac487fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/505155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

11 months agocmd/compile: scanning closures body when visiting wrapper function
Cuong Manh Le [Thu, 22 Jun 2023 18:04:29 +0000 (01:04 +0700)]
cmd/compile: scanning closures body when visiting wrapper function

CL 410344 fixed missing method value wrapper, by visiting body of
wrapper function after applying inlining pass.

CL 492017 allow more inlining of functions that construct closures,
which ends up making the wrapper function now inlineable, but can
contain closure nodes that couldn't be inlined. These closures body may
contain OMETHVALUE nodes that we never seen, thus we need to scan
closures body for finding them.

Fixes #60945

Change-Id: Ia1e31420bb172ff87d7321d2da2989ef23e6ebb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/505255
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

11 months agolog/slog: fix broken link to AnyValue in comment
Cuong Manh Le [Fri, 23 Jun 2023 11:52:31 +0000 (18:52 +0700)]
log/slog: fix broken link to AnyValue in comment

Change-Id: Ida52a2bf6a415017942bf9ccd74a1ea9ed02bc46
Reviewed-on: https://go-review.googlesource.com/c/go/+/505535
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

11 months agolog/slog: fix broken link to Record.Clone in package docs
Christopher Taylor [Thu, 22 Jun 2023 07:32:37 +0000 (07:32 +0000)]
log/slog: fix broken link to Record.Clone in package docs

Change-Id: If8b937fa9db89a537ad7d4ccb8c04f84d2cff3db
GitHub-Last-Rev: fdd4338118e6e19a0a3673f364afcdb0b60236a4
GitHub-Pull-Request: golang/go#60938
Reviewed-on: https://go-review.googlesource.com/c/go/+/505075
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
11 months agocmd/go: impersonate 'go tool dist list' if 'go tool dist' is not present
Bryan C. Mills [Thu, 22 Jun 2023 15:56:55 +0000 (11:56 -0400)]
cmd/go: impersonate 'go tool dist list' if 'go tool dist' is not present

Fixes #60939.

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

11 months agointernal/platform,cmd/dist: export the list of supported platforms
Bryan C. Mills [Thu, 22 Jun 2023 15:04:45 +0000 (11:04 -0400)]
internal/platform,cmd/dist: export the list of supported platforms

Also switch internal/platform to commit the generated code instead of
regenerating it in cmd/dist. Nothing in the generated code depends on
the target configuration, and committing the source file makes it
more amenable to searching and indexing (particularly on
https://cs.opensource.google/go/go).

For #60939.

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

11 months agocmd/{go,cover}: enable response file args for cmd/cover
Than McIntosh [Thu, 15 Jun 2023 13:14:03 +0000 (09:14 -0400)]
cmd/{go,cover}: enable response file args for cmd/cover

Change the cover command to accept arguments via response files, using
the same mechanism employed for the compiler and the assembler. This
is needed now that the cover tool accepts a list of all source files
in a package, as opposed to just a single source file, and as a result
can run into system-dependent command line length limits.

Fixes #60785.

Change-Id: I67dbc96ad9fc5c6f43d5c1e4e903e4b8589b154f
Reviewed-on: https://go-review.googlesource.com/c/go/+/503735
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

11 months agointernal/fuzz: fix typo in comment
Oleksandr Redko [Thu, 22 Jun 2023 13:33:06 +0000 (16:33 +0300)]
internal/fuzz: fix typo in comment

Change-Id: I04f0aa2730cd7d60027a36a3b81289e4972d4a9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/505115
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocrypto/x509: tolerate multiple matching chains in testVerify
Roland Shoemaker [Wed, 21 Jun 2023 21:43:05 +0000 (14:43 -0700)]
crypto/x509: tolerate multiple matching chains in testVerify

Due to the semantics of roots, a root store may contain two valid roots
that have the same subject (but different SPKIs) at the asme time. As
such in testVerify it is possible that when we verify a certificate we
may get two chains that has the same stringified representation.

Rather than doing something fancy to include keys (which is just overly
complicated), tolerate multiple matches.

Fixes #60925

Change-Id: I5f51f7635801762865a536bcb20ec75f217a36ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/505035
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agonet/mail: permit more characters in mail headers
Ian Lance Taylor [Mon, 19 Jun 2023 22:35:50 +0000 (15:35 -0700)]
net/mail: permit more characters in mail headers

We parse mail messages using net/textproto. For #53188, we tightened
up the bytes permitted by net/textproto to match RFC 7230.
However, this package uses RFC 5322 which is more permissive.
Restore the permisiveness we used to have, so that older code
continues to work.

Fixes #58862
Fixes #60332

Change-Id: I5437f5e18a756f6ca61c13c4d8ba727be73eff9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/504416
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

11 months agotest: add test that caused a gofrontend crash
Ian Lance Taylor [Wed, 21 Jun 2023 20:52:42 +0000 (13:52 -0700)]
test: add test that caused a gofrontend crash

Change-Id: Idd872c5b90dbca564ed8a37bb3683e642142ae63
Reviewed-on: https://go-review.googlesource.com/c/go/+/505015
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

11 months agodoc/go1.21: correct GOOS to GOARCH (another location)
Ian Lance Taylor [Wed, 21 Jun 2023 20:21:00 +0000 (13:21 -0700)]
doc/go1.21: correct GOOS to GOARCH (another location)

Change-Id: Ie71bc41bd7f1aecf6ce69a8b310668fdd03da42b
Reviewed-on: https://go-review.googlesource.com/c/go/+/504880
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rhys Hiltner <rhys@justin.tv>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
11 months agodoc/go1.21: correct GOOS to GOARCH
Ian Lance Taylor [Wed, 21 Jun 2023 19:44:48 +0000 (12:44 -0700)]
doc/go1.21: correct GOOS to GOARCH

For #57752
Fixes #60924

Change-Id: Ie1e16c041885abb51dd6c2f0b7dfa03091cfb338
Reviewed-on: https://go-review.googlesource.com/c/go/+/504879
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

11 months agogo/types, types2: avoid spurious "declared and not used" error
Robert Griesemer [Wed, 21 Jun 2023 18:14:34 +0000 (11:14 -0700)]
go/types, types2: avoid spurious "declared and not used" error

Fixes #60906.

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

11 months agoruntime: relate GODEBUG=gctrace output to runtime/metrics
Michael Anthony Knyszek [Fri, 16 Jun 2023 18:28:22 +0000 (18:28 +0000)]
runtime: relate GODEBUG=gctrace output to runtime/metrics

There's more I could list here, but the mapping becomes more complicated
and more fragile. I think this is sufficient to start with.

Fixes #46846.

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

11 months agocmd/go: shorten longest 5 tests
Russ Cox [Tue, 20 Jun 2023 14:58:26 +0000 (10:58 -0400)]
cmd/go: shorten longest 5 tests

Running go test -parallel=1 -v, these are the top 10 tests:

PASS: TestScript/mod_invalid_version 40.14s
PASS: TestScript/build_cache_output 46.82s
PASS: TestScript/get_legacy 48.69s
PASS: TestTestCache 58.44s
PASS: TestScript/mod_get_direct 62.88s
PASS: TestScript/build_pgo_auto_multi 63.49s
PASS: TestScript/build_pgo_auto 70.69s
PASS: TestScript/gcflags_patterns 95.17s
PASS: TestScript/mod_list_compiled_concurrent 124.31s
PASS: TestScript/vet_flags 202.85s

Change the top 5 not to run builds at all, so they don't
have to use -a or clear the go build cache.

mod_get_direct should be replaced with a vcs-test test.
mod_invalid_version should be replaced with a vcs-test test.
get_legacy should be deleted eventually.

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

11 months agocmd/compile/internal/ir: typo
cuiweixie [Tue, 20 Jun 2023 05:58:56 +0000 (13:58 +0800)]
cmd/compile/internal/ir: typo

n.TypeCheck() == 3 is never true now, in n.SetTypecheck(x), when x > 2,
it panic.

Change-Id: Ic876680435d4536eb63dcedee20a07ccdf918b91
Reviewed-on: https://go-review.googlesource.com/c/go/+/504435
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

11 months agolog/slog: fix HandlerOptions.ReplaceAttr doc
Jonathan Amsterdam [Tue, 20 Jun 2023 12:55:49 +0000 (08:55 -0400)]
log/slog: fix HandlerOptions.ReplaceAttr doc

It said that Attrs with an empty key are ignored.
In fact, zero Attrs are ignored.

Fixes #60870.

Change-Id: I221d3a25b0f0cc9001e06e9cc76bab29292c0741
Reviewed-on: https://go-review.googlesource.com/c/go/+/504535
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agoencoding/binary: on invalid type return -1 from Size
Ian Lance Taylor [Tue, 20 Jun 2023 16:38:39 +0000 (09:38 -0700)]
encoding/binary: on invalid type return -1 from Size

Size is defined as returning -1 if the type is not fixed-size.
Before this CL cases like Size((*[]int)(nil)) would crash.

Fixes #60892

Change-Id: Iee8e20a0aee24b542b78cb4160c3b2c5a3eb02c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/504575
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
11 months agocmd/go: add comment for intentional misspelling
Ian Lance Taylor [Mon, 12 Jun 2023 22:57:00 +0000 (15:57 -0700)]
cmd/go: add comment for intentional misspelling

Try to avoid fixes from automatic spell checkers.

Change-Id: I1d134fb2721decffa865a3f4d78bca4fce8e8fee
Reviewed-on: https://go-review.googlesource.com/c/go/+/502658
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@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>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

11 months agocmd/go: do not index std as a module in modcache
Russ Cox [Fri, 16 Jun 2023 20:30:52 +0000 (16:30 -0400)]
cmd/go: do not index std as a module in modcache

We do not index std as a whole module ever.

When working in the main Go repo, files in package change often,
so we don't want to pay the cost of reindexing all of std when what
we really need is just to reindex strings. Per-package indexing
works better for that case.

When using a released Go toolchain, we don't have to worry about
the whole module changing, but if we switch to whole-module indexing
at that point, we have the potential for bugs that only happen in
released toolchains. Probably not worth the risk.

For similar reasons, we don't index the current work module as
a whole module (individual packages are changing), so we use the heuristic
that we only do whole-module indexing in the module cache.

The new toolchain modules live in the module cache, though, and
our heuristic was causing whole-module indexing for them.
As predicted, enabling whole-module indexing for std when it's
completely untested does in fact lead to bugs (a very minor one).

This CL turns off whole-module indexing for std even when it is
in the module cache, to bring toolchain module behavior back in
line with the other ways to run toolchains.

For #57001.

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

11 months agocmd/go: restore go.mod files during toolchain selection
Russ Cox [Fri, 16 Jun 2023 19:59:43 +0000 (15:59 -0400)]
cmd/go: restore go.mod files during toolchain selection

They have to be renamed to _go.mod to make a valid module.
Copy them back to go.mod so that 'go test cmd' has a better
chance of working.

For #57001.

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

11 months agocmd/distpack: rename go.mod to _go.mod in toolchain modules
Russ Cox [Fri, 16 Jun 2023 17:04:50 +0000 (13:04 -0400)]
cmd/distpack: rename go.mod to _go.mod in toolchain modules

Modules cannot contain go.mod files except at the root
(and we don't keep one at the root). Rename the other go.mod
files to _go.mod.

dl2mod, which we used to convert all the old releases,
did this renaming, but it was missed when porting that
code to distpack.

For #57001.
Fixes #60847.

Change-Id: I4d646b96b5be15df3b79193e254ddc9b11cc8734
Reviewed-on: https://go-review.googlesource.com/c/go/+/503979
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
11 months agocmd/go: disable sumdb less often for toolchain downloads
Russ Cox [Fri, 16 Jun 2023 17:08:23 +0000 (13:08 -0400)]
cmd/go: disable sumdb less often for toolchain downloads

There is a chicken and egg problem with always requiring
the checksum database for toolchain module downloads, since the
checksum database populates its entry by doing its own module
download.

Don't require the checksum database for GOPROXY=file:/// (for local testing)
and when running on the Go module mirror.

For #60847.

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

11 months agointernal/bisect: add 'q' hash option for quiet hash behavior switching
David Chase [Thu, 15 Jun 2023 17:56:02 +0000 (13:56 -0400)]
internal/bisect: add 'q' hash option for quiet hash behavior switching

This is intended for the specific case of 'fmahash=qn' where someone
wants to disable fma without all the hash-search-handshake output.
There are cases where arm64, ppc64, and s390x users might want to do
this.

Change-Id: Iaf46c68a00d7c9f7f82fd98a4548b72610f84bed
Reviewed-on: https://go-review.googlesource.com/c/go/+/503776
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agoruntime/trace: add godoc links
Olivier Mengué [Mon, 19 Jun 2023 17:17:46 +0000 (19:17 +0200)]
runtime/trace: add godoc links

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

11 months agocmd/go/internal/modfetch: fix retractions slice initial length not zero
James Yang [Tue, 23 May 2023 02:52:55 +0000 (02:52 +0000)]
cmd/go/internal/modfetch: fix retractions slice initial length not zero

When make slice of retractions, it should have initial length zero, to append more VersionIntervals.

Currently without the zero length, the capacity used will be doubled after the appending, looks like a bug.

Change-Id: Id3acaeffe557ca1d15c864b0377a66fee3a41f6c
GitHub-Last-Rev: ed5fd5f6784c43195c531d8acc75560adff104ba
GitHub-Pull-Request: golang/go#60354
Reviewed-on: https://go-review.googlesource.com/c/go/+/497118
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
11 months agoos/exec: document a method to check if a process is alive
Moritz Poldrack [Fri, 16 Jun 2023 21:12:25 +0000 (21:12 +0000)]
os/exec: document a method to check if a process is alive

Fixes #34396

Change-Id: I35c4e3447f84e349adf7edba92ccb19b324bfe14
GitHub-Last-Rev: 4f06764109ddd9bdfbe4841fc1bebebe026eeb29
GitHub-Pull-Request: golang/go#60763
Reviewed-on: https://go-review.googlesource.com/c/go/+/502815
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

11 months agocmd/internal/moddeps: allow the "misc" module to be missing from GOROOT
Bryan C. Mills [Fri, 16 Jun 2023 19:58:03 +0000 (15:58 -0400)]
cmd/internal/moddeps: allow the "misc" module to be missing from GOROOT

cmd/distpack deletes that module from its distribution.

For #24904.

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

11 months agocmd/compile/internal/syntax: skip GOROOT/misc in TestStdLib if it doesn't exist
Bryan C. Mills [Fri, 16 Jun 2023 19:56:37 +0000 (15:56 -0400)]
cmd/compile/internal/syntax: skip GOROOT/misc in TestStdLib if it doesn't exist

cmd/distpack deletes GOROOT/misc from its distribution.

For #24904.

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

11 months agocmd/internal/testdir: skip Test if GOROOT/test does not exist
Bryan C. Mills [Fri, 16 Jun 2023 19:45:13 +0000 (15:45 -0400)]
cmd/internal/testdir: skip Test if GOROOT/test does not exist

cmd/distpack removes GOROOT/test from its distribution.

For #24904.

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

11 months agogo/types: skip tests that require GOROOT/test if it is not present
Bryan C. Mills [Fri, 16 Jun 2023 19:24:56 +0000 (15:24 -0400)]
go/types: skip tests that require GOROOT/test if it is not present

cmd/distpack removes GOROOT/test from its archive of the distribution.

For #24904.

Change-Id: Ifde441f048f8af52f8973555b196ab0520b48ab7
Reviewed-on: https://go-review.googlesource.com/c/go/+/504057
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agogo/internal/gcimporter: skip TestImportTypeparamTests if GOROOT/test is missing
Bryan C. Mills [Fri, 16 Jun 2023 19:15:25 +0000 (15:15 -0400)]
go/internal/gcimporter: skip TestImportTypeparamTests if GOROOT/test is missing

cmd/distpack removes GOROOT/test, so skip the test if it isn't there.

For #24904.

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

11 months agocmd/go/internal/test: don't wait for previous test actions when interrupted
Bryan C. Mills [Thu, 15 Jun 2023 21:41:37 +0000 (17:41 -0400)]
cmd/go/internal/test: don't wait for previous test actions when interrupted

Fixes #60203.

Change-Id: I59a3320ede1eb3cf4443d7ea37b8cb39d01f222a
Reviewed-on: https://go-review.googlesource.com/c/go/+/503936
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agopath/filepath: avoid assuming that GOROOT/test is present
Bryan C. Mills [Fri, 16 Jun 2023 18:46:37 +0000 (14:46 -0400)]
path/filepath: avoid assuming that GOROOT/test is present

GOROOT/test is pruned out by cmd/distpack. It isn't really needed for
the test anyway; the test can instead use the "src/unicode" subdirectory,
which is even within the same module.

This test was previously adjusted in CL 13467045 and CL 31859.

Unlike in previous iterations of the test, the directories used in
this revision are covered by the Go 1 compatibility policy and thus
unlikely to disappear.

For #24904.

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

11 months agocmd/cgo/internal/testshared: disable gccgo tests on PPC64
Paul E. Murphy [Fri, 16 Jun 2023 17:20:41 +0000 (12:20 -0500)]
cmd/cgo/internal/testshared: disable gccgo tests on PPC64

Disable PPC64 gccgo tests until issue #60798 is fixed in gcc.

Change-Id: I4d330e3d0ab6d4174ee6d8ff2cbedf53c8c4e3d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/504095
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
11 months agocmd/cgo/internal/testshared: strip newline from gccgo -dumpversion
Paul E. Murphy [Wed, 14 Jun 2023 20:20:11 +0000 (15:20 -0500)]
cmd/cgo/internal/testshared: strip newline from gccgo -dumpversion

Otherwise, gccgo tests may be quietly skipped.

For #60798

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

11 months agocompress/bzip2: fix typo
Jes Cok [Thu, 15 Jun 2023 09:50:03 +0000 (09:50 +0000)]
compress/bzip2: fix typo

Remove redundant "this".

Change-Id: Ia845e44119bf5ba1862f62da335466219a37c325
GitHub-Last-Rev: f0cdaf03285da8b053b71cc2911f5ab5beff580b
GitHub-Pull-Request: golang/go#60807
Reviewed-on: https://go-review.googlesource.com/c/go/+/503655
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@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>

11 months agonet/http: check RemoteAddr isn't nil before dereferencing
Al Cutter [Thu, 15 Jun 2023 15:23:12 +0000 (15:23 +0000)]
net/http: check RemoteAddr isn't nil before dereferencing

RemoteAddr can return nil in some cases, this fix prevents a panic.

I chatted with @neild about this beforehand, but what's happening in our
case is that a connection comes in to the HTTP server which is then
immediately closed (we discovered this issue by accident using nmap).
The network implementation that we're using (it happens to be gVisor
via its gonet adaptor) is returning nil from RemoteAddr(), presumably
as there is no remote at that point.

But, ultimately, since RemoteAddr returns an interface it is always
possible for it to return nil, and indeed conn.RemoteAddr in this file
does exactly that if the conn is not ok.

Change-Id: Ibe67ae6e30b68e2776df5ee2911bf5f1dc539641
GitHub-Last-Rev: ff3505d1d0b00ca16c68ec2a05f542978b79b170
GitHub-Pull-Request: golang/go#60823
Reviewed-on: https://go-review.googlesource.com/c/go/+/503656
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agonet/http: close req.Body only when it's non-nil on js
Dmitri Shuralyov [Thu, 15 Jun 2023 05:39:04 +0000 (01:39 -0400)]
net/http: close req.Body only when it's non-nil on js

The main change here is fixing the panic where it was called even when
req.Body was nil. It might also work better to keep the req.Body.Close
calls closer after req.Body is read, so do that too.

Calling readableStreamPull.Release on a js.Func with a zero value
is currently a no-op, but it seems better to avoid it anyway.

Also remove readableStreamStart, readableStreamCancel while here.
They were used in the initial but not final patch set of CL 458395.

Fixes #60809.

Change-Id: I6ff2e3b6ec2cd4b0c9c67939903e32908312db8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/503676
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agotesting/fstest: fix the Glob test when dir entries are out of order
Achille Roussel [Wed, 14 Jun 2023 04:39:54 +0000 (21:39 -0700)]
testing/fstest: fix the Glob test when dir entries are out of order

This change adds a test highlighting an issue with the fstest.TestFS
test suite which occurred when the fs.FS implementation would expose
directories returning unordered directory entries from their ReadDir
method.

--- FAIL: TestShuffledFS (0.00s)
    testfs_test.go:76: testing fs.Sub(fsys, tmp): TestFS found errors:
        .: Glob(`*e*`): wrong output:
        extra: one
        missing: one

The issue came from having the wrong variable passed to the checkGlob
method. There are two variables named list and list2, the latter is
sorted, and the checkGlob method expects a sorted list but was passed
list instead of list2.

Change-Id: I5e49dccf14077e7d1fee51687eb6a5eeb0330c16
Reviewed-on: https://go-review.googlesource.com/c/go/+/503175
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@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>

11 months agoreflect: fix ArenaNew to match documentation
Michael Anthony Knyszek [Thu, 8 Jun 2023 18:40:31 +0000 (18:40 +0000)]
reflect: fix ArenaNew to match documentation

Currently ArenaNew expects the type passed in to be a *T and it returns
a *T. This does not match the function's documentation.

Since this is an experiment, change ArenaNew to match the documentation.
This more closely aligns ArenaNew with arena.New. (Takes a type T,
returns a *T value.)

Note that this is a breaking change. However, as far as pkg.go.dev can
tell, there's exactly one package using it in the open source world.

Also, add smoke test for the exported API, which is just a wrapper
around the internal API. Clearly there's enough room for error here that
it should be tested, but we don't need thorough tests at this layer
because that already exists in the runtime. We just need to make sure it
basically works.

Fixes #60528.

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

11 months agocmd/distpack: make go_$GOOS_$GOARCH_exec programs executable
Dmitri Shuralyov [Fri, 16 Jun 2023 13:03:11 +0000 (09:03 -0400)]
cmd/distpack: make go_$GOOS_$GOARCH_exec programs executable

The go command recognizes when a program named go_$GOOS_$GOARCH_exec
is in PATH. There are two such programs living in GOROOT/misc/wasm.
Like GOROOT/bin/{go,gofmt} and GOROOT/pkg/tool/**, these programs
need to have the executable bit set to do their job, so set it.

Comparing a distpack produced before and after this change shows that
the pack.go file is modified, the two go_{js,wasip1}_wasm_exec programs
have the new file mode, and there are no other changes, as expected.

The mode change is relevant to the binary and source distributions only.
No change to the module zip since it doesn't include GOROOT/misc at all,
so no effect on previously created toolchain modules whose checksums
are already recorded in the Go checksum database and cannot be changed.
(Other than by changing their "v0.0.1" version, but that's expensive.)

Fixes #60843.

Change-Id: I799b6aacff59c0785cb7743cbd17dda5a9ef91be
Reviewed-on: https://go-review.googlesource.com/c/go/+/503975
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

11 months agoruntime: use 1-byte load for address checking in racecallatomic
Cherry Mui [Thu, 15 Jun 2023 22:16:51 +0000 (18:16 -0400)]
runtime: use 1-byte load for address checking in racecallatomic

In racecallatomic, we do a load before calling into TSAN, so if
the address is invalid we fault on the Go stack. We currently use
a 8-byte load instruction, regardless of the data size that the
atomic operation is performed on. So if, say, we are doing a
LoadUint32 at an address that is the last 4 bytes of a memory
mapping, we may fault unexpectedly. Do a 1-byte load instead.
(Ideally we should do a load with the right size, so we fault
correctly if we're given an unaligned address for a wide load
across a page boundary. Leave that for another CL.)

Fix AMD64, ARM64, and PPC64. The code already uses 1-byte load
on S390X.

Should fix #60825.

Change-Id: I3dee93eb08ba180c85e86a9d2e71b5b520e8dcf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/503937
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
11 months agocmd/go: fix build config for 'go list -cover'
Than McIntosh [Tue, 13 Jun 2023 20:13:01 +0000 (16:13 -0400)]
cmd/go: fix build config for 'go list -cover'

When 'go list -cover' is run in a way that triggers package builds
(for example, -export), ensure that the build step actually includes
coverage instrumentation as part of the config. Without this we will
wind up with incorrect build IDs.

Fixes #60755.

Change-Id: Ic84ab9e301d075bee5ff9d6828370a1708be0035
Reviewed-on: https://go-review.googlesource.com/c/go/+/502877
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

11 months agonet/http: only disable Fetch API in tests
Dmitri Shuralyov [Thu, 15 Jun 2023 06:08:47 +0000 (02:08 -0400)]
net/http: only disable Fetch API in tests

The Fetch API was meant to only be disabled in tests.
Since wasm_exec.js defines a global 'process' object,
it ended up being disabled anywhere that script is used.

Make the heuristic stricter so that it's less likely to
trigger anywhere but when testing js/wasm using Node.js.

For #57613.
Fixes #60808.

Change-Id: Ief8def802b466ef4faad16daccefcfd72e4398b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/503675
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
11 months agomath: document that Min/Max differ from min/max
Ian Lance Taylor [Tue, 6 Jun 2023 21:31:21 +0000 (14:31 -0700)]
math: document that Min/Max differ from min/max

For #59488
Fixes #60616

Change-Id: Idf9f42d7d868999664652dd7b478684a474f1d96
Reviewed-on: https://go-review.googlesource.com/c/go/+/501355
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Rob Pike <r@golang.org>
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>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

11 months agocmd/compile: do not report division by error during typecheck
Cuong Manh Le [Thu, 8 Jun 2023 02:58:22 +0000 (09:58 +0700)]
cmd/compile: do not report division by error during typecheck

types2 have already errored about any spec-required overflows, and
division by zero. CL 469595 unintentionally fixed typecheck not to error
about overflows, but zero division is still be checked during tcArith.
This causes unsafe operations with variable size failed to compile,
instead of raising runtime error.

Fixes #60601

Change-Id: I7bea2821099556835c920713397f7c5d8a4025ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/501735
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
11 months agoslices: add sort benchmark for sorted strings
Eli Bendersky [Thu, 15 Jun 2023 16:34:22 +0000 (09:34 -0700)]
slices: add sort benchmark for sorted strings

For #60777

Change-Id: I424535ce6454156c61af2f299228630ee304d165
Reviewed-on: https://go-review.googlesource.com/c/go/+/503815
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Eli Bendersky <eliben@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>