]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
3 years ago[release-branch.go1.16] go1.16rc1 go1.16rc1
Alexander Rakoczy [Wed, 27 Jan 2021 21:19:02 +0000 (16:19 -0500)]
[release-branch.go1.16] go1.16rc1

Change-Id: I978f6df491a19a9c45ab906dbc5194b8665bf4a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/287352
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agoapi/go1.16: add go/build/constraint APIs
Alexander Rakoczy [Wed, 27 Jan 2021 20:26:02 +0000 (15:26 -0500)]
api/go1.16: add go/build/constraint APIs

These APIs were added in CL 240604 as part of an approved proposal. It
was submitted after the initial api/go1.16.txt creation.

For #41184
For #43407

Change-Id: Ifb54df2b61c554c32bd9d17afbb74f4e42e0b228
Reviewed-on: https://go-review.googlesource.com/c/go/+/287412
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocrypto/x509: remove leftover CertificateRequest field
Roland Shoemaker [Wed, 27 Jan 2021 20:00:46 +0000 (12:00 -0800)]
crypto/x509: remove leftover CertificateRequest field

Removes the KeyUsage field that was missed in the rollback in
CL 281235.
Also updates CreateCertificateRequest to reflect that these fields
were removed.

For #43407.
Updates #43477.
Updates #37172.

Change-Id: I6244aed4a3ef3c2460c38af5511e5c2e82546179
Reviewed-on: https://go-review.googlesource.com/c/go/+/287392
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: make sure to remove open-coded defer entries in all cases after a recover
Dan Scales [Tue, 26 Jan 2021 01:51:03 +0000 (17:51 -0800)]
runtime: make sure to remove open-coded defer entries in all cases after a recover

We add entries to the defer list at panic/goexit time on-the-fly for
frames with open-coded defers. We do this so that we can correctly
process open-coded defers and non-open-coded defers in the correct order
during panics/goexits. But we need to remove entries for open-coded
defers from the defer list when there is a recover, since those entries
may never get removed otherwise and will get stale, since their
corresponding defers may now be processed normally (inline).

This bug here is that we were only removing higher-up stale entries
during a recover if all defers in the current frame were done. But we
could have more defers in the current frame (as the new test case
shows). In this case, we need to leave the current defer entry around
for use by deferreturn, but still remove any stale entries further along
the chain.

For bug 43921, simple change that we should abort the removal loop for
any defer entry that is started (i.e. in process by a still
not-recovered outer panic), even if it is not an open-coded defer.

This change does not fix bug 43920, which looks to be a more complex fix.

Fixes #43882
Fixes #43921

Change-Id: Ie05b2fa26973aa26b25c8899a2abc916090ee4f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/286712
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

3 years agoruntime: block console ctrlhandler when the signal is handled
Nuno Cruces [Wed, 27 Jan 2021 19:02:37 +0000 (19:02 +0000)]
runtime: block console ctrlhandler when the signal is handled

Fixes #41884

I can confirm this change fixes my issue.
I can't confirm that this doesn't break any and everything else.
I see that this code has been tweaked repeatedly, so I would really welcome guidance into further testing.

Change-Id: I1986dd0c2f30cfe10257f0d8c658988d6986f7a6
GitHub-Last-Rev: 92f02c96973e12f1472511bcf3c5ebb36c6b0440
GitHub-Pull-Request: golang/go#41886
Reviewed-on: https://go-review.googlesource.com/c/go/+/261057
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>

3 years agocmd/go: skip issue33139 when the 'cc' script command is unavailable
Nehal J Wani [Wed, 27 Jan 2021 16:24:14 +0000 (16:24 +0000)]
cmd/go: skip issue33139 when the 'cc' script command is unavailable

With CGO disabled, the test suite tries to run the following and fail:

CGO_ENABLED=0 go test -run=TestScript/link_syso_issue33139 cmd/go
go test proxy running at GOPROXY=http://127.0.0.1:38829/mod
--- FAIL: TestScript (0.01s)
    --- FAIL: TestScript/link_syso_issue33139 (0.01s)
        script_test.go:215:
            # Test that we can use the external linker with a host syso file that is
            # embedded in a package, that is referenced by a Go assembly function.
            # See issue 33139. (0.000s)
            # External linking is not supported on linux/ppc64.
            # See: https://github.com/golang/go/issues/8912 (0.000s)
            # External linking is not supported on linux/riscv64.
            # See: https://github.com/golang/go/issues/36739 (0.001s)
            > [linux] [riscv64] skip
            > cc -c -o syso/objTestImpl.syso syso/src/objTestImpl.c
            FAIL: testdata/script/link_syso_issue33139.txt:15:
                unexpected error starting command:
                        fork/exec /dev/null: permission denied

CC was set to /dev/null (during build) in the scenario mentioned above

This patch replaces [!exec:cc] with [!cgo] because we care about the
availability of the 'cc' builtin and not the 'cc' executable in $PATH

Change-Id: Ifbd2441f5f8e903ca3da213aba76f44c2e2eebab
GitHub-Last-Rev: 3b743787d08502f7a936e800ee7b6909fcf56068
GitHub-Pull-Request: golang/go#43912
Reviewed-on: https://go-review.googlesource.com/c/go/+/286633
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoruntime: switch runtime to libc for openbsd/arm64
Joel Sing [Tue, 26 Jan 2021 12:06:51 +0000 (23:06 +1100)]
runtime: switch runtime to libc for openbsd/arm64

Use libc rather than performing direct system calls for the runtime on
openbsd/arm64.

Updates #36435

Change-Id: I8bd41dfec16209f2b9a83dda24b9a1e4b06757c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/286814
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agoruntime: convert openbsd/arm64 locking to libc
Joel Sing [Tue, 26 Jan 2021 06:52:19 +0000 (17:52 +1100)]
runtime: convert openbsd/arm64 locking to libc

Switch openbsd/arm64 to locking via libc, rather than performing direct
system calls.

Update #36435

Change-Id: I2f30432c4bc232224cf87dca750665b8c40c7b72
Reviewed-on: https://go-review.googlesource.com/c/go/+/286813
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agosyscall: clean up mkasm related changes
Joel Sing [Tue, 26 Jan 2021 14:00:05 +0000 (01:00 +1100)]
syscall: clean up mkasm related changes

The mkasm_darwin.go file was renamed to mkasm.go in CL 270380, with OpenBSD
support being added. The mkasm_openbsd.go file should not have been merged,
so remove it. Fix up references to mkasm_$GOOS.go and provide $GOOS as an
argument on invocation.

Updates #36435

Change-Id: I868d3f2146973d026e6a663d437749dbb6b312ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/286812
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agodoc/go1.16: fix closing brace in .Export format
Ryuji Iwata [Tue, 26 Jan 2021 12:53:08 +0000 (12:53 +0000)]
doc/go1.16: fix closing brace in .Export format

A parenthesis of go list "-f" flag format is double curly braces.

Change-Id: Ifd38e0b0ae3c46272a4acd65584818228168b7c6
GitHub-Last-Rev: b46030492b5caf18fe127621fdf92cbec4c03ad5
GitHub-Pull-Request: golang/go#43924
Reviewed-on: https://go-review.googlesource.com/c/go/+/286752
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>

3 years agomath: fix typo in sqrt.go code comment
Paul Davis [Tue, 26 Jan 2021 23:29:47 +0000 (23:29 +0000)]
math: fix typo in sqrt.go code comment

"it does not necessary" -> "it is not necessary"

Change-Id: I66f9cf2670d76b3686badb4a537b3ec084447d62
GitHub-Last-Rev: 52a0f9993abf25369cdb6b31eaf476df1626cf87
GitHub-Pull-Request: golang/go#43935
Reviewed-on: https://go-review.googlesource.com/c/go/+/287052
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>

3 years agoruntime,syscall: convert syscall on openbsd/amd64 to libc
Joel Sing [Sun, 15 Nov 2020 17:47:56 +0000 (04:47 +1100)]
runtime,syscall: convert syscall on openbsd/amd64 to libc

Convert the syscall package on openbsd/amd64 to use libc rather than performing
direct system calls.

Updates #36435

Change-Id: Ieb5926a91ed34f7c722e3667004ec484c86804ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/270380
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoos: further document limitations around naked file descriptors
Victor Michel [Sun, 24 Jan 2021 05:53:36 +0000 (05:53 +0000)]
os: further document limitations around naked file descriptors

NewFile requires the file descriptor to be either closed
through the returned File instance, or to stay valid at least
until the finalizer runs during garbage collection.

These requirements are easily violated when file descriptors
are closed via unix.Close, or when the *File returned by
NewFile is garbage collected while the underlying file descriptor is
still in use.

This commit adds further documentation for NewFile and Fd, making it
explicit that using naked file descriptors is subject to constraints
due to garbage collection of File objects.

Fixes #43863

Change-Id: I49ea1f0054eb2d2a72b616450c8e83476f4d07fb
GitHub-Last-Rev: 180d0130ae9009456914fb265b4bafa0e599de0e
GitHub-Pull-Request: golang/go#43867
Reviewed-on: https://go-review.googlesource.com/c/go/+/286032
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
3 years agoos: correct names in CreateTemp and MkdirTemp doc comments
Ian Lance Taylor [Fri, 22 Jan 2021 00:13:35 +0000 (16:13 -0800)]
os: correct names in CreateTemp and MkdirTemp doc comments

For #42026

Change-Id: I51e3ce9d3a4729cfac44bd3ff3f3ec80dcd5abb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/285376
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agonet/http/fcgi: remove locking added to prevent a test-only race
Hilko Bengen [Mon, 25 Jan 2021 22:54:20 +0000 (22:54 +0000)]
net/http/fcgi: remove locking added to prevent a test-only race

The race reported in issue #41167 was detected only because the
ReadWriter used in test code happened to be a bytes.Buffer whose
Read and Write operate (unsafely) on shared state. This is not the
case in any realistic scenario where the FastCGI protocol is spoken
over sockets or pairs of pipes.

Since tests that use nopWriteCloser don't care about any output
generate by child.Serve(), we change nopWriteCloser to provide
a dummy Write method.

Remove the locking added in CL 252417, since it causes a deadlock
during write as reported in #43901. The race in tests no longer
happens thanks to the aforementioned change to nopWriteCloser.

Fixes #43901.
Updates #41167.

Change-Id: I8cf31088a71253c34056698f8e2ad0bee9fcf6c6
GitHub-Last-Rev: b06d8377fdada075775d79a20577d38a7c471b45
GitHub-Pull-Request: golang/go#43027
Reviewed-on: https://go-review.googlesource.com/c/go/+/275692
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agodoc/go1.16: mention os.DirFS in os section
Ian Lance Taylor [Fri, 22 Jan 2021 01:58:17 +0000 (17:58 -0800)]
doc/go1.16: mention os.DirFS in os section

For #40700
For #41190

Change-Id: I8ade6efd5be09003fc3e5db5a9b91ba6e0f023f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/285593
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocmd/compile: fix order-of-assignment issue w/ defers
Matthew Dempsky [Fri, 22 Jan 2021 03:27:12 +0000 (19:27 -0800)]
cmd/compile: fix order-of-assignment issue w/ defers

CL 261677 fixed a logic issue in walk's alias detection, where it was
checking the RHS expression instead of the LHS expression when trying
to determine the kind of assignment. However, correcting this exposed
a latent issue with assigning to result parameters in functions with
defers, where an assignment could become visible earlier than intended
if a later expression could panic.

Fixes #43835.

Change-Id: I061ced125e3896e26d65f45b28c99db2c8a74a8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/285633
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

3 years agodoc/go1.16: mention os.DirEntry and types moved from os to io/fs
Ian Lance Taylor [Fri, 22 Jan 2021 01:29:36 +0000 (17:29 -0800)]
doc/go1.16: mention os.DirEntry and types moved from os to io/fs

For #40700
For #41467
For #41190

Change-Id: Id94e7511c98c38a22b1f9a55af6e200c9df07fd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/285592
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agodoc/go1.16: mention new testing/iotest functions
Ian Lance Taylor [Fri, 22 Jan 2021 06:47:18 +0000 (22:47 -0800)]
doc/go1.16: mention new testing/iotest functions

For #38781
For #40700
For #41190

Change-Id: I72f1055e51edb517041d3861640734ba6ef5f342
Reviewed-on: https://go-review.googlesource.com/c/go/+/285673
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agodoc/go1.16: mention deprecation of io/ioutil
Ian Lance Taylor [Fri, 22 Jan 2021 00:23:18 +0000 (16:23 -0800)]
doc/go1.16: mention deprecation of io/ioutil

For #40025
For #40700
For #42026

Change-Id: Ib51b5e1398c4eb811506df21e3bd56dd84bd1f7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/285377
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agodoc/go1.16: mention go/build changes
Ian Lance Taylor [Thu, 21 Jan 2021 04:41:16 +0000 (20:41 -0800)]
doc/go1.16: mention go/build changes

For #40070
For #41191
For #43469
For #43632

Change-Id: I6dc6b6ea0f35876a4c252e4e287a0280aca9d502
Reviewed-on: https://go-review.googlesource.com/c/go/+/285213
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agohtml/template: revert "avoid race when escaping updates template"
Ian Lance Taylor [Fri, 22 Jan 2021 22:54:23 +0000 (14:54 -0800)]
html/template: revert "avoid race when escaping updates template"

This reverts CLs 274450 and 279492, except for the new tests.
The new race test is changed to skip, as it now fails.
We can try again for 1.17.

Original CL descriptions:

    html/template: attach functions to namespace

    The text/template functions are stored in a data structure shared by
    all related templates, so do the same with the original, unwrapped,
    functions on the html/template side.

    html/template: avoid race when escaping updates template

For #39807
Fixes #43855

Change-Id: I2ce91321ada06ea496a982aefe170eb5af9ba847
Reviewed-on: https://go-review.googlesource.com/c/go/+/285957
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agocmd/go: fix TestScript/cgo_path, cgo_path_space when CC set
Jay Conrod [Mon, 25 Jan 2021 15:34:28 +0000 (10:34 -0500)]
cmd/go: fix TestScript/cgo_path, cgo_path_space when CC set

These tests failed if CC was set to a path containing a separator
during make.bash. They now set CC explicitly.

Fixes #43897

Change-Id: Ic6e7f192fcb363f0ac9f45b329113255453bf76f
Reviewed-on: https://go-review.googlesource.com/c/go/+/286292
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agodoc/asm: add a section on go_asm.h, clean up go_tls.h section
Austin Clements [Fri, 22 Jan 2021 15:58:12 +0000 (10:58 -0500)]
doc/asm: add a section on go_asm.h, clean up go_tls.h section

Currently the only mention of go_asm.h is buried in a confusing
section about the runtime-specific go_tls.h header. We actually want
people to use go_asm.h, so this CL adds a section with a proper
discussion of this header. As part of this, we remove the discussion
of go_asm.h from the go_tls.h section and clean up what remains.

I stumbled on this when working on the internal ABI specification. I
wanted to refer to stable documentation on how to access struct fields
from assembly and found there was none.

Change-Id: I0d53741e7685e65794611939e76285f7c82e1d65
Reviewed-on: https://go-review.googlesource.com/c/go/+/286052
Trust: Austin Clements <austin@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 years agolib/time, time/tzdata: update tzdata to 2021a
Tobias Klauser [Mon, 25 Jan 2021 11:31:54 +0000 (12:31 +0100)]
lib/time, time/tzdata: update tzdata to 2021a

Changelog:

  South Sudan changes from +03 to +02 on 2021-02-01 at 00:00.

Release announcement:

  http://mm.icann.org/pipermail/tz-announce/2021-January/000065.html

Updates #22487

Change-Id: Ia0a1a7a8f5d47adac9782bc2a445f69e02440f77
Reviewed-on: https://go-review.googlesource.com/c/go/+/285719
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
3 years agoos: force consistent mtime before running fstest on directory on Windows
Jason A. Donenfeld [Mon, 18 Jan 2021 14:23:16 +0000 (15:23 +0100)]
os: force consistent mtime before running fstest on directory on Windows

FindFileNext sometimes returns a different mtime than looking at the
file directly, because the MFT on NTFS is written to lazily. In order to
keep these in sync, we use GetFileInformationByHandle to get the actual
mtime, and then write it back to the file explicitly.

Fixes #42637.

Change-Id: I774016d3ac55d0dc9b0f9c1b681516c33ba0d28a
Reviewed-on: https://go-review.googlesource.com/c/go/+/285720
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>

3 years agodoc/go1.16: fix WalkDir and Walk links
Tobias Klauser [Mon, 25 Jan 2021 10:14:57 +0000 (11:14 +0100)]
doc/go1.16: fix WalkDir and Walk links

Reported by Ben on golang-dev:
https://groups.google.com/g/golang-dev/c/gsoj5Vv15j0/m/XR9CYSRkAgAJ

For #40700.

Change-Id: If4702cf0e9858aaef99c231251dc646a67d1026e
Reviewed-on: https://go-review.googlesource.com/c/go/+/285718
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
3 years agodoc/go1.16: add crypto/x509 memory optimization
Brad Fitzpatrick [Sat, 23 Jan 2021 04:38:29 +0000 (20:38 -0800)]
doc/go1.16: add crypto/x509 memory optimization

Change-Id: I0c61b0e0d1430f66e3f7dbf07817264258a1c15a
Reviewed-on: https://go-review.googlesource.com/c/go/+/285682
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

3 years agodoc/go1.16: reword ambiguously parsable sentence
Brad Fitzpatrick [Sat, 23 Jan 2021 04:21:22 +0000 (20:21 -0800)]
doc/go1.16: reword ambiguously parsable sentence

Change-Id: Idc54967e962352a598c9d4c563d1d9f51ec5c889
Reviewed-on: https://go-review.googlesource.com/c/go/+/285680
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

3 years agocmd/internal/obj/arm64: fix VMOVQ instruction encoding error
eric fang [Thu, 14 Jan 2021 07:14:02 +0000 (07:14 +0000)]
cmd/internal/obj/arm64: fix VMOVQ instruction encoding error

The VMOVQ instruction moves a 128-bit constant into a V register, as 128-bit
constant can't be loaded into a register directly, we split it into two 64-bit
constants and load it from constant pool. Currently we add the 128-bit constant
to literal pool by calling the 'addpool' function twice, this is not the right
way because it doesn't guarantee the two DWORD instructions are consecutive,
and the second call of addpool will overwrite the p.Pool field,resulting in a
wrong PC-relative offset value of the Prog.

This CL renames the flag LFROM3 to LFROM128, and adds a new function addpool128
to add a 128-bit constant to the literal pool.

Change-Id: I616f043c99a9a18a663f8768842cc980de2e6f79
Reviewed-on: https://go-review.googlesource.com/c/go/+/282334
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: eric fang <eric.fang@arm.com>
Trust: eric fang <eric.fang@arm.com>

3 years agoruntime: restore cgo_import_dynamic for libc.so on openbsd
Joel Sing [Fri, 22 Jan 2021 19:18:30 +0000 (06:18 +1100)]
runtime: restore cgo_import_dynamic for libc.so on openbsd

This was removed in change 285692, however we need to explicitly pull libc.so
in when libpthread.so is being used. The current code works on openbsd/amd64
since we pull libc.so in via runtime/sys_openbsd2.go, however openbsd/arm64
does not do this currently.

Change-Id: Ibe93d936a22e69e2fe12620f6d27ccca7a91dba5
Reviewed-on: https://go-review.googlesource.com/c/go/+/285912
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoio/ioutil: fix example test for WriteFile to allow it to run in the playground
Pantonshire [Mon, 18 Jan 2021 17:41:36 +0000 (17:41 +0000)]
io/ioutil: fix example test for WriteFile to allow it to run in the playground

The example for WriteFile assumed the existence of a testdata/ directory, which is not present on the playground. The example now writes the file to the current working directory, rather than to testdata/.

Fixes #32916

Change-Id: I577caac7e67ba9d9941b2dd19346ad5ff61e78d9
GitHub-Last-Rev: 40f14e0adc4ebc00fb2946fe0cbaf8e0cb99f62c
GitHub-Pull-Request: golang/go#43757
Reviewed-on: https://go-review.googlesource.com/c/go/+/284452
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>

3 years agoruntime: define dummy msanmove
Cherry Zhang [Fri, 22 Jan 2021 21:35:21 +0000 (16:35 -0500)]
runtime: define dummy msanmove

In msan mode we instrument code with msan* functions, including
msanmove. In some configurations the code is instrumented by the
compiler but msan is not actually linked in, so we need dummy
definitions for those functions so the program links. msanmove is
newly added in CL 270859 but a dummy definition in msan0.go was
not added, causing link failures. Add it.

Change-Id: I91f8e749919f57f1182e90b43412b0282cf4767c
Reviewed-on: https://go-review.googlesource.com/c/go/+/285955
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoruntime: check for g0 stack last in signal handler
Cherry Zhang [Fri, 22 Jan 2021 14:47:59 +0000 (09:47 -0500)]
runtime: check for g0 stack last in signal handler

In the signal handler, we adjust gsingal's stack to the stack
where the signal is delivered. TSAN may deliver signals to the
g0 stack, so we have a special case for the g0 stack. However,
we don't have very good accuracy in determining the g0 stack's
bounds, as it is system allocated and we don't know where it is
exactly. If g0.stack.lo is too low, the condition may be
triggered incorrectly, where we thought the signal is delivered to
the g0 stack but it is actually not. In this case, as the stack
bounds is actually wrong, when the stack grows, it may go below
the (inaccurate) lower bound, causing "morestack on gsignal"
crash.

Check for g0 stack last to avoid this situation. There could still
be false positives, but for those cases we'll crash either way.

(If we could in some way determine the g0 stack bounds accurately,
this would not matter (but probably doesn't hurt).)

Fixes #43853.

Change-Id: I759717c5aa2b0deb83ffb23e57b7625a6b249ee8
Reviewed-on: https://go-review.googlesource.com/c/go/+/285772
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agocmd/go: don't lookup the path for CC when invoking cgo
Jay Conrod [Fri, 22 Jan 2021 19:27:24 +0000 (14:27 -0500)]
cmd/go: don't lookup the path for CC when invoking cgo

Previously, if CC was a path without separators (like gcc or clang),
we'd look it up in PATH in cmd/go using internal/execabs.LookPath,
then pass the resolved path to cgo in CC.

This caused a regression: if the directory in PATH containing CC has a
space, cgo splits it and interprets it as multiple arguments.

With this change, cmd/go no longer resolves CC before invoking
cgo. cgo does the path lookup on each invocation. This reverts the
security fix CL 284780, but that was redundant with the addition of
internal/execabs (CL 955304), which still protects us.

Fixes #43808
Updates #41400

Change-Id: I65d91a1e303856df8653881eb6e2e75a3bf95c49
Reviewed-on: https://go-review.googlesource.com/c/go/+/285873
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoruntime: switch runtime to libc for openbsd/amd64
Joel Sing [Sun, 15 Nov 2020 12:28:57 +0000 (23:28 +1100)]
runtime: switch runtime to libc for openbsd/amd64

Use libc rather than performing direct system calls for the runtime on
openbsd/amd64.

Updates #36435

Change-Id: Ib708009c3743f56a3fd6cb3bc731451e4a398849
Reviewed-on: https://go-review.googlesource.com/c/go/+/270379
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocmd/go: add documentation for test and xtest fields output by go list
Michael Matloob [Sat, 16 Jan 2021 00:41:26 +0000 (19:41 -0500)]
cmd/go: add documentation for test and xtest fields output by go list

The TestEmbedPatterns, TestEmbedFiles, XTestEmbedPatterns, and
XTestEmbedFiles fields were left out of golang.org/cl/282195 which was
supposed to document the embed fields available in the go list
output. Add documentation for them in this CL.

Fixes #43081

Change-Id: Ifc256c476daec7c0f0e2c41f86b82f958b3e2b1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/284258
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoruntime: remove pthread_kill/pthread_self for openbsd
Joel Sing [Fri, 22 Jan 2021 08:32:43 +0000 (19:32 +1100)]
runtime: remove pthread_kill/pthread_self for openbsd

We're now using getthrid() and thrkill() instead.

Updates #36435

Change-Id: I1c6bcfb9b46d149e0a2a10e936a244576489a88e
Reviewed-on: https://go-review.googlesource.com/c/go/+/285692
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agoruntime: fix typo in mgcscavenge.go
Ikko Ashimine [Fri, 22 Jan 2021 15:00:35 +0000 (15:00 +0000)]
runtime: fix typo in mgcscavenge.go

recieved -> received

Change-Id: I84336170e179832604e1311ea9263af36f9ce15a
GitHub-Last-Rev: a6068c1d2b5a7711b93899f798dbc84f1ea339e4
GitHub-Pull-Request: golang/go#43845
Reviewed-on: https://go-review.googlesource.com/c/go/+/285675
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

3 years agonet/http: fix flaky TestDisableKeepAliveUpgrade
Damien Neil [Fri, 22 Jan 2021 02:24:55 +0000 (18:24 -0800)]
net/http: fix flaky TestDisableKeepAliveUpgrade

This test hijacks a connection. It was reading from the net.Conn
returned by Hijack, not the bufio.ReadWriter, causing flaky failures
when a read-ahead byte was held in the read buffer.

Fixes #43073.

Change-Id: Ic3e7f704fba9635fd851cb3c0c0c74e312b75f6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/285596
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Anmol Sethi <nhooyr@gmail.com>
3 years agotime: clarify Timer.Reset behavior on AfterFunc Timers
Brad Fitzpatrick [Fri, 22 Jan 2021 03:41:56 +0000 (19:41 -0800)]
time: clarify Timer.Reset behavior on AfterFunc Timers

Fixes #28100

Change-Id: I37d4d7badf455e4ecf982d4fc7cb070052de2e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/285632
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agodoc/go1.16: mention net/http.Transport.GetProxyConnectHeader
Ian Lance Taylor [Fri, 22 Jan 2021 02:10:47 +0000 (18:10 -0800)]
doc/go1.16: mention net/http.Transport.GetProxyConnectHeader

For #40700
For #41048

Change-Id: Ida6bcaaf5edaa2bba9ba2b8e02ec9959481f8302
Reviewed-on: https://go-review.googlesource.com/c/go/+/285594
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agodoc/go1.16: mention path/filepath.WalkDir
Ian Lance Taylor [Fri, 22 Jan 2021 02:21:35 +0000 (18:21 -0800)]
doc/go1.16: mention path/filepath.WalkDir

For #40700
For #42027

Change-Id: Ifb73050dfdab21784fa52d758ad9c408e6489684
Reviewed-on: https://go-review.googlesource.com/c/go/+/285595
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agodoc/go1.16: mention syscall.AllThreadsSyscall
Ian Lance Taylor [Fri, 22 Jan 2021 02:29:13 +0000 (18:29 -0800)]
doc/go1.16: mention syscall.AllThreadsSyscall

For #1435
For #40700

Change-Id: I01d277617ab511c90b9663fc89e418402e5ee2be
Reviewed-on: https://go-review.googlesource.com/c/go/+/285597
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agodoc/go1.16: add notes about package-specific fs.FS changes
Ian Lance Taylor [Thu, 21 Jan 2021 02:01:56 +0000 (18:01 -0800)]
doc/go1.16: add notes about package-specific fs.FS changes

For #40700
For #41190

Change-Id: I964d6856d5cad62c859d0f3a7afdd349a8ad87cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/285093
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agodoc/go1.16: minor formatting fix
Austin Clements [Thu, 21 Jan 2021 19:24:14 +0000 (14:24 -0500)]
doc/go1.16: minor formatting fix

Change-Id: Ie924a15da0d9a35089d1d4b3d6c4a07b93bdf270
Reviewed-on: https://go-review.googlesource.com/c/go/+/285393
Trust: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agodoc/go1.16: mention new debug/elf constants
Ian Lance Taylor [Thu, 21 Jan 2021 04:09:18 +0000 (20:09 -0800)]
doc/go1.16: mention new debug/elf constants

For #40700

Change-Id: If105d2f043539bb0893f577a984f14ee3e7ca753
Reviewed-on: https://go-review.googlesource.com/c/go/+/285212
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocmd/go: overwrite program name with full path
Roland Shoemaker [Tue, 19 Jan 2021 17:59:24 +0000 (09:59 -0800)]
cmd/go: overwrite program name with full path

If the program path is resolved, replace the first argument of the
exec.Cmd, which is the bare program name with the resolved path.

Change-Id: I92cf5e6f4bb7c8fef9b59f5eab963f4e75b90d07
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/957908
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/284784
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>

3 years agoall: introduce and use internal/execabs
Roland Shoemaker [Fri, 15 Jan 2021 20:14:06 +0000 (12:14 -0800)]
all: introduce and use internal/execabs

Introduces a wrapper around os/exec, internal/execabs, for use in
all commands. This wrapper prevents exec.LookPath and exec.Command from
running executables in the current directory.

All imports of os/exec in non-test files in cmd/ are replaced with
imports of internal/execabs.

This issue was reported by RyotaK.

Fixes CVE-2021-3115
Fixes #43783

Change-Id: I0423451a6e27ec1e1d6f3fe929ab1ef69145c08f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955304
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/284783
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>

3 years agocmd/go: add test case for cgo CC setting
Russ Cox [Mon, 11 Jan 2021 14:43:08 +0000 (09:43 -0500)]
cmd/go: add test case for cgo CC setting

Change-Id: Ied986053a64447c5eac6369f6c9b69ed3d3f94d9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949415
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/284782
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Roland Shoemaker <roland@golang.org>

3 years agocmd/cgo: report exec errors a bit more clearly
Russ Cox [Mon, 11 Jan 2021 15:01:24 +0000 (10:01 -0500)]
cmd/cgo: report exec errors a bit more clearly

Change-Id: I0e6bebf0e2e6efdef4be880e0c6c7451b938924b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949417
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/284781
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Roland Shoemaker <roland@golang.org>

3 years agocmd/go: pass resolved CC, GCCGO to cgo
Russ Cox [Mon, 11 Jan 2021 14:41:54 +0000 (09:41 -0500)]
cmd/go: pass resolved CC, GCCGO to cgo

This makes sure the go command and cgo agree about
exactly which compiler is being used.

This issue was reported by RyotaK.

Fixes CVE-2021-3115
Fixes #43783

Change-Id: If171c5c8b2523efb5ea2d957e5ad1380a038149c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949416
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/284780
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Roland Shoemaker <roland@golang.org>

3 years agoruntime: switch openbsd/arm64 to pthreads
Joel Sing [Mon, 24 Aug 2020 15:29:02 +0000 (01:29 +1000)]
runtime: switch openbsd/arm64 to pthreads

This switches openbsd/arm64 to thread creation via pthreads, rather than doing
direct system calls.

Update #36435

Change-Id: I7cf60fa954f92628e05f15d2732833a2fbdccdb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/250182
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocrypto/elliptic: fix P-224 field reduction
Filippo Valsorda [Fri, 8 Jan 2021 02:56:58 +0000 (03:56 +0100)]
crypto/elliptic: fix P-224 field reduction

This patch fixes two independent bugs in p224Contract, the function that
performs the final complete reduction in the P-224 field. Incorrect
outputs due to these bugs were observable from a high-level
P224().ScalarMult() call.

The first bug was in the calculation of out3GT. That mask was supposed
to be all ones if the third limb of the value is greater than the third
limb of P (out[3] > 0xffff000). Instead, it was also set if they are
equal. That meant that if the third limb was equal, the value was always
considered greater than or equal to P, even when the three bottom limbs
were all zero. There is exactly one affected value, P - 1, which would
trigger the subtraction by P even if it's lower than P already.

The second bug was more easily hit, and is the one that caused the known
high-level incorrect output: after the conditional subtraction by P, a
potential underflow of the lowest limb was not handled. Any values that
trigger the subtraction by P (values between P and 2^224-1, and P - 1
due to the bug above) but have a zero lowest limb would produce invalid
outputs. Those conditions apply to the intermediate representation
before the subtraction, so they are hard to trace to precise inputs.

This patch also adds a test suite for the P-224 field arithmetic,
including a custom fuzzer that automatically explores potential edge
cases by combining limb values that have various meanings in the code.
contractMatchesBigInt in TestP224Contract finds the second bug in less
than a second without being tailored to it, and could eventually find
the first one too by combining 0, (1 << 28) - 1, and the difference of
(1 << 28) and (1 << 12).

The incorrect P224().ScalarMult() output was found by the
elliptic-curve-differential-fuzzer project running on OSS-Fuzz and
reported by Philippe Antoine (Catena cyber).

Fixes CVE-2021-3114
Fixes #43786

Change-Id: I50176602d544de3da854270d66a293bcaca57ad7
Reviewed-on: https://go-review.googlesource.com/c/go/+/284779
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
3 years agocmd/internal/moddeps: check content of all modules in GOROOT
Dmitri Shuralyov [Sat, 5 Dec 2020 20:03:27 +0000 (15:03 -0500)]
cmd/internal/moddeps: check content of all modules in GOROOT

Expand the scope of the TestAllDependenciesVendored test to check
that all modules in GOROOT are tidy, that packages are vendored,
the vendor content matches the upstream copy exactly, and that
bundled packages are re-generated (using x/tools/cmd/bundle at
the version selected in cmd module; this is deterministic and
guaranteed to be updated over time).

This is done in a conceptually simple way:

1. Make a temporary copy of the entire GOROOT tree (except .git),
one that is safe to modify.
2. Run a list of high-level commands, the same commands we expect
Go developers should be able to run in a normal complete GOROOT
tree to make it clean and tidy.
3. Diff the end result with the original GOROOT tree being tested
to catch any unexpected differences.

The current set of commands that are run require the cmd/go command,
and a functional compiler itself (because re-generating the syscall
package involves a directive like //go:generate go run [...]). As a
result, copying a large majority of the GOROOT tree is a requirement.

Instead of looking for the few files or directories that can we can
get away not copying (e.g., the testdata directories aren't strictly
needed at this time), we opt not to optimize and just do the simple
copy. This is motivated by these reasons:

• We end up having a complete, normal GOROOT tree, one that happens
to be located at another path. There's a very high likelihood that
module management/code generation commands, both the ones we run
today and any additional ones that we might want to add in the
future, will result in correct results even as the Go project
evolves over time.

• Having a completely stand-alone copy of the GOROOT tree without
symlinks minimizes the risk of some of the module management/code
generation commands, either now or in the future, from modifying
the user's original GOROOT tree, something that should not happen
during test execution. Overlays achieved with symlinks work well
when we can guarantee only new files are added, but that isn't
the case here.

• Copying the entire GOROOT (without .git), takes around 5 seconds
on a fairly modern computer with an SSD. The most we can save is
a couple of seconds.

(We make some minor exceptions: the GOROOT/.git directory isn't copied,
and GOROOT/{bin,pkg} are deemed safe to share and thus symlink instead
of copying. If these optimizations cease to be viable to make, we'll
need to remove them.)

Since this functionality is fairly expensive to execute and requires
network access, it runs only when the test is executed without -short
flag. The previous behavior of the TestAllDependenciesVendored test is
kept in -short test mode. all.bash runs package tests with -short flag,
so its behavior is unchanged. The expectation is that the new test will
run on some of the longtest builders to catch problems. Users can invoke
the test manually 'go test cmd/internal/moddeps' (and it's run as part
of 'go test cmd', again, only when -short flag isn't provided).

On a 2017 MacBook Pro, a successful long test takes under 15 seconds,
which should be within scope of all long tests that are selected by
'go test std cmd'. We may further adjust when and where the test runs
by default based on our experience.

Fixes #36852.
Fixes #41409.
Fixes #43687.
Updates #43440.

Change-Id: I9eb85205fec7ec62e3f867831a0a82e3c767f618
Reviewed-on: https://go-review.googlesource.com/c/go/+/283643
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agoruntime: don't adjust timer pp field in timerWaiting status
Ian Lance Taylor [Wed, 20 Jan 2021 05:30:36 +0000 (21:30 -0800)]
runtime: don't adjust timer pp field in timerWaiting status

Before this CL, the following sequence was possible:

* GC scavenger starts and sets up scavenge.timer
* GC calls readyForScavenger, but sysmon is sleeping
* program calls runtime.GOMAXPROCS to shrink number of processors
* procresize destroys a P, the one that scavenge.timer is on
* (*pp).destroy calls moveTimers, which gets to the scavenger timer
* scavenger timer is timerWaiting, and moveTimers clears t.pp
* sysmon wakes up and calls wakeScavenger
* wakeScavengers calls stopTimer on scavenger.timer, still timerWaiting
* stopTimer calls deltimer which loads t.pp, which is still nil
* stopTimer tries to increment deletedTimers on nil t.pp, and crashes

The point of vulnerability is the time that t.pp is set to nil by
moveTimers and the time that t.pp is set to non-nil by moveTimers,
which is a few instructions at most. So it's not likely and in
particular is quite unlikely on x86. But with a more relaxed memory
model the area of vulnerability can be somewhat larger. This appears
to tbe the cause of two builder failures in a few months on linux-mips.

This CL fixes the problem by making moveTimers change the status from
timerWaiting to timerMoving while t.pp is clear. That will cause
deltimer to wait until the status is back to timerWaiting, at which
point t.pp has been set again.

Fixes #43712

Change-Id: I66838319ecfbf15be66c1fac88d9bd40e2295852
Reviewed-on: https://go-review.googlesource.com/c/go/+/284775
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agocmd/go: set Incomplete field on go list output if no files match embed
Michael Matloob [Sat, 16 Jan 2021 00:18:34 +0000 (19:18 -0500)]
cmd/go: set Incomplete field on go list output if no files match embed

If no files match the embed pattern, the Error field will be set on
the package output by go list. Also set the Incomplete field for
consistency.

Fixes #43727

Change-Id: I5b4bb2a03a751269641a9bc4ef1d0fa0e37d46aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/284257
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: have go mod vendor copy embedded files in subdirs
Michael Matloob [Thu, 14 Jan 2021 01:58:00 +0000 (20:58 -0500)]
cmd/go: have go mod vendor copy embedded files in subdirs

If a package vendored with go mod vendor depends on embedded
files contained in subdirectories, copy them into the the
corresponding place in the module's vendor tree. (Embeds in
parent directories are disallowed by the embed pattern rules, and
embeds in the same directory are copied because go mod vendor
already copies the non-go files in the package's own directory).

Export the vendor pattern expansion code in internal/load so
internal/modcmd's vendor code can use it.

Fixes #43077

Change-Id: I61edb344d73df590574a6498ffb6069e8d72a147
Reviewed-on: https://go-review.googlesource.com/c/go/+/283641
Trust: Michael Matloob <matloob@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/go: fix mod_get_fallback test
Jay Conrod [Wed, 20 Jan 2021 14:45:03 +0000 (09:45 -0500)]
cmd/go: fix mod_get_fallback test

Fixes #43795

Change-Id: I3d791d0ac9ce0b523c78c649aaf5e339a7f63b76
Reviewed-on: https://go-review.googlesource.com/c/go/+/284797
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: convert openbsd/amd64 locking to libc
Joel Sing [Fri, 15 Jan 2021 17:38:50 +0000 (04:38 +1100)]
runtime: convert openbsd/amd64 locking to libc

Switch openbsd/amd64 to locking via libc, rather than performing direct
system calls.

Update #36435

Change-Id: I5e92bd70ce557b78ff385577088a9775cc468ea9
Reviewed-on: https://go-review.googlesource.com/c/go/+/270378
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocmd/go: allow go fmt to complete when embedded file is missing
Constantin Konstantinidis [Fri, 15 Jan 2021 16:05:29 +0000 (17:05 +0100)]
cmd/go: allow go fmt to complete when embedded file is missing

Fixes #43273

Change-Id: I75fe2e608cb43c048e3c2a22fe7fbb6eb779504a
Reviewed-on: https://go-review.googlesource.com/c/go/+/280452
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/compile: require 'go 1.16' go.mod line for //go:embed
Russ Cox [Fri, 8 Jan 2021 22:02:41 +0000 (17:02 -0500)]
cmd/compile: require 'go 1.16' go.mod line for //go:embed

This will produce better errors when earlier versions of
Go compile code using //go:embed. (The import will cause
a compilation error but then the go command will add to
the output that the Go toolchain in use looks too old
and maybe that's the problem.)

This CL also adds a test for disallowing embed of a var inside a func.
It's a bit too difficult to rebase down into that CL.

The build system configuration check is delayed in order to
make it possible to use errorcheck for these tests.

Change-Id: I12ece4ff2d8d53380b63f54866e8f3497657d54c
Reviewed-on: https://go-review.googlesource.com/c/go/+/282718
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/link: exit before Asmb2 if error
Cherry Zhang [Tue, 19 Jan 2021 16:02:10 +0000 (11:02 -0500)]
cmd/link: exit before Asmb2 if error

If there are already errors emitted, don't run the Asmb2 pass
and just exit. At the point of Asmb2 relocations are already
resolved and errors should have been reported, if any. Asmb2 is
unlikely to emit additional useful users errors. Instead, the
invalid input may cause inconsistencies and crash the linker, or
it may emit some internal errors which are more confusing than
helpful. Exit on error before Asmb2.

Fixes #43748.

Change-Id: Icf6e27f2eef5b6259e921ec0e64bebad5dd805f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/284576
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agoembed: treat uninitialized FS as empty
Jay Conrod [Thu, 14 Jan 2021 18:04:17 +0000 (13:04 -0500)]
embed: treat uninitialized FS as empty

As described in the FS documentation.

This prevents http.FS and other clients from panicking when the
go:embed directive is missing.

For #43682
Related #43698

Change-Id: Iecf26d229a099e55d24670c3119cd6c6d17ecc6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/283852
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/link,runtime: switch openbsd/amd64 to pthreads
Joel Sing [Sun, 23 Aug 2020 17:13:54 +0000 (03:13 +1000)]
cmd/link,runtime: switch openbsd/amd64 to pthreads

This switches openbsd/amd64 to thread creation via pthreads, rather than doing
direct system calls.

Update #36435

Change-Id: I1105d5c392aa3e4c445d99c8cb80b927712e3529
Reviewed-on: https://go-review.googlesource.com/c/go/+/250180
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agoruntime: factor out usesLibcall
Joel Sing [Sat, 3 Oct 2020 15:44:41 +0000 (01:44 +1000)]
runtime: factor out usesLibcall

Rather than inline lists of GOOS values, factor out the code that checks
if a runtime makes system calls via libcall.

Change-Id: Ib19d7e63a2b4b8314f1841c0ff26e1b3a16b4b22
Reviewed-on: https://go-review.googlesource.com/c/go/+/259239
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: factor out mStackIsSystemAllocated
Joel Sing [Mon, 24 Aug 2020 08:04:13 +0000 (18:04 +1000)]
runtime: factor out mStackIsSystemAllocated

Rather than repeat long lists of GOOS values, factor out the code that checks
if a runtime starts on a system allocated stack. Note that this adds aix to
one case, which appears to have been previously missed.

Change-Id: I5cecb0bb47dd79cde8d723e5a42ba541e43cbfff
Reviewed-on: https://go-review.googlesource.com/c/go/+/250179
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: free Windows event handles after last lock is dropped
Jason A. Donenfeld [Fri, 15 Jan 2021 12:01:37 +0000 (13:01 +0100)]
runtime: free Windows event handles after last lock is dropped

Calls to lock may need to use global members of mOS that also need to be
cleaned up before the thread exits. Before this commit, these resources
would leak. Moving them to be cleaned up in unminit, however, would race
with gstack on unix. So this creates a new helper, mdestroy, to release
resources that must be destroyed only after locks are no longer
required. We also move highResTimer lifetime to the same semantics,
since it doesn't help to constantly acquire and release the timer object
during dropm.

Updates #43720.

Change-Id: Ib3f598f3fda1b2bbcb608099616fa4f85bc1c289
Reviewed-on: https://go-review.googlesource.com/c/go/+/284137
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>

3 years agoos: do not close syscall.Stdin in TestReadStdin
Jason A. Donenfeld [Mon, 18 Jan 2021 12:31:28 +0000 (13:31 +0100)]
os: do not close syscall.Stdin in TestReadStdin

By calling NewConsoleFile on syscall.Stdin, we wind up closing it when
the function returns, which causes errors when all the tests are run in
a loop. To fix this, we instead create a duplicate handle of stdin.

Fixes #43720.

Change-Id: Ie6426e6306c7e1e39601794f4ff48bbf2fe67502
Reviewed-on: https://go-review.googlesource.com/c/go/+/284140
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>

3 years agoruntime: detect errors in DuplicateHandle
Jason A. Donenfeld [Fri, 15 Jan 2021 15:29:00 +0000 (16:29 +0100)]
runtime: detect errors in DuplicateHandle

These functions rely on DuplicateHandle succeeding, but they don't check
the return value, which might be masking subtle bugs that cause other
problems down the line.

Updates #43720.

Change-Id: I77f0e6645affa534777ffc173144a52e4afa5f81
Reviewed-on: https://go-review.googlesource.com/c/go/+/284135
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>

3 years agocmd/link: remove GOROOT write in TestBuildForTvOS
Dmitri Shuralyov [Fri, 15 Jan 2021 18:19:31 +0000 (13:19 -0500)]
cmd/link: remove GOROOT write in TestBuildForTvOS

Tests should avoid writing to GOROOT when possible. Such writes
would fail if GOROOT is non-writeable, and it can interfere with
other tests that don't expect GOROOT to change during test execution.

Updates #28387.

Change-Id: I7d72614f218df3375540f5c2f9c9f8c11034f602
Reviewed-on: https://go-review.googlesource.com/c/go/+/284293
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: allow embed into any string or byte slice type
Russ Cox [Fri, 8 Jan 2021 19:27:00 +0000 (14:27 -0500)]
cmd/compile: allow embed into any string or byte slice type

The current implementation requires saying "string" or "[]byte"
and disallows aliases, defined types, and even "[]uint8".
This was not 100% intended and mostly just fell out of when
the checks were being done in the implementation (too early,
before typechecking).

After discussion on #43217 (forked into #43602),
the consensus was to allow all string and byte slice types,
same as we do for string conversions in the language itself.
This CL does that.

It's more code than you'd expect because the decision has
to be delayed until after typechecking.

But it also more closely aligns with the version that's
already on dev.regabi.

Fixes #43602.

Change-Id: Iba919cfadfbd5d7116f2bf47e2512fb1d5c36731
Reviewed-on: https://go-review.googlesource.com/c/go/+/282715
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/compile: disallow embed of var inside func
Russ Cox [Fri, 8 Jan 2021 20:35:19 +0000 (15:35 -0500)]
cmd/compile: disallow embed of var inside func

Allowing embedding into []byte inside a func creates an
unfortunate problem: either all calls start with the same
underlying data and can see each other's changes to the
underlying data (surprising and racy!) or all calls start
by making their own copy of the underlying data
(surprising and expensive!).

After discussion on #43216, the consensus was to remove
support for all vars embedded inside functions.

Fixes #43216.

Change-Id: I01e62b5f0dcd9e8566c6d2286218e97803f54704
Reviewed-on: https://go-review.googlesource.com/c/go/+/282714
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/go: fix go generate docs
Russ Cox [Wed, 13 Jan 2021 19:40:07 +0000 (14:40 -0500)]
cmd/go: fix go generate docs

The docs were never updated for the change to the placement
of the DO NOT EDIT line.

Also, the description of the DO NOT EDIT line interrupted the
description of the //go:generate line, which made for some
confusing references in the text that followed. Move it lower.

Fixes #41196.

Change-Id: I6af2a199fa98d45f5ccac7cdf7e9e54257699e61
Reviewed-on: https://go-review.googlesource.com/c/go/+/283633
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agosyscall: remove RtlGenRandom and move it into internal/syscall
Jason A. Donenfeld [Thu, 14 Jan 2021 23:04:10 +0000 (00:04 +0100)]
syscall: remove RtlGenRandom and move it into internal/syscall

There's on need to expose this to the frozen syscall package, and it
also doesn't need to be unsafe. So we move it into internal/syscall and
have the generator make a safer function signature.

Fixes #43704.

Change-Id: Iccae69dc273a0aa97ee6846eb537f1dc1412f2de
Reviewed-on: https://go-review.googlesource.com/c/go/+/283992
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>

3 years agoos: invoke processKiller synchronously in testKillProcess
Bryan C. Mills [Fri, 15 Jan 2021 15:16:25 +0000 (10:16 -0500)]
os: invoke processKiller synchronously in testKillProcess

Previously, testKillProcess needlessly invoked processKiller in a
separate goroutine and failed to wait for that goroutine to complete,
causing the calls to t.Fatalf in that goroutine to potentially occur
after the test function had already returned.

Fixes #43722

Change-Id: I5d03cb24af51bb73f0ff96419dac57ec39776967
Reviewed-on: https://go-review.googlesource.com/c/go/+/284153
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocrypto/x509: update iOS bundled roots to version 55188.40.9
Filippo Valsorda [Fri, 15 Jan 2021 14:23:23 +0000 (15:23 +0100)]
crypto/x509: update iOS bundled roots to version 55188.40.9

Updates #38843

Change-Id: If76844e1caf23f98d814de89f77610de59d96a34
Reviewed-on: https://go-review.googlesource.com/c/go/+/284134
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocmd/go: in 'go mod edit', validate versions given to -retract and -exclude
Jay Conrod [Thu, 14 Jan 2021 18:28:37 +0000 (13:28 -0500)]
cmd/go: in 'go mod edit', validate versions given to -retract and -exclude

Fixes #43280

Change-Id: Icb6c6807fe32a89202a2709d4a1c8d8af967628f
Reviewed-on: https://go-review.googlesource.com/c/go/+/283853
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/dist, cmd/go: pass -arch for C compilation on Darwin
Cherry Zhang [Thu, 14 Jan 2021 17:29:16 +0000 (12:29 -0500)]
cmd/dist, cmd/go: pass -arch for C compilation on Darwin

On Apple Silicon Mac, the C compiler has an annoying default
target selection, depending on the ancestor processes'
architecture. In particular, if the shell or IDE is x86, when
running "go build" even with a native ARM64 Go toolchain, the C
compiler defaults to x86, causing build failures. We pass "-arch"
flag explicitly to avoid this situation.

Fixes #43692.
Fixes #43476.
Updates golang/vscode-go#1087.

Change-Id: I80b6a116a114e11e273c6886e377a1cc969fa3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/283812
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/cgo: remove unnecessary space in cgo export header
Quim Muntal [Thu, 14 Jan 2021 20:29:49 +0000 (21:29 +0100)]
cmd/cgo: remove unnecessary space in cgo export header

The cgo header has an unnecessary space in the exported function
definition on non-windows goos.

This was introduced in go1.16 so it would be good to fix it before
release.

Example:

// Current behavior, notice there is an unecessary space
// between extern and void
extern  void Foo();

// With this CL
extern void Foo();

Change-Id: Ic2c21f8d806fe35a7be7183dbfe35ac605b6e4f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/283892
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Katie Hockman <katie@golang.org>

3 years agocmd/test2json: document passing -test.paniconexit0
Ian Lance Taylor [Thu, 14 Jan 2021 20:00:23 +0000 (12:00 -0800)]
cmd/test2json: document passing -test.paniconexit0

For #29062
Fixes #43263

Change-Id: I160197c94cc4f936967cc22c82cec01663a14fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/283873
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go/internal/load: report positions for embed errors
Jay Conrod [Wed, 13 Jan 2021 22:08:38 +0000 (17:08 -0500)]
cmd/go/internal/load: report positions for embed errors

Fixes #43469
Fixes #43632

Change-Id: I862bb9da8bc3e4f15635bc33fd7cb5f12b917d71
Reviewed-on: https://go-review.googlesource.com/c/go/+/283638
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: fix wrong complement for arm64 floating-point comparisons
Junchen Li [Fri, 8 Jan 2021 02:20:34 +0000 (10:20 +0800)]
cmd/compile: fix wrong complement for arm64 floating-point comparisons

Consider the following example,

  func test(a, b float64, x uint64) uint64 {
    if a < b {
      x = 0
    }
    return x
  }

  func main() {
    fmt.Println(test(1, math.NaN(), 123))
  }

The output is 0, but the expectation is 123.

This is because the rewrite rule

  (CSEL [cc] (MOVDconst [0]) y flag) => (CSEL0 [arm64Negate(cc)] y flag)

converts

  FCMP NaN, 1
  CSEL MI, 0, 123, R0 // if 1 < NaN then R0 = 0 else R0 = 123

to

  FCMP NaN, 1
  CSEL GE, 123, 0, R0 // if 1 >= NaN then R0 = 123 else R0 = 0

But both 1 < NaN and 1 >= NaN are false. So the output is 0, not 123.

The root cause is arm64Negate not handle negation of floating comparison
correctly. According to the ARM manual, the meaning of MI, GE, and PL
are

  MI: Less than
  GE: Greater than or equal to
  PL: Greater than, equal to, or unordered

Because NaN cannot be compared with other numbers, the result of such
comparison is unordered. So when NaN is involved, unlike integer, the
result of !(a < b) is not a >= b, it is a >= b || a is NaN || b is NaN.
This is exactly what PL means. We add NotLessThanF to represent PL. Then
the negation of LessThanF is NotLessThanF rather than GreaterEqualF. The
same reason for the other floating comparison operations.

Fixes #43619

Change-Id: Ia511b0027ad067436bace9fbfd261dbeaae01bcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/283572
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>

3 years agocmd/go/internal/load: refactor setErrorPos to PackageError.setPos
Jay Conrod [Wed, 13 Jan 2021 21:21:16 +0000 (16:21 -0500)]
cmd/go/internal/load: refactor setErrorPos to PackageError.setPos

Renamed setErrorPos to setPos, made it a method of PackageError,
and removed its Package parameter and return value. This makes it
more clear that setPos modifies PackageError and does not create a new
Package.

Change-Id: I26c58d3d456c7c18a5c2598e1e8e158b1e6b4b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/283637
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agogo/build: report positions for go:embed directives
Jay Conrod [Wed, 13 Jan 2021 22:07:09 +0000 (17:07 -0500)]
go/build: report positions for go:embed directives

For #43469
For #43632

Change-Id: I9ac2da690344935da0e1dbe00b134dfcee65ec8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/283636
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: add hints to more missing sum error messages
Jay Conrod [Fri, 8 Jan 2021 20:14:22 +0000 (15:14 -0500)]
cmd/go: add hints to more missing sum error messages

When a command fails due to a module zip sum missing from go.sum,
if the module is in the build list, the go command will print a
'go mod download' command the user can run to fix it.

Previously, a hint was only printed if the module provided a package
in 'all'. We don't print a 'go get' hint, since we may not want to add
a new requirement to go.mod.

Fixes #43572

Change-Id: I88c61b1b42ad56c04e4482f6a1bb97ce758aaeff
Reviewed-on: https://go-review.googlesource.com/c/go/+/282712
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>

3 years agocmd/go/internal/modload: delete unused *mvsReqs.next method
Bryan C. Mills [Wed, 16 Dec 2020 03:00:02 +0000 (22:00 -0500)]
cmd/go/internal/modload: delete unused *mvsReqs.next method

For #36460
Updates #36465

Change-Id: Id818dce21d39a48cf5fc9c015b30497dce9cd1ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/278596
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
3 years agoencoding/asn1: document unmarshaling behavior for IMPLICIT string fields
Eric Chiang [Fri, 13 Nov 2020 03:13:02 +0000 (19:13 -0800)]
encoding/asn1: document unmarshaling behavior for IMPLICIT string fields

Fixes #42570.

Change-Id: I73e339cdebe1720c141861a12e28a94cef13c75b
Reviewed-on: https://go-review.googlesource.com/c/go/+/269798
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Katie Hockman <katie@golang.org>

3 years agocmd/go: fix non-script staleness checks interacting badly with GOFLAGS
Jakub Warczarek [Sat, 12 Dec 2020 17:43:52 +0000 (17:43 +0000)]
cmd/go: fix non-script staleness checks interacting badly with GOFLAGS

Fixes #43012.

Change-Id: Idc7a64b53c411e6dadd98521a48e15e664737d42
GitHub-Last-Rev: b56c0880c3b5ceb86c6fa2ba6bf82f8969e10472
GitHub-Pull-Request: golang/go#43155
Reviewed-on: https://go-review.googlesource.com/c/go/+/277453
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agodoc: update editors.html for Go 1.16
Rebecca Stambler [Mon, 11 Jan 2021 19:21:40 +0000 (14:21 -0500)]
doc: update editors.html for Go 1.16

Rerank editor plugins based on popularity (Go 2019 survey), and remove
Atom, as it is no longer popular.

Change-Id: I06d39b67eec24a920439b9ea1198b6e2a939874e
Reviewed-on: https://go-review.googlesource.com/c/go/+/283073
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/internal/objfile: don't require runtime.symtab symbol for XCOFF
Cherry Zhang [Wed, 23 Dec 2020 22:33:18 +0000 (17:33 -0500)]
cmd/internal/objfile: don't require runtime.symtab symbol for XCOFF

For some reason (that I didn't look into), externally linked
AIX binaries don't have runtime.symtab symbol. Since recent Go
releases (Go 1.3 maybe?), that symbol is empty and not necessary
anyway. Don't require it.

Fixes #40972.

Change-Id: I73a1f0142195ea6debdba8a4f6e12cadc3980dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/279995
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/go: add hint to read 'go help vcs' to GOVCS errors
Jay Conrod [Fri, 8 Jan 2021 21:12:46 +0000 (16:12 -0500)]
cmd/go: add hint to read 'go help vcs' to GOVCS errors

Fixes #43596

Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/282713
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: revise 'go help' documentation for modules
Jay Conrod [Fri, 8 Jan 2021 16:35:35 +0000 (11:35 -0500)]
cmd/go: revise 'go help' documentation for modules

Module-related help pages now contain a brief summary and point to the
reference documentation at golang.org/ref/mod for details.

Help pages for commands like 'go get' still describe the basic usage
and summarize flags but don't provide as much background detail.

Fixes #41427
Fixes #43419

Change-Id: Icacd38e0f33c352c447cc5a496c99674493abde2
Reviewed-on: https://go-review.googlesource.com/c/go/+/282615
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: make hints in error messages more consistent
Jay Conrod [Thu, 7 Jan 2021 16:14:06 +0000 (11:14 -0500)]
cmd/go: make hints in error messages more consistent

* All commands the user can run to fix the problem now appear alone on
  a separate line after a tab.
* Removed -d from 'go get' commands.
* Replaced 'go mod tidy' with 'go mod download $modpath' when a
  package might be provided by a module missing a sum.
* Errors about 'path@version' syntax are more explicit.

Fixes #29415
Fixes #42087
Fixes #43430
Fixes #43523

Change-Id: I4427c2c4506a727a2c727d652fd2d506bb134d3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/282121
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: preserve sums for indirect deps fetched by 'go mod download'
Jay Conrod [Fri, 8 Jan 2021 18:24:23 +0000 (13:24 -0500)]
cmd/go: preserve sums for indirect deps fetched by 'go mod download'

Previously, commands that wrote go.sum (except 'go mod tidy') would
retain sums for zip files of directly required modules. Sums of
indirect dependencies wouldn't be retained unless they were used to
load packages.

With this change, sums for indirect dependencies will be retained if
they're available. This allows users to add missing sums with
'go mod download example.com/mod', which previously only worked for
directly required modules.

Note that 'go mod download' without arguments now adds sums for every
module in the build list. That matches 1.15 behavior.

For #41103

Change-Id: I4cce2bf1c73578dae836bdb5adb32da071554f1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282692
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoruntime/metrics: mark histogram metrics as cumulative
Michael Anthony Knyszek [Fri, 8 Jan 2021 17:12:50 +0000 (17:12 +0000)]
runtime/metrics: mark histogram metrics as cumulative

All the current histogram metrics accumulate counts from program start
to infinity, and can be reasonably used to compute rates (also to
generate windowed distributions).

Change-Id: I5196c59867de34fba41bb8552606fa315460cef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/282633
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
3 years agoruntime/metrics: remove unused StopTheWorld Description field
Michael Anthony Knyszek [Fri, 8 Jan 2021 16:56:24 +0000 (16:56 +0000)]
runtime/metrics: remove unused StopTheWorld Description field

This change removes the as-of-yet unused StopTheWorld field in the
Description struct. Adding a new field to a struct is much easier than
removing it, so let's save it for when we actually need it.

Change-Id: I8074b8569187c1a148500575fa8a661534e875d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/282632
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
3 years agocmd/compile: fix exponential-time init-cycle reporting
Russ Cox [Thu, 7 Jan 2021 16:24:26 +0000 (11:24 -0500)]
cmd/compile: fix exponential-time init-cycle reporting

I have a real 7,000-line Go program (not so big)
that took over two minutes to report a trivial init cycle.
I thought the compiler was in an infinite loop but
it was actually just very slow.

CL 170062 rewrote init cycle reporting but replaced
a linear-time algorithm with an exponential one:
it explores all paths through the call graph of functions
involved in the cycle.

The net effect was that  Go 1.12 took 0.25 seconds to load,
typecheck, and then diagnose the cycle in my program,
while Go 1.13 takes 600X longer.

This CL makes the new reporting code run in linear time,
restoring the speed of Go 1.12 but preserving the semantic
fixes from CL 170062.

Change-Id: I7d6dc95676d577d9b96f5953b516a64db93249bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/282314
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agotest: fix timeout code for invoking compiler
Russ Cox [Thu, 7 Jan 2021 16:22:42 +0000 (11:22 -0500)]
test: fix timeout code for invoking compiler

When running go tool compile,
go tool is running compile as a subprocess.
Killing go tool with Process.Kill leaves the subprocess behind.
Send an interrupt signal first, which it can forward on
to the compile subprocess.

Also report the timeout in errorcheck -t.

Change-Id: I7ae0029bbe543ed7e60e0fea790dd0739d10bcaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/282313
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/go: pass signals forward during "go tool"
Russ Cox [Thu, 7 Jan 2021 16:21:37 +0000 (11:21 -0500)]
cmd/go: pass signals forward during "go tool"

This way, if a SIGINT is sent to the go command,
it is forwarded on to the underlying tool.

Otherwise trying to use os.Process.Signal to kill
"go tool compile" only kills the "go tool" not the "compile".

Change-Id: Iac7cd4f06096469f5e76164df813a379c0da3822
Reviewed-on: https://go-review.googlesource.com/c/go/+/282312
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>