]> Cypherpunks repositories - gostls13.git/log
gostls13.git
6 years agocmd/compile: fix racewalk{enter,exit} removal
Keith Randall [Fri, 28 Dec 2018 20:43:48 +0000 (12:43 -0800)]
cmd/compile: fix racewalk{enter,exit} removal

We can't remove race instrumentation unless there are no calls,
not just no static calls. Closure and interface calls also count.

The problem in issue 29329 is that there was a racefuncenter, an
InterCall, and a racefuncexit.  The racefuncenter was removed, then
the InterCall was rewritten to a StaticCall. That prevented the
racefuncexit from being removed. That caused an imbalance in
racefuncenter/racefuncexit calls, which made the race detector barf.

Bug introduced at CL 121235

Fixes #29329

Change-Id: I2c94ac6cf918dd910b74b2a0de5dc2480d236f16
Reviewed-on: https://go-review.googlesource.com/c/155917
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoencoding/gob: mention that Encoder and Decoder are safe for concurrent use
Mostyn Bramley-Moore [Fri, 28 Dec 2018 20:02:13 +0000 (20:02 +0000)]
encoding/gob: mention that Encoder and Decoder are safe for concurrent use

Fixes #29416

Change-Id: I24364bfee77aceace53f85f1046ef4d73f8feebb

Change-Id: I24364bfee77aceace53f85f1046ef4d73f8feebb
GitHub-Last-Rev: ad9f31145763dc16f53dd9f3154667b162759f69
GitHub-Pull-Request: golang/go#29417
Reviewed-on: https://go-review.googlesource.com/c/155742
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile,runtime: redo mid-stack inlining tracebacks
Keith Randall [Tue, 4 Dec 2018 15:58:18 +0000 (07:58 -0800)]
cmd/compile,runtime: redo mid-stack inlining tracebacks

Work involved in getting a stack trace is divided between
runtime.Callers and runtime.CallersFrames.

Before this CL, runtime.Callers returns a pc per runtime frame.
runtime.CallersFrames is responsible for expanding a runtime frame
into potentially multiple user frames.

After this CL, runtime.Callers returns a pc per user frame.
runtime.CallersFrames just maps those to user frame info.

Entries in the result of runtime.Callers are now pcs
of the calls (or of the inline marks), not of the instruction
just after the call.

Fixes #29007
Fixes #28640
Update #26320

Change-Id: I1c9567596ff73dc73271311005097a9188c3406f
Reviewed-on: https://go-review.googlesource.com/c/152537
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
6 years agoos: don't let sendFile put a pipe into blocking mode
Ian Lance Taylor [Thu, 20 Dec 2018 00:47:50 +0000 (16:47 -0800)]
os: don't let sendFile put a pipe into blocking mode

Use SyscallConn to avoid calling the Fd method in sendFile on Unix
systems, since Fd has the side effect of putting the descriptor into
blocking mode.

Fixes #28330

Change-Id: If093417a225fe44092bd2c0dbbc3937422e98c0b
Reviewed-on: https://go-review.googlesource.com/c/155137
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agosyscall: document LockOSThread with GNU/Linux SysProcAttr.Ptrace
Ian Lance Taylor [Thu, 20 Dec 2018 02:25:08 +0000 (18:25 -0800)]
syscall: document LockOSThread with GNU/Linux SysProcAttr.Ptrace

Fixes #28315

Change-Id: Ie02c72d02ad2f66c9cdbbba579a304641f327672
Reviewed-on: https://go-review.googlesource.com/c/155138
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoos: add SyscallConn method for os.File
Ian Lance Taylor [Thu, 20 Dec 2018 23:09:41 +0000 (15:09 -0800)]
os: add SyscallConn method for os.File

Fixes #24331

Change-Id: I119c09a4259d852cdf8ea31b3e03e6f09a5f7bda
Reviewed-on: https://go-review.googlesource.com/c/155517
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: fix MIPS SGTconst-with-shift rules
Cherry Zhang [Wed, 26 Dec 2018 00:36:25 +0000 (19:36 -0500)]
cmd/compile: fix MIPS SGTconst-with-shift rules

(SGTconst [c] (SRLconst _ [d])) && 0 <= int32(c) && uint32(d) <= 31 && 1<<(32-uint32(d)) <= int32(c) -> (MOVWconst [1])

This rule is problematic. 1<<(32-uint32(d)) <= int32(c) meant to
say that it is true if c is greater than the largest possible
value of the right shift. But when d==1, 1<<(32-1) is negative
and results in the wrong comparison.

Rewrite the rules in a more direct way.

Fixes #29402.

Change-Id: I5940fc9538d9bc3a4bcae8aa34672867540dc60e
Reviewed-on: https://go-review.googlesource.com/c/155798
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agomath/big: fix incorrect comment variable reference
Will Beason [Wed, 26 Dec 2018 01:17:47 +0000 (01:17 +0000)]
math/big: fix incorrect comment variable reference

Fix comment as w&1 is the parity of 'x', not of 'n'.

Change-Id: Ia0e448f7e5896412ff9b164459ce15561ab624cc
GitHub-Last-Rev: 54ba08ab1055b5e6e506fc8ac06c2920ff095b6e
GitHub-Pull-Request: golang/go#29419
Reviewed-on: https://go-review.googlesource.com/c/155743
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd: vendor x/sys/unix into the stdlib
Keith Randall [Sat, 22 Dec 2018 02:23:31 +0000 (18:23 -0800)]
cmd: vendor x/sys/unix into the stdlib

Last of the Macos libSystem changes, hopefully.

Fixes #17490

Change-Id: I88b303bafd92494cc4ddde712213d2ef976ce4e2
Reviewed-on: https://go-review.googlesource.com/c/155737
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agotime: return ENOENT if a zoneinfo zip file is not found
Max Ushakov [Fri, 21 Dec 2018 14:53:33 +0000 (17:53 +0300)]
time: return ENOENT if a zoneinfo zip file is not found

Updates #20969

Change-Id: Ibcf0bf932d5b1de67c22c63dd8514ed7a5d198fb
Reviewed-on: https://go-review.googlesource.com/c/155538
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agopath/filepath: walkSymlinks: return correct error for file with trailing slash
LE Manh Cuong [Fri, 21 Dec 2018 04:21:02 +0000 (11:21 +0700)]
path/filepath: walkSymlinks: return correct error for file with trailing slash

Rather than return os.ErrNotExist for /path/to/existing_file/,
walkSymLinks now returns syscall.ENOTDIR.

This is consistent with behavior of os.Lstat.

Fixes #29372

Change-Id: Id5c471d901db04b2f35d60f60a81b2a0be93cae9
Reviewed-on: https://go-review.googlesource.com/c/155597
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoreflect: fix panic when Value.IsNil is called for UnsafePointer
Andrew Bonventre [Sun, 23 Dec 2018 21:48:38 +0000 (16:48 -0500)]
reflect: fix panic when Value.IsNil is called for UnsafePointer

UnsafePointer is a valid type kind to call IsNil on.

Fixes #29381

Change-Id: Iaf65d582c67f4be52cd1885badf40f174920500b
Reviewed-on: https://go-review.googlesource.com/c/155797
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/go: add regression test for cryptic vcs errors
Daniel Martí [Thu, 20 Dec 2018 23:04:18 +0000 (00:04 +0100)]
cmd/go: add regression test for cryptic vcs errors

On Go 1.11.x, if one ran 'go build' on a main package within a module,
while a needed vcs program like git was missing, a confusing error would
show up:

build testmod: cannot find module for path rsc.io/quote

The error should instead point at the source of the problem, which is
the missing vcs program. Thankfully, Go 1.12 doesn't have this bug, even
though it doesn't seem like the bug was fixed directly and
intentionally.

To ensure that this particular edge case isn't broken again, add a
regression test. Piggyback on mod_vcs_missing, since it already requires
a missing vcs program and network access.

I double-checked that Go 1.11 fails this test via /usr/bin/go, which is
1.11.3 on my system:

$ PATH=~/tip/bin go test -v -run Script/mod_vcs_missing
[...]
> exec /usr/bin/go build
[stderr]
build m: cannot find module for path launchpad.net/gocheck

Fixes #28948.

Change-Id: Iff1bcf77d9f7c11d15935cb87d6f58d7981d33d2
Reviewed-on: https://go-review.googlesource.com/c/155537
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/compile/internal/ssa/gen: set wasm genfile
Josh Bleecher Snyder [Sun, 16 Dec 2018 05:39:00 +0000 (21:39 -0800)]
cmd/compile/internal/ssa/gen: set wasm genfile

This appears to have been an oversight and/or
left over from development.

Setting the genfile means that extra sanity
checks are executed when regenerating SSA files.
They already pass.

Change-Id: Icc01ecf85020d3d51355e8bccfbc521b52371747
Reviewed-on: https://go-review.googlesource.com/c/154459
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: pad zero-sized stack variables
Keith Randall [Sat, 22 Dec 2018 00:36:45 +0000 (16:36 -0800)]
cmd/compile: pad zero-sized stack variables

If someone takes a pointer to a zero-sized stack variable, it can
be incorrectly interpreted as a pointer to the next object in the
stack frame. To avoid this, add some padding after zero-sized variables.

We only need to pad if the next variable in memory (which is the
previous variable in the order in which we allocate variables to the
stack frame) has pointers. If the next variable has no pointers, it
won't hurt to have a pointer to it.

Because we allocate all pointer-containing variables before all
non-pointer-containing variables, we should only have to pad once per
frame.

Fixes #24993

Change-Id: Ife561cdfdf964fdbf69af03ae6ba97d004e6193c
Reviewed-on: https://go-review.googlesource.com/c/155698
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: fix line number for implicitly declared method expressions
Keith Randall [Fri, 21 Dec 2018 23:41:28 +0000 (15:41 -0800)]
cmd/compile: fix line number for implicitly declared method expressions

Method expressions where the method is implicitly declared have no
line number. The Error method of the built-in error type is one such
method.  We leave the line number at the use of the method expression
in this case.

Fixes #29389

Change-Id: I29c64bb47b1a704576abf086599eb5af7b78df53
Reviewed-on: https://go-review.googlesource.com/c/155639
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/cgo: don't let inserted /*line*/ become a // comment
Ian Lance Taylor [Fri, 21 Dec 2018 21:14:09 +0000 (13:14 -0800)]
cmd/cgo: don't let inserted /*line*/ become a // comment

Fixes #29383

Change-Id: I0fb2929863e153b96d32d851e25e536231e4ae65
Reviewed-on: https://go-review.googlesource.com/c/155638
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agodoc: go_mem: clarify Once docs
Ian Lance Taylor [Fri, 21 Dec 2018 19:16:43 +0000 (11:16 -0800)]
doc: go_mem: clarify Once docs

Fixes #27808

Change-Id: Ia643d51004c47953642a2ba41dfed281f1112be6
Reviewed-on: https://go-review.googlesource.com/c/155637
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: use cached source files in "go list -find -compiled"
Jay Conrod [Fri, 21 Dec 2018 18:47:20 +0000 (13:47 -0500)]
cmd/go: use cached source files in "go list -find -compiled"

When "go list" is invoked with -find, it clears the list of imports
for each package matched on the command line. This affects action IDs,
since they incorporate dependencies' action IDs. Consequently, the
build triggered by -compiled won't find sources cached by
"go build".

We can still safely cache compiled sources from multiple runs of
"go list -find -compiled" though, since cgo generated sources are not
affected by imported dependencies. This change adds a second look into
the cache in this situation.

Fixes #29371

Change-Id: Ia0ae5a403ab5d621feaa16f521e6a65ac0ae6d9a
Reviewed-on: https://go-review.googlesource.com/c/155481
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: fix -n output in runtime/internal/atomic
Jay Conrod [Fri, 21 Dec 2018 17:23:18 +0000 (12:23 -0500)]
cmd/go: fix -n output in runtime/internal/atomic

When building runtime/internal/atomic, the toolchain writes a symabis2
file. This file is read back in, filtered, and appended to the symabis
file. This breaks with -n, since the symabis2 file is never written.

With this change, when -n is used, an equivalent "grep" command is
printed instead. The output for -x is unchanged.

Fixes #29346

Change-Id: Id25e06e06364fc6689e71660d000f09c649c4f0c
Reviewed-on: https://go-review.googlesource.com/c/155480
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>

6 years agoruntime: skip TestLockOSThreadAvoidsStatePropagation if one can't unshare
Michael Anthony Knyszek [Thu, 20 Dec 2018 20:21:45 +0000 (20:21 +0000)]
runtime: skip TestLockOSThreadAvoidsStatePropagation if one can't unshare

This change splits a testprog out of TestLockOSThreadExit and makes it
its own test. Then, this change makes the testprog exit prematurely with
a special message if unshare fails with EPERM because not all of the
builders allow the user to call the unshare syscall.

Also, do some minor cleanup on the TestLockOSThread* tests.

Fixes #29366.

Change-Id: Id8a9f6c4b16e26af92ed2916b90b0249ba226dbe
Reviewed-on: https://go-review.googlesource.com/c/155437
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: clarify change to File.Sync on macOS
Ian Lance Taylor [Wed, 19 Dec 2018 15:08:38 +0000 (07:08 -0800)]
doc: clarify change to File.Sync on macOS

Updates #26650

Change-Id: I0ec070127dcacc7fc68dd5baf125eb762e1ea846
Reviewed-on: https://go-review.googlesource.com/c/155038
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/compile: fix ICE due to bad rune width
Matthew Dempsky [Thu, 20 Dec 2018 19:10:06 +0000 (11:10 -0800)]
cmd/compile: fix ICE due to bad rune width

It was possible that

    var X interface{} = 'x'

could cause a compilation failure due to having not calculated rune's
width yet. typecheck.go normally calculates the width of things, but
it doesn't for implicit conversions to default type. We already
compute the width of all of the standard numeric types in universe.go,
but we failed to calculate it for the rune alias type. So we could
later crash if the code never otherwise explicitly mentioned 'rune'.

While here, explicitly compute widths for 'byte' and 'error' for
consistency.

Fixes #29350.

Change-Id: Ifedd4899527c983ee5258dcf75aaf635b6f812f8
Reviewed-on: https://go-review.googlesource.com/c/155380
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agoos: clearer doc for Interrupt
Kevin Burke [Tue, 25 Sep 2018 16:22:09 +0000 (09:22 -0700)]
os: clearer doc for Interrupt

I was confused by the juxtaposition of os.Interrupt docs, which are
"guaranteed to exist on all platforms" in one sentence and then
"not implemented" in the next sentence. Reading the code reveals
"not implemented" refers specifically to the implementation of
os.Process.Signal on Windows, not to the os.Interrupt variable itself.
Reword the doc to make this distinction clearer.

Fixes #27854.

Change-Id: I5fe7cddea61fa1954cef2006dc51b8fa8ece4d6e
Reviewed-on: https://go-review.googlesource.com/c/137336
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
6 years agodoc/go1.12: correct types for math/bits
Brian Kessler [Thu, 20 Dec 2018 18:16:23 +0000 (11:16 -0700)]
doc/go1.12: correct types for math/bits

Extended precision math/bits functions are unsigned.

Change-Id: Ic1633e9c367fc3d5a80bc503008f035db4e78945
Reviewed-on: https://go-review.googlesource.com/c/155379
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocompress/flate: fix the old url for the flate algorithm
Osamu TONOMORI [Thu, 20 Dec 2018 13:39:01 +0000 (22:39 +0900)]
compress/flate: fix the old url for the flate algorithm

Change-Id: I84b74bc96516033bbf4a01f9aa81fe60d5a41355
Reviewed-on: https://go-review.googlesource.com/c/155317
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoos: clarify O_TRUNC comment
Ian Lance Taylor [Thu, 20 Dec 2018 01:49:11 +0000 (17:49 -0800)]
os: clarify O_TRUNC comment

Fixes #28699

Change-Id: Ic340c3171bb7d91d8cb9553967c2b51e7d9daba8
Reviewed-on: https://go-review.googlesource.com/c/155177
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/compile: ignore out-of-bounds reads from readonly constants
Keith Randall [Thu, 13 Dec 2018 17:31:21 +0000 (09:31 -0800)]
cmd/compile: ignore out-of-bounds reads from readonly constants

Out-of-bounds reads of globals can happen in dead code. For code
like this:

s := "a"
if len(s) == 3 {
   load s[0], s[1], and s[2]
}

The out-of-bounds loads are dead code, but aren't removed yet
when lowering. We need to not panic when compile-time evaluating
those loads. This can only happen for dead code, so the result
doesn't matter.

Fixes #29215

Change-Id: I7fb765766328b9524c6f2a1e6ab8d8edd9875097
Reviewed-on: https://go-review.googlesource.com/c/154057
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
6 years agodoc/go1.12: fix GOARCH value in Syscall18 link
Tobias Klauser [Thu, 20 Dec 2018 08:38:37 +0000 (09:38 +0100)]
doc/go1.12: fix GOARCH value in Syscall18 link

Currently the link works also with the non-existing GOARCH armd64, but
let's correct in anyhow.

Change-Id: Ida647b8f9dd2f8460b019f5a23759f10a6da8e60
Reviewed-on: https://go-review.googlesource.com/c/155277
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/vendor: update vendored golang.org/x/sys/windows
Tobias Klauser [Thu, 20 Dec 2018 09:56:47 +0000 (10:56 +0100)]
cmd/vendor: update vendored golang.org/x/sys/windows

Update to x/sys git revision 074acd46bca67915925527c07849494d115e7c43

This fixes TestFormatMessage and TestExample on windows/arm by pulling
in CL 154560 and CL 154817.

Change-Id: Ic6495fe3072b5bcc7ea68efb3f0be5fc1fe4c238
Reviewed-on: https://go-review.googlesource.com/c/155297
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet: don't accept timeouts in TestUDPZeroBytePayload
Ian Lance Taylor [Tue, 18 Dec 2018 23:10:38 +0000 (15:10 -0800)]
net: don't accept timeouts in TestUDPZeroBytePayload

Before this CL we accepted timeouts in TestUDPZeroBytePayload to avoid
flakiness and because, according to CL 9194, the test didn't work on
some platforms. On Windows, before CL 132781, the read would always
timeout, and so since the test accepted timeouts it would pass
incorrectly. CL 132781 fixed Windows, and changed the test to not
accept timeouts in the ReadFrom case.

However, the timeout was short, and so on a loaded system the Read
might timeout not due to an error in the code, but just because the
read was not delivered. So ignoring timeouts made the test flaky, as
reported in issue #29225.

This CL tries to get to a better state by increasing the timeout to a
large value and not permitting timeouts at all. If there are systems
where the test fails, we will need to explicitly skip the test on
those systems.

Fixes #29225

Change-Id: I26863369898a69cac866b34fcb5b6ffbffab31f6
Reviewed-on: https://go-review.googlesource.com/c/154759
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoos: adjust TempDir for Z:\
Alex Brainman [Mon, 17 Dec 2018 09:39:48 +0000 (20:39 +1100)]
os: adjust TempDir for Z:\

If TMP environment variable is set to Z:\, TempDir returns Z:.
But Z: refers to current directory on Z:, while Z:\ refers to root
directory on Z:. Adjust TempDir to return Z:\.

Fixes #29291

Change-Id: If04d0c7977a8ac2d9d558307502e81beb68776ef
Reviewed-on: https://go-review.googlesource.com/c/154384
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: fix the old url about deflate
catatsuy [Thu, 20 Dec 2018 03:36:27 +0000 (12:36 +0900)]
net/http: fix the old url about deflate

Change-Id: Iaa1468296fbc98389165a152cf8b591216c22489
Reviewed-on: https://go-review.googlesource.com/c/155217
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: use QPC to implement cputicks() on windows/arm
Jordan Rhee [Wed, 19 Dec 2018 00:41:57 +0000 (16:41 -0800)]
runtime: use QPC to implement cputicks() on windows/arm

Tracing uses cputicks() to generate trace event timestamps. cputicks()
is expected to be a high resolution clock source. On Windows/ARM,
call QueryPerformanceCounter() which is the highest resolution clock
source available.

Updates #26148

Change-Id: I987fa556060b3d60c02f07b87b9e6320b9b026e2
Reviewed-on: https://go-review.googlesource.com/c/154762
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: don't clear lockedExt on locked M when G exits
Michael Anthony Knyszek [Fri, 7 Dec 2018 00:07:43 +0000 (00:07 +0000)]
runtime: don't clear lockedExt on locked M when G exits

When a locked M has its G exit without calling UnlockOSThread, then
lockedExt on it was getting cleared. Unfortunately, this meant that
during P handoff, if a new M was started, it might get forked (on
most OSs besides Windows) from the locked M, which could have kernel
state attached to it.

To solve this, just don't clear lockedExt. At the point where the
locked M has its G exit, it will also exit in accordance with the
LockOSThread API. So, we can safely assume that it's lockedExt state
will no longer be used. For the case of the main thread where it just
gets wedged instead of exiting, it's probably better for it to keep
the locked marker since it more accurately represents its state.

Fixed #28979.

Change-Id: I7d3d71dd65bcb873e9758086d2cbcb9a06429b0f
Reviewed-on: https://go-review.googlesource.com/c/153078
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime: disable TestArenaCollision on Darwin in race mode
Michael Anthony Knyszek [Wed, 19 Dec 2018 17:32:22 +0000 (17:32 +0000)]
runtime: disable TestArenaCollision on Darwin in race mode

This change disables the test TestArenaCollision on Darwin in race mode
to deal with the fact that Darwin 10.10 must use MAP_FIXED in race mode
to ensure we retain our heap in a particular portion of the address
space which the race detector needs. The test specifically checks to
make sure a manually mapped region's space isn't re-used, which is
definitely possible with MAP_FIXED because it replaces whatever mapping
already exists at a given address.

This change then also makes it so that MAP_FIXED is only used in race
mode and on Darwin, not all BSDs, because using MAP_FIXED breaks this
test for FreeBSD in addition to Darwin.

Updates #26475.
Fixes #29340.

Change-Id: I1c59349408ccd7eeb30c4bf2593f48316b23ab2f
Reviewed-on: https://go-review.googlesource.com/c/155097
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoRevert "runtime: use QPC for nanotime and time.now on windows/arm"
Jordan Rhee [Wed, 19 Dec 2018 00:32:09 +0000 (16:32 -0800)]
Revert "runtime: use QPC for nanotime and time.now on windows/arm"

This reverts change https://golang.org/cl/154758.

Restore the previous implementations of nanotime and time.now, which
are sufficiently high resolution and more efficient than
QueryPerformanceCounter. The intent of the change was to improve
resolution of tracing timestamps, but the change was overly broad
as it was only necessary to fix cputicks(). cputicks() is fixed in
a subsequent change.

Updates #26148

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

6 years agodoc/go1.12: fix minor grammatical error
Agniva De Sarker [Wed, 19 Dec 2018 05:03:42 +0000 (10:33 +0530)]
doc/go1.12: fix minor grammatical error

Change-Id: I767bf77aeab62f2d42239fac9d601a8e04fe860f
Reviewed-on: https://go-review.googlesource.com/c/154957
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.12: fix typos and code formatting
Tobias Klauser [Wed, 19 Dec 2018 08:36:11 +0000 (09:36 +0100)]
doc/go1.12: fix typos and code formatting

Fix two typos and don't indent the go vet example.

Change-Id: Iccec56ca5decfbae45547a00115500ed13b703e1
Reviewed-on: https://go-review.googlesource.com/c/154721
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/cgo: ensure the command passed to run retains a trailing dash
Ian Lance Taylor [Wed, 19 Dec 2018 15:03:04 +0000 (07:03 -0800)]
cmd/cgo: ensure the command passed to run retains a trailing dash

This was accidentally broken by CL 127755.

Fixes #29333

Change-Id: I5e92048c64a55c1699d6c38eb4dbbd51c817b820
Reviewed-on: https://go-review.googlesource.com/c/155037
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/cgo,doc/go1.12.html: document breaking EGLDisplay change
Elias Naur [Wed, 19 Dec 2018 12:50:13 +0000 (13:50 +0100)]
cmd/cgo,doc/go1.12.html: document breaking EGLDisplay change

Change-Id: I3c8ba5fdb05b6b1324648622656cc10071c70a34
Reviewed-on: https://go-review.googlesource.com/c/154997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: avoid write barrier in startpanic_m
Michael Anthony Knyszek [Tue, 18 Dec 2018 20:04:53 +0000 (20:04 +0000)]
runtime: avoid write barrier in startpanic_m

startpanic_m could be called correctly in a context where there's a
valid G, a valid M, but no P, for example in a signal handler which
panics. Currently, startpanic_m has write barriers enabled because
write barriers are permitted if a G's M is dying. However, all the
current write barrier implementations assume the current G has a P.

Therefore, in this change we disable write barriers in startpanic_m,
remove the only pointer write which clears g.writebuf, and fix up gwrite
to ignore the writebuf if the current G's M is dying, rather than
relying on it being nil in the dying case.

Fixes #26575.

Change-Id: I9b29e6b9edf00d8e99ffc71770c287142ebae086
Reviewed-on: https://go-review.googlesource.com/c/154837
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime: use QPC for nanotime and time.now on windows/arm go1.12beta1
Jordan Rhee [Tue, 18 Dec 2018 20:54:23 +0000 (12:54 -0800)]
runtime: use QPC for nanotime and time.now on windows/arm

The previous implementation of nanotime and time.now used a time source
that was updated on the system clock tick, which has a maximum
resolution of about 1ms. On 386 and amd64, this time source maps to
the system performance counter, so has much higher resolution.
On ARM, use QueryPerformanceCounter() to get a high resolution timestamp.

Updates #26148

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

6 years agodoc/go1.12: note that syscall.Getdirentries is no longer supported on iOS
Elias Naur [Tue, 18 Dec 2018 20:32:48 +0000 (21:32 +0100)]
doc/go1.12: note that syscall.Getdirentries is no longer supported on iOS

Change-Id: I4277f4130b460b42c5b51fd5a5e07f6c0e62163b
Reviewed-on: https://go-review.googlesource.com/c/154720
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoapi: promote next to go1.12
Filippo Valsorda [Tue, 18 Dec 2018 20:32:58 +0000 (15:32 -0500)]
api: promote next to go1.12

Change-Id: I9a30c76d1299a494cce69b1060156bc2932ac8d5
Reviewed-on: https://go-review.googlesource.com/c/154857
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoos: show how to print permission bits in octal
Kevin Burke [Mon, 17 Dec 2018 00:37:07 +0000 (00:37 +0000)]
os: show how to print permission bits in octal

Permission bits are most commonly viewed in string form (rwx-- etc) or
in octal form (0755), but the latter is relatively rare in Go.
Demonstrate how to print a FileMode in readable octal format.

Change-Id: I41feb801bcecb5077d4eabafdea27c149fc179a1
Reviewed-on: https://go-review.googlesource.com/c/154423
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: call mmap with MAP_FIXED on BSDs in race mode
Michael Anthony Knyszek [Tue, 11 Dec 2018 22:03:04 +0000 (22:03 +0000)]
runtime: call mmap with MAP_FIXED on BSDs in race mode

This change makes it so that reserving more of the address space for the
heap calls mmap with MAP_FIXED in race mode. Race mode requires certain
guarantees on where the heap is located in the address space, and on
Darwin 10.10 it appears that the kernel may end up ignoring the hint
quite often (#26475). Using MAP_FIXED is relatively OK in race mode
because nothing else should be mapped in the memory region provided by
the initial hints.

Fixes #26475.

Change-Id: Id7ac1534ee74f6de491bc04441f27dbda09f0285
Reviewed-on: https://go-review.googlesource.com/c/153897
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/cover: avoid repeating positions
Ian Lance Taylor [Fri, 7 Dec 2018 04:54:35 +0000 (20:54 -0800)]
cmd/cover: avoid repeating positions

When using //line directives and unformatted code it is possible for
positions to repeat. Increment the final column position to avoid that.

Fixes #27350

Change-Id: I2faccc31360075e9814d4a024b0f98b117f8ce97
Reviewed-on: https://go-review.googlesource.com/c/153061
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/cover: use -toolexec in tests to run newly built cover program
Ian Lance Taylor [Thu, 6 Dec 2018 22:08:19 +0000 (14:08 -0800)]
cmd/cover: use -toolexec in tests to run newly built cover program

This ensures that "go test cmd/cover" tests the current cover program,
not the installed cover program.

Change-Id: I58e718ded7eb1cd8da448d0194262209bb025b20
Reviewed-on: https://go-review.googlesource.com/c/153058
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/dist: enable race detector test on Linux/ARM64
Cherry Zhang [Sat, 17 Nov 2018 18:58:38 +0000 (13:58 -0500)]
cmd/dist: enable race detector test on Linux/ARM64

CL 138675 added the race detector support on Linux/ARM64, but it
didn't enable the race detector tests in cmd/dist (therefore in
all.bash). Enable them.

Updates #28848

Change-Id: I4306dad2fb4167021d568436076b9f535d7f6e07
Reviewed-on: https://go-review.googlesource.com/c/149967
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.12: finish most Go 1.12 release notes
Filippo Valsorda [Tue, 18 Dec 2018 01:01:10 +0000 (20:01 -0500)]
doc/go1.12: finish most Go 1.12 release notes

Change-Id: I598c9a2031001a6780b75c31d9015c880741b170
Reviewed-on: https://go-review.googlesource.com/c/154637
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.12: add notes for syscall/js CLs 141644, 143137, 144384
Dmitri Shuralyov [Mon, 17 Dec 2018 22:15:40 +0000 (17:15 -0500)]
doc/go1.12: add notes for syscall/js CLs 141644, 143137, 144384

Also update a Go 1 compatibility promise link to canonical URL.

Updates #27592
Updates #28264

Change-Id: I5994a0a63e0870c1795c65016590dfad829d26a7
Reviewed-on: https://go-review.googlesource.com/c/154618
Reviewed-by: Richard Musiol <neelance@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.12: add release notes for GODEBUG internal/cpu options
Martin Möhrmann [Tue, 18 Dec 2018 11:46:06 +0000 (12:46 +0100)]
doc/go1.12: add release notes for GODEBUG internal/cpu options

Change-Id: Id68b62138e14d13bb352b14c7f42bcef5601eee3
Reviewed-on: https://go-review.googlesource.com/c/154717
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: fix backtrace during C syscalls for aix/ppc64
Clément Chigot [Tue, 18 Dec 2018 12:00:26 +0000 (13:00 +0100)]
runtime: fix backtrace during C syscalls for aix/ppc64

This commit fixes backtrace if a crash or an exit signal is received
during a C syscall on aix/ppc64.
This is similar to Solaris, Darwin or Windows implementation.

Change-Id: I6040c0b1577a9f5b298f58bd4ee6556258a135ef
Reviewed-on: https://go-review.googlesource.com/c/154718
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/link: optimize access to data symbols for aix/ppc64
Clément Chigot [Mon, 26 Nov 2018 10:14:09 +0000 (11:14 +0100)]
cmd/link: optimize access to data symbols for aix/ppc64

This commit changes the second instruction used to retrieve a symbol on
aix/ppc64 if it is in .data or .bss section.

The previous version always retrieves the symbol address via a load on
its TOC symbol. However, as the TOC is also in .data, the symbol's address
is close enough to be fetched directly and the load instruction can be
replaced by an addi.

Bench go1
benchmark                             old ns/op      new ns/op      delta
BenchmarkBinaryTree17-16              5919354000     5824897000     -1.60%
BenchmarkFannkuch11-16                5206937000     5162043000     -0.86%
BenchmarkFmtFprintfEmpty-16           106            105            -0.94%
BenchmarkFmtFprintfString-16          165            165            +0.00%
BenchmarkFmtFprintfInt-16             165            167            +1.21%
BenchmarkFmtFprintfIntInt-16          303            239            -21.12%
BenchmarkFmtFprintfPrefixedInt-16     282            283            +0.35%
BenchmarkFmtFprintfFloat-16           434            381            -12.21%
BenchmarkFmtManyArgs-16               1797           903            -49.75%
BenchmarkGobDecode-16                 16000450       12173630       -23.92%
BenchmarkGobEncode-16                 12007010       10258070       -14.57%
BenchmarkGzip-16                      638581500      456050333      -28.58%
BenchmarkGunzip-16                    111976900      74943900       -33.07%
BenchmarkHTTPClientServer-16          206850         153716         -25.69%
BenchmarkJSONEncode-16                32057380       17517130       -45.36%
BenchmarkJSONDecode-16                182606400      106807700      -41.51%
BenchmarkMandelbrot200-16             6896975        5616903        -18.56%
BenchmarkGoParse-16                   11248260       6094115        -45.82%
BenchmarkRegexpMatchEasy0_32-16       292            148            -49.32%
BenchmarkRegexpMatchEasy0_1K-16       540            327            -39.44%
BenchmarkRegexpMatchEasy1_32-16       243            150            -38.27%
BenchmarkRegexpMatchEasy1_1K-16       1029           657            -36.15%
BenchmarkRegexpMatchMedium_32-16      423            230            -45.63%
BenchmarkRegexpMatchMedium_1K-16      107250         59683          -44.35%
BenchmarkRegexpMatchHard_32-16        3353           3139           -6.38%
BenchmarkRegexpMatchHard_1K-16        107277         93610          -12.74%
BenchmarkRevcomp-16                   1124311500     677442500      -39.75%
BenchmarkTemplate-16                  241286600      109177400      -54.75%
BenchmarkTimeParse-16                 1058           562            -46.88%
BenchmarkTimeFormat-16                1321           581            -56.02%

benchmark                            old MB/s     new MB/s     speedup
BenchmarkGobDecode-16                47.97        63.05        1.31x
BenchmarkGobEncode-16                63.92        74.82        1.17x
BenchmarkGzip-16                     30.39        42.55        1.40x
BenchmarkGunzip-16                   173.29       258.92       1.49x
BenchmarkJSONEncode-16               60.53        110.78       1.83x
BenchmarkJSONDecode-16               10.63        18.17        1.71x
BenchmarkGoParse-16                  5.15         9.50         1.84x
BenchmarkRegexpMatchEasy0_32-16      109.42       215.86       1.97x
BenchmarkRegexpMatchEasy0_1K-16      1896.22      3126.28      1.65x
BenchmarkRegexpMatchEasy1_32-16      131.46       212.99       1.62x
BenchmarkRegexpMatchEasy1_1K-16      994.55       1557.51      1.57x
BenchmarkRegexpMatchMedium_32-16     2.36         4.34         1.84x
BenchmarkRegexpMatchMedium_1K-16     9.55         17.16        1.80x
BenchmarkRegexpMatchHard_32-16       9.54         10.19        1.07x
BenchmarkRegexpMatchHard_1K-16       9.55         10.94        1.15x
BenchmarkRevcomp-16                  226.06       375.19       1.66x
BenchmarkTemplate-16                 8.04         17.77        2.21x

Change-Id: Iaf2aa5953b99271361510c69a5ced3371f6c6c20
Reviewed-on: https://go-review.googlesource.com/c/151201
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/1.12: add notes about aix/ppc64 port
Clément Chigot [Tue, 18 Dec 2018 08:09:12 +0000 (09:09 +0100)]
doc/1.12: add notes about aix/ppc64 port

Fixes #29315

Change-Id: I6ecc5109c23e7a7d9db54250bf041acc841701e3
Reviewed-on: https://go-review.googlesource.com/c/154697
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: flush on every write barrier while debugging
Austin Clements [Tue, 18 Dec 2018 01:57:34 +0000 (20:57 -0500)]
runtime: flush on every write barrier while debugging

Currently, we flush the write barrier buffer on every write barrier
once throwOnGCWork is set, but not during the mark completion
algorithm itself. As seen in recent failures like

  https://build.golang.org/log/317369853b803b4ee762b27653f367e1aa445ac1

by the time we actually catch a late gcWork put, the write barrier
buffer is full-size again.

As a result, we're probably not catching the actual problematic write
barrier, which is probably somewhere in the buffer.

Fix this by using the gcWork pause generation to also keep the write
barrier buffer small between the mark completion flushes it and when
mark completion is done.

For #27993.

Change-Id: I77618169441d42a7d562fb2a998cfaa89891edb2
Reviewed-on: https://go-review.googlesource.com/c/154638
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agodoc: document GODEBUG options to disable use of instruction set extensions
Martin Möhrmann [Wed, 14 Nov 2018 22:13:28 +0000 (23:13 +0100)]
doc: document GODEBUG options to disable use of instruction set extensions

Fixes #27218

Change-Id: I4eb8e8f2486b20fe0ed6e3e2c6ec521c9e8c0032
Reviewed-on: https://go-review.googlesource.com/c/149579
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime,cmd/dist,cmd/link: add cgo support on openbsd/arm
Joel Sing [Sun, 16 Dec 2018 14:18:51 +0000 (01:18 +1100)]
runtime,cmd/dist,cmd/link: add cgo support on openbsd/arm

Add support for cgo on openbsd/arm.The gcc shipped with base OpenBSD armv7
is old/inadequate, so use clang by default.

Change-Id: I945a26d369378952d357727718e69249411e1127
Reviewed-on: https://go-review.googlesource.com/c/154381
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: increase nesting depth limit for type descriptors
Robert Griesemer [Mon, 17 Dec 2018 22:42:29 +0000 (14:42 -0800)]
cmd/compile: increase nesting depth limit for type descriptors

The formatting routines for types use a depth limit as primitive
mechanism to detect cycles. For now, increase the limit from 100
to 250 and file #29312 so we don't drop this on the floor.

Also, adjust some fatal error messages elsewhere to use
better formatting.

Fixes #29264.
Updates #29312.

Change-Id: Idd529f6682d478e0dcd2d469cb802192190602f6
Reviewed-on: https://go-review.googlesource.com/c/154583
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: explain how to use "go vet -shadow"
Ian Lance Taylor [Mon, 17 Dec 2018 23:09:34 +0000 (15:09 -0800)]
doc: explain how to use "go vet -shadow"

Fixes #29260

Change-Id: I419b74d06380113f4bd32b9aeb053c3be36208d5
Reviewed-on: https://go-review.googlesource.com/c/154584
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agoruntime: allocate from free and scav fairly
Michael Anthony Knyszek [Thu, 8 Nov 2018 20:06:58 +0000 (20:06 +0000)]
runtime: allocate from free and scav fairly

This change modifies the behavior of span allocations to no longer
prefer the free treap over the scavenged treap.

While there is an additional cost to allocating out of the scavenged
treap, the current behavior of preferring the unscavenged spans can
lead to unbounded growth of a program's virtual memory footprint.

In small programs (low # of Ps, low resident set size, low allocation
rate) this behavior isn't really apparent and is difficult to
reproduce.

However, in relatively large, long-running programs we see this
unbounded growth in free spans, and an unbounded amount of heap
growths.

It still remains unclear how this policy change actually ends up
increasing the number of heap growths over time, but switching the
policy back to best-fit does indeed solve the problem.

Change-Id: Ibb88d24f9ef6766baaa7f12b411974cc03341e7b
Reviewed-on: https://go-review.googlesource.com/c/148979
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime: add iterator abstraction for mTreap
Michael Anthony Knyszek [Mon, 26 Nov 2018 23:56:35 +0000 (23:56 +0000)]
runtime: add iterator abstraction for mTreap

This change adds the treapIter type which provides an iterator
abstraction for walking over an mTreap. In particular, the mTreap type
now has iter() and rev() for iterating both forwards (smallest to
largest) and backwards (largest to smallest). It also has an erase()
method for erasing elements at the iterator's current position.

For #28479.

While the expectation is that this change will slow down Go programs,
the impact on Go1 and Garbage is negligible.

Go1:     https://perf.golang.org/search?q=upload:20181214.6
Garbage: https://perf.golang.org/search?q=upload:20181214.11

Change-Id: I60dbebbbe73cbbe7b78d45d2093cec12cc0bc649
Reviewed-on: https://go-review.googlesource.com/c/151537
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agocmd/link: move XCOFF data addresses to an unreachable segment
Clément Chigot [Fri, 23 Nov 2018 14:12:04 +0000 (15:12 +0100)]
cmd/link: move XCOFF data addresses to an unreachable segment

This commit move data addresses to 0x200000000 for XCOFF executables.
.data and .bss must always be position-independent on AIX. This
modification allows to detect more easily if they aren't, as segfault
will be triggered.

Change-Id: Ied7a5b72b9f4ff9f870a1626cf07c48110635e62
Reviewed-on: https://go-review.googlesource.com/c/151040
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: prevent double-walk of switch for OPRINT/OPRINTN
David Chase [Mon, 17 Dec 2018 17:01:56 +0000 (12:01 -0500)]
cmd/compile: prevent double-walk of switch for OPRINT/OPRINTN

When a println arg contains a call to an inlineable function
that itself contains a switch, that switch statement will be
walked twice, once by the walkexprlist formerly in the
OPRINT/OPRINTN case, then by walkexprlistcheap in walkprint.

Remove the first walkexprlist, it is not necessary.
walkexprlist =
s[i] = walkexpr(s[i], init)
walkexprlistcheap = {
s[i] = cheapexpr(n, init)
s[i] = walkexpr(s[i], init)
}

Seems like this might be possible in other places, i.e.,
calls to inlineable switch-containing functions.

See also #25776.
Fixes #29220.

Change-Id: I3781e86aad6688711597b8bee9bc7ebd3af93601
Reviewed-on: https://go-review.googlesource.com/c/154497
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: fix sysUsed for Windows
Michael Anthony Knyszek [Tue, 11 Dec 2018 18:26:42 +0000 (18:26 +0000)]
runtime: fix sysUsed for Windows

sysUsed on Windows cares about the result from the VirtualAlloc syscall
returning exactly the address that was passed to it. However,
VirtualAlloc aligns the address its given to the kernel's allocation
granularity, so the returned address may not be the same.

Note that this wasn't an issue in the past because we only sysUsed
regions owned by spans, and spans are always a multiple of 8K, which
is a multiple of the allocation granularity on most Windows machines.

Change-Id: I3f5ccd63c6bbbd8b7995945ecedee17573b31667
Reviewed-on: https://go-review.googlesource.com/c/153677
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agodoc/go1.12: release notes for crypto
Filippo Valsorda [Thu, 13 Dec 2018 00:31:45 +0000 (19:31 -0500)]
doc/go1.12: release notes for crypto

Change-Id: I2a5613377a38815fb8746c5bfb07ccbbc2e6dd0b
Reviewed-on: https://go-review.googlesource.com/c/153829
Reviewed-by: Adam Langley <agl@golang.org>
6 years agodoc/go1.12: release notes for "go doc -all"
Filippo Valsorda [Thu, 13 Dec 2018 00:30:32 +0000 (19:30 -0500)]
doc/go1.12: release notes for "go doc -all"

Change-Id: If65518c76a865c03266be76b1c21c76e1c8b4763
Reviewed-on: https://go-review.googlesource.com/c/153828
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: capture pause stack for late gcWork put debugging
Austin Clements [Mon, 17 Dec 2018 19:39:05 +0000 (14:39 -0500)]
runtime: capture pause stack for late gcWork put debugging

This captures the stack trace where mark completion observed that each
P had no work, and then dumps this if that P later discovers more
work. Hopefully this will help bound where the work was created.

For #27993.

Change-Id: I4f29202880d22c433482dc1463fb50ab693b6de6
Reviewed-on: https://go-review.googlesource.com/c/154599
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agoruntime: make traceback indicate whether _defer was just allocated
Austin Clements [Mon, 17 Dec 2018 19:23:56 +0000 (14:23 -0500)]
runtime: make traceback indicate whether _defer was just allocated

Many of the crashes observed in #27993 involve committing the new
_defer object at the end of newdefer. It would be helpful to know if
the _defer was just allocated or was retrieved from the defer pool. In
order to indicate this in the traceback, this CL duplicates the tail
of newdefer so that the PC/line number will tell us whether d is new
or not.

For #27993.

Change-Id: Icd3e23dbcf00461877bb082b6f18df701149a607
Reviewed-on: https://go-review.googlesource.com/c/154598
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agoruntime: record extra information in throwOnGCWork crashes
Austin Clements [Mon, 17 Dec 2018 19:17:20 +0000 (14:17 -0500)]
runtime: record extra information in throwOnGCWork crashes

Currently we only know the slot address and the value being written in
the throwOnGCWork crash tracebacks, and we have to infer the old value
from what's dumped by gcWork.checkPut. Sometimes these old values
don't make sense, like when we see a write of a nil pointer to a
freshly-allocated object, yet we observe marking a value (where did
that pointer come from?).

This CL adds the old value of the slot and the first two pointers in
the buffer to the traceback.

For #27993.

Change-Id: Ib70eead1afb9c06e8099e520172c3a2acaa45f80
Reviewed-on: https://go-review.googlesource.com/c/154597
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agocmd: improve aix/ppc64 new symbol addressing
Clément Chigot [Wed, 28 Nov 2018 12:38:02 +0000 (13:38 +0100)]
cmd: improve aix/ppc64 new symbol addressing

This commit updates the new symbol addressing made for aix/ppc64 according
to feedbacks given in CL 151039.

Change-Id: Ic4eb9943dc520d65f7d084adf8fa9a2530f4d3f9
Reviewed-on: https://go-review.googlesource.com/c/151302
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.12: updates for runtime and compiler
Austin Clements [Mon, 17 Dec 2018 20:26:36 +0000 (15:26 -0500)]
doc/go1.12: updates for runtime and compiler

Change-Id: Ifb16fd28105efd05cebbd615b52e45330b77cede
Reviewed-on: https://go-review.googlesource.com/c/154600
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: generate interface method expression wrapper for error.Error
Robert Griesemer [Mon, 17 Dec 2018 19:33:42 +0000 (11:33 -0800)]
cmd/compile: generate interface method expression wrapper for error.Error

A prior optimization (https://golang.org/cl/106175) removed the
generation of unnecessary method expression wrappers, but also
eliminated the generation of the wrapper for error.Error which
was still required.

Special-case error type in the optimization.

Fixes #29304.

Change-Id: I54c8afc88a2c6d1906afa2d09c68a0a3f3e2f1e3
Reviewed-on: https://go-review.googlesource.com/c/154578
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: poison the write barrier buffer during flushing
Austin Clements [Mon, 17 Dec 2018 18:45:14 +0000 (13:45 -0500)]
runtime: poison the write barrier buffer during flushing

Currently we reset the write barrier buffer before processing the
pointers in it. As a result, if there were any write barriers in the
code that processes the buffer, it would corrupt the write barrier
buffer and cause us to mark objects without later scanning them.

As far as I can tell, this shouldn't be happening, but rather than
relying on hope (and incomplete static analysis), this CL changes
wbBufFlush1 to poison the write barrier buffer while processing it,
and only reset it once it's done.

Updates #27993. (Unlike many of the other changes for this issue,
there's no need to roll back this CL. It's a good change in its own
right.)

Change-Id: I6d2d9f1b69b89438438b9ee624f3fff9f009e29d
Reviewed-on: https://go-review.googlesource.com/c/154537
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agocmd/link: fix error messages for external linking on ppc64
Clément Chigot [Fri, 23 Nov 2018 14:16:18 +0000 (15:16 +0100)]
cmd/link: fix error messages for external linking on ppc64

This commit fixes error messages displayed on aix/ppc64 with external
linking.

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

6 years agoos: make Stat work on FAT file system
Alex Brainman [Sat, 15 Dec 2018 07:52:26 +0000 (18:52 +1100)]
os: make Stat work on FAT file system

It appears calling GetFileInformationByHandleEx with
FILE_ATTRIBUTE_TAG_INFO fails on FAT file system. FAT does not
support symlinks, so assume there are no symlnks when
GetFileInformationByHandleEx returns ERROR_INVALID_PARAMETER.

Fixes #29214

Change-Id: If2d9f3288bd99637681ab5fd4e4581c77b578a69
Reviewed-on: https://go-review.googlesource.com/c/154377
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/dist: re-enable VFPv3 on openbsd/arm
Joel Sing [Sat, 15 Dec 2018 14:07:58 +0000 (01:07 +1100)]
cmd/dist: re-enable VFPv3 on openbsd/arm

The OpenBSD armv7 port has working VFPv3 these days - re-enable the VFP
detection code so that GOARM=7 is used by default on openbsd/arm.

Change-Id: I0271d81c048d2d55becd2803c19e5f1542076357
Reviewed-on: https://go-review.googlesource.com/c/154378
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

6 years agoruntime: fix hangs in TestDebugCall*
Austin Clements [Fri, 14 Dec 2018 16:55:44 +0000 (11:55 -0500)]
runtime: fix hangs in TestDebugCall*

This fixes a few different issues that led to hangs and general
flakiness in the TestDebugCall* tests.

1. This fixes missing wake-ups in two error paths of the SIGTRAP
   signal handler. If the goroutine was in an unknown state, or if
   there was an unknown debug call status, we currently don't wake the
   injection coordinator. These are terminal states, so this resulted
   in a hang.

2. This adds a retry if the target goroutine is in a transient state
   that prevents us from injecting a call. The most common failure
   mode here is that the target goroutine is in _Grunnable, but this
   was previously masked because it deadlocked the test.

3. Related to 2, this switches the "ready" signal from the target
   goroutine from a blocking channel send to a non-blocking channel
   send. This makes it much less likely that we'll catch this
   goroutine while it's in the runtime performing that send.

4. This increases GOMAXPROCS from 2 to 8 during these tests. With the
   current setting of 2, we can have at most the non-preemptible
   goroutine we're injecting a call in to and the goroutine that's
   trying to make it exit. If anything else comes along, it can
   deadlock. One particular case I observed was in TestDebugCallGC,
   where runtime.GC() returns before the forEachP that prepares
   sweeping on all goroutines has finished. When this happens, the
   forEachP blocks on the non-preemptible loop, which means we now
   have at least three goroutines that need to run.

Fixes #25519.

Updates #29124.

Change-Id: I7bc41dc0b865b7d0bb379cb654f9a1218bc37428
Reviewed-on: https://go-review.googlesource.com/c/154112
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agogo/doc: handle Examples with no body
Agniva De Sarker [Sun, 16 Dec 2018 13:43:25 +0000 (19:13 +0530)]
go/doc: handle Examples with no body

Fixes #29271

Change-Id: Iff6a16c659ad6ec1b4d9559fcbcd40196086c60e
Reviewed-on: https://go-review.googlesource.com/c/154380
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/fix,cmd/cgo,misc/cgo: map the EGLDisplay C type to uintptr in Go
Elias Naur [Sat, 15 Dec 2018 16:03:37 +0000 (17:03 +0100)]
cmd/fix,cmd/cgo,misc/cgo: map the EGLDisplay C type to uintptr in Go

Similar to to macOS' CF* types and JNI's jobject and derived types,
the EGLDisplay type is declared as a pointer but can contain
non-pointers (see #27054).
Fix it the same way: map EGLDisplay to uintptr in Go.

Fixes #27054

RELNOTE=yes

Change-Id: I6136f8f8162687c5493b30ed324e29efe55a8fd7
Reviewed-on: https://go-review.googlesource.com/c/154417
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/nm: report windows/arm as relocatable in TestGoExec
Jordan Rhee [Sat, 15 Dec 2018 00:11:03 +0000 (16:11 -0800)]
cmd/nm: report windows/arm as relocatable in TestGoExec

Updates #26148

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

6 years agocmd/link: fix in-package syso linking
Shenghou Ma [Fri, 14 Dec 2018 04:55:22 +0000 (23:55 -0500)]
cmd/link: fix in-package syso linking

CL 146297 ignored archive members with short names that don't have
the .o suffix, however, it also ignored .syso files as well.
This change restores the original .syso behavior and adds a test.

As the test is basically following a shell script, we make use of
the existing cmd/go/testdata/script framework. To support running
C compiler in the script, we added a `cc` command, which runs the
C compiler along with correct platform specific arguments.

Fixes #29253.

Change-Id: If8520151c4d6a74ab9fe84d34bff9a4480688815
Reviewed-on: https://go-review.googlesource.com/c/154109
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agocmd/go/internal/cache: save more data from DefaultDir
Bryan C. Mills [Fri, 14 Dec 2018 21:59:04 +0000 (16:59 -0500)]
cmd/go/internal/cache: save more data from DefaultDir

cmd/go/main.go sets GOCACHE explicitly, so if we don't save some
metadata about how DefaultDir arrived at its answer we will be unable
to reconstruct it later.

Fixes #29243

Change-Id: Ic8bb859ab045a29c91f6a4527e65aedabf874d53
Reviewed-on: https://go-review.googlesource.com/c/154309
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
6 years agodoc: document Go 1.11.4
Filippo Valsorda [Fri, 14 Dec 2018 21:04:50 +0000 (16:04 -0500)]
doc: document Go 1.11.4

Change-Id: Ic098bd69fa9e3f7b2ed6c451a7a266167c0cde94
Reviewed-on: https://go-review.googlesource.com/c/154302
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
6 years agodoc: document Go 1.10.7
Filippo Valsorda [Fri, 14 Dec 2018 21:14:56 +0000 (16:14 -0500)]
doc: document Go 1.10.7

Change-Id: Id71aad4cf6149e0ba15f7fec0b74517827c37866
Reviewed-on: https://go-review.googlesource.com/c/154303
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
6 years agonet/http/httptest: don't register a flag unless it looks like it's in use
Brad Fitzpatrick [Fri, 14 Dec 2018 18:33:13 +0000 (18:33 +0000)]
net/http/httptest: don't register a flag unless it looks like it's in use

We shouldn't pollute people's flags with this debugging flag that was
never really meant to be public. It's certainly not documented.

So keep it for now, but don't register it unless it looks like it's in
use (by looking at os.Args). Kinda gross, but less gross than before.

Fixes #28619

Change-Id: I47498948a26a71ff36f9658a6d9dac73fd0a3016
Reviewed-on: https://go-review.googlesource.com/c/154217
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agointernal/x/net/http2/hpack: update from upstream
Brad Fitzpatrick [Thu, 13 Dec 2018 20:28:29 +0000 (20:28 +0000)]
internal/x/net/http2/hpack: update from upstream

Updates to x/net git rev 891ebc4b82d6e74f468c533b06f983c7be918a96 for:

   http2/hpack: track the beginning of a header block
   https://go-review.googlesource.com/c/153978

Updates golang/go#29187

Change-Id: Ie2568b3f8d6aaa3f097a4ac25d3acdc794f5ff5c
Reviewed-on: https://go-review.googlesource.com/c/154118
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
6 years agocmd/go/internal/get: move wildcard-trimming to before CheckImportPath
Bryan C. Mills [Fri, 14 Dec 2018 02:42:33 +0000 (21:42 -0500)]
cmd/go/internal/get: move wildcard-trimming to before CheckImportPath

Previously, RepoRootForImportPath trimmed certain "..." wildcards from
package patterns (even though its name suggests that the argument must
be an actual import path). It trimmed at the first path element that
was literally "..." (although wildcards in general may appear within a
larger path element), and relied on a subsequent check in
RepoRootForImportPath to catch confusing resolutions.

However, that causes 'go get' with wildcard patterns in fresh paths to
fail as of CL 154101: a wildcard pattern is not a valid import path,
and fails the path check. (The existing Test{Vendor,Go}Get* packages
in go_test.go and vendor_test.go catch the failure, but they are all
skipped when the "-short" flag is set — including in all.bash — and we
had forgotten to run them separately.)

We now trim the path before any element that contains a wildcard, and
perform the path check (and repo resolution) on only that prefix. It
is possible that the expanded path after fetching the repo will be
invalid, but a repository can contain directories that are not valid
import paths in general anyway.

Fixes #29241

Change-Id: I70fb2f7fc6603b7d339fd6c02e8cdeacfc93fc4b
Reviewed-on: https://go-review.googlesource.com/c/154108
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agosyscall: remove linknames to runtime symbols for aix/ppc64
Clément Chigot [Thu, 13 Dec 2018 12:37:57 +0000 (13:37 +0100)]
syscall: remove linknames to runtime symbols for aix/ppc64

Replaces //go:linkname by assembly functions for syscall
functions on aix/ppc64.
Since the new runtime internal ABI, this was triggering an error if
syscall.Syscall6 was called by others packages like x/sys/unix.
This commit should remove every future occurences of this problem.

Fixes #28769

Change-Id: I6a4bf77472ee1e974bdb76b27e74275e568f5a76
Reviewed-on: https://go-review.googlesource.com/c/153997
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
6 years agocmd/compile: fix length overflow when appending elements to a slice
Martin Möhrmann [Thu, 13 Dec 2018 16:55:52 +0000 (17:55 +0100)]
cmd/compile: fix length overflow when appending elements to a slice

Instead of testing len(slice)+numNewElements > cap(slice) use
uint(len(slice)+numNewElements) > uint(cap(slice)) to test
if a slice needs to be grown in an append operation.

This prevents a possible overflow when len(slice) is near the maximum
int value and the addition of a constant number of new elements
makes it overflow and wrap around to a negative number which is
smaller than the capacity of the slice.

Appending a slice to a slice with append(s1, s2...) already used
a uint comparison to test slice capacity and therefore was not
vulnerable to the same overflow issue.

Fixes: #29190
Change-Id: I41733895838b4f80a44f827bf900ce931d8be5ca
Reviewed-on: https://go-review.googlesource.com/c/154037
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: set user and email in test-local git repos
Bryan C. Mills [Thu, 13 Dec 2018 14:23:25 +0000 (09:23 -0500)]
cmd/go: set user and email in test-local git repos

Some of the builders cannot infer user and email from the builder hostname.

Change-Id: I27e5d011fa1471f27763b6b7fa1bf59e418b925c
Reviewed-on: https://team-review.git.corp.google.com/c/376739
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-on: https://go-review.googlesource.com/c/154107
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc: document Go 1.11.3 and Go 1.10.6
Dmitri Shuralyov [Wed, 12 Dec 2018 18:35:19 +0000 (13:35 -0500)]
doc: document Go 1.11.3 and Go 1.10.6

Change-Id: I3fe44887a84586d73be01df78a9cbb002c1fc9c5
Reviewed-on: https://team-review.git.corp.google.com/c/376465
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Reviewed-on: https://go-review.googlesource.com/c/154106
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocrypto/x509: limit number of signature checks for each verification
Filippo Valsorda [Wed, 5 Dec 2018 03:23:22 +0000 (22:23 -0500)]
crypto/x509: limit number of signature checks for each verification

That number grows quadratically with the number of intermediate
certificates in certain pathological cases (for example if they all have
the same Subject) leading to a CPU DoS. Set a fixed budget that should
fit all real world chains, given we only look at intermediates provided
by the peer.

The algorithm can be improved, but that's left for follow-up CLs:

    * the cache logic should be reviewed for correctness, as it seems to
      override the entire chain with the cached one
    * the equality check should compare Subject and public key, not the
      whole certificate
    * certificates with the right SKID but the wrong Subject should not
      be considered, and in particular should not take priority over
      certificates with the right Subject

Fixes #29233

Change-Id: Ib257c12cd5563df7723f9c81231d82b882854213
Reviewed-on: https://team-review.git.corp.google.com/c/370475
Reviewed-by: Andrew Bonventre <andybons@google.com>
Reviewed-on: https://go-review.googlesource.com/c/154105
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

6 years agocmd/go/internal/get: relax pathOK check to allow any letter
Bryan C. Mills [Tue, 4 Dec 2018 22:00:19 +0000 (17:00 -0500)]
cmd/go/internal/get: relax pathOK check to allow any letter

This fixes a regression of #18660 with the new path checks.

Updates #29230

Change-Id: I2dd9adab999e7f810e0e746ad8b75ea9622f56e7
Reviewed-on: https://team-review.git.corp.google.com/c/370578
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-on: https://go-review.googlesource.com/c/154104
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/get: use a strings.Replacer in expand
Bryan C. Mills [Tue, 4 Dec 2018 20:42:32 +0000 (15:42 -0500)]
cmd/go/internal/get: use a strings.Replacer in expand

This should be a no-op, but produces deterministic (and more correct)
behavior if we have accidentally failed to sanitize one of the inputs.

Updates #29231

Change-Id: I1271d0ffd01a691ec8c84906c4e02d9e2be19c72
Reviewed-on: https://team-review.git.corp.google.com/c/370575
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-on: https://go-review.googlesource.com/c/154103
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/get: reject Windows shortnames as path components
Bryan C. Mills [Tue, 4 Dec 2018 19:37:39 +0000 (14:37 -0500)]
cmd/go/internal/get: reject Windows shortnames as path components

Updates #29230

Change-Id: Ia32d8ec1fc0c4e242f50d8871c0ef3ce315f3c65
Reviewed-on: https://team-review.git.corp.google.com/c/370571
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-on: https://go-review.googlesource.com/c/154102
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: reject 'get' of paths containing leading dots or unsupported characters
Bryan C. Mills [Fri, 30 Nov 2018 20:06:40 +0000 (15:06 -0500)]
cmd/go: reject 'get' of paths containing leading dots or unsupported characters

On some platforms, directories beginning with dot are treated as
hidden files, and filenames containing unusual characters can be
confusing for users to manipulate (and delete).

Fixes #29230
Fixes #29231

Change-Id: Ic6f97f577d8fafa83ef62438095a5c7ae022881a
Reviewed-on: https://team-review.git.corp.google.com/c/368507
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-on: https://go-review.googlesource.com/c/154101
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agogo/doc: simplify and robustify link detection logic
Joe Tsai [Fri, 16 Feb 2018 22:52:10 +0000 (14:52 -0800)]
go/doc: simplify and robustify link detection logic

To fix #5043, we added logic to allow balanced pairs of parenthesis
so that we could match URLs like:
http://example.com/some_resource(foo)

Howewer, such logic breaks when parsing something like the following:
art by [https://example.com/person][Person Name]].
such that the following is considered the link:
https://example.com/person][Person

Since the logic added in #5043 was just a heuristic, we adjust
the heuristic that in addition to requiring balanced pairs,
the first parenthesis must be an opening one.

For further robustness, we apply this heuristic to
parenthesis, braces, and brackets.

Fixes #22285

Change-Id: I23b728a644e35ce3995b05a79129cad2c1e3b1ce
Reviewed-on: https://go-review.googlesource.com/c/94876
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agomime/multipart: quote boundary in Content-Type if necessary
Ian Lance Taylor [Thu, 13 Dec 2018 23:23:35 +0000 (15:23 -0800)]
mime/multipart: quote boundary in Content-Type if necessary

Fixes #26532

Change-Id: Ic086c90503c7b24982f947c828c7ccf016ddbf69
Reviewed-on: https://go-review.googlesource.com/c/154120
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>