]> Cypherpunks repositories - gostls13.git/log
gostls13.git
5 years agonet/http: use cancellation instead of a timeout in TestTransportProxyHTTPSConnectTimeout
Bryan C. Mills [Wed, 11 Dec 2019 14:35:31 +0000 (09:35 -0500)]
net/http: use cancellation instead of a timeout in TestTransportProxyHTTPSConnectTimeout

The use of a timeout in this test caused it to be flaky: if the
timeout occurred before the connection was attempted, then the Accept
call on the Listener could hang indefinitely, and its goroutine would
not exit until that Listener was closed. That caused the test to fail.

A longer timeout would make the test less flaky, but it would become
even slower and would still be sensitive to timing.

Instead, replace the timeout with an explicit Context cancellation
after the CONNECT request has been read. That not only ensures that
the cancellation occurs at the appropriate point, but also makes the
test much faster: a test run with -count=1000 now executes in less
than 2s on my machine, whereas before it took upwards of 50s.

Fixes #36082
Updates #28012

Change-Id: I00c20d87365fd3d257774422f39d2acc8791febd
Reviewed-on: https://go-review.googlesource.com/c/go/+/210857
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime: syscall_forkx on Solaris can return error on success
Andrew Stormont [Wed, 11 Dec 2019 00:31:44 +0000 (00:31 +0000)]
runtime: syscall_forkx on Solaris can return error on success

The syscall_forkx function returns the value of errno even on success.  This can be a problem when using cgo where an atfork handler might be registered; if the atfork handler does something which causes errno to be set the caller of syscall_forkx can be misled into thinking the fork has failed.  This causes the various exec functions in the runtime package to hang.

Change-Id: Ia1842179226078a0cbbea33d541aa1187dc47f68
GitHub-Last-Rev: 4dc4db75c82a826da9a50c323b7e3ddfe46ed6c0
GitHub-Pull-Request: golang/go#36076
Reviewed-on: https://go-review.googlesource.com/c/go/+/210742
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agodoc: remove Release History pages (moved to x/website)
Dmitri Shuralyov [Tue, 10 Dec 2019 20:31:47 +0000 (15:31 -0500)]
doc: remove Release History pages (moved to x/website)

These pages were moved to the x/website repo in CL 210797 (commit
golang/website@9aef1eefbbe663d448b04b7cc1b2b995f4cf4c0b).
Remove the old copies in this repo since they're no longer used.

Updates #36075
Updates #29206

Change-Id: I6e3ffaebd92fa753cb5f3b21e4238edfb7f5f0e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/210798
Reviewed-by: Alexander Rakoczy <alex@golang.org>
5 years agosyscall: use SOCK_CLOEXEC when creating sockets
Lorenz Bauer [Tue, 10 Dec 2019 15:58:24 +0000 (15:58 +0000)]
syscall: use SOCK_CLOEXEC when creating sockets

LsfSocket, SetLsfPromisc and NetlinkRIB currently don't force the CLOEXEC
flag on the sockets they create. While the former two functions are
deprecated, NetlinkRIB is called by various functions related to
net.Interface.

Add a helper to create CLOEXEC sockets, and use it from SetLsfPromisc and
NetlinkRIB. LsfSocket is unchanged since we don't want to break callers.

Fixes #36053

Change-Id: I72fe2b167996797698d8a44b0d28165045c42d3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/210517
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile/internal/logopt: gofmt
Tobias Klauser [Tue, 10 Dec 2019 15:21:56 +0000 (16:21 +0100)]
cmd/compile/internal/logopt: gofmt

Change-Id: Ie9d29645e7702104202ee1f338babdd9e33e1e58
Reviewed-on: https://go-review.googlesource.com/c/go/+/210679
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agotesting: use conventional comments for exported internal funcs & structs
vovapi [Tue, 10 Dec 2019 10:34:34 +0000 (10:34 +0000)]
testing: use conventional comments for exported internal funcs & structs

Change-Id: I2dd5ddc22bfff143b81d5945992d8c5fccf387f4
GitHub-Last-Rev: aa637756e772f5ee9094b802df3be9945c8466c4
GitHub-Pull-Request: golang/go#36054
Reviewed-on: https://go-review.googlesource.com/c/go/+/210497
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: use MRS instruction to read system registers on freebsd/arm64
Tobias Klauser [Tue, 10 Dec 2019 10:57:35 +0000 (11:57 +0100)]
runtime: use MRS instruction to read system registers on freebsd/arm64

Support for these was added in CL 189577

Change-Id: Iaf2a774b141995cbbdfb3888aea67ae9c7f928b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/210677
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agonet/http: await state traces earlier in TestServerConnState
Bryan C. Mills [Tue, 10 Dec 2019 15:02:27 +0000 (10:02 -0500)]
net/http: await state traces earlier in TestServerConnState

This approach attempts to ensure that the log for each connection is
complete before the next sequence of states begins.

Updates #32329

Change-Id: I25150d3ceab6568af56a40d2b14b5f544dc87f61
Reviewed-on: https://go-review.googlesource.com/c/go/+/210717
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet/http: fix timeout race in Transport proxy CONNECT
Brad Fitzpatrick [Tue, 10 Dec 2019 17:40:22 +0000 (17:40 +0000)]
net/http: fix timeout race in Transport proxy CONNECT

Fixes #36070

Change-Id: I99742aa153202436d802634c9e019a14b9ef9185
Reviewed-on: https://go-review.googlesource.com/c/go/+/210738
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agoall: fix a number of misuses of the word "an"
Daniel Martí [Tue, 10 Dec 2019 14:27:53 +0000 (14:27 +0000)]
all: fix a number of misuses of the word "an"

After golang.org/cl/210124, I wondered if the same error had gone
unnoticed elsewhere. I quickly spotted another dozen mistakes after
reading through the output of:

git grep '\<[Aa]n [bcdfgjklmnpqrtvwyz][a-z]'

Many results are false positives for acronyms like "an mtime", since
it's pronounced "an em-time". However, the total amount of output isn't
that large given how simple the grep pattern is.

Change-Id: Iaa2ca69e42f4587a9e3137d6c5ed758887906ca6
Reviewed-on: https://go-review.googlesource.com/c/go/+/210678
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Zach Jones <zachj1@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/go: document 'go env GOMOD' outside modules
Jay Conrod [Mon, 9 Dec 2019 19:29:29 +0000 (14:29 -0500)]
cmd/go: document 'go env GOMOD' outside modules

In documentation for 'go env GOMOD', note that the path will be
os.DevNull in module-aware mode when no go.mod file is present.

Fixes #36052

Change-Id: I30ced1df02ccefe1970bd856190e79d6f0384375
Reviewed-on: https://go-review.googlesource.com/c/go/+/210577
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocmd/link: fix imports problem in elf_test.go
Than McIntosh [Mon, 9 Dec 2019 20:13:24 +0000 (15:13 -0500)]
cmd/link: fix imports problem in elf_test.go

Fix an imports problem in this test (doesn't compile).

Updates #35779

Change-Id: Icaeec0384bf2e75696e43d9410df7219f0245940
Reviewed-on: https://go-review.googlesource.com/c/go/+/210578
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/link: fix loadelf failed on MIPS family
Meng Zhuo [Fri, 6 Dec 2019 08:13:44 +0000 (16:13 +0800)]
cmd/link: fix loadelf failed on MIPS family

The relocation of MIPS64 family ELF is different with other architecure according
to the document from Linux-MIPS

https://www.linux-mips.org/pub/linux/mips/doc/ABI/elf64-2.4.pdf

In "2.9 Relocation" it shows relocation section contains five parts:

1. r_sym Elf64_Word Symbol index
2. r_ssym Elf64_Byte Special symbol
3. r_type3 Elf64_Byte Relocation type
4. r_type2 Elf64_Byte Relocation type
5. r_type Elf64_Byte Relocation type

This CL makes loadelf aware the difference.

Update #35779

Change-Id: Ib221665641972b1c2bfea5a496e3118e5dc0bc45
Reviewed-on: https://go-review.googlesource.com/c/go/+/209317
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoruntime: use mprotect in sysMap for aix/ppc64
Clément Chigot [Thu, 14 Nov 2019 14:43:55 +0000 (15:43 +0100)]
runtime: use mprotect in sysMap for aix/ppc64

AIX doesn't allow to mmap an already mmap address. The previous way to
deal with this behavior was to munmap before calling mmap again.
However, mprotect syscall is able to change protections on a memory
range. Thus, memory mapped by sysReserve can be remap using it. Note
that sysMap is always called with a non-nil pointer so mprotect is
always possible.

Updates: #35451

Change-Id: I1fd1e1363d9ed9eb5a8aa7c8242549bd6dad8cd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/207237
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
5 years agonet/http: don't wait indefinitely in Transport for proxy CONNECT response
Brad Fitzpatrick [Fri, 6 Dec 2019 20:47:29 +0000 (20:47 +0000)]
net/http: don't wait indefinitely in Transport for proxy CONNECT response

Fixes #28012

Change-Id: I711ebaabf63194e3d2c608d829da49c51a294d74
Reviewed-on: https://go-review.googlesource.com/c/go/+/210286
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoruntime/race: correct typo s/is/in
Muhammad Falak R Wani [Sun, 8 Dec 2019 16:44:52 +0000 (22:14 +0530)]
runtime/race: correct typo s/is/in

Change-Id: Ic79d97c2aa107c0e5c4a8906ad757b0390228bef
Reviewed-on: https://go-review.googlesource.com/c/go/+/210417
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: suggest more kernel options for mlock failure
Mark Pulford [Fri, 6 Dec 2019 22:50:17 +0000 (09:50 +1100)]
runtime: suggest more kernel options for mlock failure

Some Linux distributions will continue to provide 5.3.x kernels for a
while rather than 5.4.x.

Updates #35777

Change-Id: I493ef8338d94475f4fb1402ffb9040152832b0fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/210299
Reviewed-by: Austin Clements <austin@google.com>
5 years agocmd/go: clarify -dropreplace help text in 'go help mod edit'
Jay Conrod [Fri, 6 Dec 2019 20:02:41 +0000 (15:02 -0500)]
cmd/go: clarify -dropreplace help text in 'go help mod edit'

Fixes #34930

Change-Id: Ie0ddd8de6e40f5a192c4d2267399126e449fe5f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/210340
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agoruntime: mlock top of signal stack on both amd64 and 386
Austin Clements [Mon, 9 Dec 2019 03:24:10 +0000 (22:24 -0500)]
runtime: mlock top of signal stack on both amd64 and 386

CL 209899 worked around an issue that corrupts vector registers in
recent versions of the Linux kernel by mlocking the top page of every
signal stack on amd64. However, the underlying issue also affects the
XMM registers on 386. This CL applies the mlock fix to both amd64 and
386.

Fixes #35777 (again).

Change-Id: I9886f2dc4c23625421296bd5518d5fd3288bfe48
Reviewed-on: https://go-review.googlesource.com/c/go/+/210345
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agogo/ast: fix a few incorrect "an" articles
Daniel Martí [Sun, 8 Dec 2019 20:54:10 +0000 (20:54 +0000)]
go/ast: fix a few incorrect "an" articles

slice, type, and select should all go with "a", not "an", since they all
start with consonant sounds.

Change-Id: I57e96dcbdc571dc21e24096779f2f756ec81103e
Reviewed-on: https://go-review.googlesource.com/c/go/+/210124
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agodoc: add missing p in install from source page
Alberto Donizetti [Sat, 7 Dec 2019 15:52:10 +0000 (16:52 +0100)]
doc: add missing p in install from source page

The last paragraph in golang.org/doc/install/source#fetch is missing a
p tag, so it doesn't get formatted with the 'max-width: 50rem' like
all the other text in the page.

Add it.

Change-Id: I1a981dd2afde561b4ab21bd90ad99b3a146111f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/210122
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet/http: unflake TestTimeoutHandlerSuperfluousLogs
Emmanuel T Odeke [Fri, 22 Nov 2019 19:18:43 +0000 (14:18 -0500)]
net/http: unflake TestTimeoutHandlerSuperfluousLogs

Uses 2 channels to synchronize that test, because
relying on sleeps creates flaky behavior, thus:

a) 1 buffered channel to send back the last spurious line
without having to reason about "happens before" behavior
a) 1 buffered channel at the end of the handler; it'll
be controlled by whether we expect to timeout or not,
but will always be closed when the test ends

Fixes #35051

Change-Id: Iff735aa8d1ed9de8d92b792374ec161cc0a72798
Reviewed-on: https://go-review.googlesource.com/c/go/+/208477
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocrypto/tls: fix a typo in TLS handshake comment
Alex Harford [Fri, 6 Dec 2019 23:27:29 +0000 (23:27 +0000)]
crypto/tls: fix a typo in TLS handshake comment

Fix a minor typo in the TLS handshake comment.

Change-Id: I0fd243e5440f6c77c97e844e6669a7974a2c8798
GitHub-Last-Rev: 21e91a1a48e8a9200e6fca89a988e1383ded7bb2
GitHub-Pull-Request: golang/go#36030
Reviewed-on: https://go-review.googlesource.com/c/go/+/210289
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/go/internal/modcmd: loosen path validation in "go mod edit"
Bryan C. Mills [Fri, 6 Dec 2019 20:51:34 +0000 (15:51 -0500)]
cmd/go/internal/modcmd: loosen path validation in "go mod edit"

Replaced modules require only valid import paths, not full
module paths that can be fetched with 'go get'.

The 'go' command does not in general reject manually-edited go.mod
files with these paths, so 'go mod edit' should not reject them
either.

Fixes #30513

Change-Id: I4f1a5c65937f91d41478f8d218c8018e0c70f320
Reviewed-on: https://go-review.googlesource.com/c/go/+/210343
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go/internal/modload: revert duplicate path suppression in modload.ImportMissingError
Bryan C. Mills [Fri, 6 Dec 2019 20:40:04 +0000 (15:40 -0500)]
cmd/go/internal/modload: revert duplicate path suppression in modload.ImportMissingError

CL 210338 suppressed duplication for import paths mentioned in an
ImportMissingError.

Unfortunately, that broke one of the cases in
cmd/go/internal/modload.TestImport, and the new error message is still
kind of awkward anyway.

Let's revert that part of the change — we can try again with more
coverage for that case.

Updates #35986

Change-Id: Ib0858aec4f89a7231e32c35ec876da80d80f2098
Reviewed-on: https://go-review.googlesource.com/c/go/+/210342
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: include cfg.BuildModReason in 'import lookup disabled' errors
Bryan C. Mills [Fri, 6 Dec 2019 20:02:28 +0000 (15:02 -0500)]
cmd/go: include cfg.BuildModReason in 'import lookup disabled' errors

This location was missed in CL 204521.

Updates #33326
Updates #33848

Change-Id: I0ece6d9b37548d8abb54f79c69be5548a0428c76
Reviewed-on: https://go-review.googlesource.com/c/go/+/210341
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/link: skip gaps between PT_LOAD segments in TestPIESize
Cherry Zhang [Fri, 6 Dec 2019 21:52:53 +0000 (16:52 -0500)]
cmd/link: skip gaps between PT_LOAD segments in TestPIESize

There may be gaps between non-writeable and writeable PT_LOAD
segments, and the gaps may be large as the segments may have
large alignment. Don't count those gaps in file size comparison.

Fixes #36023.

Change-Id: I68582bdd0f385ac5c6f87d485d476d06bc96db19
Reviewed-on: https://go-review.googlesource.com/c/go/+/210180
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/go: avoid generating "malformed module path" errors for standard-library paths
Bryan C. Mills [Fri, 6 Dec 2019 19:48:26 +0000 (14:48 -0500)]
cmd/go: avoid generating "malformed module path" errors for standard-library paths

If the path looks like it belongs in GOROOT/src and isn't there, we
should mention that in the error message — instead of the fact
that the path is not a valid module path, which the user likely
already knows.

Fixes #34769
Fixes #35734

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

5 years agostrings: fix nonexistent path in comment
po3rin [Fri, 6 Dec 2019 19:44:39 +0000 (04:44 +0900)]
strings: fix nonexistent path in comment

There is a part in the comment that points to a non-existent file.
It seems to have been overlooked in following PR.
https://go-review.googlesource.com/c/go/+/98518/

Change-Id: I21dbfbd270c654d5cd7fa88d114a356862612d90
Reviewed-on: https://go-review.googlesource.com/c/go/+/210298
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/go: reduce redundancy in direct mode lookup error messages
Jay Conrod [Fri, 6 Dec 2019 18:10:53 +0000 (13:10 -0500)]
cmd/go: reduce redundancy in direct mode lookup error messages

get.RepoRootForImportPath now returns errors that satisfy
load.ImportPathError in cases where the import path appears in the
messages. (The import path probably should appear in all errors from
this function, but this CL does not change these errors).

Changed modfetch.notExistError to be a wrapper (with an Unwrap method)
instead of a string. This means errors.As works with notFoundError and
ImportPathError.

ImportMissingError no longer prints the package path if it wraps an
ImportPathError.

TestMissingImportErrorRepetition no longer counts the package path
within a URL (like https://...?go-get=1).

Fixes #35986

Change-Id: I38f795191c46d04b542c553e705f23822260c790
Reviewed-on: https://go-review.googlesource.com/c/go/+/210338
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agoos: skip a new failing test on Windows
Brad Fitzpatrick [Fri, 6 Dec 2019 16:20:50 +0000 (16:20 +0000)]
os: skip a new failing test on Windows

This test was recently added in CL 209961.

Apparently Windows can't seek a directory filehandle?

And move the test from test/fixedbugs (which is mostly for compiler bugs) to
an os package test.

Updates #36019

Change-Id: I626b69b0294471014901d0ccfeefe5e2c7651788
Reviewed-on: https://go-review.googlesource.com/c/go/+/210283
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoruntime: give useful failure message on mlock failure
Austin Clements [Thu, 5 Dec 2019 19:41:24 +0000 (14:41 -0500)]
runtime: give useful failure message on mlock failure

Currently, we're ignoring failures to mlock signal stacks in the
workaround for #35777. This means if your mlock limit is low, you'll
instead get random memory corruption, which seems like the wrong
trade-off.

This CL checks for mlock failures and panics with useful guidance.

Updates #35777.

Change-Id: I15f02d3a1fceade79f6ca717500ca5b86d5bd570
Reviewed-on: https://go-review.googlesource.com/c/go/+/210098
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agosync: deflake TestWaitGroupMisuse3
Ian Lance Taylor [Thu, 5 Dec 2019 22:49:25 +0000 (14:49 -0800)]
sync: deflake TestWaitGroupMisuse3

If one of the helper goroutine panics, the main goroutine call to Wait
may hang forever waiting for something to call Done. Put that call in
a goroutine like the others.

Fixes #35774

Change-Id: I8d2b58d8f473644a49a95338f70111d4e6ed4e12
Reviewed-on: https://go-review.googlesource.com/c/go/+/210218
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agoall: fix most of the remaining windows -d=checkptr violations
Alex Brainman [Sat, 9 Nov 2019 08:06:24 +0000 (19:06 +1100)]
all: fix most of the remaining windows -d=checkptr violations

This change replaces

buf := [HUGE_CONST]*T)(unsafe.Pointer(p))[:]

with

buf := [HUGE_CONST]*T)(unsafe.Pointer(p))[:n:n]

Pointer p points to n of T elements. New unsafe pointer conversion
logic verifies that both first and last elements point into the same
Go variable.

This change replaces [:] with [:n:n] to please pointer checker.
According to @mdempsky, compiler specially recognizes when you
combine a pointer conversion with a full slice operation in a single
expression and makes an exception.

After this, only one failure in net remains when running:

go test -a -short -gcflags=all=-d=checkptr std cmd

Updates #34972

Change-Id: I2c8731650c856264bc788e4e07fa0530f7c250fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/208617
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agogo/types: print package path in error messages if package name is not unique
Robert Griesemer [Mon, 2 Dec 2019 17:38:03 +0000 (09:38 -0800)]
go/types: print package path in error messages if package name is not unique

Change package qualification to print the full package path for packages
that have non-unique names (that is, where multiple different packages
have the same name). Use the package name as qualifier in all other cases
(but don't print any qualification if we're talking about the package
being type-checked).

This matches the behavior of the compiler.

Fixes #35895.

Change-Id: I33ab8e7adfae1378907c01e33cabda114f65887f
Reviewed-on: https://go-review.googlesource.com/c/go/+/209578
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/go: fix check for -Wp,-U in cgo CFLAGS
Tobias Klauser [Thu, 5 Dec 2019 22:55:39 +0000 (23:55 +0100)]
cmd/go: fix check for -Wp,-U in cgo CFLAGS

There should be no space after comma.

Change-Id: I6a5c85a386d9d1611b71d5b15a31a00c24c316b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/210120
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoruntime: add Gosched to TestSelectStackAdjust loop
Ian Lance Taylor [Thu, 5 Dec 2019 21:44:01 +0000 (13:44 -0800)]
runtime: add Gosched to TestSelectStackAdjust loop

Give the runtime more of a chance to do other work in a tight loop.

Fixes #34693

Change-Id: I8df6173d2c93ecaccecf4520a6913b495787df78
Reviewed-on: https://go-review.googlesource.com/c/go/+/210217
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: mark empty block preemptible
Cherry Zhang [Tue, 3 Dec 2019 03:56:40 +0000 (22:56 -0500)]
cmd/compile: mark empty block preemptible

Currently, a block's control instruction gets the liveness info
of the last Value in the block. However, for an empty block, the
control instruction gets the invalid liveness info and therefore
not preemptible. One example is empty infinite loop, which has
only a control instruction. The control instruction being non-
preemptible makes the whole loop non-preemptible.

Fix this by using a different, preemptible liveness info for
empty block's control. We can choose an arbitrary preemptible
liveness info, as at run time we don't really use the liveness
map at that instruction.

As before, if the last Value in the block is non-preemptible, so
is the block control. For example, the conditional branch in the
write barrier test block is still non-preemptible.

Also, only update liveness info if we are actually emitting
instructions. So zero-width Values' liveness info (which are
always invalid) won't affect the block control's liveness info.
For example, if the last Values in a block is a tuple-generating
operation and a Select, the block control instruction is still
preemptible.

Fixes #35923.

Change-Id: Ic5225f3254b07e4955f7905329b544515907642b
Reviewed-on: https://go-review.googlesource.com/c/go/+/209659
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
5 years agocmd/compile: don't fuse branches with side effects
Cherry Zhang [Thu, 5 Dec 2019 23:56:54 +0000 (18:56 -0500)]
cmd/compile: don't fuse branches with side effects

Count Values with side effects but no use as live, and don't fuse
branches that contain such Values. (This can happen e.g. when it
is followed by an infinite loop.) Otherwise this may lead to
miscompilation (side effect fired at wrong condition) or ICE (two
stores live simultaneously).

Fixes #36005.

Change-Id: If202eae4b37cb7f0311d6ca120ffa46609925157
Reviewed-on: https://go-review.googlesource.com/c/go/+/210179
Reviewed-by: Keith Randall <khr@golang.org>
5 years agodoc/go1.14: document freebsd/arm64 port
Tobias Klauser [Thu, 5 Dec 2019 21:46:12 +0000 (22:46 +0100)]
doc/go1.14: document freebsd/arm64 port

Updates #24715

Change-Id: Ie6421cf2d599740bbb0576bcc37bd8ddf5af3961
Reviewed-on: https://go-review.googlesource.com/c/go/+/210119
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/go: print newline after GOOS/GOARCH error
Rhys Hiltner [Thu, 5 Dec 2019 03:37:00 +0000 (19:37 -0800)]
cmd/go: print newline after GOOS/GOARCH error

The newline was dropped during the refactor in CL 194617.

Fixes #35984

Change-Id: I7e0d7aa2d7a4d1f44898921f8bb40401620d78b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/209965
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/go: include imports in 'go list -e' output even after parse errors
Jay Conrod [Thu, 5 Dec 2019 18:28:57 +0000 (13:28 -0500)]
cmd/go: include imports in 'go list -e' output even after parse errors

If we aren't able to load imports from one file in a package due to a
parse error (scanner.ErrorList), 'go list -e' should still list
imports in other files.

Fixes #35973

Change-Id: I59f171877949bb7afaf252b6c8a970de22e60c7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/210097
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agoos: reset dirinfo when seeking on Darwin
Keith Randall [Wed, 4 Dec 2019 22:58:04 +0000 (14:58 -0800)]
os: reset dirinfo when seeking on Darwin

The first Readdirnames calls opendir and caches the result.
The behavior of that cached opendir result isn't specified on a seek
of the underlying fd. Free the opendir result on a seek so that
we'll allocate a new one the next time around.

Also fix wasm behavior in this regard, so that a seek to the
file start resets the Readdirnames position, regardless of platform.

p.s. I hate the Readdirnames API.

Fixes #35767.

Change-Id: Ieffb61b3c5cdd42591f69ab13f932003966f2297
Reviewed-on: https://go-review.googlesource.com/c/go/+/209961
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/go: test that 'go list -e -mod=readonly' reports errors correctly
Jay Conrod [Tue, 26 Nov 2019 22:07:26 +0000 (17:07 -0500)]
cmd/go: test that 'go list -e -mod=readonly' reports errors correctly

This issue was fixed by earlier improvements to error handling when
loading modules.

Fixes #34829

Change-Id: I4cf4e182a7381f8b5c359179d90bd02491ea7911
Reviewed-on: https://go-review.googlesource.com/c/go/+/209037
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agodoc: add CherryPickApproved filter to Release History links
Dmitri Shuralyov [Thu, 5 Dec 2019 14:13:21 +0000 (17:13 +0300)]
doc: add CherryPickApproved filter to Release History links

Not all closed issues in a given minor milestone are included in that
release, only the ones that have been labeled as CherryPickApproved are.

Update the links to the GitHub issue tracker to include a filter on the
CherryPickApproved label, so that the default view shows only the
backports that were included in a given release. This should more useful
to most people than seeing all backports (considered and approved).

Do this only for Go 1.9.1 and newer releases, as that is when we started
using the CherryPickCandidate and CherryPickApproved labels.

Fixes #35988

Change-Id: I51e07c1bc3ab9c4a5744e8f668c5470adf78bffe
Reviewed-on: https://go-review.googlesource.com/c/go/+/209918
Reviewed-by: Alexander Rakoczy <alex@golang.org>
5 years agocmd/go: delete TestGetFileURL temporary file
Meng Zhuo [Thu, 5 Dec 2019 09:34:57 +0000 (17:34 +0800)]
cmd/go: delete TestGetFileURL temporary file

Change-Id: I191ac2a2b469c6179d22d66c15f2d96ecb3d0902
Reviewed-on: https://go-review.googlesource.com/c/go/+/209970
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agosrc/go.mod: sync golang.org/x/net with h2_bundle.go
Filippo Valsorda [Thu, 5 Dec 2019 00:30:06 +0000 (19:30 -0500)]
src/go.mod: sync golang.org/x/net with h2_bundle.go

CL 209077 updated bundled http2 to x/net git rev ef20fe5d7 without
bumping the go.mod version.

Identified with the new go/packages based cmd/bundle from CL 189818.

$ go get golang.org/x/net@ef20fe5d7
$ go mod tidy
$ go mod vendor
$ go generate -run bundle std # with CL 189818

Updates #32031

Change-Id: I581d35f33e2adafb588b2b0569648039187234a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/209901
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: remove comment about gcCopySpans()
Johan Jansson [Wed, 4 Dec 2019 20:39:44 +0000 (22:39 +0200)]
runtime: remove comment about gcCopySpans()

Remove documentation reference to gcCopySpans(), as that function was
removed in https://golang.org/cl/30537

Fixes #35683

Change-Id: I7fb7c6cc60bfb3a133a019a20eb3f9d4c7627b31
Reviewed-on: https://go-review.googlesource.com/c/go/+/209917
Reviewed-by: Austin Clements <austin@google.com>
5 years agotesting: fix testing docs
taisa [Wed, 4 Dec 2019 08:31:59 +0000 (17:31 +0900)]
testing: fix testing docs

The Perm function return 0 or 1 or 2 or 3. 4 is not returned,
so that changed the argument to 5.

Change-Id: Ic980c71a9f29f522bdeef4fce70a6c2dd136d791
Reviewed-on: https://go-review.googlesource.com/c/go/+/209777
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/link: when changing to Segrelrodata, reset datsize
Ian Lance Taylor [Tue, 26 Nov 2019 06:17:29 +0000 (22:17 -0800)]
cmd/link: when changing to Segrelrodata, reset datsize

Otherwise we leave a gap at the start of Segrelrodata equal to the
size of the read-only non-relro data, which causes -buildmode=pie
executables to be noticeably larger than -buildmode=exe executables.

Change-Id: I98956ef29d5b7a57ad8e633c823ac09d9ca36a45
Reviewed-on: https://go-review.googlesource.com/c/go/+/208897
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoruntime: mlock top of signal stack on Linux 5.2–5.4.1
Austin Clements [Mon, 2 Dec 2019 22:36:25 +0000 (17:36 -0500)]
runtime: mlock top of signal stack on Linux 5.2–5.4.1

Linux 5.2 introduced a bug that can corrupt vector registers on return
from a signal if the signal stack isn't faulted in:
https://bugzilla.kernel.org/show_bug.cgi?id=205663

This CL works around this by mlocking the top page of all Go signal
stacks on the affected kernels.

Fixes #35326, #35777

Change-Id: I77c80a2baa4780827633f92f464486caa222295d
Reviewed-on: https://go-review.googlesource.com/c/go/+/209899
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
5 years agoruntime: add a simple version number parser
Austin Clements [Mon, 2 Dec 2019 22:32:01 +0000 (17:32 -0500)]
runtime: add a simple version number parser

This will be used to parse the Linux kernel versions, but this code is
generic and can be tested on its own.

For #35777.

Change-Id: If1df48d07250e5855dde45bc9d57c66f777b9fb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/209597
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/go: fix list_constraints test on non-amd64 platforms
Jay Conrod [Wed, 4 Dec 2019 23:01:05 +0000 (18:01 -0500)]
cmd/go: fix list_constraints test on non-amd64 platforms

Test set GOOS to linux and darwin without setting GOARCH. darwin is
not a valid GOOS for all architectures we test.

Fixes #35976

Change-Id: I4da2ebcbf9ad52e07bcc1632b48fcfdbc49b1289
Reviewed-on: https://go-review.googlesource.com/c/go/+/209900
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agogo/build: don't include imports from cgo files when CGO_ENABLED=0
Jay Conrod [Tue, 3 Dec 2019 20:02:10 +0000 (15:02 -0500)]
go/build: don't include imports from cgo files when CGO_ENABLED=0

Fixes #35873
Fixes #35946

Change-Id: I9f9a9c09006f8957569db6e5cc13382b9b28f829
Reviewed-on: https://go-review.googlesource.com/c/go/+/209660
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agomath/rand: update comment to avoid use of ^ for exponentiation
Brad Fitzpatrick [Wed, 4 Dec 2019 17:04:02 +0000 (17:04 +0000)]
math/rand: update comment to avoid use of ^ for exponentiation

Fixes #35920

Change-Id: I1a4d26c5f7f3fbd4de13fc337de482667d83c47f
Reviewed-on: https://go-review.googlesource.com/c/go/+/209758
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
5 years agodoc: fix typo in Go 1.12.14 document
Carlos Amedee [Wed, 4 Dec 2019 19:14:10 +0000 (14:14 -0500)]
doc: fix typo in Go 1.12.14 document

Change-Id: I3641a086f167a1337aaaacd2d758b6a42b84a7fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/209845
Run-TryBot: Carlos Amedee <carlos@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agodoc: document Go 1.13.5
Carlos Amedee [Wed, 4 Dec 2019 18:15:08 +0000 (13:15 -0500)]
doc: document Go 1.13.5

Change-Id: I289d13ff0a01466d93ebc555eaa81273d4297eb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/209841
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agodoc: document Go 1.12.14
Carlos Amedee [Wed, 4 Dec 2019 18:14:04 +0000 (13:14 -0500)]
doc: document Go 1.12.14

Change-Id: I7589ef4bdac776c8f141e9cc60f59f8643649310
Reviewed-on: https://go-review.googlesource.com/c/go/+/209840
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/objdump: reference tracking bug in TestDisasmCode skip message
Tobias Klauser [Wed, 4 Dec 2019 10:44:06 +0000 (11:44 +0100)]
cmd/objdump: reference tracking bug in TestDisasmCode skip message

Issue #12559 was closed and split into #19158 for mips{,le} and #19156
for mips64{,le}. Instead of referencing the individual GOARCH-specific
issues in the skip test messages of TestDisasmCode use the tracking bug

Change-Id: I6929d25f4ec5aef4f069b7692c4e29106088ce65
Reviewed-on: https://go-review.googlesource.com/c/go/+/209817
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoruntime: convert page allocator bitmap to sparse array
Michael Anthony Knyszek [Thu, 14 Nov 2019 23:58:50 +0000 (23:58 +0000)]
runtime: convert page allocator bitmap to sparse array

Currently the page allocator bitmap is implemented as a single giant
memory mapping which is reserved at init time and committed as needed.
This causes problems on systems that don't handle large uncommitted
mappings well, or institute low virtual address space defaults as a
memory limiting mechanism.

This change modifies the implementation of the page allocator bitmap
away from a directly-mapped set of bytes to a sparse array in same vein
as mheap.arenas. This will hurt performance a little but the biggest
gains are from the lockless allocation possible with the page allocator,
so the impact of this extra layer of indirection should be minimal.

In fact, this is exactly what we see:
    https://perf.golang.org/search?q=upload:20191125.5

This reduces the amount of mapped (PROT_NONE) memory needed on systems
with 48-bit address spaces to ~600 MiB down from almost 9 GiB. The bulk
of this remaining memory is used by the summaries.

Go processes with 32-bit address spaces now always commit to 128 KiB of
memory for the bitmap. Previously it would only commit the pages in the
bitmap which represented the range of addresses (lowest address to
highest address, even if there are unused regions in that range) used by
the heap.

Updates #35568.
Updates #35451.

Change-Id: I0ff10380156568642b80c366001eefd0a4e6c762
Reviewed-on: https://go-review.googlesource.com/c/go/+/207497
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/vet: honor analyzer flags when running vet outside $GOROOT/src
Xiangdong Ji [Fri, 22 Nov 2019 17:02:06 +0000 (17:02 +0000)]
cmd/vet: honor analyzer flags when running vet outside $GOROOT/src

Additional vet flags specified by user are discarded if 'go vet'
is invoked outside $GOROOT/src to check a package under $GOROOT
(including those under "vendor" of $GOROOT), fix it by avoiding the
overwriting, the logic of detemining if the package under vetting
comes from $GOROOT remains untouched.

Also checked 'go tool vet <options> <cfg>' and 'go vet <options>
<user pkg>', both worked w./w.o this fix.

Fixes #35837.

Change-Id: I549af7964e40440afd35f2d1971f77eee6f8de34
Reviewed-on: https://go-review.googlesource.com/c/go/+/209498
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agoruntime: treat call from runtime as transient in TestDebugCall
Ian Lance Taylor [Mon, 18 Nov 2019 19:13:20 +0000 (11:13 -0800)]
runtime: treat call from runtime as transient in TestDebugCall

Fixes #32985

Change-Id: I5d504715dcc92d4f4f560ea2e843d9275f938685
Reviewed-on: https://go-review.googlesource.com/c/go/+/207620
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
5 years agoruntime: use current P's race context in timer code
Ian Lance Taylor [Mon, 2 Dec 2019 20:07:22 +0000 (12:07 -0800)]
runtime: use current P's race context in timer code

We were using the race context of the P that held the timer,
but since we unlock the P's timers while executing a timer
that could lead to a race on the race context itself.

Updates #6239
Updates #27707
Fixes #35906

Change-Id: I5f9d5f52d8e28dffb88c3327301071b16ed1a913
Reviewed-on: https://go-review.googlesource.com/c/go/+/209580
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
5 years agoos/exec: document that cmd.Start() sets the Process field
Günther Noack [Mon, 2 Dec 2019 19:27:51 +0000 (19:27 +0000)]
os/exec: document that cmd.Start() sets the Process field

Change-Id: I4f41b680741e9bd2a4e8c094ecf3ce6226e48d12
GitHub-Last-Rev: 8f58bc6c4398cf739b33f8b5368926d6650059c3
GitHub-Pull-Request: golang/go#35934
Reviewed-on: https://go-review.googlesource.com/c/go/+/209558
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/link: additional fixes for -newobj and "ld -r" ELF host objects
Than McIntosh [Mon, 25 Nov 2019 19:07:59 +0000 (14:07 -0500)]
cmd/link: additional fixes for -newobj and "ld -r" ELF host objects

The previous fix for this issue (CL 208479) was not general enough;
this patch revises it to handle more cases.

The problem with the original fix was that once a sym.Symbol is
created for a given static symbol and given a bogus anonymous version
of -1, we hit problems if some other non-anonymous symbol (created by
host object loading) had relocations targeting the static symbol.

In this patch instead of assigning a fixed anonymous version of -1 to
such symbols, each time loader.Create is invoked we create a new
(unique) anonymous version for the sym.Symbol, then enter the result
into the loader's extStaticSyms map, permitting it to be found in
lookups when processing relocation targets.

NB: this code will hopefully get a lot simpler once we can move host
object loading away from early sym.Symbol creation.

Updates #35779.

Change-Id: I450ff577e17549025565d355d6707a2d28a5a617
Reviewed-on: https://go-review.googlesource.com/c/go/+/208778
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: declare with type for fmtMode constant
Tao Qingyun [Mon, 2 Dec 2019 01:38:30 +0000 (09:38 +0800)]
cmd/compile: declare with type for fmtMode constant

Like FmtFlag constant in fmt.go

Change-Id: I351bcb27095549cf19db531f532ea72d5c682610
Reviewed-on: https://go-review.googlesource.com/c/go/+/209497
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agotime: fix comment in test
Xudong Zhang [Mon, 2 Dec 2019 09:32:04 +0000 (09:32 +0000)]
time: fix comment in test

The commit de36d1 (CL 4635083) changed the test time
from 2009 to 2010 but forgot to update the comment.

Change-Id: Ia2928773dd184f168fddde126d0bb936de8cfc29
GitHub-Last-Rev: bf8eb57140dc531d1af449308b79c646d3b64d02
GitHub-Pull-Request: golang/go#35930
Reviewed-on: https://go-review.googlesource.com/c/go/+/209517
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: on plan9 don't return substitute address for sysReserve
Richard Miller [Tue, 19 Nov 2019 13:15:28 +0000 (13:15 +0000)]
runtime: on plan9 don't return substitute address for sysReserve

Plan 9 doesn't have a way to reserve virtual memory, so the
implementation of sysReserve allocates memory space (which won't
be backed with real pages until the virtual pages are referenced).
If the space is then freed with sysFree, it's not returned to
the OS (because Plan 9 doesn't allow shrinking a shared address
space), but it must be cleared to zeroes in case it's reallocated
subsequently.

This interacts badly with the way mallocinit on 64-bit machines
sets up the heap, calling sysReserve repeatedly for a very large
(64MB?) arena with a non-nil address hint, and then freeing the space
again because it doesn't have the expected alignment.  The
repeated clearing of multiple megabytes adds significant startup
time to every go program.

We correct this by restricting sysReserve to allocate memory only
when the caller doesn't provide an address hint.  If a hint is
provided, sysReserve will now return nil instead of allocating memory
at a different address.

Fixes #27744

Change-Id: Iae5a950adefe4274c4bc64dd9c740d19afe4ed1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/207917
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
5 years agoruntime: ready scavenger without next
Michael Anthony Knyszek [Fri, 22 Nov 2019 21:06:15 +0000 (21:06 +0000)]
runtime: ready scavenger without next

This change makes it so that waking up the scavenger readies its
goroutine without "next" set, so that it doesn't interfere with the
application's use of the runnext feature in the scheduler which helps
fairness.

As of CL 201763 the scavenger began waking up much more often, and in
TestPingPongHog this meant that it would sometimes supercede either a
hog or light goroutine in runnext, leading to a skew in the results and
ultimately a test flake.

This change thus re-enables the TestPingPongHog test on the builders.

Fixes #35271.

Change-Id: Iace08576912e8940554dd7de6447e458ad0d201d
Reviewed-on: https://go-review.googlesource.com/c/go/+/208380
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years agocmd/go/internal/modget: synchronize writes to modOnly map in runGet
Carlos Amedee [Wed, 27 Nov 2019 18:31:36 +0000 (18:31 +0000)]
cmd/go/internal/modget: synchronize writes to modOnly map in runGet

Adds an additional lock around an access to modOnly.

Updates #35317

Change-Id: Ia1e75f9a674ec2a2c0489b41283c1cd3e7924d1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/209237
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: enable -x in go mod download
Hana (Hyang-Ah) Kim [Sat, 23 Nov 2019 17:06:21 +0000 (12:06 -0500)]
cmd/go: enable -x in go mod download

Lack of logging hinders debugging. Like many other go commands,
let's allow users to inspect what is going on underneath.

Example:

$ GO111MODULE=on GOPROXY=direct GOPATH=`mktemp -d` go mod download -x golang.org/x/tools/gopls@latest
mkdir -p /var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/tmp.ykhTiXaS/pkg/mod/cache/vcs # git3 https://go.googlesource.com/tools
...

Update #35849

Change-Id: I5577e683ae3c0145b11822df255b210ad9f60c87
Reviewed-on: https://go-review.googlesource.com/c/go/+/208558
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
5 years agodoc: add section on resolving packages to module reference doc
Jay Conrod [Mon, 25 Nov 2019 19:38:34 +0000 (14:38 -0500)]
doc: add section on resolving packages to module reference doc

Updates #33637

Change-Id: I3b4303479b44894442a04226cbf1f1e27dbb2fb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/208779
Reviewed-by: Tyler Bui-Palsulich <tbp@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agoruntime: reset scavenge address in scavengeAll
Michael Anthony Knyszek [Tue, 26 Nov 2019 21:16:43 +0000 (21:16 +0000)]
runtime: reset scavenge address in scavengeAll

Currently scavengeAll (which is called by debug.FreeOSMemory) doesn't
reset the scavenge address before scavenging, meaning it could miss
large portions of the heap. Fix this by reseting the address before
scavenging, which will ensure it is able to walk over the entire heap.

Fixes #35858.

Change-Id: I4a7408050b8e134318ff94428f98cb96a1795aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/208960
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agonet/http: update bundled x/net/http2
Brad Fitzpatrick [Tue, 26 Nov 2019 23:57:35 +0000 (23:57 +0000)]
net/http: update bundled x/net/http2

Updates bundled http2 to x/net git rev ef20fe5d7 for:

   http2: make Transport.IdleConnTimeout consider wall (not monotonic) time
   https://golang.org/cl/208798 (#29308)

   http2: make CipherSuites validation error more verbose
   https://golang.org/cl/200317 (#34776)

   http2: track unread bytes when the pipe is broken
   https://golang.org/cl/187377 (#28634)

   http2: split cookie pair into separate hpack header fields
   https://golang.org/cl/155657 (#29386)

Fixes #29308
Fixes #28634

Change-Id: I71a03ca62ccb5ff35a5cfadd8dc705a4491ae7ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/209077
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agodoc: clarify interaction of ioutil.WriteFile with umask
Mostyn Bramley-Moore [Wed, 27 Nov 2019 00:10:47 +0000 (00:10 +0000)]
doc: clarify interaction of ioutil.WriteFile with umask

Note that ioutil.WriteFile's perm argument is the value before the
umask is applied.

Fixes #35835

Change-Id: I61cd9c88bced3be52b616d86e060cd3fd912ab1f

Change-Id: I61cd9c88bced3be52b616d86e060cd3fd912ab1f
GitHub-Last-Rev: 0069abb7c5d904fb11448148f44db023dbcf74aa
GitHub-Pull-Request: golang/go#35836
Reviewed-on: https://go-review.googlesource.com/c/go/+/208838
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoruntime: print more information on stack overflow
Cherry Zhang [Fri, 15 Nov 2019 02:34:35 +0000 (21:34 -0500)]
runtime: print more information on stack overflow

Print the current SP and (old) stack bounds when the stack grows
too large. This helps to identify the problem: whether a large
stack is used, or something else goes wrong.

For #35470.

Change-Id: I34a4064d5c7280978391d835e171b90d06f87222
Reviewed-on: https://go-review.googlesource.com/c/go/+/207351
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agocmd/internal/obj: mark split-stack prologue nonpreemptible
Cherry Zhang [Fri, 15 Nov 2019 01:23:17 +0000 (20:23 -0500)]
cmd/internal/obj: mark split-stack prologue nonpreemptible

When there are both a synchronous preemption request (by
clobbering the stack guard) and an asynchronous one (by signal),
the running goroutine may observe the synchronous request first
in stack bounds check, and go to the path of calling morestack.
If the preemption signal arrives at this point before the call to
morestack, the goroutine will be asynchronously preempted,
entering the scheduler. When it is resumed, the scheduler clears
the preemption request, unclobbers the stack guard. But the
resumed goroutine will still call morestack, as it is already on
its way. morestack will, as there is no preemption request,
double the stack unnecessarily. If this happens multiple times,
the stack may grow too big, although only a small amount is
actually used.

To fix this, we mark the stack bounds check and the call to
morestack async-nonpreemptible, starting after the memory
instruction (mostly a load, on x86 CMP with memory).

Not done for Wasm as it does not support async preemption.

Fixes #35470.

Change-Id: Ibd7f3d935a3649b80f47539116ec9b9556680cf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/207350
Reviewed-by: David Chase <drchase@google.com>
5 years agocmd/internal/obj, runtime: use register map to mark unsafe points
Cherry Zhang [Thu, 14 Nov 2019 22:03:44 +0000 (17:03 -0500)]
cmd/internal/obj, runtime: use register map to mark unsafe points

Currently we use stack map index -2 to mark unsafe points, i.e.
PC ranges that is not safe for async preemption. This has a
problem: it cannot mark CALL instructions, because for stack scan
a valid stack map index is needed.

This CL switches to use register map index for marking unsafe
points instead, which does not conflict with stack scan and can
be applied on CALL instructions. This is necessary as next CL
will mark call to morestack nonpreemptible.

For #35470.

Change-Id: I357bf26c996e1fee1e7eebe4e6bb07d62930d3f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/207349
Reviewed-by: David Chase <drchase@google.com>
5 years agodoc: add section on GOPROXY protocol to module reference doc
Jay Conrod [Mon, 25 Nov 2019 18:46:32 +0000 (13:46 -0500)]
doc: add section on GOPROXY protocol to module reference doc

Based on 'go help goproxy'.

Updates #33637

Change-Id: I2f3477cfc8f6fb53515604a28a5bc01eb4fe8f48
Reviewed-on: https://go-review.googlesource.com/c/go/+/208777
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocmd: update golang.org/x/mod and vendor
Jay Conrod [Tue, 26 Nov 2019 16:27:25 +0000 (11:27 -0500)]
cmd: update golang.org/x/mod and vendor

This CL pulls in a fix to golang.org/x/mod/modfile. No change needed
to cmd/go.

Fixes #35737

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

5 years agoruntime: disable async preemption on darwin/arm(64) if no cgo
Cherry Zhang [Tue, 26 Nov 2019 04:29:02 +0000 (23:29 -0500)]
runtime: disable async preemption on darwin/arm(64) if no cgo

On darwin, we use libc calls, and cgo is required on ARM and
ARM64 so we have TLS set up to save/restore G during C calls. If
cgo is absent, we cannot save/restore G in TLS, and if a signal
is received during C execution we cannot get the G. Therefore
don't send signals (and hope that we won't receive any signal
during C execution).

This can only happen in the go_bootstrap program (otherwise cgo
is required).

Fixes #35800.

Change-Id: I6c02a9378af02c19d32749a42db45165b578188d
Reviewed-on: https://go-review.googlesource.com/c/go/+/208818
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agolib/time: update tz data to 2019c
Kyle Shannon [Mon, 25 Nov 2019 20:51:02 +0000 (13:51 -0700)]
lib/time: update tz data to 2019c

Updates #22487

Change-Id: I32dcd604af84e2000196d64bf69c67f81535290a
Reviewed-on: https://go-review.googlesource.com/c/go/+/208797
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
5 years agoos: fix broken comment's link
skanehira [Mon, 25 Nov 2019 23:08:03 +0000 (23:08 +0000)]
os: fix broken comment's link

Change-Id: Icf6cb06dfdde00de1db5e57b243d7e60a9e4e7ac
GitHub-Last-Rev: 45003b0656dec68cf0bc1f32b3de2ab688875524
GitHub-Pull-Request: golang/go#35834
Reviewed-on: https://go-review.googlesource.com/c/go/+/208837
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/link: fix TestStrictDup in module mode
Fazlul Shahriar [Sat, 23 Nov 2019 05:31:39 +0000 (00:31 -0500)]
cmd/link: fix TestStrictDup in module mode

Fixes #35790

Change-Id: Ie9df103c5c21b34a378821dfad60804ce4b0cad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/208517
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/go: prefix calls to Windows rmdir with cmd.exe
Jason A. Donenfeld [Mon, 25 Nov 2019 18:23:44 +0000 (19:23 +0100)]
cmd/go: prefix calls to Windows rmdir with cmd.exe

rmdir is a built-in of cmd.exe. It's also an alias in powershell.exe. We
want always the cmd.exe on, so specify it explicitly.

Fixes #35813

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

5 years agomisc/cgo/testshared: do not write to GOROOT
Bryan C. Mills [Fri, 22 Nov 2019 15:34:55 +0000 (10:34 -0500)]
misc/cgo/testshared: do not write to GOROOT

Instead of installing shared libraries to GOROOT/pkg, clone the
necessary files into a new GOROOT and run there.

Given that we now have a build cache, ideally we should not need to
install into GOROOT/pkg at all, but we can't fix that during the 1.14
code freeze.

Updates #28387
Updates #28553
Updates #30316

Change-Id: I83084a8ca29a5dffcd586c7fccc3f172cac57cc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/208482
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agomisc: log 'ok' from 'go run' tests on success
Bryan C. Mills [Fri, 22 Nov 2019 22:14:25 +0000 (17:14 -0500)]
misc: log 'ok' from 'go run' tests on success

Otherwise, these tests produce no output, which can make the overall
output of all.bash a bit tricky to decipher.

Updates #30316
Updates #29062

Change-Id: I33b9e070fd28b9f21ece128e9e603a982c08b7cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/208483
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agomisc: remove use of relative directories in overlayDir functions
Bryan C. Mills [Fri, 22 Nov 2019 21:06:11 +0000 (16:06 -0500)]
misc: remove use of relative directories in overlayDir functions

It turns out that the relative-path support never worked in the first
place.

It had been masked by the fact that we ~never invoke overlayDir with
an absolute path, which caused filepath.Rel to always return an error,
and overlayDir to always fall back to absolute paths.

Since the absolute paths seem to be working fine (and are simpler),
let's stick with those. As far as I can recall, the relative paths
were only a space optimization anyway.

Updates #28387
Updates #30316

Change-Id: Ie8cd28f3c41ca6497ace2799f4193d7f5dde7a37
Reviewed-on: https://go-review.googlesource.com/c/go/+/208481
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/internal/obj/arm64: add NOOP description in Go assembly syntax
diaxu01 [Fri, 25 Oct 2019 06:19:23 +0000 (06:19 +0000)]
cmd/internal/obj/arm64: add NOOP description in Go assembly syntax

This Patch describes NOOP in Go assembly syntax and gives Go assembly
example and corresponding GNU assembly example.

Change-Id: I9db659cc5e3dc6b1f1450f2064255af8872d4b1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/207400
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoruntime: add go:nosplit to cgo_mmap.go:mmap() and sys_darwin.go:mmap()
Dan Scales [Tue, 19 Nov 2019 20:41:51 +0000 (12:41 -0800)]
runtime: add go:nosplit to cgo_mmap.go:mmap() and sys_darwin.go:mmap()

cgo_mmap.go:mmap() is called by mem_linux.go:sysAlloc(), a low-level memory
allocation function. mmap() should be nosplit, since it is called in a lot of
low-level parts of the runtime and callers often assume it won't acquire any
locks.

As an example there is a potential deadlock involving two threads if mmap is not nosplit:

trace.bufLock acquired, then stackpool[order].item.mu, then mheap_.lock
  - can happen for traceEvents that are not invoked on the system stack and cause
    a traceFlush, which causes a sysAlloc, which calls mmap(), which may cause a
    stack split. mheap_.lock
mheap_.lock acquired, then trace.bufLock
  - can happen when doing a trace in reclaimChunk (which holds the mheap_ lock)

Also, sysAlloc() has a comment that it is nosplit because it may be invoked
without a valid G, in which case its callee mmap() should also be nosplit.

Similarly, sys_darwin.go:mmap() is called by mem_darwin.go:sysAlloc(), and should
be nosplit for the same reasons.

Extra gomote testing:  linux/arm64, darwin/amd64

Change-Id: Ia4d10cec5cf1e186a0fe5aab2858c6e0e5b80fdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/207844
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/link: disable new testpoint on mips pending investigation
Than McIntosh [Sat, 23 Nov 2019 14:59:30 +0000 (09:59 -0500)]
cmd/link: disable new testpoint on mips pending investigation

Skip TestMinusRSymsWithSameName testpoint on MIPS for the time being
since it triggers failures on that arch. Will re-enable once the
problems are fixed.

Updates #35779.

Change-Id: I3e6650158ab04a2be77e3db5a5194df3bbb0859e
Reviewed-on: https://go-review.googlesource.com/c/go/+/208557
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agosyscall: follow convention for generated code comments in linux/riscv64 files
Tobias Klauser [Thu, 21 Nov 2019 13:39:24 +0000 (14:39 +0100)]
syscall: follow convention for generated code comments in linux/riscv64 files

Use generated code comments following the convention
https://golang.org/s/generatedcode.

Follow-up for CL 204659

Change-Id: I7a3467ff9477488616b17f059245368d3d82d7a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/208417
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agosyscall/js: handle interleaved functions correctly
Richard Musiol [Sat, 2 Nov 2019 20:20:24 +0000 (21:20 +0100)]
syscall/js: handle interleaved functions correctly

Because of concurrent goroutines it is possible for multiple event
handlers to return at the same time. This was not properly supported
and caused the wrong goroutine to continue, which in turn caused
memory corruption.

This change adds a stack of events so it is always clear which is the
innermost event that needs to return next.

Fixes #35256

Change-Id: Ia527da3b91673bc14e84174cdc407f5c9d5a3d09
Reviewed-on: https://go-review.googlesource.com/c/go/+/204662
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/link: add new linker testpoint for "ld -r" host object
Than McIntosh [Fri, 22 Nov 2019 19:31:13 +0000 (14:31 -0500)]
cmd/link: add new linker testpoint for "ld -r" host object

This adds a new test that builds a small Go program with linked
against a *.syso file that is the result of an "ld -r" link. The
sysobj in question has multiple static symbols in the same section
with the same name, which triggered a bug in the loader in -newobj
mode.

Updates #35779.

Change-Id: Ibe1a75662dc1d49c4347279e55646ee65a81508e
Reviewed-on: https://go-review.googlesource.com/c/go/+/208478
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/link: fix bug with -newobj and "ld -r" ELF host objects
Than McIntosh [Fri, 22 Nov 2019 20:27:01 +0000 (15:27 -0500)]
cmd/link: fix bug with -newobj and "ld -r" ELF host objects

When the ELF host object loader encounters a static/hidden symbol, it
creates a sym.Symbol for it but does not enter it into the sym.Symbols
lookup table. Under -newobj mode, this was not happening correctly; we
were adding the sym via loader.LookupOrCreate, which resulted in
collisions when it encountered symbols with the same name + version +
section (this can happen for "ld -r" objects).

Fixes #35779.

Change-Id: I36d40fc1efc03fc1cd8ae6b76cb6a0d2a957389c
Reviewed-on: https://go-review.googlesource.com/c/go/+/208479
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agonet/http: rename tests for Redirect and StripPrefix
Dmitri Shuralyov [Sat, 16 Nov 2019 23:19:33 +0000 (23:19 +0000)]
net/http: rename tests for Redirect and StripPrefix

Before May 2018, I mistakenly thought the _suffix naming convention¹
used by examples also applied to tests. Thanks to a code review comment²
from Ian Lance Taylor, I have since learned that is not true.
This trivial change fixes some collateral damage from my earlier
misunderstanding, resulting in improved test naming consistency.

¹ https://golang.org/pkg/testing/#hdr-Examples
² https://go-review.googlesource.com/c/go/+/112935/1/src/path/filepath/path_test.go#1075

Change-Id: I555f60719629eb64bf2f096aa3dd5e00851827cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/207446
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet/http: make Transport.IdleConnTimeout consider wall (not monotonic) time
Brad Fitzpatrick [Fri, 1 Nov 2019 18:23:05 +0000 (11:23 -0700)]
net/http: make Transport.IdleConnTimeout consider wall (not monotonic) time

Both laptops closing their lids and cloud container runtimes
suspending VMs both faced the problem where an idle HTTP connection
used by the Transport could be cached for later reuse before the
machine is frozen, only to wake up many minutes later to think that
their HTTP connection was still good (because only a second or two of
monotonic time passed), only to find out that the peer hung up on them
when they went to write.

HTTP/1 connection reuse is inherently racy like this, but no need for
us to step into a trap if we can avoid it. Also, not everybody sets
Request.GetBody to enable re-tryable POSTs. And we can only safely
retry requests in some cases.

So with this CL, before reusing an old connection, double check the walltime.

Testing was done both with a laptop (closing the lid for a bit) and
with QEMU, running "stop" and "cont" commands in the monitor and
sending QMP guest agent commands to update its wall clock after the
"cont":

echo '{"execute":"guest-set-time"}' | socat STDIN UNIX-CONNECT:/var/run/qemu-server/108.qga

In both cases, I was running
https://gist.github.com/bradfitz/260851776f08e4bc4dacedd82afa7aea and
watching that the RemoteAddr changed after resume.

It's kinda difficult to write an automated test for. I gave a lightning talk on
using pure emulation user mode qemu for such tests:

   https://www.youtube.com/watch?v=69Zy77O-BUM
   https://docs.google.com/presentation/d/1rAAyOTCsB8GLbMgI0CAbn69r6EVWL8j3DPl4qc0sSlc/edit?usp=sharing
   https://github.com/google/embiggen-disk/blob/master/integration_test.go

... that would probably be a good direction if we want an automated
test here. But I don't have time to do that now.

Updates #29308 (HTTP/2 remains)

Change-Id: I03997e00491f861629d67a0292da000bd94ed5ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/204797
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocmd/go/internal/work: reduce code duplication in buildModeInit by using sys.BuildMode...
Bryan C. Mills [Fri, 22 Nov 2019 18:30:47 +0000 (13:30 -0500)]
cmd/go/internal/work: reduce code duplication in buildModeInit by using sys.BuildModeSupported

Updates #34347

Change-Id: I6ea02d4737999bf24f5335508b5ed2352b498122
Reviewed-on: https://go-review.googlesource.com/c/go/+/208458
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: fix and re-enable build_trimpath test
Jay Conrod [Thu, 21 Nov 2019 21:55:11 +0000 (16:55 -0500)]
cmd/go: fix and re-enable build_trimpath test

The test was comparing a binary built from a list of files to a test
build from a named package. That should not (and did not) work. The
test now compares two binaries built the same way in different
directories.

Also add a portion of the test for GOPATH and fix the gccgo portion of
the test (verified manually).

Fixes #35435

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

5 years agocmd/go: do not panic when computing Shlib for a package with no Target
Bryan C. Mills [Thu, 21 Nov 2019 21:26:09 +0000 (16:26 -0500)]
cmd/go: do not panic when computing Shlib for a package with no Target

In module mode, a non-main package lacks an install target.

The location of the .shlib corresponding to a given target is stored
in a .shlibname file alongside its install target, so in module mode
a non-main package also lacks a .shlibname file.

This also implies that such a package cannot be installed with
'go install -buildmode=linkshared', but that is a problem
for another day.

Fixes #35759
Updates #34347

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