]> Cypherpunks repositories - gostls13.git/log
gostls13.git
7 years agotesting: roll back CL 44352 (show in-progress tests upon SIGINT)
Ian Lance Taylor [Thu, 13 Jul 2017 15:10:43 +0000 (08:10 -0700)]
testing: roll back CL 44352 (show in-progress tests upon SIGINT)

CL 44352 changed the behavior of SIGINT, which can break tests that
themselves use SIGINT.  I think we can only implement this if the
testing package has a way to know whether the code under test is using
SIGINT, but os/signal does not provide an API for that.  Roll back for
1.9 and think about this again for 1.10.

Updates #19397

Change-Id: I021c314db2b9d0a80d0088b120a6ade685459990
Reviewed-on: https://go-review.googlesource.com/48370
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: don't call t.Parallel in TestCgoSignalDeadlock
Ian Lance Taylor [Thu, 13 Jul 2017 03:51:15 +0000 (20:51 -0700)]
runtime: don't call t.Parallel in TestCgoSignalDeadlock

It seems that when too much other code is running on the system,
the testprogcgo code can overrun its timeouts.

Updates #18598.

Not marking the issue as fixed until it doesn't recur for some time.

Change-Id: Ieaf106b41986fdda76b1d027bb9d5e3fb805cc3b
Reviewed-on: https://go-review.googlesource.com/48233
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agosyscall: use correct go binary in test
Brad Fitzpatrick [Wed, 12 Jul 2017 21:31:30 +0000 (21:31 +0000)]
syscall: use correct go binary in test

Usually this test is skipped (on builders and when not root), so
people are unlikely to see this error.

Updates #19296

Change-Id: I3acb81260034dad8776c305f83d7cbac4b718e75
Reviewed-on: https://go-review.googlesource.com/48191
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agodoc: note the StripPrefix change in Go 1.9 release notes
Brad Fitzpatrick [Wed, 12 Jul 2017 19:40:39 +0000 (19:40 +0000)]
doc: note the StripPrefix change in Go 1.9 release notes

Fixes #20948

Change-Id: I222bf101a5c1bdc5cbb0970949070c4b58b9b83b
Reviewed-on: https://go-review.googlesource.com/48190
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: pass CLONE_SYSVSEM to clone
Austin Clements [Wed, 12 Jul 2017 16:12:50 +0000 (10:12 -0600)]
runtime: pass CLONE_SYSVSEM to clone

SysV semaphore undo lists should be shared by threads, just like
several other resources listed in cloneFlags. Currently we don't do
this, but it probably doesn't affect anything because 1) probably
nobody uses SysV semaphores from Go and 2) Go-created threads never
exit until the process does. Beyond being the right thing to do,
user-level QEMU requires this flag because it depends on glibc to
create new threads and glibc uses this flag.

Fixes #20763.

Change-Id: I1d1dafec53ed87e0f4d4d432b945e8e68bb72dcd
Reviewed-on: https://go-review.googlesource.com/48170
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: soften the NetBSD warning now that a unverified fix is being released
Brad Fitzpatrick [Mon, 10 Jul 2017 17:56:29 +0000 (17:56 +0000)]
doc: soften the NetBSD warning now that a unverified fix is being released

To-be-released NetBSD 7.1.1 reportedly fixes the kernel panic that was
affecting our builders and is being released because of Go's warning.

So, soften our warning.

7.1.1 might work, but I can't get a builder up and running to verify
yet as it appears that Anita either doesn't support it yet, or the
NetBSD CDN doesn't have the files yet.

Change-Id: Ifaafc566879a6afdf1174e545ad10e240da427e8
Reviewed-on: https://go-review.googlesource.com/47970
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: make TestStackGrowth a serial test
Austin Clements [Tue, 11 Jul 2017 13:26:01 +0000 (09:26 -0400)]
runtime: make TestStackGrowth a serial test

TestStackGrowth is currently a parallel test. However, it depends on a
20 second timeout, which is already dubious in a parallel test, and
became really problematic on slow builders when runtime.GC switched to
triggering concurrent GC instead of STW GC. Before that change, the
test spent much of its time in STW GC, so it wasn't *really* parallel.
After that change, it was competing with all of the other parallel
tests and GC likely started taking ~4 times longer. On most builders
the whole test runs in well under a second, but on the slow builders
that was enough to push it over the 20 second timeout.

Fix this by making the test serial.

Updates #19381 (probably fixes it, but we'll have to wait and see).

Change-Id: I21af7cf543ab07f1ec1c930bfcb355b0df75672d
Reviewed-on: https://go-review.googlesource.com/48110
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agosync/atomic: clarify 64-bit alignment bug
Austin Clements [Tue, 11 Jul 2017 15:03:36 +0000 (11:03 -0400)]
sync/atomic: clarify 64-bit alignment bug

Local variables can also be relied on the be 64-bit aligned, since
they will be escaped to the heap if used with any atomic operations.

Also, allocated arrays are also aligned, just like structs and slices.

Fixes #18955.

Change-Id: I8a1897f6ff78922c8bfcf20d6eb4bcb17a70ba2d
Reviewed-on: https://go-review.googlesource.com/48112
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: simplify description of FuncForPC behavior in case of inlining
Costin Chirvasuta [Fri, 7 Jul 2017 20:26:45 +0000 (21:26 +0100)]
runtime: simplify description of FuncForPC behavior in case of inlining

The current description refers to the outermost "frame" which can be
misleading. A user reading it can think it means a stack frame.

Change-Id: Ie2c7cb4b4db8f41572df206478ce3b46a0245a5d
Reviewed-on: https://go-review.googlesource.com/47850
Reviewed-by: Austin Clements <austin@google.com>
7 years agocmd/compile: fix lexical scope of escaped variables
Alessandro Arzilli [Sun, 9 Jul 2017 15:03:45 +0000 (17:03 +0200)]
cmd/compile: fix lexical scope of escaped variables

When a local variable is moved to the heap the declaration position
should be preserved so that later on we can assign it to the correct
DW_TAG_lexical_block.

Fixes #20959

Change-Id: I3700ef53c68ccd506d0633f11374ad88a52b2898
Reviewed-on: https://go-review.googlesource.com/47852
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/link: skip R_ADDR relocs in .rela.plt for internal PIE
Michael Pratt [Sat, 8 Jul 2017 23:47:16 +0000 (16:47 -0700)]
cmd/link: skip R_ADDR relocs in .rela.plt for internal PIE

ld.addpltsym adds an R_X86_64_JMP_SLOT dynamic relocation to .rela.plt
and uses Addaddrplus to reference the GOT in Elf64_Rela.r_offset.

Addaddrplus results in an R_ADDR relocation, which here we transform
into an R_X86_64_64 dynamic relocation. This is wrong for several
reasons:

1. .rela.plt is not a writable, relro section. It is mapped read-only,
   causing the dynamic linker to segfault when it tried to handle the
   relocation. This was the immediate cause of internal PIE cgo
   crashes.

2. Relocations targetting other reloc sections are, as far as I can
   tell, undefined behavior in the ELF spec and are unlikely to be a
   good idea.

3. Even if the relocation did work, it isn't what we want. The
   relocation, if successfully handled, would have put an absolute
   address as the JMP_SLOT offset, but it should be the offset from the
   beginning of the binary, just like any other relocation. What we want
   is a statically resolved R_ADDR relocation, just as is used below for
   the R_X86_64_64 relocation.

Skipping the .rela.plt allows reloc() to handle these R_ADDR
relocations.

With this CL, internal PIE cgo binaries work.

Updates #18968

Change-Id: Ie74e6fe249e88150baa0e340b1cb128cf7f28673
Reviewed-on: https://go-review.googlesource.com/47837
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agotest: deflake chan/select3.go
Josh Bleecher Snyder [Fri, 7 Jul 2017 23:09:20 +0000 (13:09 -1000)]
test: deflake chan/select3.go

On a slow or distracted machine, 0.1s is sometimes
not long enough for a non-blocking function call to complete.
This causes rare test flakes.
They can be easily reproduced by reducing the wait time to (say) 100ns.

For non-blocking functions, increase the window from 100ms to 10s.
Using different windows for block and non-blocking functions,
allows us to reduce the time for blocking functions.
The risk here is false negatives, but that risk is low;
this test is run repeatedly on many fast machines,
for which 10ms is ample time.
This reduces the time required to run the test by a factor of 10,
from ~1s to ~100ms.

Fixes #20299

Change-Id: Ice9a641a66c6c101d738a2ebe1bcb144ae3c9916
Reviewed-on: https://go-review.googlesource.com/47812
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: use next timer to decide whether to relax
Austin Clements [Fri, 7 Jul 2017 18:58:55 +0000 (14:58 -0400)]
runtime: use next timer to decide whether to relax

Currently, sysmon waits 60 ms during idle before relaxing. This is
primarily to avoid reducing the precision of short-duration timers. Of
course, if there are no short-duration timers, this wastes 60 ms
running the timer at high resolution.

Improve this by instead inspecting the time until the next timer fires
and relaxing the timer resolution immediately if the next timer won't
fire for a while.

Updates #20937.

Change-Id: If4ad0a565b65a9b3e8c4cdc2eff1486968c79f24
Reviewed-on: https://go-review.googlesource.com/47833
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: delay before osRelaxing
Austin Clements [Fri, 7 Jul 2017 16:03:22 +0000 (12:03 -0400)]
runtime: delay before osRelaxing

Currently, sysmon relaxes the Windows timer resolution as soon as the
Go process becomes idle. However, if it's going idle because of a
short sleep (< 15.6 ms), this can turn that short sleep into a long
sleep (15.6 ms).

To address this, wait for 60 ms of idleness before relaxing the timer
resolution. It would be better to check the time until the next wakeup
and relax immediately if it makes sense, but there's currently no
interaction between sysmon and the timer subsystem, so adding this
simple delay is a much simpler and safer change for late in the
release cycle.

Fixes #20937.

Change-Id: I817db24c3bdfa06dba04b7bc197cfd554363c379
Reviewed-on: https://go-review.googlesource.com/47832
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoRevert "cmd/dist: disable plugin test on linux-arm with GOARM=5"
Austin Clements [Fri, 7 Jul 2017 19:49:33 +0000 (19:49 +0000)]
Revert "cmd/dist: disable plugin test on linux-arm with GOARM=5"

This reverts commit 168eb9cf3395583541224af0227c19ddb13e35be.

CL 47831 fixes the issue with plugins on ARMv5, so we can re-enable the test.

Updates #19674.

Change-Id: Idcb29f93ffb0460413f1fab5bb82fa2605795038
Reviewed-on: https://go-review.googlesource.com/47834
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: save r11 in ARM addmoduledata
Austin Clements [Fri, 7 Jul 2017 18:59:35 +0000 (14:59 -0400)]
runtime: save r11 in ARM addmoduledata

R11 is callee-save in the C ABI, but the temporary register in the Go
ABI. Currently it's being clobbered by runtime.addmoduledata, which
has to follow the C ABI. The observed effect of this was that
dl_open_worker was returning to a bad PC because after it failed to
restore its SP because it was using R11 as a frame pointer.

Fix this by saving R11 around addmoduledata.

Fixes #19674.

Change-Id: Iaacbcc76809a3aa536e9897770831dcbcb6c8245
Reviewed-on: https://go-review.googlesource.com/47831
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agodoc/go1.9: DWARF lexical scopes are only with -N -l
Austin Clements [Fri, 7 Jul 2017 15:12:22 +0000 (11:12 -0400)]
doc/go1.9: DWARF lexical scopes are only with -N -l

Change-Id: If1c602176e0bea66924983eab8edd5e450228b68
Reviewed-on: https://go-review.googlesource.com/47792
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc/go1.9: discuss runtime.Callers
Austin Clements [Thu, 6 Jul 2017 18:27:25 +0000 (14:27 -0400)]
doc/go1.9: discuss runtime.Callers

A lot of code that uses runtime.Callers makes assumptions about the
result that are not true today under gccgo and will not be true in the
future in gc. This adds a section to the release notes discussing how
to correctly use runtime.Callers.

Change-Id: I96b7c7ef183cee2061442fc3501fceceefa54c09
Reviewed-on: https://go-review.googlesource.com/47691
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agoruntime: document FuncForPC behavior with inlining
Austin Clements [Thu, 6 Jul 2017 16:36:25 +0000 (12:36 -0400)]
runtime: document FuncForPC behavior with inlining

Change-Id: I1c02aa4f7131ae984fda66b32e8a993c0a40b8f4
Reviewed-on: https://go-review.googlesource.com/47690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agodoc: note that Go 1.9 is last release to support FreeBSD 9.3
Brad Fitzpatrick [Fri, 7 Jul 2017 03:45:50 +0000 (03:45 +0000)]
doc: note that Go 1.9 is last release to support FreeBSD 9.3

Fixes #20930

Change-Id: I4a59de0556cffeae9af2eaa41609601e086211b2
Reviewed-on: https://go-review.googlesource.com/47731
Reviewed-by: Rob Pike <r@golang.org>
7 years agocmd/doc: print Go syntax when printing struct.field docs
Brad Fitzpatrick [Thu, 6 Jul 2017 20:02:26 +0000 (20:02 +0000)]
cmd/doc: print Go syntax when printing struct.field docs

Fixes #20928

Change-Id: I7f7aafb8ff4b5deb50c286a9ae81c34ee85e56a9
Reviewed-on: https://go-review.googlesource.com/47730
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoencoding/base32: make NoPadding Encoding's DecodedLen return exact size
Gustav Westling [Thu, 6 Jul 2017 18:30:26 +0000 (20:30 +0200)]
encoding/base32: make NoPadding Encoding's DecodedLen return exact size

CL 47341 added support for decoding non-padded messages. But DecodedLen
still returned a multiple of 5 for messages without a padding, even
though it is possible to calculate the len exactly when using NoPadding.

This change makes DecodedLen return the exact number of bytes that
will be written. A change to the decoding logic is also made so that it
can handle this case.

DecodedLen now has the same behaviour as DecodedLen in encoding/base64.

Fixes #20854

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

7 years agoos/exec: clarify Cmd.Wait documentation a bit more explicitly
Brad Fitzpatrick [Thu, 6 Jul 2017 17:56:21 +0000 (17:56 +0000)]
os/exec: clarify Cmd.Wait documentation a bit more explicitly

It already implied that Cmd.Wait is more than os.Process.Wait, but say
so explicitly.

See https://github.com/golang/go/issues/18874#issuecomment-309921486

Updates #18874

Change-Id: Iaa46defd776ae0be817d9f4466a99ac78cfd672b
Reviewed-on: https://go-review.googlesource.com/47650
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agoencoding/base32: support custom and disabled padding when decoding
Gustav Westling [Sun, 2 Jul 2017 11:27:47 +0000 (13:27 +0200)]
encoding/base32: support custom and disabled padding when decoding

CL 38634 added support for custom (and disabled) padding characters
when encoding, but didn't update the decoding paths. This adds
decoding support.

Fixes #20854

Change-Id: I9fb1a0aaebb27f1204c9f726a780d5784eb71024
Reviewed-on: https://go-review.googlesource.com/47341
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: prevent descheduling while holding rwmutex read lock
Austin Clements [Thu, 6 Jul 2017 15:55:39 +0000 (11:55 -0400)]
runtime: prevent descheduling while holding rwmutex read lock

Currently only the rwmutex write lock prevents descheduling. The read
lock does not. This leads to the following situation:

1. A reader acquires the lock and gets descheduled.

2. GOMAXPROCS writers attempt to acquire the lock (or at least one
writer does, followed by readers). This blocks all of the Ps.

3. There is no 3. The descheduled reader never gets to run again
because there are no Ps, so it never releases the lock and the system
deadlocks.

Fix this by preventing descheduling while holding the read lock. This
requires also rewriting TestParallelRWMutexReaders to always create
enough GOMAXPROCS and to use non-blocking operations for
synchronization.

Fixes #20903.

Change-Id: Ibd460663a7e5a555be5490e13b2eaaa295fac39f
Reviewed-on: https://go-review.googlesource.com/47632
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agonet: clarify the length limit for service name
Mikio Hara [Wed, 14 Dec 2016 21:19:49 +0000 (06:19 +0900)]
net: clarify the length limit for service name

Change-Id: If5495f66d175bdacebd599abf1e064d2343669c2
Reviewed-on: https://go-review.googlesource.com/34430
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet: don't return IPv4 unspecified addr for Resolve*Addr of [::] or [::]:n
Brad Fitzpatrick [Thu, 6 Jul 2017 05:00:21 +0000 (22:00 -0700)]
net: don't return IPv4 unspecified addr for Resolve*Addr of [::] or [::]:n

ResolveTCPAddr, ResolveUDPAddr, and ResolveIPAddr return at most one
address. When given a name like "golang.org" to resolve that might
have more than 1 address, the net package has historically preferred
IPv4 addresses, with the assumption that many users don't yet have
IPv6 connectivity and randomly selecting between an IPv4 address and
an IPv6 address at runtime wouldn't be a good experience for IPv4-only
users.

In CL 45088 (78cf0e56) I modified the resolution of the
unspecified/empty address to internally resolve to both IPv6 "::" and
0.0.0.0 to fix issue #18806.

That code has 3 other callers I hadn't considered, though: the
Resolve*Addr functions. Since they preferred IPv4, any Resolve*Addr of
"[::]:port" or "::" (for ResolveIPAddr) would internally resolve both
"::" and 0.0.0.0 and then prefer 0.0.0.0, even though the user was
looking up an IPv6 literal.

Add tests and fix it, not by undoing the fix to #18806 but by
selecting the preference function for Resolve*Addr more explicitly: we
still prefer IPv4, but if the address being looked up was an IPv6
literal, prefer IPv6.

The tests are skipped on machines without IPv6.

Fixes #20911

Change-Id: Ib7036cc43182ae4118cd1390c254e17c04a251a3
Reviewed-on: https://go-review.googlesource.com/47554
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agodoc: complete remaining Go 1.9 documentation TODOs
Brad Fitzpatrick [Thu, 6 Jul 2017 00:22:31 +0000 (00:22 +0000)]
doc: complete remaining Go 1.9 documentation TODOs

Updates #20587

Change-Id: Ie4846f90611390eebf037ffafaed5ddd273565e4
Reviewed-on: https://go-review.googlesource.com/47551
Reviewed-by: Rob Pike <r@golang.org>
7 years agocmd/go: fix docs for -timeout
Russ Cox [Thu, 6 Jul 2017 04:14:15 +0000 (00:14 -0400)]
cmd/go: fix docs for -timeout

The text before CL 45816 was:

-timeout t
If a test runs longer than t, panic.
The default is 10 minutes (10m).

CL 45816 was supposed to be about clarifying test vs test binary,
and it did add the clarification of referring to "duration d",
but it also introduced incorrect text about timeout 0.

The new text in this CL preserves the good change and
eliminates the incorrect one:

-timeout d
If a test binary runs longer than duration d, panic.
The default is 10 minutes (10m).

For #14780.

Change-Id: I4f79d6e48ed9295bc9f34a36aa90d3b03b40d7f5
Reviewed-on: https://go-review.googlesource.com/47571
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoreflect: match MakeMapWithSize docs about initial capacity with spec
Emmanuel Odeke [Wed, 21 Jun 2017 06:35:18 +0000 (00:35 -0600)]
reflect: match MakeMapWithSize docs about initial capacity with spec

Following the spec clarification in CL 40393, copy that text
to reflect docs to state that the initial capacity of MakeMapWithSize
is a hint/approximate.

Fixes #19903

Change-Id: I6b3315b8183cafaa61fbb2839a4e42b76fd71544
Reviewed-on: https://go-review.googlesource.com/46270
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agotime: document the Time.String is meant for debugging
Brad Fitzpatrick [Thu, 6 Jul 2017 03:39:58 +0000 (03:39 +0000)]
time: document the Time.String is meant for debugging

Fixes #20876

Change-Id: Ic62c4f59e3ddcae891aa9526f9693d233dd524fc
Reviewed-on: https://go-review.googlesource.com/47552
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
7 years agoos/exec: document lack of implicit shell usage or globbing
Brad Fitzpatrick [Wed, 5 Jul 2017 23:05:42 +0000 (23:05 +0000)]
os/exec: document lack of implicit shell usage or globbing

Fixes #20894

Change-Id: I0c0e906964bbd789317d07f245e64e3d61ecfa8c
Reviewed-on: https://go-review.googlesource.com/47550
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agoRevert "bufio: make Reader.Peek invalidate Unreads"
Russ Cox [Thu, 6 Jul 2017 03:06:08 +0000 (03:06 +0000)]
Revert "bufio: make Reader.Peek invalidate Unreads"

Go 1.9 beta 2 is already out.
It's too late to break code with a change like this.
This can be rolled forward for Go 1.10.

This reverts commit ae238688d2813e83f16050408487ea34ba1c2fff.

Change-Id: Ib67b8629e3deac5d50d76581aba6a91ca7a7853e
Reviewed-on: https://go-review.googlesource.com/47570
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agoruntime/pprof: Fix type name in function comment
Fabian Wickborn [Wed, 5 Jul 2017 08:09:05 +0000 (10:09 +0200)]
runtime/pprof: Fix type name in function comment

The name LabelList was changed to LabelSet during the development of the
proposal [1], except in one function comment. This commit fixes that.

Fixes #20905.

[1] https://github.com/golang/go/issues/17280

Change-Id: Id4f48d59d7d513fa24b2e42795c2baa5ceb78f36
Reviewed-on: https://go-review.googlesource.com/47470
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agogo/printer: fix typo
Kale Blankenship [Tue, 4 Jul 2017 15:33:56 +0000 (08:33 -0700)]
go/printer: fix typo

Change-Id: Idf89559c9945c5a8743539658fe92e860fcc6a92
Reviewed-on: https://go-review.googlesource.com/47362
Reviewed-by: Matt Layher <mdlayher@gmail.com>
7 years agoruntime: clean up mheap.allocLarge
Austin Clements [Fri, 30 Jun 2017 20:51:07 +0000 (16:51 -0400)]
runtime: clean up mheap.allocLarge

mheap.allocLarge just calls bestFitTreap and is the only caller of
bestFitTreap. Flatten these into a single function. Also fix their
comments: allocLarge claims to return exactly npages but can in fact
return a larger span, and h.freelarge is not in fact indexed by span
start address.

Change-Id: Ia20112bdc46643a501ea82ea77c58596bc96f125
Reviewed-on: https://go-review.googlesource.com/47315
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
7 years agonet/http/httptest: allow creation of Server manually
Joe Tsai [Fri, 30 Jun 2017 21:10:48 +0000 (14:10 -0700)]
net/http/httptest: allow creation of Server manually

The Server struct has exported fields, which allows users to manually
create a Server object without using using NewServer or NewTLSServer
and directly call Start or StartTLS on their object.

In order to ensure that manual creation of Server works, the
NewUnstartedServer function should not initialize Server in any way
that the user was not able to do themselves. For example, the setting
of a unexported filed, client, is not something a user can do.
Thus, rather than setting the client field in NewUnstartedServer,
we lazily initialize it when Start or StartTLS is called.

Otherwise, the Server logic can nil panic later when it assumes that this
field has been initialized.

Fixes #20871

Change-Id: I65c6a9f893ea963b0fbad0990b33af08007c1140
Reviewed-on: https://go-review.googlesource.com/47353
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: allow calling Func.Name on nil pointer
Joe Tsai [Fri, 30 Jun 2017 22:44:25 +0000 (15:44 -0700)]
runtime: allow calling Func.Name on nil pointer

The Func type has allowed calling the Func.Name method on a nil pointer
since Go1.2, where it returned an empty string. A regression caused by
CL/37331 caused this behavior to change. This breaks code that lazily
does runtime.FuncForPC(myPtr).Name() without first checking that myPtr
is actually non-nil.

Fixes #20872

Change-Id: Iae9a2ebabca5e9d1f5a2cdaf2f30e9c6198fec4f
Reviewed-on: https://go-review.googlesource.com/47354
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodatabase/sql: fix outdated package name in doc.txt
Martin Garton [Fri, 30 Jun 2017 19:03:27 +0000 (20:03 +0100)]
database/sql: fix outdated package name in doc.txt

Change-Id: I4417c5a8537095a6464ce919b2e5cb250e179939
Reviewed-on: https://go-review.googlesource.com/47332
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/internal/obj/arm: check illegal base registers in ARM instructions
Ben Shi [Tue, 20 Jun 2017 03:03:12 +0000 (03:03 +0000)]
cmd/internal/obj/arm: check illegal base registers in ARM instructions

Wrong instructions "MOVW 8(F0), R1" and "MOVW R0<<0(F1), R1"
are silently accepted, and all Fx are treated as Rx.

The patch checks all those illegal base registers.

fixes #20724

Change-Id: I05d41bb43fe774b023205163b7daf4a846e9dc88
Reviewed-on: https://go-review.googlesource.com/46132
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agonet: fix sendfile for Solaris
Shawn Walker-Salas [Fri, 30 Jun 2017 17:57:04 +0000 (10:57 -0700)]
net: fix sendfile for Solaris

If a retryable error such as EAGAIN/EINTR is encountered during a call
to sendfile(), we should not assume that a partial write occurred.
Instead, just like any other platform, we should always try again even
if 0 bytes were written.

Fixes #20857

Change-Id: I9aa48d193c27c6794c550320da4d3f7544041f37
Reviewed-on: https://go-review.googlesource.com/47351
Run-TryBot: Shawn Walker-Salas <shawn.walker@oracle.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/internal/obj/arm64: fix assemble LDXP bug
fanzha02 [Tue, 13 Jun 2017 07:24:36 +0000 (07:24 +0000)]
cmd/internal/obj/arm64: fix assemble LDXP bug

The current code calculates register number incorrectly.

The fix corrects the register number calculation.

Add cases created by decoder to test assembler.

Fixes #20697
Fixes #20723

Change-Id: I73ac153df9ea9f51c43a5104828d7a5389551c92
Reviewed-on: https://go-review.googlesource.com/45850
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agotesting: revert CL 36791's conditional ReadMemStats
Brad Fitzpatrick [Fri, 30 Jun 2017 16:12:28 +0000 (16:12 +0000)]
testing: revert CL 36791's conditional ReadMemStats

Now that ReadMemStats is fast (CL 34937), CL 36791 is not so
necessary, and causes confusion. See #20863

This was already partially reverted in CL 46612 but missed two of the
spots.

Fixes #20863

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

7 years agodoc: note quoted cookie value change in Go 1.9 relnotes
Lucas Clemente [Thu, 29 Jun 2017 08:55:48 +0000 (10:55 +0200)]
doc: note quoted cookie value change in Go 1.9 relnotes

Fixes #20834.

Change-Id: Ic60000db6b8ae489a5cedbdc938d9ca1dc34c6d4
Reviewed-on: https://go-review.googlesource.com/47151
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoos: add documentation for Windows users
Brad Fitzpatrick [Thu, 29 Jun 2017 22:47:29 +0000 (22:47 +0000)]
os: add documentation for Windows users

Updates #18581
Updates #20858

Change-Id: I6b5ce0e255a42c028d46815fff5a5aca68690fd9
Reviewed-on: https://go-review.googlesource.com/47254
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/vet/all: in case of vet panic, don't filter stacktrace
Robert Griesemer [Thu, 29 Jun 2017 21:14:26 +0000 (14:14 -0700)]
cmd/vet/all: in case of vet panic, don't filter stacktrace

Fixes #20839.

Change-Id: I125460c5da09b7fa0cf470ff5be436f8d650cde7
Reviewed-on: https://go-review.googlesource.com/47253
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoio: clarify documentation for io.ByteReader on error values
smasher164 [Wed, 28 Jun 2017 08:22:25 +0000 (04:22 -0400)]
io: clarify documentation for io.ByteReader on error values

Document that the byte value returned by ReadByte() is meaningless
if its error != nil. Because io.Reader and io.ByteReader are similar in
name, this CL aims to clear up any ambiguity surrounding the returned
values, particularly where io.Reader is allowed to return both a
non-zero number of valid bytes and err == EOF.

Fixes #20825

Change-Id: I3a23c18c80c471c0caae3b4d2f6f8e547da0bed9
Reviewed-on: https://go-review.googlesource.com/46950
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: update binary requirements
Brad Fitzpatrick [Thu, 29 Jun 2017 19:44:07 +0000 (19:44 +0000)]
doc: update binary requirements

FreeBSD 9.3.
Add Linux arm64. (required second line)
Clarify glibc requirement now that we have second line in notes.
OS X to macOS

Updates #20850

Change-Id: I684d464ed32a072081726b7c805a346c22c42f97
Reviewed-on: https://go-review.googlesource.com/47252
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoRevert "encoding/json: reduce unmarshal mallocs for unmapped fields"
Brad Fitzpatrick [Thu, 29 Jun 2017 17:06:54 +0000 (17:06 +0000)]
Revert "encoding/json: reduce unmarshal mallocs for unmapped fields"

This reverts commit df68afd07ce67727 (https://golang.org/cl/33276)

Reason for revert: made other benchmarks worse

Fixes #20693 (details)
Updates #17914
Updates #10335

Change-Id: If451b620803ccb0536b89c76c4353d2185d57d7e
Reviewed-on: https://go-review.googlesource.com/47211
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agotesting: clarify rules for concurrent t.Run calls
Alberto Donizetti [Thu, 1 Jun 2017 10:14:23 +0000 (12:14 +0200)]
testing: clarify rules for concurrent t.Run calls

Apparently, "all such calls must happen" means that the t.Run call
must *return* before the outer test function returns, or the calls
will cause a data race on t.ran.

Clarify the docs.

Fixes #20339

Change-Id: I191a9af2a9095be1e0aaf10b79c30e00a9c495cb
Reviewed-on: https://go-review.googlesource.com/47150
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet: fix Windows TestInterfaceHardwareAddrWithGetmac
Egon Elbre [Thu, 29 Jun 2017 10:58:28 +0000 (13:58 +0300)]
net: fix Windows TestInterfaceHardwareAddrWithGetmac

TestInterfaceHardwareAddrWithGetmac was panicing when getmac returned
multiple network cards.

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

7 years agoreflect: document that value.NumMethod counts exported methods
Ian Lance Taylor [Thu, 29 Jun 2017 15:06:22 +0000 (08:06 -0700)]
reflect: document that value.NumMethod counts exported methods

Updates #17686
Fixes #20848

Change-Id: I35d58c7d1aa74d3e7867124070e27c787d444b04
Reviewed-on: https://go-review.googlesource.com/47210
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocrypto/x509: improve internal comment
Dmitri Shuralyov [Thu, 29 Jun 2017 04:38:38 +0000 (00:38 -0400)]
crypto/x509: improve internal comment

Apply code review suggestion from CL 46715.

The block is doing more than just checking len(r.certs) == len(tc.cns).
It also verifies that certificate common names match.

Change-Id: I28d6926a5da48bd8f6c80aa5e5a1ed6d4990f845
Reviewed-on: https://go-review.googlesource.com/47132
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc, api: add syscall.SysProcAttr.AmbientCaps change to 1.9 notes, API
Brad Fitzpatrick [Wed, 28 Jun 2017 23:02:51 +0000 (23:02 +0000)]
doc, api: add syscall.SysProcAttr.AmbientCaps change to 1.9 notes, API

Updates #20587

Change-Id: I08377281270631ee08cd05ba835aa698ca23fa56
Reviewed-on: https://go-review.googlesource.com/47092
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agotime: warn that RFC3339Nano does not guarantee a natural ordering
Brad Fitzpatrick [Wed, 28 Jun 2017 22:07:06 +0000 (22:07 +0000)]
time: warn that RFC3339Nano does not guarantee a natural ordering

Fixes #19635

Change-Id: I85e725dbc85843afd0f4d82f5127fecacc1cb524
Reviewed-on: https://go-review.googlesource.com/47090
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoencoding/binary: clarify the repercussions for not following the docs
Brad Fitzpatrick [Wed, 28 Jun 2017 23:12:41 +0000 (23:12 +0000)]
encoding/binary: clarify the repercussions for not following the docs

Fixes #19794

Change-Id: I462cbc432fe9d4a9e6e79a9833b0013d82a0780e
Reviewed-on: https://go-review.googlesource.com/47093
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agonet/http: update bundled http2
Brad Fitzpatrick [Thu, 29 Jun 2017 00:10:57 +0000 (00:10 +0000)]
net/http: update bundled http2

Updates http2 to x/net/http2 git rev d4223d6710a for:

    http2: refund connection flow control on DATA frames received after reset
    https://golang.org/cl/46591

Fixes #46591

Change-Id: I5e6999599e921fed279c6d29ae77439191e99615
Reviewed-on: https://go-review.googlesource.com/47096
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
7 years agoencoding/gob: warn about decoding data from untrusted sources
Brad Fitzpatrick [Wed, 28 Jun 2017 23:20:59 +0000 (23:20 +0000)]
encoding/gob: warn about decoding data from untrusted sources

And some double space after period cleanup while I'm here.
I guess my previous regexps missed these. My next cleaner should
probably use go/ast instead of perl.

Updates #20221

Change-Id: Idb051e7ac3a7fb1fb86e015f709e32139d065d92
Reviewed-on: https://go-review.googlesource.com/47094
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agosyscall: add AmbientCaps to linux SysProcAttr
Michael Stapelberg [Wed, 17 May 2017 09:05:32 +0000 (02:05 -0700)]
syscall: add AmbientCaps to linux SysProcAttr

Fixes #19713

Change-Id: Id1ca61b35bca2a4bea23dd64c7fb001a3a14fd88
Reviewed-on: https://go-review.googlesource.com/43512
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agogo/importer: don't return packages that are not fully type-checked
Robert Griesemer [Wed, 28 Jun 2017 22:04:47 +0000 (15:04 -0700)]
go/importer: don't return packages that are not fully type-checked

Fixes #20837.

Change-Id: I266519c26c8849da267b77e11abe7734d8275112
Reviewed-on: https://go-review.googlesource.com/47074
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agoruntime: use rwmutex for execLock
Austin Clements [Wed, 28 Jun 2017 19:58:59 +0000 (15:58 -0400)]
runtime: use rwmutex for execLock

Currently the execLock is a mutex, which has the unfortunate
side-effect of serializing all thread creation. This replaces it with
an rwmutex so threads can be created in parallel, but exec still
blocks thread creation.

Fixes #20738.

Change-Id: Ia8f30a92053c3d28af460b0da71176abe5fd074b
Reviewed-on: https://go-review.googlesource.com/47072
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: make rwmutex work on Ms instead of Gs
Austin Clements [Wed, 28 Jun 2017 19:54:46 +0000 (15:54 -0400)]
runtime: make rwmutex work on Ms instead of Gs

Currently runtime.rwmutex is written to block the calling goroutine
rather than the calling thread. However, rwmutex was intended to be
used in the scheduler, which means it needs to be a thread-level
synchronization primitive.

Hence, this modifies rwmutex to synchronize threads instead of
goroutines. This has the consequence of making it write-barrier-free,
which is also important for using it in the scheduler.

The implementation makes three changes: it replaces the "w" semaphore
with a mutex, since this was all it was being used for anyway; it
replaces "writerSem" with a single pending M that parks on its note;
and it replaces "readerSem" with a list of Ms that park on their notes
plus a pass count that together emulate a counting semaphore. I
model-checked the safety and liveness of this implementation through
>1 billion schedules.

For #20738.

Change-Id: I3cf5a18c266a96a3f38165083812803510217787
Reviewed-on: https://go-review.googlesource.com/47071
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agosync: deflake TestPool and TestPoolNew
Aliaksandr Valialkin [Thu, 25 May 2017 22:14:30 +0000 (01:14 +0300)]
sync: deflake TestPool and TestPoolNew

Prevent possible goroutine rescheduling to another P between
Put and Get calls by locking the goroutine to OS thread.

Inspired by the CL 42770.

Fixes #20198.

Change-Id: I18e24fcad1630658713e6b9d80d90d7941f604be
Reviewed-on: https://go-review.googlesource.com/44310
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agogo/ast: improve comment on FuncDecl.Body
Alan Donovan [Wed, 28 Jun 2017 21:40:05 +0000 (17:40 -0400)]
go/ast: improve comment on FuncDecl.Body

"Forward declaration" suggests that declarations must precede calls.

Change-Id: I1b3a26b58f52a39bc11d75696df928a6b66c7313
Reviewed-on: https://go-review.googlesource.com/47073
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agotesting: always ReadMemStats before first benchmark run
Meir Fischer [Mon, 26 Jun 2017 01:17:52 +0000 (21:17 -0400)]
testing: always ReadMemStats before first benchmark run

If the only way the user indicates they want alloc stats shown
is via ReportAllocs, we don't know that until benchFunc is run.
Therefore, StopTimer's ReadMemStats will return incorrect data
for single cycle runs since there's no counterpart ReadMemStats from
StartTimer that initializes alloc stats.

It appears that this bug was introduced by CL 46612,
"testing: only call ReadMemStats if necessary when benchmarking"

Fixes #20590

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

7 years agodoc: document the state of NetBSD in the Go 1.9 release notes
Brad Fitzpatrick [Wed, 28 Jun 2017 20:03:41 +0000 (20:03 +0000)]
doc: document the state of NetBSD in the Go 1.9 release notes

Updates #20836
Updates #19339
Updates #19652
Updates #20835
Updates #16511
Updates #10166
Updates #8574

Change-Id: If9a7f560489f1a8d628dafab227925bd8989326e
Reviewed-on: https://go-review.googlesource.com/47036
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/vet/all: fix print statement, add platform information
Robert Griesemer [Wed, 28 Jun 2017 17:50:31 +0000 (10:50 -0700)]
cmd/vet/all: fix print statement, add platform information

Change-Id: Ibbb89c01f3e812a0602961f959672fcb6523449b
Reviewed-on: https://go-review.googlesource.com/47031
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: mention gccgo status in 1.9 release notes
Ian Lance Taylor [Wed, 28 Jun 2017 19:14:49 +0000 (12:14 -0700)]
doc: mention gccgo status in 1.9 release notes

Updates #20587

Change-Id: If35868345d9697d4afa2e9c19b85e01d94c87908
Reviewed-on: https://go-review.googlesource.com/47034
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agosyscall: fix Exec on solaris
Shawn Walker-Salas [Wed, 28 Jun 2017 17:58:44 +0000 (10:58 -0700)]
syscall: fix Exec on solaris

The test added for issue #18146 exposed a long-existing bug in the
Solaris port; notably, that syscall.Exec uses RawSyscall -- which is not
actually functional for the Solaris port (intentionally) and only exists
as a placebo to satisfy build requirements.

Call syscall.execve instead for Solaris.

Fixes #20832

Change-Id: I327d863f4bbbbbb6e5ecf66b82152c4030825d09
Reviewed-on: https://go-review.googlesource.com/47032
Run-TryBot: Shawn Walker-Salas <shawn.walker@oracle.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoos: fix passing long paths to Chmod on Windows
Ibrahim AshShohail [Wed, 28 Jun 2017 17:09:15 +0000 (20:09 +0300)]
os: fix passing long paths to Chmod on Windows

os.Chmod returns an error when passed a long path (>=260) characters on
Windows. CL 32451 fixed most file functions in os. This change applies the
same fix to os.Chmod.

Fixes #20829

Change-Id: I3270db8317ce6e06e6d77070a32a5df6ab2491e0
Reviewed-on: https://go-review.googlesource.com/47010
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agotime: show how to get midnight on the current day
Kevin Burke [Tue, 27 Jun 2017 18:36:32 +0000 (11:36 -0700)]
time: show how to get midnight on the current day

A common task is trying to get today's date in the local time zone
with zero values for the hour, minute, second, and nanosecond fields.
I tried this recently and incorrectly used Truncate(24*time.Hour),
which truncates based on a UTC clock, and gave me 5pm Pacific time
instead of midnight Pacific.

I thought it would be helpful to show a "correct" way to do this.

Change-Id: I479e6b0cc56367068530981ca69882b34febf945
Reviewed-on: https://go-review.googlesource.com/46833
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agospec: minor grammar fix
Robert Griesemer [Wed, 28 Jun 2017 17:15:24 +0000 (10:15 -0700)]
spec: minor grammar fix

Fixes #20830.

Change-Id: I18178064c955ad8d259df05ee954075ae42909b0
Reviewed-on: https://go-review.googlesource.com/47030
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: fix slice-in-bound check on amd64p32
Cherry Zhang [Tue, 27 Jun 2017 20:34:06 +0000 (16:34 -0400)]
cmd/compile: fix slice-in-bound check on amd64p32

Should use CMPL instead of CMPQ.

Fixes #20811.

Change-Id: I610d487949c2c8a08b3743656149069d931a51bb
Reviewed-on: https://go-review.googlesource.com/46870
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agotime: fix example in monotonic time comment
Russ Cox [Wed, 28 Jun 2017 14:33:15 +0000 (10:33 -0400)]
time: fix example in monotonic time comment

t.Sub(u) would be -20 milliseconds.
The right computation is u.Sub(t), but rewrite to be even clearer.

Thanks to Karsten Weiss for catching this.

Change-Id: I6e274d69b0301840d57c5c65bf4114da0d33bf10
Reviewed-on: https://go-review.googlesource.com/46971
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: Proper default value for the $GOPATH.
Gabriel Nicolas Avellaneda [Tue, 27 Jun 2017 21:00:59 +0000 (18:00 -0300)]
doc: Proper default value for the $GOPATH.

It should be $HOME/go instead of $HOME/work

Change-Id: I22e0a89deff30f935c3e25a237d6c0c161103339
Reviewed-on: https://go-review.googlesource.com/46890
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: temporarily skip gdb python-related tests on solaris
Shawn Walker-Salas [Tue, 27 Jun 2017 23:49:09 +0000 (16:49 -0700)]
runtime: temporarily skip gdb python-related tests on solaris

Updates #20821

Change-Id: I77a5b9a3bbb931845ef52a479549d71069af9540
Reviewed-on: https://go-review.googlesource.com/46913
Run-TryBot: Shawn Walker-Salas <shawn.walker@oracle.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoarchive/tar: use best effort at writing USTAR header
Joe Tsai [Wed, 28 Jun 2017 00:30:39 +0000 (17:30 -0700)]
archive/tar: use best effort at writing USTAR header

Prior to this change, if the Writer needed to use the PAX format, it would
output a USTAR header with an empty name. This should be okay since the PAX
specification dictates that the PAX record for "path" should override the
semantic meaning of any of the old USTAR fields.

Unfortunately, the implementation of tar on OpenBSD 6.1 is too strict with
their handling of PAX files such that they check for the validity of this
bogus field even though the PAX header is present.

To allow Go's Writer output be parsible by OpenBSD's tar utility,
we write a best-effort (ASCII-only and truncated) version of the original
file name. Note that this still fails in some edge-cases (for example,
a Chinese filename containing all non-ASCII characters). OpenBSD should really
relax their checking, as you honestly can't always expect a sensible path
to be generated when USTAR cannot handle the original path.

Fixes #20707

Change-Id: Id7d77349023d2152d7291d582cd050b6681760e4
Reviewed-on: https://go-review.googlesource.com/46914
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/cgo: unwrap typedef-chains before type checking
Hiroshi Ioka [Sun, 4 Jun 2017 03:11:19 +0000 (12:11 +0900)]
cmd/cgo: unwrap typedef-chains before type checking

clang can emit some dwarf.VoidType which are wrapped by multiple
dwarf.TypedefType. We need to unwrap those before further processing.

Fixes #20129

Change-Id: I671ce6aef2dc7b55f1a02aec5f9789ac1b369643
Reviewed-on: https://go-review.googlesource.com/44772
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodoc: mention testing/quick RNG seeding change in Go 1.9 notes
Brad Fitzpatrick [Tue, 27 Jun 2017 22:17:21 +0000 (22:17 +0000)]
doc: mention testing/quick RNG seeding change in Go 1.9 notes

Also reword the testing/quick.Config field docs to conform to the
normal subject-first style. Without that style, godoc links
/pkg/testing/quick/#Config.Rand to the wrong line, since it doesn't
recognize the preceding comment as necessarily being attached.

Fixes #20809

Change-Id: I9aebbf763eed9b1ab1a153fa11850d88a65571c6
Reviewed-on: https://go-review.googlesource.com/46910
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agonet/http: whitelist another non-http goroutine in leak checker
Brad Fitzpatrick [Tue, 27 Jun 2017 20:21:39 +0000 (20:21 +0000)]
net/http: whitelist another non-http goroutine in leak checker

Fixes #20810

Change-Id: I09365b2db50c41aa3383dd730859b6f2cdb78e63
Reviewed-on: https://go-review.googlesource.com/46836
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile: suppress errors after "cannot assign to X"
Matthew Dempsky [Tue, 27 Jun 2017 19:58:32 +0000 (12:58 -0700)]
cmd/compile: suppress errors after "cannot assign to X"

If the LHS is unassignable, there's no point in trying to make sure
the RHS can be assigned to it or making sure they're realizable
types. This is consistent with go/types.

In particular, this prevents "1 = 2" from causing a panic when "1"
still ends up with the type "untyped int", which is not realizable.

Fixes #20813.

Change-Id: I4710bdaac2e375ef12ec29b888b8ac84fb640e56
Reviewed-on: https://go-review.googlesource.com/46835
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agobufio: make Reader.Peek invalidate Unreads
Martin Garton [Tue, 27 Jun 2017 17:02:23 +0000 (18:02 +0100)]
bufio: make Reader.Peek invalidate Unreads

Since Reader.Peek potentially reads from the underlying io.Reader,
discarding previous buffers, UnreadRune and UnreadByte cannot
necessarily work.  Change Peek to invalidate the unread buffers in all
cases (as allowed according to the documentation) and thus prevent
hiding bugs in the caller.

Fixes #18556

Change-Id: I8d836db7ce31c4aaecb4f61c24573b0332bbf30d
Reviewed-on: https://go-review.googlesource.com/46850
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/go: skip broken TestExecutableGOROOT/RelocatedExe
Brad Fitzpatrick [Tue, 27 Jun 2017 16:21:48 +0000 (16:21 +0000)]
cmd/go: skip broken TestExecutableGOROOT/RelocatedExe

Test just doesn't work.

Updates #20284

Change-Id: I31c3f771e68dcdc471767594a1467e19fbf5fe88
Reviewed-on: https://go-review.googlesource.com/46830
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@google.com>
7 years agocmd/go: update helpdoc.go about '-buildmode'
Dong-hee Na [Tue, 27 Jun 2017 14:04:44 +0000 (23:04 +0900)]
cmd/go: update helpdoc.go about '-buildmode'

After https://golang.org/cl/46421 is landed.
helpdoc.go should be updated that -buildmode=c-shared
requires only one main package.

Fixes #15082

Change-Id: I30a0ee956e6c4655c975ecdaa905887bd474952c
Reviewed-on: https://go-review.googlesource.com/46810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoencoding/binary: improve comment formatting consistency
Dmitri Shuralyov [Tue, 27 Jun 2017 05:18:30 +0000 (01:18 -0400)]
encoding/binary: improve comment formatting consistency

Use 2 slashes, space, then tab. This is more consistent, and removes
inadvertent leading space.

Change-Id: I383770ed4eb8ac17c78c7ae5675b553d4fb70b1e
Reviewed-on: https://go-review.googlesource.com/46726
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocrypto/x509: fix panic in TestEnvVars, improve style
Dmitri Shuralyov [Mon, 26 Jun 2017 18:32:55 +0000 (14:32 -0400)]
crypto/x509: fix panic in TestEnvVars, improve style

This panic happens when the test fails due to the returned number of
certificates (r.certs) being less than expected by test case (tc.cns).
When i == len(r.certs) in the for loop, r.certs[i] will cause an index
out of range panic.

Also improve readability, consistency and style of the code. Use the
more common "got x, want y" pattern. See https://golang.org/s/style#useful-test-failures
for reference (and grep codebase for most common occurrences). Add a
comment, and remove blank line separating two blocks that are both
related to verifying that len(r.certs) == len(tc.cns). This should
help with readability.

Remove space after colon in call to t.Fatal, since it adds spaces
between its arguments.

Fixes #20801.

Change-Id: I40476103f1b5a0fa74b05637c250926b571c92fd
Reviewed-on: https://go-review.googlesource.com/46715
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: get more info for TestCgoSignalDeadlock failures
Ian Lance Taylor [Mon, 26 Jun 2017 23:11:33 +0000 (16:11 -0700)]
runtime: get more info for TestCgoSignalDeadlock failures

Updates #18598

Change-Id: I13c60124714cf9d1537efa0a7dd1e6a0fed9ae5b
Reviewed-on: https://go-review.googlesource.com/46723
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agotest/fixedbugs: Close opening parenthesis in comment in issue20789.go
Gabríel Arthúr Pétursson [Mon, 26 Jun 2017 23:54:04 +0000 (23:54 +0000)]
test/fixedbugs: Close opening parenthesis in comment in issue20789.go

Updates #20789

Change-Id: Ic7a94394e283bc1b667cdad999ceee9513f35e37
Reviewed-on: https://go-review.googlesource.com/46770
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agonet/http/pprof: mention mutex profile in doc
Hana (Hyang-Ah) Kim [Fri, 28 Apr 2017 13:11:50 +0000 (09:11 -0400)]
net/http/pprof: mention mutex profile in doc

mutex profile requires explicit calls to
runtime.SetMutexProfileFraction to enable/disable
profiling (like block profile). It is worth
mentioning in the doc.

Change-Id: I2b8d654be9f5c6bc49fc802b7708c4c552fea9b2
Reviewed-on: https://go-review.googlesource.com/42070
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: add FMA mention to Go 1.9 release notes
Brad Fitzpatrick [Mon, 26 Jun 2017 19:43:56 +0000 (19:43 +0000)]
doc: add FMA mention to Go 1.9 release notes

Fixes #20795
Updates #17895
Updates #20587

Change-Id: Iea375f3a6ffe3f51e3ffdae1fb3fd628b6b3316c
Reviewed-on: https://go-review.googlesource.com/46717
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agonet/http: fix double-close of req.Body
Matt Harden [Tue, 21 Feb 2017 04:07:44 +0000 (20:07 -0800)]
net/http: fix double-close of req.Body

Add a test and fix for the request body being closed twice.

Fixes #19186

Change-Id: I1e35ad4aebfef68e6099c1dba7986883afdef4d7
Reviewed-on: https://go-review.googlesource.com/37298
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/go: add more info in t.Fatal message go1.9beta2
Brad Fitzpatrick [Mon, 26 Jun 2017 21:08:05 +0000 (21:08 +0000)]
cmd/go: add more info in t.Fatal message

Updates #20284

Change-Id: I4d55d6adec4e8efb54285ca27bb4fa39c76582c3
Reviewed-on: https://go-review.googlesource.com/46719
Reviewed-by: Chris Broadfoot <cbro@golang.org>
7 years agonet/http/httputil: always deep copy the Request.Header map in ReverseProxy
Brad Fitzpatrick [Mon, 26 Jun 2017 19:07:24 +0000 (19:07 +0000)]
net/http/httputil: always deep copy the Request.Header map in ReverseProxy

We used to do it sometimes as an optimization, but the optimization is
flawed: in all non-contrived cases we need to deep clone the map
anyway. So do it always, which both simplifies the code but also fixes
the X-Forward-For value leaking to the caller's Request, as well as
modifications from the optional Director func.

Fixes #18327

Change-Id: I0c86d10c557254bf99fdd988227dcb15f968770b
Reviewed-on: https://go-review.googlesource.com/46716
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: drain local runq when dedicated mark worker runs
Austin Clements [Fri, 23 Jun 2017 21:54:39 +0000 (17:54 -0400)]
runtime: drain local runq when dedicated mark worker runs

When the dedicated mark worker runs, the scheduler won't run on that P
again until GC runs out of mark work. As a result, any goroutines in
that P's local run queue are stranded until another P steals them. In
a normally operating system this may take a long time, and in a 100%
busy system, the scheduler never attempts to steal from another P.

Fix this by draining the local run queue into the global run queue if
the dedicated mark worker has run for long enough. We don't do this
immediately upon scheduling the dedicated mark worker in order to
avoid destroying locality if the mark worker runs for a short time.
Instead, the scheduler delays draining the run queue until the mark
worker gets its first preemption request (and otherwise ignores the
preemption request).

Fixes #20011.

Change-Id: I13067194b2f062b8bdef25cb75e4143b7fb6bb73
Reviewed-on: https://go-review.googlesource.com/46610
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
7 years agocmd/compile: use correct variable when setting up dummy CallStmt in error
Robert Griesemer [Mon, 26 Jun 2017 18:12:43 +0000 (11:12 -0700)]
cmd/compile: use correct variable when setting up dummy CallStmt in error

Fixes crash when printing a related error message later on.

Fixes #20789.

Change-Id: I6d2c35aafcaeda26a211fc6c8b7dfe4a095a3efe
Reviewed-on: https://go-review.googlesource.com/46713
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet/http/httptest: close client connections in separate goroutines
Yasha Bubnov [Mon, 28 Nov 2016 20:16:16 +0000 (23:16 +0300)]
net/http/httptest: close client connections in separate goroutines

The existing implementation sequentially closes connection in the loop
and until the previous client connections is not closed the next one
would not be processed. Instead, the algorithm modified to spawn the
function that closes single connection in a standalone goroutine, thus
making at least a try to close it.

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

7 years agoos/signal: check MustHaveExec in TestAtomicStop
Ian Lance Taylor [Sun, 25 Jun 2017 03:54:47 +0000 (20:54 -0700)]
os/signal: check MustHaveExec in TestAtomicStop

Change-Id: I284ecfab574b3058ba66b75f8f8d2ccdb90a8a0c
Reviewed-on: https://go-review.googlesource.com/46650
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoos/signal: avoid race between Stop and receiving on channel
Ian Lance Taylor [Fri, 16 Jun 2017 16:29:44 +0000 (09:29 -0700)]
os/signal: avoid race between Stop and receiving on channel

When Stop is called on a channel, wait until all signals have been
delivered to the channel before returning.

Use atomic operations in sigqueue to communicate more reliably between
the os/signal goroutine and the signal handler.

Fixes #14571

Change-Id: I6c5a9eea1cff85e37a34dffe96f4bb2699e12c6e
Reviewed-on: https://go-review.googlesource.com/46003
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agocmd/internal/obj/arm: fix wrong encoding of MULBB
Ben Shi [Fri, 23 Jun 2017 08:05:37 +0000 (08:05 +0000)]
cmd/internal/obj/arm: fix wrong encoding of MULBB

"MULBB R1, R2, R3" is encoded to 0xe163f182, which should be
0xe1630182.

This patch fix it.

fix #20764

Change-Id: I9d3c3ffa40ecde86638e5e083eacc67578caebf4
Reviewed-on: https://go-review.googlesource.com/46491
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoos: align siginfo argument to waitid
Ian Lance Taylor [Fri, 23 Jun 2017 14:08:56 +0000 (07:08 -0700)]
os: align siginfo argument to waitid

I have no test case for this, but there is one report on the mailing list
(https://groups.google.com/d/msg/golang-dev/sDg-t1_DPw0/-AJmLxgPBQAJ)
in which waitid running on MIPS returns EFAULT.

Change-Id: I79bde63c7427eefc1f2925d78d97cc9cf2fffde3
Reviewed-on: https://go-review.googlesource.com/46511
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>