]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
17 months agomisc/cgo/testsanitizers: add libfuzzer tests
Cherry Mui [Tue, 27 Dec 2022 18:46:23 +0000 (13:46 -0500)]
misc/cgo/testsanitizers: add libfuzzer tests

Apparently we don't have tests for libfuzzer mode. Add some tests.

Updates #57449.

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

17 months agotesting: rephrase the sentence about naming test files
Andrey Bozhko [Wed, 21 Dec 2022 22:24:05 +0000 (22:24 +0000)]
testing: rephrase the sentence about naming test files

This updates the explanation about
naming test files to be a little more clear.

Fixes #57389

Change-Id: I9b3a8e2dae5e3ad398b55624e183809b7d90864c
GitHub-Last-Rev: 9ff81b74b201ca032fd373424aa02a3fedaec008
GitHub-Pull-Request: golang/go#57399
Reviewed-on: https://go-review.googlesource.com/c/go/+/458435
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Fahad King <fahadking750@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
17 months agocmd/link, runtime: use a different section for Go libfuzzer counters
Cherry Mui [Wed, 21 Dec 2022 21:35:57 +0000 (16:35 -0500)]
cmd/link, runtime: use a different section for Go libfuzzer counters

Currently in libfuzzer mode, we put our counters in section
__sancov_cntrs. When linking with C/C++ code that also has fuzzer
counters, apparently the C linker combines our counters and their
counters and registers them together. But in the Go runtime we
also have code to register our counters. So the Go counters ended
up registered twice, causing problems.

Since we already have code to register our counters, put them in
a Go-specific section so it won't be combined with the C counters.

Fixes #57449.

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

17 months agoruntime: call __fork instead of fork on darwin
Russ Cox [Thu, 22 Dec 2022 14:44:56 +0000 (09:44 -0500)]
runtime: call __fork instead of fork on darwin

Issues #33565 and #56784 were caused by hangs in the child process
after fork, while it ran atfork handlers that ran into slow paths that
didn't work in the child.

CL 451735 worked around those two issues by calling a couple functions
at startup to try to warm up those child paths. That mostly worked,
but it broke programs using cgo with certain macOS frameworks (#57263).

CL 459175 reverted CL 451735.

This CL introduces a different fix: bypass the atfork child handlers
entirely. For a general fork call where the child and parent are both
meant to keep executing the original program, atfork handlers can be
necessary to fix any state that would otherwise be tied to the parent
process. But Go only uses fork as preparation for exec, and it takes
care to limit what it attempts to do in the child between the fork and
exec. In particular it doesn't use any of the things that the macOS
atfork handlers are trying to fix up (malloc, xpc, others). So we can
use the low-level fork system call (__fork) instead of the
atfork-wrapped one.

The full list of functions that can be called in a child after fork in
exec_libc2.go is:

 - ptrace
 - setsid
 - setpgid
 - getpid
 - ioctl
 - chroot
 - setgroups
 - setgid
 - setuid
 - chdir
 - dup2
 - fcntl
 - close
 - execve
 - write
 - exit

I disassembled all of these while attached to a hung exec.test binary
and confirmed that nearly all of them are making direct kernel calls,
not using anything that the atfork handler needs to fix up.
The exceptions are ioctl, fcntl, and exit.

The ioctl and fcntl implementations do some extra work around the
kernel call but don't call any other functions, so they should still
be OK. (If not, we could use __ioctl and __fcntl instead, but without
a good reason, we should keep using the standard entry points.)

The exit implementation calls atexit handlers. That is almost
certainly inappropriate in a failed fork child, so this CL changes
that call to __exit on darwin. To avoid making unnecessary changes at
this point in the release cycle, this CL leaves OpenBSD calling plain
exit, even though that is probably a bug in the OpenBSD port
(filed #57446).

Fixes #33565.
Fixes #56784.
Fixes #57263.

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

17 months agoruntime: revert Apple libc atfork workaround
Russ Cox [Thu, 22 Dec 2022 14:21:03 +0000 (09:21 -0500)]
runtime: revert Apple libc atfork workaround

Revert CL 451735 (1f4394a0c926), which fixed #33565 and #56784
but also introduced #57263.

I have a different fix to apply instead. Since the first fix was
never backported, it will be easiest to backport the new fix
if the new fix is done in a separate CL from the revert.

Change-Id: I6c8ea3a46e542ee4702675bbc058e29ccd2723e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/459175
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

17 months agomisc/cgo/testshared: test build std in shared mode
Cherry Mui [Thu, 22 Dec 2022 04:31:48 +0000 (23:31 -0500)]
misc/cgo/testshared: test build std in shared mode

Test that "go install -buildmode=shared std" works.

For #57334.

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

17 months agoruntime/internal/startlinetest: work around shared buildmode linking issue
Cherry Mui [Tue, 20 Dec 2022 22:26:18 +0000 (17:26 -0500)]
runtime/internal/startlinetest: work around shared buildmode linking issue

The runtime/internal/startlinetest package contains a call to a
function defined in runtime_test. Generally this is fine as this
package is only linked in for runtime_test. Except that for "go
install -buildmode=shared std", which include all packages in std,
including this test-only internal package. In this mode, the
caller is included in the linking but the callee is not, causing
linking error. Work around it by calling
runtime_test.callerStartLine via a function pointer. The function
pointer is only set in runtime_test. In the shared std build, the
function pointer will not be set, and this is fine.

Fixes #57334.

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

17 months agoruntime/race: add build tag to internal amd64vN packages
Cherry Mui [Tue, 20 Dec 2022 22:19:09 +0000 (17:19 -0500)]
runtime/race: add build tag to internal amd64vN packages

Only one of the runtime/race/internal/amd64vN packages should be
included in a build. Generally this is true because the
runtime/race package would import only one of them depending on
the build configuration. But for "go install -buildmode=shared std"
it includes all Go packages in std, which includes both, which
then causes link-time failure due to duplicated symbols. To avoid
this, we add build tags to the internal packages, so, depending on
the build configuation, only one package would contain buildable
go files therefore be included in the build.

For #57334.

Change-Id: I52ddc3a40e16c7d04b4dd861e9689918d27e8509
Reviewed-on: https://go-review.googlesource.com/c/go/+/458695
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
17 months agodoc/go1.20: fix typo
Tobias Klauser [Wed, 21 Dec 2022 12:27:04 +0000 (13:27 +0100)]
doc/go1.20: fix typo

Change-Id: Ia0ce728ca18eefd835220b2076c4aa8ba00cda6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/458815
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
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>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
17 months agoruntime/coverage: add missing file close in test support helper
Than McIntosh [Wed, 21 Dec 2022 16:03:16 +0000 (11:03 -0500)]
runtime/coverage: add missing file close in test support helper

The processPod() helper (invoked by processCoverTestDir, which is in
turn called by _testmain.go) was opening and reading counter data
files, but never closing them. Add a call to close the files after
they have been read.

Fixes #57407.

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

17 months agocrypto/x509: return typed verification errors on macOS
Roland Shoemaker [Tue, 22 Nov 2022 00:47:39 +0000 (16:47 -0800)]
crypto/x509: return typed verification errors on macOS

On macOS return the error code from SecTrustEvaluateWithError, and use
it to create typed errors that can be returned from Verify.

Fixes #56891

Change-Id: Ib597ce202abb60702f730e75da583894422e4c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/452620
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
17 months agoarchive/tar, archive/zip: revert documentation of ErrInsecurePath
Damien Neil [Wed, 21 Dec 2022 17:50:48 +0000 (09:50 -0800)]
archive/tar, archive/zip: revert documentation of ErrInsecurePath

CL 452616 disables path security checks by default, enabling them
only when GODEBUG=tarinsecurepath=0 or GODEBUG=zipinsecurepath=0
is set. Remove now-obsolete documenation of the path checks.

For #55356

Change-Id: I4ae57534efe9e27368d5e67773a502dd0e56eff4
Reviewed-on: https://go-review.googlesource.com/c/go/+/458875
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>

17 months agonet/http/httputil: don't add X-Forwarded-{Host,Proto} after invoking Director funcs
Damien Neil [Wed, 14 Dec 2022 17:55:06 +0000 (09:55 -0800)]
net/http/httputil: don't add X-Forwarded-{Host,Proto} after invoking Director funcs

This reverts CL 407414.

When forwarding an inbound request that contains an existing
X-Forwarded-Host or X-Forwarded-Proto header, a proxy might want
to preserve the header from the inbound request, replace it with
its own header, or not include any header at all.

CL 407414 replaces inbound X-Forwarded-{Host,Proto} headers by default,
and allows a Director func to disable sending these headers at all.
However, the Director hook API isn't sufficiently flexible to permit the
previous behavior of preserving inbound values unchanged.

The new Rewrite API does have this flexibility; users of Rewrite can
easily pick the exact behavior they want.

Revert the change to ReverseProxy when using a Director func.
Users who want a convenient way to set X-Forwarded-* headers to
reasonable values can migrate to Rewrite at their convenience,
and users depending on the current behavior will be unaffected.

For #50465.
Fixes #57132.

Change-Id: Ic42449c1bb525d6c9920bf721efbc519697f4f20
Reviewed-on: https://go-review.googlesource.com/c/go/+/457595
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
17 months agosyscall: don't use faccessat2 on android
Michael Pratt [Tue, 20 Dec 2022 16:25:38 +0000 (11:25 -0500)]
syscall: don't use faccessat2 on android

The Android seccomp policy does not allow faccessat2, so attempting to
use it results in a SIGSYS. Avoid it and go straight to the fallback.

Fixes #57393.

Change-Id: I8d4e12a6f46cea5642d3b5b5a02c682529882f29
Reviewed-on: https://go-review.googlesource.com/c/go/+/458495
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Changkun Ou <mail@changkun.de>
Run-TryBot: Michael Pratt <mpratt@google.com>

17 months agonet: use correct dns msg size
Mateusz Poliwczak [Tue, 20 Dec 2022 15:24:06 +0000 (15:24 +0000)]
net: use correct dns msg size

Set bufSize to the actual dns message size, so that the p.Start (below) gets a fully valid dns message.

Change-Id: I585e8a3d71f88db93e09bd0dbbc0875ee6de9a97
GitHub-Last-Rev: 0967be35012d2e28366e6d47eee4968c7e8d5e4a
GitHub-Pull-Request: golang/go#57392
Reviewed-on: https://go-review.googlesource.com/c/go/+/458375
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: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
17 months agoos: reenable TestReaddirSmallSeek on windows
qmuntal [Mon, 19 Dec 2022 13:41:09 +0000 (14:41 +0100)]
os: reenable TestReaddirSmallSeek on windows

TestReaddirSmallSeek should have been reenabled as part of
CL 405275, but didn't. Do it now.

Updates #36019

Change-Id: I5676eee4e63675d30e9d48ac708e72bd036b6aee
Reviewed-on: https://go-review.googlesource.com/c/go/+/458336
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
17 months agocmd/compile: sign-extend the 2nd argument of the LoweredAtomicCas32 on loong64,mips64...
Guoqi Chen [Sun, 18 Dec 2022 21:04:48 +0000 (05:04 +0800)]
cmd/compile: sign-extend the 2nd argument of the LoweredAtomicCas32 on loong64,mips64x,riscv64

The function LoweredAtomicCas32 is implemented using the LL-SC instruction pair
on loong64, mips64x, riscv64. However,the LL instruction on loong64, mips64x,
riscv64 is sign-extended, so it is necessary to sign-extend the 2nd parameter
"old" of the LoweredAtomicCas32, so that the instruction BNE after LL can get
the desired result.

The function prototype of LoweredAtomicCas32 in golang:
    func Cas32(ptr *uint32, old, new uint32) bool

When using an intrinsify implementation:
    case 1: (*ptr) <= 0x80000000 && old < 0x80000000
        E.g: (*ptr) = 0x7FFFFFFF, old = Rarg1= 0x7FFFFFFF

        After run the instruction "LL (Rarg0), Rtmp": Rtmp = 0x7FFFFFFF
        Rtmp ! = Rarg1(old) is false, the result we expect

    case 2: (*ptr) >= 0x80000000 && old >= 0x80000000
        E.g: (*ptr) = 0x80000000, old = Rarg1= 0x80000000

        After run the instruction "LL (Rarg0), Rtmp": Rtmp = 0xFFFFFFFF_80000000
        Rtmp ! = Rarg1(old) is true, which we do not expect

When using an non-intrinsify implementation:
    Because Rarg1 is loaded from the stack using sign-extended instructions
    ld.w, the situation described in Case 2 above does not occur

Benchmarks on linux/loong64:
name     old time/op  new time/op  delta
Cas      50.0ns ± 0%  50.1ns ± 0%   ~     (p=1.000 n=1+1)
Cas64    50.0ns ± 0%  50.1ns ± 0%   ~     (p=1.000 n=1+1)
Cas-4    56.0ns ± 0%  56.0ns ± 0%   ~     (p=1.000 n=1+1)
Cas64-4  56.0ns ± 0%  56.0ns ± 0%   ~     (p=1.000 n=1+1)

Benchmarks on Loongson 3A4000 (GOARCH=mips64le, 1.8GHz)
name     old time/op  new time/op  delta
Cas      70.4ns ± 0%  70.3ns ± 0%   ~     (p=1.000 n=1+1)
Cas64    70.7ns ± 0%  70.6ns ± 0%   ~     (p=1.000 n=1+1)
Cas-4    81.1ns ± 0%  80.8ns ± 0%   ~     (p=1.000 n=1+1)
Cas64-4  80.9ns ± 0%  80.9ns ± 0%   ~     (p=1.000 n=1+1)

Fixes #57282

Change-Id: I190a7fc648023b15fa392f7fdda5ac18c1561bac
Reviewed-on: https://go-review.googlesource.com/c/go/+/457135
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
17 months agoos/user,net: add -fno-stack-protector to CFLAGS
Than McIntosh [Mon, 12 Dec 2022 15:53:17 +0000 (10:53 -0500)]
os/user,net: add -fno-stack-protector to CFLAGS

Some compilers default to having -fstack-protector on, which breaks
when using internal linking because the linker doesn't know how to
find the support functions.

Updates #52919.
Updates #54313.
Fixes #57261.

Change-Id: Iaae731851407af4521fff2dfefc5b7e3e92cf284
Reviewed-on: https://go-review.googlesource.com/c/go/+/456855
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
17 months agonet/http: improve errors in TestCancelRequestWhenSharingConnection
Damien Neil [Wed, 14 Dec 2022 23:49:58 +0000 (15:49 -0800)]
net/http: improve errors in TestCancelRequestWhenSharingConnection

Provide more information about why this test might be hanging waiting
for PutIdleConn to be called (#56587): If the round trip that should
result in PutIdleConn being invoked completes, report that to the
goroutine waiting for PutIdleConn.

For #56587

Change-Id: Ie476ea0ce4a48d2bda6b9b109f89d675a10e7e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/457775
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
17 months agosyscall, internal/poll: fall back to accept on linux-arm
Ian Lance Taylor [Thu, 15 Dec 2022 21:54:33 +0000 (13:54 -0800)]
syscall, internal/poll: fall back to accept on linux-arm

Our minimum Linux version is 2.6.32, and the accept4 system call was
introduced in 2.6.28, so we use accept4 everywhere. Unfortunately,
it turns out that the accept4 system call was only added to
linux-arm in 2.6.36, so for linux-arm only we need to try the accept4
system call and then fall back to accept if it doesn't work.

The code we use on linux-arm is the code we used in Go 1.17.
On non-arm platforms we continue using the simpler code introduced
in Go 1.18.

Adding accept4 to the ARM Linux kernel was:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=21d93e2e29722d7832f61cc56d73fb953ee6578e

Fixes #57333

Change-Id: I6680cb54dd4d3514a6887dda8906e6708c64459d
Reviewed-on: https://go-review.googlesource.com/c/go/+/457995
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@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>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agoos/exec: retry ETXTBSY errors in TestFindExecutableVsNoexec
Bryan C. Mills [Thu, 15 Dec 2022 22:09:00 +0000 (17:09 -0500)]
os/exec: retry ETXTBSY errors in TestFindExecutableVsNoexec

I made this test parallel in CL 439196, which exposed it to the
fork/exec race condition described in #22315. The ETXTBSY errors from
that race should resolve on their own, so we can simply retry the call
to get past them.

Fixes #56811.
Updates #22315.

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

17 months agodoc/go1.20: fix typo
Robert Griesemer [Thu, 15 Dec 2022 17:10:20 +0000 (09:10 -0800)]
doc/go1.20: fix typo

Change-Id: Icddf980e533b86ca955660ad028f5ad04b6aecbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/457916
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
17 months agospec: fix typo
Robert Griesemer [Thu, 15 Dec 2022 16:15:06 +0000 (08:15 -0800)]
spec: fix typo

Fixes #57323.

Change-Id: I77d3d747aa4746bb9a8cca0c0500ff8fa6ae33a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/457915
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
17 months agospec: document which recursive arrays and structs are valid/invalid
Robert Griesemer [Wed, 14 Dec 2022 05:16:09 +0000 (21:16 -0800)]
spec: document which recursive arrays and structs are valid/invalid

Fixes #5069.

Change-Id: I4bc0f52a9cd1e64a49846dffeb4be5cbecc29a96
Reviewed-on: https://go-review.googlesource.com/c/go/+/457342
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
17 months agodoc/go1.20.html: pre-announce dropping Windows 7, 8, and friends
Heschi Kreinick [Wed, 14 Dec 2022 19:55:30 +0000 (14:55 -0500)]
doc/go1.20.html: pre-announce dropping Windows 7, 8, and friends

For #57003, #57004.

Change-Id: Ic1386a0ce83897411fbc68c83a9125af1cc11b54
Reviewed-on: https://go-review.googlesource.com/c/go/+/457695
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agocmd/compile: desugar OCALLMETH->OCALLFUNC within devirtualization
Matthew Dempsky [Wed, 14 Dec 2022 19:48:02 +0000 (11:48 -0800)]
cmd/compile: desugar OCALLMETH->OCALLFUNC within devirtualization

Devirtualization can turn OCALLINTER into OCALLMETH, but then we want
to actually desugar into OCALLFUNC instead for later phases. Just
needs a missing call to typecheck.FixMethodCall.

Fixes #57309.

Change-Id: I331fbd40804e1a370134ef17fa6dd501c0920ed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/457715
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agospec: document illegal recursive type parameter lists
Robert Griesemer [Wed, 14 Dec 2022 01:41:19 +0000 (17:41 -0800)]
spec: document illegal recursive type parameter lists

Fixes #40882.

Change-Id: I90f99d75e6d66f857b6ab8789c6d436f85d20993
Reviewed-on: https://go-review.googlesource.com/c/go/+/457515
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
17 months agospec: describe new semantics for comparable and constraint satisfaction
Robert Griesemer [Tue, 13 Dec 2022 21:59:12 +0000 (13:59 -0800)]
spec: describe new semantics for comparable and constraint satisfaction

For #56548.
Fixes #57012.

Change-Id: I44f850522e52b1811025fb31bcef289da8f8089d
Reviewed-on: https://go-review.googlesource.com/c/go/+/457437
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
17 months agospec: introduce notion of strict comparability
Robert Griesemer [Tue, 13 Dec 2022 00:30:42 +0000 (16:30 -0800)]
spec: introduce notion of strict comparability

- Rephrase the notion of "comparability" from a property
  of values (operands) to a property of types and adjust
  dependent prose.
- Introduce the notion of "strict comparability".
- Fix the definitions of comparability for type interfaces
  and type parameters.
- Define the predeclared identifier "comparable" as stricly
  comparable.

These changes address existing problems in the spec as outlined
in the section on "Related spec issues" in issue #56548.

For #56548.

Change-Id: Ibc8c2f36d92857a5134eadc18358624803d3dd21
Reviewed-on: https://go-review.googlesource.com/c/go/+/457095
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
17 months agosyscall: fix closing of reordered FDs in plan9 ForkExec
miller [Tue, 13 Dec 2022 10:43:23 +0000 (10:43 +0000)]
syscall: fix closing of reordered FDs in plan9 ForkExec

After dup'ing file descriptors in syscall.ProcAttr.Files to pass
to the exec'ed process, the logic for closing the old descriptors
was incorrect and could close the new descriptor instead.

Fixes #57180

Change-Id: I7725f21a465ffba57050fe4e36f3d36ba181cfb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/457115
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
17 months agogo/types, types2: report type mismatch error when conversion is impossible
Robert Griesemer [Mon, 12 Dec 2022 21:36:44 +0000 (13:36 -0800)]
go/types, types2: report type mismatch error when conversion is impossible

Rather than reporting an impossible conversion error when mixing an
untyped value with a pointer type in an operation, report a type
mismatch error. This fixes a regression in error quality compared
to pre-1.18.

For the fix, clean up the implementation of canMix, add documentation,
and give it a better name.

Adjust test case for corresponding error code bacause we now get a
better error message (and error code) for the old error code example.

Fixes #57160.

Change-Id: Ib96ce7cbc44db6905fa2f1c90a3769af609e101b
Reviewed-on: https://go-review.googlesource.com/c/go/+/457055
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
17 months agocmd/gc: test temp string comparison with all ops
Oleg Zaytsev [Fri, 9 Dec 2022 12:05:34 +0000 (13:05 +0100)]
cmd/gc: test temp string comparison with all ops

The comment on `slicebytetostringtmp` mention that `==` operator does
not allocate []byte to string conversion, but the test was testing only
`==` and `!=` and the compiler actually optimizes all comparison
operators.

Also added a test for concatenation comparison, which also should not
allocate.

Change-Id: I6f4c5c4f238808138fa901732e1fd5b6ab25f725
Reviewed-on: https://go-review.googlesource.com/c/go/+/456415
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
17 months agosyscall: skip TestUseCgroupFD if cgroupfs mounted RO
Paul E. Murphy [Mon, 12 Dec 2022 15:31:59 +0000 (09:31 -0600)]
syscall: skip TestUseCgroupFD if cgroupfs mounted RO

The skipping logic should also trigger if /sys/fs/cgroup is
mounted read-only too. This is how it is mounted on the
ppc64le/p10 containers today.

Fixes #57262

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

17 months agosyscall: fix shadowing bugs in forkAndExecInChild
Bryan C. Mills [Fri, 9 Dec 2022 17:25:22 +0000 (12:25 -0500)]
syscall: fix shadowing bugs in forkAndExecInChild

Fixes #57208.
Updates #23152.

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

17 months agosync: remove unused const
Changkun Ou [Fri, 9 Dec 2022 17:19:52 +0000 (18:19 +0100)]
sync: remove unused const

Change-Id: I4382b5317cf7f39a48005516ff6d437883c6fd07
Reviewed-on: https://go-review.googlesource.com/c/go/+/456495
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Changkun Ou <mail@changkun.de>

17 months agodoc/go1.20: fix typo
Alexander Frolov [Fri, 9 Dec 2022 07:56:21 +0000 (07:56 +0000)]
doc/go1.20: fix typo

Change-Id: Id0319a9cc9acc549022fdcd6b7d71c7343afd245
GitHub-Last-Rev: 2b84d25763c3f8a03663d4ba75cefa4a372fefbd
GitHub-Pull-Request: golang/go#57187
Reviewed-on: https://go-review.googlesource.com/c/go/+/456395
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: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
17 months agodebug/buildinfo: check pointer size on buildinfo.Read
Nikola Jokic [Fri, 2 Dec 2022 16:42:48 +0000 (17:42 +0100)]
debug/buildinfo: check pointer size on buildinfo.Read

Previous implementation has a check on pointer size but only if ptrSize
is 4. but it does not check on ptrSize 8 causing the panic on read for
some inputs.

The explicit check for pointer size 8 is added and error is returned if
ptrSize is not 4 and not 8.

Fixes #57002

Change-Id: Id51de72bdef4da9955d086bfc2a5d735678ee2ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/454616
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
17 months agodoc/go1.20: fix URL anchor
Shengyu Zhang [Thu, 8 Dec 2022 18:39:06 +0000 (18:39 +0000)]
doc/go1.20: fix URL anchor

The URL anchor was invalid. Add the missing "array_or_" part.

Change-Id: Ib27f4d0f21b0148bea8b63ef962ba0ea30166ed3
GitHub-Last-Rev: f8addc607812290ebbdbb1560f336f56390d0d8d
GitHub-Pull-Request: golang/go#57154
Reviewed-on: https://go-review.googlesource.com/c/go/+/456175
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

17 months agocmd/compile: fix conditional move rule on PPC64
Keith Randall [Sat, 10 Dec 2022 03:49:53 +0000 (19:49 -0800)]
cmd/compile: fix conditional move rule on PPC64

Similar to CL 456556 but for ppc64 instead of arm64.

Change docs about how booleans are stored in registers for ppc64.
We now don't promise to keep the upper bits zeroed; they might be junk.

To test, I changed the boolean generation instructions (MOVBZload* and ISEL*
with boolean type) to OR in 0x100 to the result. all.bash still passed,
so I think nothing else is depending on the upper bits of booleans.

Update #57184

Change-Id: Ie66f8934a0dafa34d0a8c2a37324868d959a852c
Reviewed-on: https://go-review.googlesource.com/c/go/+/456437
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: KAMPANAT THUMWONG (KONG PC) <1992kongpc.kth@gmail.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>

17 months agoos: skip size test in TestLstat if the file is a symlink
Ian Lance Taylor [Fri, 9 Dec 2022 19:22:32 +0000 (11:22 -0800)]
os: skip size test in TestLstat if the file is a symlink

Tested by temporarily changing sysdir to use a directory where
the expected files were all symlinks. We should consider using
a different approach that doesn't rely on sysdir, but for now
do a minimal fix.

Fixes #57210

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

17 months agocmd/compile: fix conditional select rule
Keith Randall [Fri, 9 Dec 2022 18:55:28 +0000 (10:55 -0800)]
cmd/compile: fix conditional select rule

ARM64 maintains booleans in the low byte of registers. Upper parts
of that register are junk.
This rule is using all 32 bits of a boolean-containing register, which
is wrong. Change the rule to only look at the low bit.

Fixes #57184

Change-Id: Ibbef86b2be859df3d06d993db00e1231c481c428
Reviewed-on: https://go-review.googlesource.com/c/go/+/456556
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

17 months agodoc: fix typo in 1.20 release notes
Than McIntosh [Thu, 8 Dec 2022 19:31:38 +0000 (14:31 -0500)]
doc: fix typo in 1.20 release notes

Fix typo.

Change-Id: Id3a78ac5d8ea429ba1685889cd1661aaca8572c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/456238
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
17 months agoos/user: zero-initialize C structs returned to Go
Bryan C. Mills [Thu, 8 Dec 2022 15:47:03 +0000 (10:47 -0500)]
os/user: zero-initialize C structs returned to Go

In the wrappers for getgrnam_r and similar, the structs to be returned
are allocated on the C stack and may be uninitialized. If the call to
the wrapped C function returns an error (such as ERANGE), it may leave
the struct uninitialized, expecting that the caller will not read it.

However, when that struct is returned to Go, it may be read by the Go
garbage collector. If the uninitialized struct fields happen to
contain wild pointers, the Go garbage collector will throw an error.
(Prior to CL 449335, the Go runtime would not scan the struct fields
because they did not reside in Go memory.)

Fix this by always zeroing the struct before the C call.

Fixes #57170.

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

17 months agogo/types, types2: always rename type parameters during inference
Robert Findley [Thu, 8 Dec 2022 15:03:03 +0000 (10:03 -0500)]
go/types, types2: always rename type parameters during inference

Type inference uses a trick of "renaming" type parameters in the type
parameter list to avoid cycles during unification. This separates the
identity of type parameters from type arguments. When this trick was
introduced in CL 385494, we restricted its application to scenarios
where inference is truly self-recursive: the type parameter list being
inferred was the same as the type parameter list of the outer function
declaration. Unfortunately, the heuristic used to determine
self-recursiveness was flawed: type-checking function literals clobbers
the type-checker environment, losing information about the outer
signature.

We could fix this by introducing yet more state into the type-checker
(e.g. a 'declSig' field that would hold the signature of the active
function declaration), but it is simpler to just avoid this optimization
and always perform type parameter renaming. We can always optimize
later.

This CL removes the check for true self-recursion, always performing the
renaming.

Fixes golang/go#57155

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

17 months agodoc: fix typo
Zhizhen He [Mon, 5 Dec 2022 17:22:01 +0000 (17:22 +0000)]
doc: fix typo

Change-Id: Ie639fe39b83336c0d885cdcb2fddc06f2b06c2dd
GitHub-Last-Rev: b5cc78ad42ee57d77cf027cc5fb6840eb38a0f1b
GitHub-Pull-Request: golang/go#57082
Reviewed-on: https://go-review.googlesource.com/c/go/+/455196
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

17 months agodoc/go1.20: correct test binary -v flag value for test2json
Dmitri Shuralyov [Thu, 8 Dec 2022 17:53:26 +0000 (12:53 -0500)]
doc/go1.20: correct test binary -v flag value for test2json

The -v flag value is "test2json", not "json", since it emits output
in a custom format that the cmd/test2json tool interprets.
The cmd/test2json documentation and implementation have this right.

For #54202.

Change-Id: I2b52861d926e14488aa9fc89fff8c26da32ca710
Reviewed-on: https://go-review.googlesource.com/c/go/+/456124
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
17 months agocmd/{go,cover,covdata}: fix 'package main' inconsistent handling
Than McIntosh [Thu, 8 Dec 2022 15:58:49 +0000 (10:58 -0500)]
cmd/{go,cover,covdata}: fix 'package main' inconsistent handling

Fix a buglet in cmd/cover in how we handle package name/path for the
"go build -o foo.exe *.go" and "go run *.go" cases.

The go command assigns a dummy import path of "command-line-arguments"
to the main package built in these cases; rather than expose this
dummy to the user in coverage reports, the cover tool had a special
case hack intended to rewrite such package paths to "main". The hack
was too general, however, and was rewriting the import path of all
packages with (p.name == "main") to an import path of "main". The hack
also produced unexpected results for cases such as

  go test -cover foo.go foo_test.go

This patch removes the hack entirely, leaving the package path for
such cases as "command-line-arguments".

Fixes #57169.

Change-Id: Ib6071db5e3485da3b8c26e16ef57f6fa1712402c
Reviewed-on: https://go-review.googlesource.com/c/go/+/456237
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
17 months agocmd/link: fix dynamic interpreter path for musl-based linux amd64
cia-rana [Thu, 8 Dec 2022 06:19:39 +0000 (15:19 +0900)]
cmd/link: fix dynamic interpreter path for musl-based linux amd64

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

17 months agoruntime: remove arbitrary timeouts in finalizer tests
Bryan C. Mills [Thu, 8 Dec 2022 13:24:57 +0000 (08:24 -0500)]
runtime: remove arbitrary timeouts in finalizer tests

These short timeouts can overrun due to system scheduling delay
(or GC latency) on a slow or heavily-loaded host.

Moreover, if the test deadlocks we will probably want to know what the
GC goroutines were doing at the time. With an arbitrary timeout, we
never get that information; however, if we allow the test to time out
completely we will get a goroutine dump (and, if GOTRACEBACK is
configured in the environment, that may even include GC goroutines).

Fixes #57166.

Change-Id: I136501883373c3ce4e250dc8340c60876b375f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/456118
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
17 months agocmd/go: deflake TestScript/test2json_interrupt
Bryan C. Mills [Wed, 7 Dec 2022 21:33:42 +0000 (16:33 -0500)]
cmd/go: deflake TestScript/test2json_interrupt

- Start handling signals in 'go test' just before starting the test
  subprocess instead of just after. (It is unlikely that starting the
  process will cause cmd/go to hang in a way that requires signals to
  debug, and it is possible that something the test does — such as
  sending os.Interrupt to its parent processes — will immediately
  send a signal that needs to be handled.)

- In the test-test, don't try to re-parse the parent PIDs after
  sending signals, and sleep for a much shorter time interval.
  (Overrunning the sleep caused the next call to strconv.Atoi — which
  shouldn't even happen! — to fail with a parse error, leading to the
  failure mode observed in
  https://build.golang.org/log/f0982dcfc6a362f9c737eec3e7072dcc7ef29e32.)

Fixes #56083.
Updates #53563.

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

17 months agoos/user: on AIX getpwuid_r seems to return -1 on overflow
Ian Lance Taylor [Wed, 7 Dec 2022 21:27:22 +0000 (13:27 -0800)]
os/user: on AIX getpwuid_r seems to return -1 on overflow

The getpwuid_r function is expected to return ERANGE on overflow.
Accept -1 on AIX as we see that in practice.

This problem was uncovered by, but not caused by, CL 455815,
which introduced a test that forced a buffer overflow.

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

17 months agointernal/safefilepath: fix TestFromFS on Plan 9
David du Colombier [Wed, 7 Dec 2022 14:20:25 +0000 (15:20 +0100)]
internal/safefilepath: fix TestFromFS on Plan 9

CL 455716 added TestFromFS. This test was failing on Plan 9
because fromFS didn't return an empty string in case of error.

This change fixes TestFromFS by returning an empty string
in case of error.

Fixes #57142.

Change-Id: Ie50dfba5e70154d641f762fa43f1c26c3d12b6f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/455835
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: David du Colombier <0intro@gmail.com>

17 months agocmd/go: in TestTerminalPassthrough, delay subprocess exit until the PTY has been...
Bryan C. Mills [Wed, 7 Dec 2022 16:18:50 +0000 (11:18 -0500)]
cmd/go: in TestTerminalPassthrough, delay subprocess exit until the PTY has been read

Empirically, unread PTY output may be discarded on macOS when the
child process exits.

Fixes #57141.

Tested with 'go test cmd/go -run=TestTerminalPassthrough -count=1000'
on a darwin-amd64-12_0 gomote.

Change-Id: I11508e6429c61488f30e10d9ae0cc94fdf059257
Reviewed-on: https://go-review.googlesource.com/c/go/+/455915
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
17 months agoapi: promote next to go1.20
Michael Pratt [Tue, 6 Dec 2022 16:55:54 +0000 (11:55 -0500)]
api: promote next to go1.20

Change-Id: I180f262837b164095f9ac9459d900ec1ac0585a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/455697
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agodoc/go1.20: delete remaining TODO
Michael Pratt [Wed, 7 Dec 2022 16:24:49 +0000 (11:24 -0500)]
doc/go1.20: delete remaining TODO

This section is complete.

For #54202.

Change-Id: I304cc55a5b8ed53e8b8dff73a5feb5ef39207846
Reviewed-on: https://go-review.googlesource.com/c/go/+/455895
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agodoc/go1.20: add section on coverage
Than McIntosh [Wed, 30 Nov 2022 17:04:59 +0000 (12:04 -0500)]
doc/go1.20: add section on coverage

Add some basic material on the changes to code coverage testing
to the release notes.

For #54202.

Change-Id: I28200d43b4952ce8e8ecf46c8fe8e97c81d245e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/453857
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
17 months agoos/user: fix buffer retry loop on macOS
Russ Cox [Wed, 7 Dec 2022 14:18:11 +0000 (09:18 -0500)]
os/user: fix buffer retry loop on macOS

getpwnam_r and friends return the errno as the result,
not in the global errno. The code changes in CL 449316
inadvertently started using the global errno.
So if a lookup didn't fit in the first buffer size,
it was treated as not found instead of growing the buffer.

Fixes #56942.

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

17 months agodoc/go1.20: relnote and take care of TODOs
Russ Cox [Tue, 6 Dec 2022 23:54:11 +0000 (18:54 -0500)]
doc/go1.20: relnote and take care of TODOs

The main change here is documenting the last-minute addition types.Satisfies.

Change-Id: I8be2d2ad730ba108706bd849b68cbd1f4d68a4b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/455698
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
17 months agogo/internal/gcimporter: simplify unified IR importer
Matthew Dempsky [Thu, 18 Aug 2022 20:47:43 +0000 (13:47 -0700)]
go/internal/gcimporter: simplify unified IR importer

CL 424854 changed the unified IR writer's handling of type
declarations to write the underlying type rather than the RHS type
expression's type. This in turn allows us to simplify the go/types
importer, because now there's no need to delay caling SetUnderlying.

Fixes #57015.

Change-Id: I80caa61f6cad5b7f9d829939db733a66cfca621c
Reviewed-on: https://go-review.googlesource.com/c/go/+/424876
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
17 months agocmd/compile: restore test/nested.go test cases
Matthew Dempsky [Thu, 18 Aug 2022 18:04:21 +0000 (11:04 -0700)]
cmd/compile: restore test/nested.go test cases

[Re-land of CL 424854, which was reverted as CL 425214.]

When handling a type declaration like:

```
type B A
```

unified IR has been writing out that B's underlying type is A, rather
than the underlying type of A.

This is a bit awkward to implement and adds complexity to importers,
who need to handle resolving the underlying type themselves. But it
was necessary to handle when A was declared like:

```
//go:notinheap
type A int
```

Because we expected A's not-in-heap'ness to be conferred to B, which
required knowing that A was on the path from B to its actual
underlying type int.

However, since #46731 was accepted, we no longer need to support this
case. Instead we can write out B's actual underlying type.

One stumbling point though is the existing code for exporting
interfaces doesn't work for the underlying type of `comparable`, which
is now needed to implement `type C comparable`. As a bit of a hack, we
we instead export its underlying type as `interface{ comparable }`.

Fixes #54512.

Change-Id: I9aa087e0a277527003195ebc7f4fbba6922e788c
Reviewed-on: https://go-review.googlesource.com/c/go/+/455279
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
17 months agoall: update vendored golang.org/x/net
Damien Neil [Tue, 6 Dec 2022 22:04:32 +0000 (14:04 -0800)]
all: update vendored golang.org/x/net

Pull in HTTP/2 security fix:

1e63c2f08a http2: limit canonical header cache by bytes, not entries

Fixes #56350

Change-Id: Ib14024ed894ba266f05d4a6e8c454234a45677d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/455717
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agolib/time: update to 2022g/2022g
Russ Cox [Tue, 6 Dec 2022 04:07:54 +0000 (23:07 -0500)]
lib/time: update to 2022g/2022g

Commit generated by update.bash.

For #22487.

Change-Id: I6a995a3baea7c511b9bd5155f81d8b8e2cdff09d
Reviewed-on: https://go-review.googlesource.com/c/go/+/455356
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agoos, net/http: avoid escapes from os.DirFS and http.Dir on Windows
Damien Neil [Thu, 10 Nov 2022 20:16:27 +0000 (12:16 -0800)]
os, net/http: avoid escapes from os.DirFS and http.Dir on Windows

Do not permit access to Windows reserved device names (NUL, COM1, etc.)
via os.DirFS and http.Dir filesystems.

Avoid escapes from os.DirFS(`\`) on Windows. DirFS would join the
the root to the relative path with a path separator, making
os.DirFS(`\`).Open(`/foo/bar`) open the path `\\foo\bar`, which is
a UNC name. Not only does this not open the intended file, but permits
reference to any file on the system rather than only files on the
current drive.

Make os.DirFS("") invalid, with all file access failing. Previously,
a root of "" was interpreted as "/", which is surprising and probably
unintentional.

Fixes CVE-2022-41720
Fixes #56694

Change-Id: I275b5fa391e6ad7404309ea98ccc97405942e0f0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1663834
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/455362
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/455716
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>

17 months agoRevert "runtime/pprof: unskip TestTimeVDSO on Android"
Cherry Mui [Tue, 6 Dec 2022 21:47:29 +0000 (21:47 +0000)]
Revert "runtime/pprof: unskip TestTimeVDSO on Android"

This reverts CL 455358, commit 98da0fb43fb481a25b3b4399cd9f517fe94d9f3f.

Reason for revert: still failing https://build.golang.org/log/c9f13a76069f523b5b4a37a75ec52b30a1f3427a

Change-Id: I8246d233c4fb86781b882f19dea82065cc21bc26
Reviewed-on: https://go-review.googlesource.com/c/go/+/455696
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
17 months agocmd/go: unskip TestScript/build_issue48319 on Windows
Bryan C. Mills [Fri, 2 Dec 2022 21:41:23 +0000 (16:41 -0500)]
cmd/go: unskip TestScript/build_issue48319 on Windows

Now that we have newer C compilers on the Windows builders, they
should fully support reproducible builds.

Updates #35006.

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

17 months agoarchive/zip: only consider UncompressedSize when checking dirs
Roland Shoemaker [Tue, 6 Dec 2022 19:58:10 +0000 (11:58 -0800)]
archive/zip: only consider UncompressedSize when checking dirs

CL 454475 switched from checking CompressedSize to UncompressedSize
when determining if we should consider an archive malformed because
it contains data and added a test for an example of this (a JAR). We
should also remove the hasDataDescriptor check, since that is basically
an alias for CompressedSize > 0. The test didn't catch this because we
didn't actually attempt to read from the returned reader.

Change-Id: Ibc4c1aa9c3a733f3ebf4a956d1e2f8f4900a29cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/455523
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agorun.bash, cmd/dist: document GO_TEST_SHORT and GO_TEST_TIMEOUT_SCALE
Dmitri Shuralyov [Fri, 2 Dec 2022 18:30:06 +0000 (13:30 -0500)]
run.bash, cmd/dist: document GO_TEST_SHORT and GO_TEST_TIMEOUT_SCALE

These environment variables affect cmd/dist, and in turn run.bash.
They exist primarily for the Go build system, but are still needed
sometimes when investigating problems. Document them in one place.

Fixes #46054.

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

17 months agogo/types, types2: better error message for invalid method expression
Robert Griesemer [Tue, 6 Dec 2022 00:17:56 +0000 (16:17 -0800)]
go/types, types2: better error message for invalid method expression

Fixes #53358.

Change-Id: I38528da1596b6e1aaedcab89b1513fb8acac596c
Reviewed-on: https://go-review.googlesource.com/c/go/+/455335
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
17 months agoruntime/pprof: unskip TestTimeVDSO on Android
Cherry Mui [Tue, 6 Dec 2022 17:11:57 +0000 (12:11 -0500)]
runtime/pprof: unskip TestTimeVDSO on Android

It is possible that CL 455166 fixes this. Try unskipping the test
and see. If it fails again we can skip it again.

Fixes #48655.

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

17 months agocmd/link: pass -Wl,--no-insert-timestamp to external linker on windows
Than McIntosh [Tue, 6 Dec 2022 15:22:09 +0000 (10:22 -0500)]
cmd/link: pass -Wl,--no-insert-timestamp to external linker on windows

Pass -Wl,--no-insert-timestamp to the external linker on windows, so
as to suppress generation of the PE file header data/time stamp. This
is in order to make it possible to get reproducible CGO builds on
windows (note that we already zero the timestamp field in question for
internal linkage).

Updates #35006.

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

17 months agocmd/compile: turn off jump tables when spectre retpolines are on
Keith Randall [Tue, 6 Dec 2022 00:26:26 +0000 (16:26 -0800)]
cmd/compile: turn off jump tables when spectre retpolines are on

Fixes #57097

Change-Id: I6ab659abbca1ae0ac8710674d39aec116fab0baa
Reviewed-on: https://go-review.googlesource.com/c/go/+/455336
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

17 months agocmd/asm: improve assembler error messages
Keith Randall [Mon, 5 Dec 2022 19:19:51 +0000 (11:19 -0800)]
cmd/asm: improve assembler error messages

Provide file/line numbers for errors when we have them.
Make the assembler error text closer to the equivalent errors from the compiler.

Abort further processing when we come across errors.
Fixes #53994

Change-Id: I4d6a037d6d713c1329923fce4c1189b5609f3660
Reviewed-on: https://go-review.googlesource.com/c/go/+/455276
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agogo/types, types2: better error message for failing constraint type inference
Robert Griesemer [Mon, 5 Dec 2022 22:09:09 +0000 (14:09 -0800)]
go/types, types2: better error message for failing constraint type inference

We know the type argument against which constraint type inference fails:
print the type argument instead of the corresponding type parameter.

Fixes #57096.

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

17 months agocmd/compile: clean up amd64 opcode comments
Keith Randall [Sun, 11 Sep 2022 21:26:10 +0000 (14:26 -0700)]
cmd/compile: clean up amd64 opcode comments

Put comments about what operations do per block of related opcodes
instead of on each line. This is less repetitive and lets us be a bit
more verbose in our descriptions.

Doesn't change the generated code at all.

Change-Id: I98fbd4029df6537b10aac2113a00df121d0fca1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/433736
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
17 months agoruntime: prioritize VDSO and libcall unwinding in profiler
Cherry Mui [Mon, 5 Dec 2022 18:02:22 +0000 (13:02 -0500)]
runtime: prioritize VDSO and libcall unwinding in profiler

In the profiler, when unwinding the stack, we have special
handling for VDSO calls. Currently, the special handling is only
used when the normal unwinding fails. If the signal lands in the
function that makes the VDSO call (e.g. nanotime1) and after the
stack switch, the normal unwinding doesn't fail but gets a stack
trace with exactly one frame (the nanotime1 frame). The stack
trace stops because of the stack switch. This 1-frame stack trace
is not as helpful. Instead, if vdsoSP is set, we know we are in
VDSO call or right before or after it, so use vdsoPC and vdsoSP
for unwinding. Do the same for libcall.

Also remove _TraceTrap for VDSO unwinding, as vdsoPC and vdsoSP
correspond to a call, not an interrupted instruction.

Fixes #56574.

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

17 months agonet: support context cancellation in resSearch
Mateusz Poliwczak [Sat, 3 Dec 2022 08:14:33 +0000 (08:14 +0000)]
net: support context cancellation in resSearch

As with all the stuff that call cgo from net package.

Change-Id: I7c42ae44a1d47f4f949b203682217498fcdba92a
GitHub-Last-Rev: 70406493bbbe10bf556a17e453623d3decf00822
GitHub-Pull-Request: golang/go#57043
Reviewed-on: https://go-review.googlesource.com/c/go/+/454697
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
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: Ian Lance Taylor <iant@google.com>
17 months agodoc: 1.20 compiler changes
David Chase [Thu, 1 Dec 2022 18:39:23 +0000 (13:39 -0500)]
doc: 1.20 compiler changes

This adds the nonPGO, non-coverage compiler changes
for the 1.20 release.  There's not that much user
visible change.

For #54202.

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

17 months agoruntime/cgo: fix typo in gcc_loong64.S
Cherry Mui [Mon, 5 Dec 2022 18:02:22 +0000 (13:02 -0500)]
runtime/cgo: fix typo in gcc_loong64.S

Fix typo in CL 454838.

Change-Id: I0e91d22cf09949f0bf924ebcf09f1ddac525bac4
Reviewed-on: https://go-review.googlesource.com/c/go/+/455161
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
17 months agoruntime/cgo: add .file directive to GNU assembly files
Cherry Mui [Fri, 2 Dec 2022 18:34:03 +0000 (13:34 -0500)]
runtime/cgo: add .file directive to GNU assembly files

Without it, at least on ARM64 with older BFD linker, it will
include the file of the object file (which is of a temporary path)
as a debug symbol into the binary, causing the build to be
nondeterministic. Adding a .file directive makes it to create a
STT_FILE symbol with deterministic input, and prevent the linker
creating one using the temporary object file path.

Fixes #57035.

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

17 months agoall: fix some comments for method
cui fliter [Mon, 14 Nov 2022 12:13:10 +0000 (20:13 +0800)]
all: fix some comments for method

Change-Id: I4cff6b2a1fed6acdf754539c3c53a61eaa3b3f84
Reviewed-on: https://go-review.googlesource.com/c/go/+/450176
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
17 months agoruntime/debug: add missing period
Russ Cox [Tue, 29 Nov 2022 20:13:52 +0000 (15:13 -0500)]
runtime/debug: add missing period

Pointed out in review of CL 453602,
but it looks like I forgot to re-upload before submitting.

Change-Id: I8f4fac52ea0f904f6f9b06e13fc8ed2e778f2360
Reviewed-on: https://go-review.googlesource.com/c/go/+/454835
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Julie Qiu <julieqiu@google.com>
17 months agodoc/go1.20: preannounce dropping macOS 10.13 and 10.14 support
Heschi Kreinick [Fri, 2 Dec 2022 22:06:15 +0000 (17:06 -0500)]
doc/go1.20: preannounce dropping macOS 10.13 and 10.14 support

For #23011.

Change-Id: I386920928a98403180098f1da5ea7696a239210e
Reviewed-on: https://go-review.googlesource.com/c/go/+/454957
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>

17 months agocmd/go: remove TestScript/version_buildvcs_git_gpg
Bryan C. Mills [Fri, 2 Dec 2022 19:11:00 +0000 (14:11 -0500)]
cmd/go: remove TestScript/version_buildvcs_git_gpg

This was a regression test added for a 'git' command line
used for build stamping. Unfortunately, 'gpg' has proved to
be extremely fragile:

* In recent versions, it appears to always require 'gpg-agent' to be
  installed for anything involving secret keys, but for some reason is
  not normally marked as requiring gpg-agent in Debian's package
  manager.

* It tries to create a Unix domain socket in a subdirectory of $TMPDIR
  without checking the path length, which fails when $TMPDIR is too
  long to fit in the 'sun_path' field of a sockaddr_un struct (which
  typically tops out somewhere between 92 and 108 bytes).

We could theoretically address those by artificially reducing the
script's TMPDIR length and checking for gpg-agent in addition to gpg,
but arguably those should both be fixed upstream instead. On balance,
the incremental value that this test provides does not seem worth the
complexity of dealing with such a fragile third-party tool.

Updates #50675.
Updates #48802.
Fixes #57034.

Change-Id: Ia3288c2f84f8db86ddfa139b4d1c0112d67079ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/454502
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
17 months agocmd/go: skip TestScript/mod_replace_gopkgin
Bryan C. Mills [Fri, 2 Dec 2022 19:52:34 +0000 (14:52 -0500)]
cmd/go: skip TestScript/mod_replace_gopkgin

(Until it can be made hermetic.)

The gopkg.in service has had a lot of flakiness lately. Go users in
general are isolated from that flakiness by the Go module mirror
(proxy.golang.org), but this test intentionally bypasses the module
mirror because the mirror itself uses cmd/go to download the module.

In the long term, we can redirect the gopkg.in URL to the local
(in-process) vcweb server added for #27494.

In the meantime, let's skip the test to reduce the impact of upstream
outages.

For #54503.

Change-Id: Icf3de7ca416db548e53864a71776fe22b444fcea
Reviewed-on: https://go-review.googlesource.com/c/go/+/454503
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
17 months agopath/filepath: make Join("c:", "/a") return "c:/a" again
Damien Neil [Wed, 30 Nov 2022 01:07:02 +0000 (20:07 -0500)]
path/filepath: make Join("c:", "/a") return "c:/a" again

Historically, on Windows filepath.Join("c:", elt) does not insert
a path separator between "c:" and elt, but preserves leading slashes
in elt. Restore this behavior, which was inadvertently changed by
CL 444280.

Fixes #56988

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

17 months agogo/internal/gcimporter: in short tests, avoid creating export data for all of std
Bryan C. Mills [Thu, 1 Dec 2022 20:37:50 +0000 (15:37 -0500)]
go/internal/gcimporter: in short tests, avoid creating export data for all of std

gcimporter.TestImportTypeparamTests still needs to create full export
data because it loads lots of source files from GOROOT/test that
expect to be able to import arbitrary subsets of the standard library,
so we now skip it in short mode.

On a clean build cache, this reduces
'go test -short cmd/compile/internal/importer go/internal/gcimporter'
on my machine from 21–28s per test to <6s per test.

Updates #56967.
Updates #47257.

Change-Id: I8fd80293ab135e0d2d213529b74e0ca6429cdfc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/454498
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
17 months agodoc/go1.20: resolve root bundle package TODO
Roland Shoemaker [Tue, 29 Nov 2022 21:19:27 +0000 (13:19 -0800)]
doc/go1.20: resolve root bundle package TODO

We're unlikely to get this package out of the door all that soon. For
now add a note that SetFallbackRoots will be most commonly used with
an TBA package, and link the tracking issue.

We could also just remove the "It will most commonly be used ..."
sentence.

Change-Id: Ie96134d757f5b4c69f1878d53c92b5ed602671e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/454056
Reviewed-by: Julie Qiu <julieqiu@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>

17 months agomath/big: fix BitLen performance regression
Filippo Valsorda [Fri, 2 Dec 2022 16:58:00 +0000 (17:58 +0100)]
math/big: fix BitLen performance regression

CL 450055 replaced BitLen with a slower constant-time implementation,
which caused a performance regression in some ecosystem benchmarks.

https://perf.golang.org/search?q=upload%3A20221130.13+pkg%3Agithub.com%2Fericlagergren%2Fdecimal%2Fbenchmarks

Current tip vs this CL

name                                   old time/op  new time/op  delta
Pi/foo=ericlagergren_(Go)/prec=100-4    151µs ± 0%   129µs ± 0%  -14.89%  (p=0.000 n=10+9)
Pi/foo=ericlagergren_(GDA)/prec=100-4   305µs ± 0%   269µs ± 1%  -11.88%  (p=0.000 n=9+10)
Pi/foo=cockroachdb/apd/prec=100-4      5.74ms ± 0%  5.33ms ± 0%   -7.02%  (p=0.000 n=9+10)
Pi/foo=shopspring/prec=100-4            265µs ±16%   268µs ±11%     ~     (p=0.796 n=10+10)
Pi/foo=apmckinlay/prec=100-4           3.10µs ± 0%  3.08µs ± 0%   -0.60%  (p=0.000 n=8+10)
Pi/foo=go-inf/prec=100-4                132µs ± 9%   137µs ± 9%     ~     (p=0.182 n=10+9)
Pi/foo=float64/prec=100-4              4.97µs ± 0%  4.98µs ± 0%     ~     (p=0.196 n=10+10)

CL 450055's parent vs this CL

name                                   old time/op  new time/op  delta
Pi/foo=ericlagergren_(Go)/prec=100-4    129µs ± 1%   129µs ± 0%    ~     (p=0.182 n=10+9)
Pi/foo=ericlagergren_(GDA)/prec=100-4   267µs ± 1%   269µs ± 1%  +0.93%  (p=0.001 n=9+10)
Pi/foo=shopspring/prec=100-4            252µs ± 9%   268µs ±11%    ~     (p=0.052 n=10+10)
Pi/foo=apmckinlay/prec=100-4           3.10µs ± 1%  3.08µs ± 0%  -0.66%  (p=0.000 n=9+10)
Pi/foo=go-inf/prec=100-4                135µs ± 6%   137µs ± 9%    ~     (p=0.605 n=9+9)
Pi/foo=float64/prec=100-4              4.97µs ± 0%  4.98µs ± 0%  +0.23%  (p=0.005 n=8+10)

goos: linux
goarch: amd64
pkg: github.com/ericlagergren/decimal_benchmarks
cpu: Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz

Fixes #57014

Change-Id: I08478bea122212320a592ad2652e33077807de09
Reviewed-on: https://go-review.googlesource.com/c/go/+/454617
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

17 months agocmd/api: track darwin arm64 port
Russ Cox [Wed, 23 Nov 2022 21:30:11 +0000 (16:30 -0500)]
cmd/api: track darwin arm64 port

The darwin arm64 port was added in Go 1.16 and is a first-class port,
so it should be tracked by cmd/api. This CL does that, backfilling
API files as needed.

It also removes a spurious cgo.Incomplete API feature.

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

17 months agoencoding/csv: use proper doc comment for Deprecated notes
Russ Cox [Mon, 28 Nov 2022 16:02:52 +0000 (11:02 -0500)]
encoding/csv: use proper doc comment for Deprecated notes

End-of-line comments are not doc comments,
so Deprecated notes in them are not recognized
as deprecation notices. Rewrite the comments.

Change-Id: I275fa9aec403132fda45853e52daa22bc06fcd36
Reviewed-on: https://go-review.googlesource.com/c/go/+/453617
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>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
17 months agoarchive/zip: use proper doc comment for Deprecated notes
Russ Cox [Mon, 28 Nov 2022 16:02:23 +0000 (11:02 -0500)]
archive/zip: use proper doc comment for Deprecated notes

End-of-line comments are not doc comments,
so Deprecated notes in them are not recognized
as deprecation notices. Rewrite the comments.

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

17 months agoarchive/tar: use proper doc comment for Deprecated notes
Russ Cox [Mon, 28 Nov 2022 16:01:36 +0000 (11:01 -0500)]
archive/tar: use proper doc comment for Deprecated notes

End-of-line comments are not doc comments,
so Deprecated notes in them are not recognized
as deprecation notices. Rewrite the comments.

Change-Id: Idb19603d7fc2ec8e3a2f74bacb74fbbec5583d20
Reviewed-on: https://go-review.googlesource.com/c/go/+/453615
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
17 months agocmd/api: track deprecations
Russ Cox [Wed, 23 Nov 2022 18:45:56 +0000 (13:45 -0500)]
cmd/api: track deprecations

Deprecating an API creates notices that go out to potentially
millions of Go developers encouraging them to update their code.
The choice to deprecate an API is as important as the choice to
add a new API. We should track those and make them explicit.
This will also ensure that deprecations go through proposal review.

Change-Id: Ide9f60c32e5a88fb133e0dfedd984b8b0f70f510
Reviewed-on: https://go-review.googlesource.com/c/go/+/453259
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
17 months agoruntime/debug: more complete BuildInfo documentation
Russ Cox [Tue, 29 Nov 2022 20:13:52 +0000 (15:13 -0500)]
runtime/debug: more complete BuildInfo documentation

A potential user did not realize Deps included all transitive dependencies,
not just direct dependencies of the main module. Clarify that and add
various other useful information.

Change-Id: I5b8e1314bb26092edbcc090ba8eb9859f0a70662
Reviewed-on: https://go-review.googlesource.com/c/go/+/453602
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
18 months agogo/internal/gcimporter: load cached export data for packages individually
Bryan C. Mills [Thu, 1 Dec 2022 18:39:39 +0000 (13:39 -0500)]
go/internal/gcimporter: load cached export data for packages individually

Previously, we were using internal/goroot.PkgfileMap to locate
cached export data. However, PkgfileMap regenerates export data
for the entire standard library, whereas gcimporter may only need
a single package.

Under the new approach, we load the export data (still using
'go list -export') for each GOROOT package individually, avoiding work
to rebuild export data for packages that are not needed.
This is a tradeoff: if most packages in GOROOT are actually needed, we
end up making many more calls to 'go list', and may build packages
sequentially instead of in parallel (but with lower latency to start
using the export data from the earlier packages).

On my workstation, starting from a clean cache for each run,
this reduces the wall time of
'go test go/internal/gcimporter -run=TestImportedTypes'
from 22s real time (2m10s user time) to 6s real (27s user),
and only increases 'go test go/internal/gcimporter' from
28s real (2m16s user) to 30s real (2m19s user).

Updates #56967.
Updates #47257.

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

18 months agocmd/dist: remove pkg/$GOOS_$GOARCH and pkg/obj at exit
Michael Matloob [Tue, 29 Nov 2022 23:32:32 +0000 (18:32 -0500)]
cmd/dist: remove pkg/$GOOS_$GOARCH and pkg/obj at exit

pkg/obj will be empty, so just remove it.
pkg/$GOOS_$GOARCH will be empty unless the user has specified
GODEBUG=installgoroot=all, so check if it's empty, and if so, delete
it.

Also remove xreaddirfiles, which is unused.

Also remove the copy of pkg/$GOOS_$GOARCH in the cmd/go test
TestNewReleaseRebuildsStalePackagesInGOPATH. The directory is empty so
copying it has no effect.

For #47257

Change-Id: Ief90b882d157bd16078cd5d2b83a915bfc831f9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/453496
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
18 months agodoc/go1.20: add code tags in crypto/{rsa,subtle} and net/netip sections
Tobias Klauser [Wed, 30 Nov 2022 10:03:47 +0000 (11:03 +0100)]
doc/go1.20: add code tags in crypto/{rsa,subtle} and net/netip sections

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

18 months agonet: acquire thread in resSearch
Mateusz Poliwczak [Thu, 1 Dec 2022 09:26:18 +0000 (09:26 +0000)]
net: acquire thread in resSearch

Change-Id: I042906d8eee8defafbd98f671fd30c2a68281705
GitHub-Last-Rev: 0660c9a989600eeb8652d1228777488d28397731
GitHub-Pull-Request: golang/go#57021
Reviewed-on: https://go-review.googlesource.com/c/go/+/454396
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

18 months agonet: retry with bigger buffer in resSearch
Mateusz Poliwczak [Thu, 1 Dec 2022 17:54:49 +0000 (17:54 +0000)]
net: retry with bigger buffer in resSearch

Glibc returns size > bufSize, when the entire dns reply does not fit inside the provided buffer.

Change-Id: Ie1c1c6a3411880bd8bdb4371f1f1b7bcce837ea2
GitHub-Last-Rev: 488cd3ed0db2a86433aa921117b8f1e9192b1fa5
GitHub-Pull-Request: golang/go#57020
Reviewed-on: https://go-review.googlesource.com/c/go/+/454395
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@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>

18 months agocrypto/des: fix a typo in the comment for permuteFinalBlock
Chaoshuai Lü [Wed, 30 Nov 2022 12:29:46 +0000 (12:29 +0000)]
crypto/des: fix a typo in the comment for permuteFinalBlock

The comment copy pasted from the permuteInitialBlock and should be fixed.

Change-Id: I101f1deceadf9b0480e5b679e4e237bda601950b
GitHub-Last-Rev: 7662df772e4ac171c79467678861ac4d7547da78
GitHub-Pull-Request: golang/go#56982
Reviewed-on: https://go-review.googlesource.com/c/go/+/453995
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>