1
0
mirror of https://github.com/golang/go synced 2024-11-14 09:00:21 -07:00
Commit Graph

42400 Commits

Author SHA1 Message Date
Bryan C. Mills
ea89ce1ea2 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>
2019-12-06 23:45:07 +00:00
Bryan C. Mills
94ddb2d621 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>
2019-12-06 23:44:51 +00:00
Bryan C. Mills
76d2f6cc62 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>
2019-12-06 23:44:28 +00:00
Cherry Zhang
df0ac45002 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>
2019-12-06 23:12:11 +00:00
Bryan C. Mills
1de31310d9 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>
2019-12-06 20:31:18 +00:00
po3rin
bf865823ba 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>
2019-12-06 20:12:47 +00:00
Jay Conrod
b2a5893f44 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>
2019-12-06 19:49:21 +00:00
Brad Fitzpatrick
a6c8fac781 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>
2019-12-06 18:04:42 +00:00
Austin Clements
69614c0d0e 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>
2019-12-06 15:19:52 +00:00
Ian Lance Taylor
0915a19a11 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>
2019-12-06 05:12:15 +00:00
Alex Brainman
6ef7794b24 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>
2019-12-06 05:10:34 +00:00
Robert Griesemer
b81e01dc2e 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>
2019-12-06 03:52:48 +00:00
Tobias Klauser
5fd7581006 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>
2019-12-06 03:14:41 +00:00
Ian Lance Taylor
d2dec04056 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>
2019-12-06 03:07:20 +00:00
Cherry Zhang
a037582eff 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>
2019-12-06 01:11:02 +00:00
Cherry Zhang
7673884a7f 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>
2019-12-06 00:57:11 +00:00
Tobias Klauser
eeb319a5a5 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>
2019-12-05 22:16:02 +00:00
Rhys Hiltner
e751af1aba 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>
2019-12-05 22:08:26 +00:00
Jay Conrod
993ec7f6cd 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>
2019-12-05 21:42:53 +00:00
Keith Randall
e3c7ffcd95 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>
2019-12-05 20:40:38 +00:00
Jay Conrod
d72dce8783 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>
2019-12-05 20:14:44 +00:00
Dmitri Shuralyov
a253b38de3 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>
2019-12-05 19:53:44 +00:00
Meng Zhuo
50535e6b42 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>
2019-12-05 17:23:50 +00:00
Filippo Valsorda
af0882247b 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>
2019-12-05 16:20:26 +00:00
Johan Jansson
cdf3db5df6 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>
2019-12-05 04:58:28 +00:00
taisa
7bdef2dfa4 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>
2019-12-05 03:44:34 +00:00
Ian Lance Taylor
9a8b497240 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>
2019-12-05 02:00:50 +00:00
Austin Clements
8174f7fb2b 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>
2019-12-05 01:48:14 +00:00
Austin Clements
fa3a121a79 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>
2019-12-05 01:48:12 +00:00
Jay Conrod
709dbd2870 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>
2019-12-04 23:54:27 +00:00
Jay Conrod
ae2e2446c2 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>
2019-12-04 21:29:42 +00:00
Brad Fitzpatrick
7d1d944626 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>
2019-12-04 21:14:24 +00:00
Carlos Amedee
98e7270a3d 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>
2019-12-04 19:27:51 +00:00
Carlos Amedee
ebfe057489 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>
2019-12-04 19:24:32 +00:00
Carlos Amedee
f805b05b39 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>
2019-12-04 18:45:05 +00:00
Tobias Klauser
aab0280476 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>
2019-12-04 14:53:20 +00:00
Michael Anthony Knyszek
acf3ff2e8a 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>
2019-12-03 17:35:06 +00:00
Xiangdong Ji
2ac1ca9160 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>
2019-12-03 15:26:50 +00:00
Ian Lance Taylor
386b1a4280 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>
2019-12-03 04:15:58 +00:00
Ian Lance Taylor
94f4686a77 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>
2019-12-02 22:42:22 +00:00
Günther Noack
a18608a044 os/exec: document that cmd.Start() sets the Process field
Change-Id: I4f41b680741e9bd2a4e8c094ecf3ce6226e48d12
GitHub-Last-Rev: 8f58bc6c43
GitHub-Pull-Request: golang/go#35934
Reviewed-on: https://go-review.googlesource.com/c/go/+/209558
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-12-02 20:12:54 +00:00
Than McIntosh
e4c01f088b 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>
2019-12-02 19:05:01 +00:00
Tao Qingyun
bf3ee57d27 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>
2019-12-02 16:45:37 +00:00
Xudong Zhang
3edd1d8d99 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: bf8eb57140
GitHub-Pull-Request: golang/go#35930
Reviewed-on: https://go-review.googlesource.com/c/go/+/209517
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-12-02 16:11:24 +00:00
Richard Miller
8054b13536 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>
2019-11-28 15:16:27 +00:00
Michael Anthony Knyszek
8a5af7910a 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>
2019-11-27 23:14:19 +00:00
Carlos Amedee
9174e2c03c 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>
2019-11-27 20:27:15 +00:00
Hana (Hyang-Ah) Kim
f1c8e2c14a 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>
2019-11-27 18:42:33 +00:00
Jay Conrod
b11d02ef74 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>
2019-11-27 16:41:28 +00:00
Michael Anthony Knyszek
4e3d58009a 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>
2019-11-27 15:06:55 +00:00