]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
10 months agogo/ast: add Unparen(Expr) helper
Alan Donovan [Tue, 16 May 2023 17:33:15 +0000 (13:33 -0400)]
go/ast: add Unparen(Expr) helper

Fixes #60061

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

10 months agocmd/go: attach PGO profile for test dependencies
Cherry Mui [Tue, 18 Jul 2023 20:23:27 +0000 (16:23 -0400)]
cmd/go: attach PGO profile for test dependencies

When running "go test" including a main package which has a PGO
profile, we currently build the package being tested and its
dependencies with PGO, but we failed to attach the profile to
test-only dependencies. If a package is (transitively) imported
by both the package being tested and the test, the PGO version
and the non-PGO version of the package are both linked into the
binary, causing link-time error.

This CL fixes this by attaching the PGO profile to dependencies of
the test.

Fixes #61376.

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

10 months agocmd/internal/obj: print relocation type by name in -S output
Cherry Mui [Thu, 8 Jun 2023 02:28:20 +0000 (22:28 -0400)]
cmd/internal/obj: print relocation type by name in -S output

The compiler/assembler's -S output prints relocation type
numerically, which is hard to understand. Every time I need to
count the relocation type constants to figure out which relocation
it actually is. Print the symbolic name instead.

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

10 months agocmd/link: clean up some relocation handling
Cherry Mui [Thu, 8 Jun 2023 17:23:39 +0000 (13:23 -0400)]
cmd/link: clean up some relocation handling

We don't use R_PCREL for calls to dynamic symbols (we use R_CALL
instead). Don't handle R_PCREL as a call.

We don't use R_CALL on ARM64 (we use R_CALLARM64 instead).

Remove those cases, which we don't expect to see.

Change-Id: Idd99022a8eeb65750ffc2936ffdccf8bb0405e30
Reviewed-on: https://go-review.googlesource.com/c/go/+/501859
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
10 months agocmd/link: handle dynamic import variables on Darwin
Cherry Mui [Thu, 8 Jun 2023 16:19:54 +0000 (12:19 -0400)]
cmd/link: handle dynamic import variables on Darwin

Currently, on darwin, we only support cgo_dynamic_import for
functions, but not variables, as we don't need it before.
mach_task_self_ is a variable defined in the system library, which
can be used to e.g. access the process's memory mappings via the
mach API. The C header defines a macro mach_task_self(), which
refers to the variable. To use mach_task_self_ (in pure-Go
programs) we need to access it in Go.

This CL handles cgo_dynamic_import for variables in the linker,
loading its address via the GOT. (Currently only on Darwin, as
we only need it there.)

For #50891.

Change-Id: Idf64fa88ba2f2381443a1ed0b42b14b581843493
Reviewed-on: https://go-review.googlesource.com/c/go/+/501855
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
10 months agoruntime/pprof: use testenv.Command in tests instead of exec.Command
Bryan C. Mills [Fri, 30 Jun 2023 16:47:06 +0000 (12:47 -0400)]
runtime/pprof: use testenv.Command in tests instead of exec.Command

If the test is about to time out, testenv.Command sends SIGQUIT to the
child process. The runtime's SIGQUIT goroutine dump should help us to
determine whether the hangs observed in TestCPUProfileWithFork are a
symptom of #60108 or a separate bug.

For #59995.
Updates #60108.

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

10 months agonet: remove sysSocket fallback for Windows 7
qmuntal [Mon, 26 Jun 2023 13:10:30 +0000 (15:10 +0200)]
net: remove sysSocket fallback for Windows 7

`syscall.ForkLock` is not used in `syscall.StartProcess` since
CL 288297, so using it in `sysSocket` makes no sense. This CL
goes a little bit further and removes the `sysSocket` fallback for
Windows 7, since it is not supported since go 1.21 (#57003).

Updates #60942

Change-Id: If14a0d94742f1b80af994f9f69938701ee41b402
Reviewed-on: https://go-review.googlesource.com/c/go/+/506136
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 months agointernal/fuzz: pass handle to temporary file instead of the path
qmuntal [Tue, 27 Jun 2023 14:54:44 +0000 (16:54 +0200)]
internal/fuzz: pass handle to temporary file instead of the path

This CL partially reverts CL 297034. Inheritable handles are not
inherited by all workers thanks to using AdditionalInheritedHandles,
which explicitly specifies which handles to inherit by each worker.

This CL doesn't fix any bug, it's more of a cleanup, but also makes
the code more robust and more similar to its Unix counterpart.

Change-Id: I24c2d7f69dfb839a1aeb5858088d8f38b022f702
Reviewed-on: https://go-review.googlesource.com/c/go/+/506535
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agocmd/go: don't collect package CGOLDFLAGS when using gccgo
Ian Lance Taylor [Tue, 23 May 2023 00:55:43 +0000 (17:55 -0700)]
cmd/go: don't collect package CGOLDFLAGS when using gccgo

They are already collected via cmd/cgo.

The gccgo_link_c test is tweaked to do real linking as with this
change the cgo ldflags are not fully reflected in go build -n output,
since they now only come from the built archive.

Fixes #60287

Change-Id: Id433435fe8aeb9571327bf936e52a37f400cef4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/497117
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Andrey Bokhanko <andreybokhanko@gmail.com>
10 months agoimage/draw: replace deprecated image.ZP and image.ZR in xx_test.go
ryomak [Wed, 28 Jun 2023 13:06:38 +0000 (22:06 +0900)]
image/draw: replace deprecated image.ZP and image.ZR in xx_test.go

Change-Id: I87545a46e5871452075152b4c99ba85089ef86b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/506735
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agocmp.bash: fix comment grammar
Jes Cok [Fri, 14 Jul 2023 04:07:45 +0000 (04:07 +0000)]
cmp.bash: fix comment grammar

Change-Id: I290806279983b528e35a3b81641c78a4e3424a74
GitHub-Last-Rev: d6f888e7de9d8eb205a1111f37ee1e2f71e04c5c
GitHub-Pull-Request: golang/go#61351
Reviewed-on: https://go-review.googlesource.com/c/go/+/509655
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
10 months agoruntime: use unsafe.{String,StringData} in arena test
Ian Lance Taylor [Thu, 8 Jun 2023 20:11:31 +0000 (13:11 -0700)]
runtime: use unsafe.{String,StringData} in arena test

Change-Id: Ia567b163efe7b323694c15abcf0cef0effc6ff6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/501995
Reviewed-by: Heschi Kreinick <heschi@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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agostrings: add benchmark for Builder.WriteString
Roger Peppe [Tue, 4 Jul 2023 14:25:07 +0000 (15:25 +0100)]
strings: add benchmark for Builder.WriteString

This is in preparation for an optimization.

```
name                                     time/op
BuildString_WriteString/1Write_NoGrow-8  30.8ns ± 0%
BuildString_WriteString/3Write_NoGrow-8   111ns ± 0%
BuildString_WriteString/3Write_Grow-8    44.1ns ± 4%

name                                     alloc/op
BuildString_WriteString/1Write_NoGrow-8   48.0B ± 0%
BuildString_WriteString/3Write_NoGrow-8    336B ± 0%
BuildString_WriteString/3Write_Grow-8      112B ± 0%

name                                     allocs/op
BuildString_WriteString/1Write_NoGrow-8    1.00 ± 0%
BuildString_WriteString/3Write_NoGrow-8    3.00 ± 0%
BuildString_WriteString/3Write_Grow-8      1.00 ± 0%
```

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I0e2c82edcdc72f381c5160f315401678ff76f3d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/507777
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoslices: refactor DeleteFunc to improve code readability
amdahliu [Mon, 3 Jul 2023 10:09:36 +0000 (10:09 +0000)]
slices: refactor DeleteFunc to improve code readability

Reuse IndexFunc function to avoid confusing subscript indexing, and to reduce code nesting depth.

Change-Id: I309416ebf928071f71054433e078f0fda802fba8
GitHub-Last-Rev: af54738bda7f27afda5f92496363c0a68493c369
GitHub-Pull-Request: golang/go#61154
Reviewed-on: https://go-review.googlesource.com/c/go/+/507635
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoos: remove unused containsAny
Tobias Klauser [Thu, 25 May 2023 10:37:52 +0000 (12:37 +0200)]
os: remove unused containsAny

It's unused since CL 455716.

Change-Id: I78bf7ad0e546c7dda8e78b911feb6399e1e6e088
Reviewed-on: https://go-review.googlesource.com/c/go/+/498235
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

10 months agocrypto/internal/boring,crypto/sha1: remove cmd_go_bootstrap build tag
qmuntal [Tue, 11 Jul 2023 15:56:17 +0000 (17:56 +0200)]
crypto/internal/boring,crypto/sha1: remove cmd_go_bootstrap build tag

Since CL 402595, the Go compiler no longer uses any package under
crypto, so there is no need to explicitly exclude boring from the
go bootstrap build.

Change-Id: Ib71349fffaab151c6e1fb42a9684151439b70cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/508402
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agoos: remove executable bits from os.OpenFile example
Rami [Sun, 16 Jul 2023 10:25:40 +0000 (10:25 +0000)]
os: remove executable bits from os.OpenFile example

The mode used in the os.OpenFile example (0755) has all executable bits set.
I suspect that this ill-advised usage propagates to other codebases (by means of people carelessly copying the usage example), which is why I suggest modifying the example.

Change-Id: Ic36c8b41974f3fe00471822c2414e36b4e5dc1bc
GitHub-Last-Rev: 638f3beefe8926c8e5c2c4ab9a1a5899e55de892
GitHub-Pull-Request: golang/go#61384
Reviewed-on: https://go-review.googlesource.com/c/go/+/510135
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agointernal/bytealg: use generic IndexByte on plan9/amd64
Philip Silva [Mon, 10 Jul 2023 20:22:15 +0000 (22:22 +0200)]
internal/bytealg: use generic IndexByte on plan9/amd64

Use generic implementation of IndexByte/IndexByteString
on plan9/amd64 since the assembly implementation
uses SSE instructions which are classified as floating
point instructions and cannot be used in a note handler.
A similar issue was fixed in CL 100577.

This fixes runtime.TestBreakpoint.

Fixes #61087.

Change-Id: Id0c085e47da449be405ea04ab9b93518c4e2fde8
Reviewed-on: https://go-review.googlesource.com/c/go/+/508400
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
10 months agonet/url: document requirements for IPv6 addresses in URL.Host
Damien Neil [Tue, 11 Jul 2023 22:34:09 +0000 (15:34 -0700)]
net/url: document requirements for IPv6 addresses in URL.Host

When the host subcomponent of a URL is an IPv6 address, it must be
surrounded by square brackets to prevent colons in the address
from being interpreted as the port: "[fe80::1]:80".

Document this requirement.

Fixes #61093
Fixes #61276

Change-Id: Iaf411b9dc211fd876468d6e2e94ff672ba0d329d
Reviewed-on: https://go-review.googlesource.com/c/go/+/508976
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Cherry Mui <cherryyz@google.com>
10 months agonet: remove unused error result from newRawConn
Daniel Martí [Fri, 7 Jul 2023 09:17:28 +0000 (11:17 +0200)]
net: remove unused error result from newRawConn

It's currently always nil, and the code gets generally less verbose.

Change-Id: Id4f5f9ac6eac0218dda34b8bd5ef41c633cfaf2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/508396
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agonet/http: declare publicErr as a constant
Jes Cok [Tue, 20 Jun 2023 11:35:10 +0000 (11:35 +0000)]
net/http: declare publicErr as a constant

Do the same as the code above: "case err == errTooLarge", declare
publicErr as a constant to avoid runtime calls.

Change-Id: I50a9951232c70eff027b0da86c0bbb8bea51acbe
GitHub-Last-Rev: 71d4458ded3a1e99a0d027ccca6c9d6269a1ab06
GitHub-Pull-Request: golang/go#60884
Reviewed-on: https://go-review.googlesource.com/c/go/+/504456
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Olif Oftimis <oftimisolif@gmail.com>
10 months agoruntime: adjust netpollWaiters after goroutines are ready
Ian Lance Taylor [Wed, 19 Jul 2023 23:09:35 +0000 (16:09 -0700)]
runtime: adjust netpollWaiters after goroutines are ready

The runtime was adjusting netpollWaiters before the waiting
goroutines were marked as ready. This could cause the scheduler
to report a deadlock because there were no goroutines ready to run.
Keeping netpollWaiters non-zero ensures that at least one goroutine
will call netpoll(-1) from findRunnable.

This does mean that if a program has network activity for a while
and then never has it again, and also has no timers, then we can leave
an M stranded in a call to netpoll from which it will never return.
At least this won't be a common case. And it's not new; this has been
a potential problem for some time.

Fixes #61454

Change-Id: I17c7f891c2bb1262fda12c6929664e64686463c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/511455
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
10 months agocmd/asm, cmd/internal/obj: generate proper atomic ops for riscv64
Meng Zhuo [Tue, 11 Jul 2023 06:53:54 +0000 (14:53 +0800)]
cmd/asm, cmd/internal/obj: generate proper atomic ops for riscv64

Go's memory model closely follows the approach C++ concurrency memory
model (https://go.dev/ref/mem) and Go atomic "has the same semantics as C++'s
sequentially consistent atomics".

Meanwhile according to RISCV manual A.6 "Mappings from C/C++ primitives to RISC-V primitives".
C/C++ atomic operations (memory_order_acq_rel) should be map to "amo<op>.{w|d}.aqrl"
LR/SC (memory_order_acq_rel) should map to "lr.{w|d}.aq; <op>; sc.{w|d}.rl"

goos: linux
goarch: riscv64
pkg: runtime/internal/atomic
                │ atomic.old.bench │          atomic.new.bench           │
                │      sec/op      │   sec/op     vs base                │
AtomicLoad64-4         4.216n ± 1%   4.202n ± 0%        ~ (p=0.127 n=10)
AtomicStore64-4        5.040n ± 0%   6.718n ± 0%  +33.30% (p=0.000 n=10)
AtomicLoad-4           4.217n ± 0%   4.213n ± 0%        ~ (p=0.145 n=10)
AtomicStore-4          5.040n ± 0%   6.718n ± 0%  +33.30% (p=0.000 n=10)
And8-4                 9.237n ± 0%   9.240n ± 0%        ~ (p=0.582 n=10)
And-4                  5.878n ± 0%   6.719n ± 0%  +14.31% (p=0.000 n=10)
And8Parallel-4         28.44n ± 0%   28.46n ± 0%   +0.07% (p=0.000 n=10)
AndParallel-4          28.40n ± 0%   28.43n ± 0%   +0.11% (p=0.000 n=10)
Or8-4                  8.399n ± 0%   8.398n ± 0%        ~ (p=0.357 n=10)
Or-4                   5.879n ± 0%   6.718n ± 0%  +14.27% (p=0.000 n=10)
Or8Parallel-4          28.43n ± 0%   28.45n ± 0%   +0.09% (p=0.000 n=10)
OrParallel-4           28.40n ± 0%   28.43n ± 0%   +0.11% (p=0.000 n=10)
Xadd-4                 30.05n ± 0%   30.10n ± 0%   +0.18% (p=0.000 n=10)
Xadd64-4               30.05n ± 0%   30.09n ± 0%   +0.12% (p=0.000 n=10)
Cas-4                  60.48n ± 0%   61.13n ± 0%   +1.08% (p=0.000 n=10)
Cas64-4                62.28n ± 0%   62.34n ± 0%        ~ (p=0.810 n=10)
Xchg-4                 30.05n ± 0%   30.09n ± 0%   +0.15% (p=0.000 n=10)
Xchg64-4               30.05n ± 0%   30.09n ± 0%   +0.13% (p=0.000 n=10)
geomean                15.42n        16.17n        +4.89%

Fixes #61295

Change-Id: I97b5325db50467eeec36fb079bded7b09a32330f
Reviewed-on: https://go-review.googlesource.com/c/go/+/508715
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: M Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoruntime: ensure stack is aligned in _rt0_amd64_windows_lib
qmuntal [Tue, 18 Jul 2023 14:55:26 +0000 (16:55 +0200)]
runtime: ensure stack is aligned in _rt0_amd64_windows_lib

The Windows DLL loader may call a DLL entry point, in our case
_rt0_amd64_windows_lib, with a stack that is
not 16-byte aligned. In theory, it shouldn't, but under some
circumstances, it does (see below how to reproduce it).

Having an unaligned stack can, and probably will, cause problems
down the line, for example if a movaps instruction tries to store
a value in an unaligned address it throws an Access Violation exception
(code 0xc0000005).

I managed to consistently reproduce this issue by loading a Go DLL into
a C program that has the Page Heap Verification diagnostic enabled [1].

Updates #54187 (and potentially fixes)

[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/example-12---using-page-heap-verification-to-find-a-bug

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

10 months agodoc/go1.21: add release notes for linux/loong64
Guoqi Chen [Tue, 4 Jul 2023 05:03:58 +0000 (13:03 +0800)]
doc/go1.21: add release notes for linux/loong64

Fixes #53301

Change-Id: Id447d57d43b12c3748267295928d45a089549340
Reviewed-on: https://go-review.googlesource.com/c/go/+/507815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agonet: tolerate permission errors in interface tests
Heschi Kreinick [Tue, 18 Jul 2023 17:38:21 +0000 (13:38 -0400)]
net: tolerate permission errors in interface tests

On our linux-arm64 builders, we're getting permission errors despite
running as root. Detect those errors and skip the test.

For #61414.

Change-Id: I5d7c45789337bee3860b19335bbb9eb884c48986
Reviewed-on: https://go-review.googlesource.com/c/go/+/510737
Auto-Submit: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agospec: clarify prose in rule for clear built-in
Robert Griesemer [Tue, 18 Jul 2023 23:21:45 +0000 (16:21 -0700)]
spec: clarify prose in rule for clear built-in

Per feedback on #56351.

For #56351.

Change-Id: I63dd1713a1efe4d7180d932dbd8e1510cbb32e90
Reviewed-on: https://go-review.googlesource.com/c/go/+/510935
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
10 months agoall: update go.mod go version to 1.22
Heschi Kreinick [Tue, 18 Jul 2023 21:08:00 +0000 (17:08 -0400)]
all: update go.mod go version to 1.22

For #60558.

Change-Id: I1a390f4619e181936d71964f5666052080689374
Reviewed-on: https://go-review.googlesource.com/c/go/+/510836
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
10 months agodoc: start draft Go 1.22 release notes
Heschi Kreinick [Tue, 18 Jul 2023 20:55:13 +0000 (16:55 -0400)]
doc: start draft Go 1.22 release notes

For #61422.

Change-Id: I1a7430d9113cbaede1822115a7daeb45a894af25
Reviewed-on: https://go-review.googlesource.com/c/go/+/510377
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
10 months agoall: fix typos
Jes Cok [Fri, 23 Jun 2023 07:47:48 +0000 (07:47 +0000)]
all: fix typos

Change-Id: I510b0a4bf3472d937393800dd57472c30beef329
GitHub-Last-Rev: 8d289b73a37bd86080936423d981d21e152aaa33
GitHub-Pull-Request: golang/go#60960
Reviewed-on: https://go-review.googlesource.com/c/go/+/505398
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agoruntime/coverage: use unsafe.Slice, not reflect.SliceHeader
Ian Lance Taylor [Wed, 12 Jul 2023 00:42:53 +0000 (17:42 -0700)]
runtime/coverage: use unsafe.Slice, not reflect.SliceHeader

Change-Id: I59c4757df83c12b4c8b85cdd523552c5e5e7bf95
Reviewed-on: https://go-review.googlesource.com/c/go/+/508977
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>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
10 months agoruntime: decrement netpollWaiters in netpollunblock
Ian Lance Taylor [Fri, 16 Jun 2023 00:41:19 +0000 (17:41 -0700)]
runtime: decrement netpollWaiters in netpollunblock

We used to decrement it in netpollgoready, but that missed
the common case of a descriptor becoming ready due to I/O.
All calls to netpollgoready go through netpollunblock,
so this shouldn't miss any decrements we missed before.

Fixes #60782

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

10 months agointernal/goversion: update Version to 1.22
Heschi Kreinick [Mon, 17 Jul 2023 16:14:31 +0000 (12:14 -0400)]
internal/goversion: update Version to 1.22

For #40705.

Change-Id: I06df5f4ea5cf65420c2dac754a1e65ac819c1090
Reviewed-on: https://go-review.googlesource.com/c/go/+/510735
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>

10 months agodoc: run relnotes again
Carlos Amedee [Mon, 17 Jul 2023 16:42:14 +0000 (12:42 -0400)]
doc: run relnotes again

Relnote (golang.org/x/build/cmd/relnote) was run again. Some of the
simpler entries were resolved. TODO's remain for other entries.

For #58645

Change-Id: I0acb5e87b2e9655ffd472e728259a4aa6c4da50e
Reviewed-on: https://go-review.googlesource.com/c/go/+/510375
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agonet/rpc: use conventional `err` in example
darkfeline [Tue, 18 Jul 2023 03:34:30 +0000 (03:34 +0000)]
net/rpc: use conventional `err` in example

It is conventional to use `err` for error variables, so change the example to use `err` instead of `e`.

Change-Id: I53bc3c5384fe608b322a55c564e9aee228b43329
GitHub-Last-Rev: 3e2ed84eefad7104b952bc6eab1c3b0af6f8f80e
GitHub-Pull-Request: golang/go#61375
Reviewed-on: https://go-review.googlesource.com/c/go/+/510075
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Allen Li <ayatane@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>

10 months agogo/types, types2: remove unnecessary assert on pointer size
Rob Findley [Tue, 11 Jul 2023 19:54:48 +0000 (15:54 -0400)]
go/types, types2: remove unnecessary assert on pointer size

As described in #61249, uncommon pointer sizes do exist. Remove an
unnecessary assertion.

Fixes #61249

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

10 months agomath: test large negative values as args for trig functions
Keith Randall [Fri, 14 Jul 2023 15:34:39 +0000 (08:34 -0700)]
math: test large negative values as args for trig functions

Sin/Tan are odd, Cos is even, so it is easy to compute the correct
result from the positive argument case.

Change-Id: If851d00fc7f515ece8199cf56d21186ced51e94f
Reviewed-on: https://go-review.googlesource.com/c/go/+/509815
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Srinivas Pokala <Pokala.Srinivas@ibm.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
10 months agocmd/go: fix tests when go.env sets GOPROXY=direct GOSUMDB=off
Bryan C. Mills [Fri, 14 Jul 2023 18:50:37 +0000 (14:50 -0400)]
cmd/go: fix tests when go.env sets GOPROXY=direct GOSUMDB=off

Tested locally by changing GOROOT/go.env. At some point perhaps we
should also set up a builder that runs with some common expected
modifications to go.env
(such as GOTOOLCHAIN=local GOPROXY=direct GOSUMDB=off).

Fixes #61358.
Updates #61359.

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

10 months agodoc/go1.21: use consistent capitalization for amd64
Austin Clements [Mon, 17 Jul 2023 14:39:00 +0000 (10:39 -0400)]
doc/go1.21: use consistent capitalization for amd64

Fixes #61388

Change-Id: I173498b57081aacf772f0d3a9ce0a76ed7b19385
Reviewed-on: https://go-review.googlesource.com/c/go/+/510295
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Austin Clements <austin@google.com>

10 months agolog/slog: doc commonHandler.handle
Jonathan Amsterdam [Fri, 14 Jul 2023 12:23:18 +0000 (08:23 -0400)]
log/slog: doc commonHandler.handle

Change-Id: Id301b772e472e1cb7cd8bccaa5a13ff7b6f94711
Reviewed-on: https://go-review.googlesource.com/c/go/+/509596
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agolog/slog: fix issue with concurrent writes
Will Roden [Wed, 12 Jul 2023 22:23:09 +0000 (17:23 -0500)]
log/slog: fix issue with concurrent writes

This causes instances commonHandler created by withAttrs or withGroup to
share a mutex with their parent preventing concurrent writes to their
shared writer.

Fixes #61321

Change-Id: Ieec225e88ad51c84b41bad6c409fac48c90320b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/509196
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
10 months agocmd/covdata: format package comment for 'go doc' rendering
Bryan C. Mills [Thu, 13 Jul 2023 21:30:34 +0000 (17:30 -0400)]
cmd/covdata: format package comment for 'go doc' rendering

Due to an errant newline, both 'go doc' and pkg.go.dev currently
interpret the long comment in cmd/covdata/doc.go as a file comment
instead of package documentation.

Removing the errant newline caused 'go doc' to render the comment, but
it does not strip out the interior '//' tokens from the '/* … */'
block.

Removing those tokens and fixing up indentation seems to give
satisfactory rendering.

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

10 months agobytes: remove builders check from compare test
Johan Brandhorst-Satzkorn [Fri, 30 Jun 2023 20:48:10 +0000 (13:48 -0700)]
bytes: remove builders check from compare test

TestCompareBytes already took into account the -short
testing flag, however, only if not run on one of the Go builders.
This extra condition is no longer necessary as we have much
better longtest coverage than we did when the check was added.

Fixes #61071

Change-Id: I0fc716f4e7baa04019ee00608f223f27c931edcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/507416
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Bypass: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agocmd/go/internal/modfetch: always allow Stat for the current toolchain to succeed
Bryan C. Mills [Thu, 13 Jul 2023 14:12:33 +0000 (10:12 -0400)]
cmd/go/internal/modfetch: always allow Stat for the current toolchain to succeed

This fixes a failure mode observed in TestScript/gotoolchain_version
when building go1.21rc3.

Updates #61259.

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

10 months agonet/http: revert stray edit to h2_bundle.go from CL 508996
Bryan C. Mills [Thu, 13 Jul 2023 14:55:55 +0000 (10:55 -0400)]
net/http: revert stray edit to h2_bundle.go from CL 508996

h2_bundle.go is generated from x/net/http2, so it must not be edited
manually.

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

10 months agoall: remove duplicate word and fix comment
cui fliter [Wed, 12 Jul 2023 11:11:05 +0000 (19:11 +0800)]
all: remove duplicate word and fix comment

Change-Id: I3302b94a47f384ec2519d08af50b3b5725c5b42a
Reviewed-on: https://go-review.googlesource.com/c/go/+/508995
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.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>

10 months agoall: fix typos and remove repeated words
Dan Kortschak [Wed, 12 Jul 2023 12:56:57 +0000 (22:26 +0930)]
all: fix typos and remove repeated words

Change-Id: I5f06a4ef1d827eb0fe32a8d98444142108b0d573
Reviewed-on: https://go-review.googlesource.com/c/go/+/508996
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
10 months agoall: update vendored dependencies
Russ Cox [Wed, 12 Jul 2023 18:08:12 +0000 (14:08 -0400)]
all: update vendored dependencies

Generated by:

go install golang.org/x/tools/cmd/bundle@latest
go install golang.org/x/build/cmd/updatestd@latest
updatestd -goroot=$GOROOT -branch=master

For #36905.
For #55079.

Fixes #61174 (vet checkers understanding Go language version).
Fixes #61200 (slog InfoCtx -> InfoContext etc).

Change-Id: I4f2c86960ce72d6df06e23da1b1297ab3ff2eecf
Reviewed-on: https://go-review.googlesource.com/c/go/+/509099
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
10 months agocmd/go: fix go get go@badversion
Russ Cox [Wed, 12 Jul 2023 13:53:49 +0000 (09:53 -0400)]
cmd/go: fix go get go@badversion

It was panicking instead of printing a nice error.

Fixes #61258.
Fixes #61259.

Change-Id: Ia30853db5bc7f1f2a4c7e91169c659ae2b79adcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/509097
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agocmd/go: fix GOTOOLCHAIN parsing for +auto
Russ Cox [Tue, 11 Jul 2023 19:15:51 +0000 (15:15 -0400)]
cmd/go: fix GOTOOLCHAIN parsing for +auto

The call from toolchain.Select to gover.FromToolchain was passing the
wrong argument but this was masked by gover.IsValid being a little bit
too lax.

Fix and test IsValid, which then breaks the existing gotoolchain_local
test, and then fix toolchain.Select to fix the test.

Fixes #61068.

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

10 months agodoc/go1.21: add a release note for CL 463177
Bryan C. Mills [Wed, 12 Jul 2023 17:56:44 +0000 (13:56 -0400)]
doc/go1.21: add a release note for CL 463177

I'm not sure why the relnote tool did not fill in a TODO for that
change; one was requested in
http://go.dev/cl/c/go/+/463177/3#message-87065dffb06e196fba9a325fefb32f16b41b6b15.

Updates #50807.
Updates #27225.

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

10 months agocmd/compile: on PPC64, fix sign/zero extension when masking
Paul E. Murphy [Tue, 11 Jul 2023 14:07:43 +0000 (09:07 -0500)]
cmd/compile: on PPC64, fix sign/zero extension when masking

(ANDCCconst [y] (MOV.*reg x)) should only be merged when zero
extending. Otherwise, sign bits are lost on negative values.

(ANDCCconst [0xFF] (MOVBreg x)) should be simplified to a zero
extension of x. Likewise for the MOVHreg variant.

Fixes #61297

Change-Id: I04e4fd7dc6a826e870681f37506620d48393698b
Reviewed-on: https://go-review.googlesource.com/c/go/+/508775
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
10 months agosrc/README.vendor: s/latest/master/
Jonathan Amsterdam [Tue, 11 Jul 2023 21:12:33 +0000 (17:12 -0400)]
src/README.vendor: s/latest/master/

Update the README to specify the module query "@master" instead of
"@latest".

Vendoring the highest tagged version is unlikely to be right. Usually
one wants to vendor the module at HEAD.

Change-Id: Id00d23523a13fd3dcd73d6eacefdf50bcdbfa26e
Reviewed-on: https://go-review.googlesource.com/c/go/+/508823
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agotesting/slogtest: check for no group with empty record
Jonathan Amsterdam [Fri, 7 Jul 2023 13:55:56 +0000 (09:55 -0400)]
testing/slogtest: check for no group with empty record

As #61067 pointed out, slog did not properly handle empty groups.
https://go.dev/cl/508436 dealt with most cases inside slog itself,
but handlers must still do a check on their own. Namely, a handler
must not output a group created by WithGroup unless the Record
has attributes.

This change adds a test to slogtest to check that case.

Fixes #61227.

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

10 months agonet/http/fcgi: eliminate goroutine leaks in tests
Bryan C. Mills [Tue, 11 Jul 2023 14:52:42 +0000 (10:52 -0400)]
net/http/fcgi: eliminate goroutine leaks in tests

Also fix a (minor) double-Close error in Serve that was exposed by the
test fix.

Serve accepts a net.Listener, which produces net.Conn instances.
The documentation for net.Conn requires its methods to be safe for
concurrent use, so most implementations likely allow Close to be
called multiple times as a side effect of making it safe to call
concurrently with other methods. However, the net.Conn interface is a
superset of the io.Closer interface, io.Closer explicitly leaves the
behavior of multiple Close calls undefined, and net.Conn does not
explicitly document a stricter requirement.

Perhaps more importantly, the test for the fcgi package calls
unexported functions that accept an io.ReadWriteCloser (not a
net.Conn), and at least one of the test-helper ReadWriteCloser
implementations expects Close to be called only once.

The goroutine leaks were exposed by a racy arbitrary timeout reported
in #61271. Fixing the goroutine leak exposed the double-Close error:
one of the leaked goroutines was blocked on reading from an unclosed
pipe. Closing the pipe (to unblock the goroutine) triggered the second
Close call.

Fixes #61271.

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

10 months agoos/exec: ignore context.Canceled errors in TestConcurrentExec
Bryan C. Mills [Tue, 11 Jul 2023 14:08:48 +0000 (10:08 -0400)]
os/exec: ignore context.Canceled errors in TestConcurrentExec

We cancel the Context to unblock the test as soon as all of the "exit"
processes have completed. If that happens to occur before all of the
"hang" processes have started, the Start calls may fail with
context.Canceled.

Since those errors are possible in normal operation of the test,
ignore them.

Fixes #61277.
Updates #61080.

Change-Id: I20db083ec89ca88eb085ceb2892b9f87f83705ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/508755
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agolog/slog: replace nil contexts with context.Background()
Jonathan Amsterdam [Fri, 7 Jul 2023 13:11:46 +0000 (09:11 -0400)]
log/slog: replace nil contexts with context.Background()

Passing nil for a context is discouraged. We should avoid it.

Fixes #61219.

Change-Id: I664387070aacb56af580b6b0791ca40982d2a711
Reviewed-on: https://go-review.googlesource.com/c/go/+/508437
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
10 months agolog/slog: change XXXCtx functions to XXXContext
Jonathan Amsterdam [Thu, 6 Jul 2023 17:06:44 +0000 (13:06 -0400)]
log/slog: change XXXCtx functions to XXXContext

Fixes #61200.

Change-Id: I3071dbf673bcd2d24e62644b40d481c953703978
Reviewed-on: https://go-review.googlesource.com/c/go/+/508195
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agotime: increase arbitrary upper bound in TestReset to 10s
Bryan C. Mills [Mon, 10 Jul 2023 22:40:47 +0000 (18:40 -0400)]
time: increase arbitrary upper bound in TestReset to 10s

The previous upper bound was around 0.375 s, which is empirically
too short on a slow, heavily-loaded builder. Since the test doesn't
seem to depend on the actual duration in any meaningful way, let's
make it several orders of magnitude larger.

Fixes #61266.

Change-Id: I6dde5e174966ee385db67e3cb87334f463c7e597
Reviewed-on: https://go-review.googlesource.com/c/go/+/508695
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agonet: mptcp: force using MPTCP with GODEBUG
Matthieu Baerts [Fri, 30 Jun 2023 15:24:57 +0000 (17:24 +0200)]
net: mptcp: force using MPTCP with GODEBUG

When adding MPTCP support to address the proposal #56539, I missed the
GODEBUG setting from Russ Cox's plan:

  I am inclined to say that we add MPTCP as an opt-in for a release or
  two, and then make it opt-out. There should be a GODEBUG setting (...)

See: https://github.com/golang/go/issues/56539#issuecomment-1309294637

Thanks to andrius4669 for having reported this issue to me.

It makes sense to have this GODEBUG setting not to have to modify
applications to use MPTCP (if available). It can then be useful to
estimate the impact in case we want to switch from opt-in to opt-out
later.

The MPTCP E2E test has been modified to make sure we can enable MPTCP
either via the source code like it was already the case before or with
this environment variable:

  GODEBUG=multipathtcp=1

The documentation has been adapted accordingly.

I don't know if it is too late for Go 1.21 but I had to put a version in
the documentation. The modification is small, the risk seems low and
this was supposed to be there from the beginning according to Russ Cox's
specifications. It can also be backported or only be present in the
future v1.22 if it is easier.

Note: I didn't re-open #56539 or open a new one. It is not clear to me
what I should do in this case.

Fixes #56539

Change-Id: I9201f4dc0b99e3643075a34c7032a95528c48fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/507375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
10 months agosyscall: serialize locks on ForkLock on platforms where forkExecPipe is not atomic
Bryan C. Mills [Fri, 30 Jun 2023 15:50:47 +0000 (11:50 -0400)]
syscall: serialize locks on ForkLock on platforms where forkExecPipe is not atomic

In CL 421441, we changed syscall to allow concurrent calls to
forkExec.

On platforms that support the pipe2 syscall that is the right
behavior, because pipe2 atomically opens the pipe with CLOEXEC already
set.

However, on platforms that do not support pipe2 (currently aix and
darwin), syscall.forkExecPipe is not atomic, and the pipes do not
initially have CLOEXEC set. If two calls to forkExec proceed
concurrently, a pipe intended for one child process can be
accidentally inherited by the other. If the process is long-lived, the
pipe can be held open unexpectedly and prevent the parent process from
reaching EOF reading the child's status from the pipe.

Fixes #61080.
Updates #23558.
Updates #54162.

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

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>