]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
6 years agotime: vendor tzdata-2017b and update test
Alberto Donizetti [Mon, 5 Jun 2017 08:20:00 +0000 (10:20 +0200)]
time: vendor tzdata-2017b and update test

This change updates the vendored tzdata database to version 2017b
(released 2017-03-20).

The TestFirstZone test (which always uses the vendored database) is
updated to make it work with the new timezones database. (The Tokelau
abbreviation was changed from 'TKT' to the numeric abbreviation in
tzdata-2017a)

Fixes #19376

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

6 years agocmd/compile: don't implicitly dereference pointer to arrays for real/imag
Robert Griesemer [Wed, 7 Jun 2017 20:10:05 +0000 (13:10 -0700)]
cmd/compile: don't implicitly dereference pointer to arrays for real/imag

Fixes #20602.

Change-Id: Iac1589484dec626c018314e0cea7efce091fd87d
Reviewed-on: https://go-review.googlesource.com/45075
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agodatabase/sql: Use Tx.ctx in Tx non-context methods
Bulat Gaifullin [Tue, 6 Jun 2017 17:20:06 +0000 (20:20 +0300)]
database/sql: Use Tx.ctx in Tx non-context methods

The Tx methods Query and Exec uses context.Background()
even Tx was created by context.
This patch enables using Tx.ctx in all Tx methods
which do not has context arg.
Backward compatibility:
- If Tx has created without context, nothing changes.
- If Tx has created with context and non-context method is called:
  - If context is expired, the execution fails,
    but it can fail on Commit or Rollback as well,
    so in terms of whole transaction - nothing changes.
  - If context is not expired, nothing changes too.

Fixes #20098
Change-Id: I9570a2deaace5875bb4c5dcf7b3a084a6bcd0d00
Reviewed-on: https://go-review.googlesource.com/44956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agofmt: remove unnecessary trailing commas in doc.go
Rob Phoenix [Wed, 7 Jun 2017 19:19:15 +0000 (20:19 +0100)]
fmt: remove unnecessary trailing commas in doc.go

Change-Id: Ib5efe172c55ff624b6771c2f02c466e35ba6cc50
Reviewed-on: https://go-review.googlesource.com/45090
Reviewed-by: Rob Pike <r@golang.org>
6 years agodoc: list testing package changes in 1.9 release notes
Alberto Donizetti [Wed, 7 Jun 2017 08:54:52 +0000 (10:54 +0200)]
doc: list testing package changes in 1.9 release notes

Updates #20587

Change-Id: I39f7c43a13c887d9d563c108d3575db7f2dffe0e
Reviewed-on: https://go-review.googlesource.com/45050
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: don't crash in Request.WithContext if Request.URL is nil
Brad Fitzpatrick [Wed, 7 Jun 2017 18:13:38 +0000 (18:13 +0000)]
net/http: don't crash in Request.WithContext if Request.URL is nil

Fixes #20601

Change-Id: I296d50dc5210a735a2a65d64bfef05d14c93057b
Reviewed-on: https://go-review.googlesource.com/45073
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/internal/obj/arm: don't split instructions on NaCl
Cherry Zhang [Wed, 7 Jun 2017 14:00:58 +0000 (10:00 -0400)]
cmd/internal/obj/arm: don't split instructions on NaCl

We insert guard instructions after each "dangerous" instruction
to make NaCl's validator happy. This happens before asmout. If
in asmout an instruction is split to two dangerous instructions,
but only one guard instruction is inserted, the validation fails.
Therefore don't split instructions on NaCl.

Fixes #20595.

Change-Id: Ie34f209bc7d907d6d16ecef6721f88420981ac01
Reviewed-on: https://go-review.googlesource.com/45021
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: remove math/bits from 'minor changes' section
Alberto Donizetti [Wed, 7 Jun 2017 09:15:55 +0000 (11:15 +0200)]
doc: remove math/bits from 'minor changes' section

The new math/bits package has a section for itself, and should not be
mentioned in the 'Minor changes to the library' section of the release
notes.

Updates #20587

Change-Id: I13ecd35f5cee4324e50b2d31800e399c00159126
Reviewed-on: https://go-review.googlesource.com/45051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: add type aliases to go1.9.html
Brad Fitzpatrick [Tue, 6 Jun 2017 22:03:45 +0000 (22:03 +0000)]
doc: add type aliases to go1.9.html

Updates #20587

Change-Id: I5df603505ae1d4b65687bec1e973a4ab318b34f1
Reviewed-on: https://go-review.googlesource.com/45014
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agoruntime: mark extra M's G as dead when not in use
Austin Clements [Tue, 6 Jun 2017 22:37:59 +0000 (18:37 -0400)]
runtime: mark extra M's G as dead when not in use

Currently the extra Ms created for cgo callbacks have a corresponding
G that's kept in syscall state with only a call to goexit on its
stack. This leads to confusing output from runtime.NumGoroutines and
in tracebacks:

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
.../src/runtime/asm_amd64.s:2197 +0x1

Fix this by putting this goroutine into state _Gdead when it's not in
use instead of _Gsyscall. To keep the goroutine counts correct, we
also add one to sched.ngsys while the goroutine is in _Gdead. The
effect of this is as if the goroutine simply doesn't exist when it's
not in use.

Fixes #16631.
Fixes #16714.

Change-Id: Ieae08a2febd4b3d00bef5c23fd6ca88fb2bb0087
Reviewed-on: https://go-review.googlesource.com/45030
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: deflake TestPanicRace
Ian Lance Taylor [Wed, 7 Jun 2017 00:31:57 +0000 (17:31 -0700)]
runtime: deflake TestPanicRace

The test is inherently racy, and for me fails about 0.05% of the time.
So only fail the test if it fails ten times in a row.

Fixes #20594

Change-Id: I3b3f7598f2196f7406f1a3937f38f21ff0c0e4b5
Reviewed-on: https://go-review.googlesource.com/45020
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agobuiltin: use type aliases for rune and byte
Brad Fitzpatrick [Tue, 6 Jun 2017 22:17:50 +0000 (22:17 +0000)]
builtin: use type aliases for rune and byte

As motivated by https://golang.org/design/18130-type-alias which says:

https://github.com/golang/proposal/blob/master/design/18130-type-alias.md#relationship-to-byte-and-rune

> The language specification already defines byte as an alias for
> uint8 and similarly rune as an alias for int32, using the word alias
> as an informal term. It is a goal that the new type declaration
> semantics not introduce a different meaning for alias. That is, it
> should be possible to describe the existing meanings of byte and
> uint8 by saying that they behave as if predefined by:
>
>     type byte = uint8
>     type rune = int32

So, do that. Seems to work.

Updates #18130

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

6 years agocmd/compile: check that phis are always first after scheduling
Keith Randall [Tue, 6 Jun 2017 22:25:29 +0000 (15:25 -0700)]
cmd/compile: check that phis are always first after scheduling

Update #20178

Change-Id: I603f77268ed38afdd84228c775efe006f08f14a7
Reviewed-on: https://go-review.googlesource.com/45018
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agoruntime: intercept munmap as we do mmap
Ian Lance Taylor [Tue, 6 Jun 2017 22:08:59 +0000 (15:08 -0700)]
runtime: intercept munmap as we do mmap

For cgo programs on linux-amd64 we call the C function mmap.
This supports programs such as the C memory sanitizer that need to
intercept all calls to mmap. It turns out that there are programs that
intercept both mmap and munmap, or that at least expect that if they
intercept mmap, they also intercept munmap. So, if we permit mmap
to be intercepted, also permit munmap to be intercepted.

No test, as it requires two odd things: a C program that intercepts
mmap and munmap, and a Go program that calls munmap.

Change-Id: Iec33f47d59f70dbb7463fd12d30728c24cd4face
Reviewed-on: https://go-review.googlesource.com/45016
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agodoc: delete go1.8.txt
Brad Fitzpatrick [Tue, 6 Jun 2017 22:05:34 +0000 (22:05 +0000)]
doc: delete go1.8.txt

Fixes #20591

Change-Id: I2a4674a3430c5a4d3c569f3ea654c6ff4d9bf7ee
Reviewed-on: https://go-review.googlesource.com/45015
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomath: clarify comment about bit-identical results across architectures
Ian Lance Taylor [Tue, 6 Jun 2017 21:21:16 +0000 (14:21 -0700)]
math: clarify comment about bit-identical results across architectures

Updates #18354.

Change-Id: I76bc4a73d8dc99eeda14b395e451d75a65184191
Reviewed-on: https://go-review.googlesource.com/45013
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/compile: reject unknown //go: comments in std library
Keith Randall [Tue, 6 Jun 2017 20:23:59 +0000 (13:23 -0700)]
cmd/compile: reject unknown //go: comments in std library

Fixes #18331

Change-Id: Ie5c6685be3002533b84604ff1f13f2f0850f29e2
Reviewed-on: https://go-review.googlesource.com/45010
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agodoc: start of go1.9.html release notes
Brad Fitzpatrick [Tue, 6 Jun 2017 00:04:12 +0000 (00:04 +0000)]
doc: start of go1.9.html release notes

Many TODOs remain.

Updates #20587

Change-Id: If49854ae4d36346d9e072a386f413cc85c66b62a
Reviewed-on: https://go-review.googlesource.com/45012
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomath: add doc note about floating point operation
gulyasm [Sat, 7 Jan 2017 22:30:47 +0000 (23:30 +0100)]
math: add doc note about floating point operation

Go doesn't guarantee that the result of floating point operations will
be the same on different architectures. It was not stated in the
documentation, that can lead to confusion.

Fixes #18354

Change-Id: Idb1b4c256fb9a7158a74256136eca3b8ce44476f
Reviewed-on: https://go-review.googlesource.com/34938
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: use file content, not suffix, to distinguish .a and .o files
Russ Cox [Thu, 1 Jun 2017 18:26:55 +0000 (14:26 -0400)]
cmd/compile: use file content, not suffix, to distinguish .a and .o files

This allows reading from package storage systems that may not
preserve the .a suffix (used with -importcfg).

Fixes #20579 (combined with CLs earlier in stack).

Change-Id: If2fc6a3d01bd0170a757e1f2ba9a22a4d9be7dbf
Reviewed-on: https://go-review.googlesource.com/44853
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/link: add -importcfg to specify import resolution
Russ Cox [Wed, 31 May 2017 15:35:29 +0000 (11:35 -0400)]
cmd/link: add -importcfg to specify import resolution

Adds the ability to specify the file location of each imported package,
like in the -importcfg added to cmd/compile in a related CL.
In effect, -importcfg is a generalization of and supersedes -installsuffix
and -L. Of course, those flags will continue to be supported, for
compatibility with other tools.

Having this flag in Go 1.9 will let us try some experiments involving
package management without needing guinea pigs to build a custom
Go toolchain.

This flag also helps with #14271 at some later point.

For #20579.

Change-Id: Ie4c171bcd3aa2faa446ac340e36516f2f9853882
Reviewed-on: https://go-review.googlesource.com/44851
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: add -importcfg to specify import resolution
Russ Cox [Wed, 31 May 2017 15:19:54 +0000 (11:19 -0400)]
cmd/compile: add -importcfg to specify import resolution

Allows reading -importmap options from a file instead of putting
them all on the command line, and adds the ability to specify the
file location of specific packages. In effect, -importcfg is a generalization
of and supersedes -importmap, -importsuffix, and -I.
Of course, those flags will continue to be supported,
for compatibility with other tools.

Having this flag in Go 1.9 will let us try some experiments involving
package management without needing guinea pigs to build a
custom Go toolchain.

This flag also helps with #14271 at some later point.

For #20579.

Change-Id: If005dbc2b01d8fd16cbfd3687dfbe82499f4bc56
Reviewed-on: https://go-review.googlesource.com/44850
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agotime: strip monotonic clock reading in t.UTC, t.Local, t.In
Russ Cox [Mon, 5 Jun 2017 15:00:34 +0000 (11:00 -0400)]
time: strip monotonic clock reading in t.UTC, t.Local, t.In

Fixes #18991.

Change-Id: I46ded007b0c6a6e1173a55f3938007ab3a928dd9
Reviewed-on: https://go-review.googlesource.com/44858
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
6 years agostrings: document Split{,N,After,AfterN} edge cases
Alberto Donizetti [Tue, 6 Jun 2017 09:25:17 +0000 (11:25 +0200)]
strings: document Split{,N,After,AfterN} edge cases

Apparently people get confused by the fact that

  Split("", ",")

returns []{""} instead of []{}.

This is actually just a consequence of the fact that if the separator
sep (2nd argument) is not found the string s (1st argument), then the
Split* functions return a length 1 slice with the string s in it.

Document the general case: if sep is not in s, what you get is a len 1
slice with s in it; unless both s and sep are "", in that case you get
an empty slice of length 0.

Fixes #19726

Change-Id: I64c8220b91acd1e5aa1cc1829199e0cd8c47c404
Reviewed-on: https://go-review.googlesource.com/44950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
6 years agoruntime: delay exiting while panic is running deferred functions
Ian Lance Taylor [Wed, 19 Apr 2017 14:32:34 +0000 (07:32 -0700)]
runtime: delay exiting while panic is running deferred functions

Try to avoid a race between the main goroutine exiting and a panic
occurring. Don't try too hard, to avoid hanging.

Updates #3934
Fixes #20018

Change-Id: I57a02b6d795d2a61f1cadd137ce097145280ece7
Reviewed-on: https://go-review.googlesource.com/41052
Reviewed-by: Austin Clements <austin@google.com>
6 years agogo/types: don't panic in complex division
Alberto Donizetti [Sat, 13 May 2017 17:11:44 +0000 (19:11 +0200)]
go/types: don't panic in complex division

Make sure that in complex division we reject divisors that would
underflow to zero when using the textbook complex-division method we
currently use.

This change does for go/types what golang.org/cl/42650 did for gc.

Fixes #20227

Change-Id: Iaa784ac5e60141f51c501eb0e3ce0e9c1c2993d0
Reviewed-on: https://go-review.googlesource.com/44590
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agoruntime: save and restore CR for ppc64le
Ian Lance Taylor [Fri, 2 Jun 2017 22:56:35 +0000 (15:56 -0700)]
runtime: save and restore CR for ppc64le

C code expects CR2, CR3, and CR4 to be preserved across function calls.
Preserve the entire CR register across function calls in
_rt0_ppc64le_linux_lib and crosscall2. The standard ppc64le call frame
uses 8(R1) as the place to save CR; emulate that.

It's hard to write a reliable test for this as it requires writing C
code that sets CR2, CR3, or CR4 across a call to a Go function.

Change-Id: If39e771a5b574602b848227312e83598fe74eab7
Reviewed-on: https://go-review.googlesource.com/44733
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
6 years agocmd/internal/obj/ppc64: fix MOVFL REG, CONST
Ian Lance Taylor [Fri, 2 Jun 2017 22:51:18 +0000 (15:51 -0700)]
cmd/internal/obj/ppc64: fix MOVFL REG, CONST

The MOVFL instruction (which external PPC64 docs call mtcrf) can take
either a CR register or a constant. It doesn't make sense to specify
both, as the CR register implies the constant value. Specifying either
a register or a constant is enforced by the implementation in the
asmout method (case 69).

However, the optab was providing a form that specified both a constant
and a CR register, and was not providing a form that specified only a
constant. This CL fixes the optab table to provide a form that takes
only a constant.

No test because I don't know where to write it. The next CL in this
series will use the new instruction format.

Change-Id: I8bb5d3ed60f483b54c341ce613931e126f7d7be6
Reviewed-on: https://go-review.googlesource.com/44732
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
6 years agocmd/link: fix accidentally-quadratic library loading
Russ Cox [Wed, 31 May 2017 15:33:04 +0000 (11:33 -0400)]
cmd/link: fix accidentally-quadratic library loading

Programs built from N libraries required O(N²) time to do the
deduplication checks, even if there were never any duplicates.
In most programs N is small enough not to worry, but this may
affect large programs.

Noticed by inspection, not any specific bug report.

Fixes #20578.

Change-Id: Ic4108f1058be39da990a79b1e0b8ce95fde44cef
Reviewed-on: https://go-review.googlesource.com/44852
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: fix ugly "BUG" in go help message output
Russ Cox [Wed, 31 May 2017 15:47:33 +0000 (11:47 -0400)]
cmd/go: fix ugly "BUG" in go help message output

Change-Id: I4c579d0d02f6c9cbef1dc2bc2c93cff614538dea
Reviewed-on: https://go-review.googlesource.com/44854
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: include Fortran files in build ID computation
Russ Cox [Mon, 5 Jun 2017 14:23:42 +0000 (10:23 -0400)]
cmd/go: include Fortran files in build ID computation

Otherwise removing a .f file won't trigger a rebuild.
Noticed by inspection while working on the code.
I don't have a good way to write a test for this,
and I expect the code to change significantly in the next
release, but might as well get it right for Go 1.9.

Change-Id: I3f6f9f71b3a7d4f0be49a47419dac59899959e7c
Reviewed-on: https://go-review.googlesource.com/44855
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodatabase/sql: ensure Rows is closed when Tx closes
Daniel Theophanes [Mon, 5 Jun 2017 16:04:05 +0000 (09:04 -0700)]
database/sql: ensure Rows is closed when Tx closes

Close any Rows queried within a Tx when the Tx is closed. This prevents
the Tx from blocking on rollback if a Rows query has not been closed yet.

Fixes #20575

Change-Id: I4efe9c4150e951d8a0f1c40d9d5e325964fdd608
Reviewed-on: https://go-review.googlesource.com/44812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: make Transport retry GetBody requests if nothing written
David Glasser [Fri, 28 Apr 2017 23:40:39 +0000 (16:40 -0700)]
net/http: make Transport retry GetBody requests if nothing written

This is another attempt at the change attempted in
https://golang.org/cl/27117 and rolled back in https://golang.org/cl/34134

The difference between this and the previous attempt is that this version only
retries if the new field GetBody is set on the Request.

Additionally, this allows retries of requests with idempotent methods even if
they have bodies, as long as GetBody is defined.

This also fixes an existing bug where readLoop could make a redundant call to
setReqCanceler for DELETE/POST/PUT/etc requests with no body with zero bytes
written.

This clarifies the existing TestRetryIdempotentRequestsOnError test (and changes
it into a test with 4 subtests).  When that test was written, it was in fact
testing "retry idempotent requests" logic, but the logic had changed since then,
and it was actually testing "retry requests with no body when no bytes have been
written". (You can confirm this by changing the existing test from a GET to a
DELETE; it passes without the changes in this CL.) We now test for the no-Body
and GetBody cases for both idempotent and nothing-written-non-idempotent
requests.

Fixes #18241
Fixes #17844

Change-Id: I69a48691796f6dc08c31f7aa7887b7dfd67e278a
Reviewed-on: https://go-review.googlesource.com/42142
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/internal/obj/arm: fix constant decomposition
Ben Shi [Sat, 27 May 2017 10:00:55 +0000 (10:00 +0000)]
cmd/internal/obj/arm:  fix constant decomposition

There are two issues in constant decomposition.

1. A typo in "func immrot2s" blocks "case 107" of []optab be triggered.

2. Though "ADD $0xffff, R0, R0" is decomposed to "ADD $0xff00, R0, R0" and
   "ADD $0x00ff, R0, R0" as expected, "ADD $0xffff, R0" still uses the
   constant pool, which should be the same as "ADD $0xffff, R0, R0".

This patch fixes them and adds more instruction encoding tests.

fix #20516

Change-Id: Icd7bdfa1946b29db15580dcb429111266f1384c6
Reviewed-on: https://go-review.googlesource.com/44335
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agoencoding/json: clarify unmarshaling behaviour on bad fields
Alberto Donizetti [Sat, 3 Jun 2017 19:36:51 +0000 (21:36 +0200)]
encoding/json: clarify unmarshaling behaviour on bad fields

Fixes #19526

Change-Id: Ifaaf454e0e89fdf4309118c2e2e6ac0d0a43c39d
Reviewed-on: https://go-review.googlesource.com/44711
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: avoid division in gc
Ilya Tocar [Mon, 1 May 2017 19:27:36 +0000 (14:27 -0500)]
runtime: avoid division in gc

Replace int division with (cheaper) byte division in heapBitsSetType.
Provides noticeable speed-up:

GrowSlicePtr-6   181ns ± 3%   169ns ± 3%  -6.85%  (p=0.000 n=10+10)

Change-Id: I4064bb72e8e692023783b8f58d19491844c39382
Reviewed-on: https://go-review.googlesource.com/42290
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime: expand acceptable PingPongHog factor from 2 to 5
Austin Clements [Mon, 5 Jun 2017 14:59:57 +0000 (10:59 -0400)]
runtime: expand acceptable PingPongHog factor from 2 to 5

Since TestPingPongHog tests the scheduler, it's ultimately
probabilistic. Currently, it requires the result be at most of factor
of 2 off of the ideal. It turns out this isn't quite enough in
practice, with factors on 1000 iterations on linux/amd64 ranging from
0.48 to 2.5. If the test were failing, we would expect a factor closer
to 1000X, so it's pretty safe to expand the accepted factor from 2 to
5.

Fixes #20494.

Change-Id: If8f2e96194fe66f1fb981a965d1167fe74ff38d7
Reviewed-on: https://go-review.googlesource.com/44859
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: reject -buildmode=plugin if package is not main
Alexander Menzhinsky [Thu, 13 Apr 2017 21:15:26 +0000 (16:15 -0500)]
cmd/go: reject -buildmode=plugin if package is not main

Fixes #17625

Change-Id: I09319b888b547c631a50dbfab9255cc08e8a2426
Reviewed-on: https://go-review.googlesource.com/40691
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 agocmd/compile: add valState to ssa sizeof tests
Josh Bleecher Snyder [Sat, 3 Jun 2017 15:25:15 +0000 (08:25 -0700)]
cmd/compile: add valState to ssa sizeof tests

I learned from CL 41770 that valState’s size
matters to compiler performance.
Encode that knowledge in a test.

Change-Id: I7c0fde6a4cf460017619dbcce1c1ddaa7af10239
Reviewed-on: https://go-review.googlesource.com/44737
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/cgo: show pos info in undefined name errors
Alberto Donizetti [Thu, 5 Jan 2017 16:27:34 +0000 (17:27 +0100)]
cmd/cgo: show pos info in undefined name errors

For test.go:

package main

import (
   "C"
   "fmt"
)

func main() {
 fmt.Println("Hello, world!")
 C.no_such_f()
}

Before:

could not determine kind of name for C.no_such_f

After:

./test.go:10:2: could not determine kind of name for C.no_such_f

Fixes #18452

Change-Id: I49c136b7fa60fab25d2d5b905d440fe4d106e565
Reviewed-on: https://go-review.googlesource.com/34783
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoC: add Filippo Valsorda's cloudflare.com email (Cloudflare CLA)
Filippo Valsorda [Fri, 2 Jun 2017 20:01:30 +0000 (13:01 -0700)]
C: add Filippo Valsorda's cloudflare.com email (Cloudflare CLA)

Change-Id: I98d265bfa4f5944360d0258d2cb6bbc78010c708
Reviewed-on: https://go-review.googlesource.com/44731
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agogo/printer: don't emit unnecessary //line directives before empty lines
Robert Griesemer [Fri, 2 Jun 2017 00:51:02 +0000 (17:51 -0700)]
go/printer: don't emit unnecessary //line directives before empty lines

1) Split atLineBegin into its two components: writing of // line directives
and writing of indentation (no functionality changes).

2) Don't call writeLineDirective at the beginning of a line if we're
writing white space - it's not necessary. This is the bug fix.

3) Move testing of the SourcePos mode out of writeLineDirective and
into the (single) caller. Clearer and more efficient.

(Instead of these 3 changes one could also have simply called the
original atLineBegin with position p.out rather than p.pos. This
would have caused atLineBegin to not write a line directive.
Factoring the code seemed like a cleaner and more direct approach.)

Fixes #5945.

Change-Id: Ia8710806b6d3d4e5044116b142c036a4ab5a1764
Reviewed-on: https://go-review.googlesource.com/44651
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agobytes: note that NewBuffer take ownership of its argument
Alberto Donizetti [Fri, 2 Jun 2017 15:07:33 +0000 (17:07 +0200)]
bytes: note that NewBuffer take ownership of its argument

Fixes #19383

Change-Id: Ic84517053ced7794006f6fc65e6f249e97d6cf35
Reviewed-on: https://go-review.googlesource.com/44691
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/cover: take default value of total only once.
Dhananjay Nakrani [Sun, 28 May 2017 16:09:07 +0000 (09:09 -0700)]
cmd/cover: take default value of total only once.

Defaulting total to 1 for each function, adds up to the
counting error. testing/cover.go already does this once.

Fixes #20515

Change-Id: I0e3f524c2ccb628eb9a8f0a1f81c22365c24cf9a
Reviewed-on: https://go-review.googlesource.com/44337
Run-TryBot: Dhananjay Nakrani <dhananjayn@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/compile: retain source positions of arguments to inlined calls
David Lazar [Sat, 27 May 2017 21:43:37 +0000 (17:43 -0400)]
cmd/compile: retain source positions of arguments to inlined calls

Arguments to inlined calls are hidden from setPos as follows:

    args := as.Rlist
    as.Rlist.Set(nil)
    // setPos...
    as.Rlist.Set(args.Slice())

Previously, this code had no effect since the value of as was
overwritten by the assignment in the retvars loop.

Fixes #19799.

Change-Id: Iaf97259f82fdba8b236136337cc42b2774c7fef5
Reviewed-on: https://go-review.googlesource.com/44351
Run-TryBot: David Lazar <lazard@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
7 years agocmd/go: remove TestCoverageUsesActualSettingToOverrideEvenForRace
Ian Lance Taylor [Fri, 2 Jun 2017 00:49:55 +0000 (17:49 -0700)]
cmd/go: remove TestCoverageUsesActualSettingToOverrideEvenForRace

The test no longer passes as of https://golang.org/cl/43777, which
intentionally disables the feature that this test was checking for.
Nobody noticed since the test is not run in -short mode.

Updates #20435.

Change-Id: I64f37fd94c01f22ead88470b6d9bfe8a151ddb1c
Reviewed-on: https://go-review.googlesource.com/44650
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
7 years agocompress/gzip: clarify behavior of Writer.Close
Joe Tsai [Fri, 2 Jun 2017 00:31:24 +0000 (17:31 -0700)]
compress/gzip: clarify behavior of Writer.Close

Fixes #20551

Change-Id: Ia47cae14a26fe5f278ad7209218d083cc50a3ff8
Reviewed-on: https://go-review.googlesource.com/44572
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agosort: clarify comment about not-a-number values
Ian Lance Taylor [Wed, 31 May 2017 21:06:25 +0000 (14:06 -0700)]
sort: clarify comment about not-a-number values

Updates #20540

Change-Id: I864008fadd77b0aeb10fe7e7f1ec696516a5add5
Reviewed-on: https://go-review.googlesource.com/44492
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/compile/internal/gc: speed-up small array comparison
Ilya Tocar [Fri, 14 Apr 2017 18:53:40 +0000 (13:53 -0500)]
cmd/compile/internal/gc: speed-up small array comparison

Currently we inline array comparisons for arrays with at most 4 elements.
Compare arrays with small size, but more than 4 elements (e. g. [16]byte)
with larger compares. This provides very slightly smaller binaries,
and results in faster code.

ArrayEqual-6  7.41ns ± 0%  3.17ns ± 0%  -57.15%  (p=0.000 n=10+10)

For go tool:
global text (code) = -559 bytes (-0.014566%)

This also helps mapaccess1_faststr, and maps in general:

MapDelete/Str/1-6               195ns ± 1%     186ns ± 2%   -4.47%  (p=0.000 n=10+10)
MapDelete/Str/2-6               211ns ± 1%     177ns ± 1%  -16.01%  (p=0.000 n=10+10)
MapDelete/Str/4-6               225ns ± 1%     183ns ± 1%  -18.49%  (p=0.000 n=8+10)
MapStringKeysEight_16-6        31.3ns ± 0%    28.6ns ± 0%   -8.63%  (p=0.000 n=6+9)
MapStringKeysEight_32-6        29.2ns ± 0%    27.6ns ± 0%   -5.45%  (p=0.000 n=10+10)
MapStringKeysEight_64-6        29.1ns ± 1%    27.5ns ± 0%   -5.46%  (p=0.000 n=10+10)
MapStringKeysEight_1M-6        29.1ns ± 1%    27.6ns ± 0%   -5.49%  (p=0.000 n=10+10)

Change-Id: I9ec98e41b233031e0e96c4e13d86a324f628ed4a
Reviewed-on: https://go-review.googlesource.com/40771
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agodoc: update bootstrap archive URL
Chris Broadfoot [Wed, 31 May 2017 18:20:16 +0000 (11:20 -0700)]
doc: update bootstrap archive URL

This includes the patch for systems that build PIE executables by
defaul

Updates #20276.

Change-Id: Iecf8dfcf11bc18d397b8075559c37e3610f825cb
Reviewed-on: https://go-review.googlesource.com/44470
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agosort: document NaN behavior for Float64Slice and friends
Ian Lance Taylor [Wed, 31 May 2017 20:43:52 +0000 (13:43 -0700)]
sort: document NaN behavior for Float64Slice and friends

Fixes #20540

Change-Id: I440eee02d37b6921613f9ae77875d91eeec48b1e
Reviewed-on: https://go-review.googlesource.com/44490
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/compile: fix subword store/load elision for MIPS
Cherry Zhang [Wed, 31 May 2017 12:30:25 +0000 (08:30 -0400)]
cmd/compile: fix subword store/load elision for MIPS

Apply the fix in CL 44355 to MIPS.

ARM64 has these rules but commented out for performance reason.
Fix the commented rules, in case they are enabled in the future.

Enhance the test so it triggers the failure on ARM and MIPS without
the fix.

Updates #20530.

Change-Id: I82d77448e3939a545fe519d0a29a164f8fa5417c
Reviewed-on: https://go-review.googlesource.com/44430
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agomath/big: fix Add, Sub when receiver aliases 2nd operand
Alberto Donizetti [Thu, 25 May 2017 09:50:40 +0000 (11:50 +0200)]
math/big: fix Add, Sub when receiver aliases 2nd operand

Fixes #20490

Change-Id: I9cfa604f9ff94df779cb9b4cbbd706258fc473ac
Reviewed-on: https://go-review.googlesource.com/44150
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agosyscall: allow processes steal a controlling terminal on Linux
Julio Montes [Mon, 22 May 2017 15:33:31 +0000 (10:33 -0500)]
syscall: allow processes steal a controlling terminal on Linux

The current implementation of forkAndExecInChild for Linux does not allow
spawned processes steal the controlling terminal from a different session
group. This patch passes 1 as the argument to TIOCSCTTY in order to allow
spawned processes steal controlling terminals.

Fixes #20454

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

7 years agoruntime: work around NetBSD bug in thread creation
Benny Siegert [Fri, 21 Apr 2017 08:48:57 +0000 (08:48 +0000)]
runtime: work around NetBSD bug in thread creation

Block signals explicitly during lwp_create since blocking via
the context does not work.

This was originally added in pkgsrc as
http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/go/patches/patch-src_runtime_os__netbsd.go?rev=1.1

Fixes #19295.

Change-Id: I431e70c047cff446e9cfc20d356f45df98c63487
Reviewed-on: https://go-review.googlesource.com/41350
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 agocmd/vet: add a test for embedded stringer
Aliaksandr Valialkin [Mon, 29 May 2017 16:50:24 +0000 (19:50 +0300)]
cmd/vet: add a test for embedded stringer

This should help narrowing down the possible cause of #20514.

Updates #20514.

Change-Id: Ie997400c9749aace7783bd585b23dbb4cefc181d
Reviewed-on: https://go-review.googlesource.com/44375
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile: don't generate liveness maps when the stack is too large
Josh Bleecher Snyder [Tue, 30 May 2017 22:05:42 +0000 (15:05 -0700)]
cmd/compile: don't generate liveness maps when the stack is too large

Fixes #20529

Change-Id: I3cb0c037b1737fbc3fa3b1b61ed8a42cfaf8e10d
Reviewed-on: https://go-review.googlesource.com/44344
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile: fix subword store/load elision for amd64, x86, arm
David Chase [Tue, 30 May 2017 20:06:59 +0000 (16:06 -0400)]
cmd/compile: fix subword store/load elision for amd64, x86, arm

Replacing byteload-of-bytestore-of-x with x is incorrect
when x contains a larger-than-byte value (and so on for
16 and 32-bit load/store pairs).  Replace "x" with the
appropriate zero/sign extension of x, which if unnecessary
will be repaired by other rules.

Made logic for arm match x86 and amd64; yields minor extra
optimization, plus I am (much) more confident it's correct,
despite inability to reproduce bug on arm.

Ppc64 lacks this optimization, hence lacks this problem.

See related https://golang.org/cl/37154/
Fixes #20530.

Change-Id: I6af9cac2ad43bee99cafdcb04725ce7e55a43323
Reviewed-on: https://go-review.googlesource.com/44355
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agotesting: clarify that subtests are run as goroutines
Marcel van Lohuizen [Tue, 30 May 2017 10:11:04 +0000 (12:11 +0200)]
testing: clarify that subtests are run as goroutines

Fixes #20394

Change-Id: Iabb2a53fd1ddb783e7fb5b60ced8482c2e2569c4
Reviewed-on: https://go-review.googlesource.com/44377
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/link: fix left-over reference to reflect.c
Dmitry Savintsev [Mon, 29 May 2017 20:14:32 +0000 (22:14 +0200)]
cmd/link: fix left-over reference to reflect.c

Replaced ../gc/reflect.c with
cmd/compile/internal/gc/reflect.go.

Fixes #20525

Change-Id: Ibafd36ea446ace5c677df27873a4bbf716a0a9bc
Reviewed-on: https://go-review.googlesource.com/44376
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agovendor: update vendored lif
Mikio Hara [Sat, 27 May 2017 10:02:22 +0000 (19:02 +0900)]
vendor: update vendored lif

Updates golang_org/x/net/lif to rev fcc8ed8 for:
- lif: rename internal types (http://golang.org/cl/43070)

Change-Id: I0aad9a8b504d673b29d3c26b3717ffa8512e0cdf
Reviewed-on: https://go-review.googlesource.com/44392
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: fix stack split at bad time when disable inlining
Wei Xiao [Thu, 25 May 2017 05:59:39 +0000 (13:59 +0800)]
runtime: fix stack split at bad time when disable inlining

key32 is called between entersyscallblock and exitsyscall
stack split may occur if disable inlining and the G is preempted

Fix the problem by describing key32 as nosplit function

Fixes #20510

Change-Id: I1f0787995936f34ef0052cf79fde036f1b338865
Reviewed-on: https://go-review.googlesource.com/44390
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 agoruntime: fix file reference in comments
Dmitry Savintsev [Mon, 29 May 2017 10:01:45 +0000 (12:01 +0200)]
runtime: fix file reference in comments

cmd/compile/internal/ld/decodesym.go is now
cmd/link/internal/ld/decodesym.go

Change-Id: I16ec5c89aa3507e70676c2b50d70f1fde533a085
Reviewed-on: https://go-review.googlesource.com/44373
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/vet: set exit status to non zero for all cases
Fatih Arslan [Sat, 27 May 2017 23:42:34 +0000 (02:42 +0300)]
cmd/vet: set exit status to non zero for all cases

Vet returns with a nonzero exit for all possible messages in the
buildtag check. However for this file:

    //+buildlinux

    package main

vet returns a zero exit status:

    $ go vet main.go
    demo.go:1: possible malformed +build comment
    $ echo $?
    0

This CL sets the exit status to non zero for the remaining messages in
the buildtag check.

Change-Id: Ia2c35ebc3ec5ac311d2a0295b5b9fdd997a85726
Reviewed-on: https://go-review.googlesource.com/44371
Reviewed-by: Rob Pike <r@golang.org>
7 years agocmd/internal/dwarf: update to DWARF4, emit frame_base
Heschi Kreinick [Wed, 24 May 2017 21:43:08 +0000 (17:43 -0400)]
cmd/internal/dwarf: update to DWARF4, emit frame_base

In preparation for CL 41770, upgrade .debug_info to DWARF4, and emit
DW_AT_frame_base on subprograms. This should make no semantic
difference.

Also fix a long-standing bug/inconsistency in puttattr: it didn't
add the addend to ref_addrs. Previously this didn't matter because it
was only used for types, but now it's used for section offsets into
symbols that have multiple entries.

RELNOTE=yes

Change-Id: Ib10654ac92edfa29c5167c44133648151d70cf76
Reviewed-on: https://go-review.googlesource.com/44210
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
7 years agoencoding/gob: speedup decoding of maps by zeroing values
Filip Gruszczyński [Fri, 31 Mar 2017 02:09:56 +0000 (19:09 -0700)]
encoding/gob: speedup decoding of maps by zeroing values

Instead of allocating a new reflect.Value object on every loop we zero it.

DecodeComplex128Slice-8  13.1µs ± 7%  13.2µs ± 8%     ~     (p=0.347 n=18+19)
DecodeFloat64Slice-8     8.13µs ± 5%  8.00µs ± 3%     ~     (p=0.168 n=20+19)
DecodeInt32Slice-8       8.27µs ± 5%  8.08µs ± 5%   -2.27%  (p=0.001 n=19+18)
DecodeStringSlice-8      17.9µs ±12%  17.8µs ±11%     ~     (p=0.989 n=20+19)
DecodeInterfaceSlice-8    163µs ±10%   159µs ± 4%     ~     (p=0.057 n=19+19)
DecodeMap-8               220µs ± 2%   183µs ± 1%  -17.07%  (p=0.000 n=19+18)

Updates #19525

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

7 years agonet/http: update bundled x/net/http2
Tom Bergan [Fri, 26 May 2017 17:05:38 +0000 (10:05 -0700)]
net/http: update bundled x/net/http2

This updates the bundled copy of x/net/http2 to x/net git rev
3470a06c1357df53 for:

http2: fix typo in comment
https://golang.org/cl/44271

http2: fix nil dereference after Read completes with an error
https://golang.org/cl/44330

Fixes #20501

Change-Id: Ie6a5fb092f77044f504f146721dae86299e04011
Reviewed-on: https://go-review.googlesource.com/44331
Run-TryBot: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoarchive/zip: set utf-8 flag
Yasuhiro Matsumoto [Wed, 5 Apr 2017 08:32:09 +0000 (17:32 +0900)]
archive/zip: set utf-8 flag

See: https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.0.TXT

Document says:
> If general purpose bit 11 is set, the filename and comment must support The
> Unicode Standard, Version 4.1.0 or greater using the character encoding form
> defined by the UTF-8 storage specification.

Since Go encode the filename to UTF-8, general purpose bit 11 should be set.

Change-Id: Ica4af02b4dc695e9a5c015ae360e70171efb6ee3
Reviewed-on: https://go-review.googlesource.com/39570
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime/cgo: add TSAN annotations for C sigaction call
Bryan C. Mills [Thu, 25 May 2017 18:30:23 +0000 (14:30 -0400)]
runtime/cgo: add TSAN annotations for C sigaction call

This avoids false-positive TSAN reports when using the C sigaction
function to read handlers registered by the Go runtime.

(Unfortunately, I can't seem to coax the runtime into reproducing the
failure in a small unit-test.)

Change-Id: I744279a163708e24b1fbe296ca691935c394b5f3
Reviewed-on: https://go-review.googlesource.com/44270
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
7 years agodebug/dwarf: heuristically handle both UNIX and Windows paths
Austin Clements [Wed, 24 May 2017 20:21:01 +0000 (16:21 -0400)]
debug/dwarf: heuristically handle both UNIX and Windows paths

Currently debug/dwarf assumes all paths in line tables will be
UNIX-style paths, which obviously isn't the case for binaries built on
Windows. However, we can't simply switch from the path package to the
filepath package because we don't know that we're running on the same
host type that built the binary and we want this to work even if we're
not. This is essentially the approach taken by GDB, which treats paths
in accordance with the system GDB itself is compiled for. In fact, we
can't even guess the compilation system from the type of the binary
because it may have been cross-compiled.

We fix this by heuristically determining whether paths are UNIX-style
or DOS-style by looking for a drive letter or UNC path. If we see a
DOS-style path, we use appropriate logic for determining whether the
path is absolute and for joining two paths. This is helped by the fact
that we should basically always be starting with an absolute path.
However, it could mistake a relative UNIX-style path that begins with
a directory like "C:" for an absolute DOS-style path. There doesn't
seem to be any way around this.

Fixes #19784.

Change-Id: Ie13b546d2f1dcd8b02e668583a627b571b281588
Reviewed-on: https://go-review.googlesource.com/44017
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
7 years agocmd/cgo, runtime/cgo: add docs for TSAN interaction
Ian Lance Taylor [Thu, 25 May 2017 19:20:58 +0000 (12:20 -0700)]
cmd/cgo, runtime/cgo: add docs for TSAN interaction

Change-Id: I3b3ae4ecad0894781a3019326c7262cb9790ad4d
Reviewed-on: https://go-review.googlesource.com/44250
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
7 years agocmd/asm/internal/asm: fix a bug in ARM assembly encoding test
Ben Shi [Tue, 23 May 2017 10:12:36 +0000 (10:12 +0000)]
cmd/asm/internal/asm: fix a bug in ARM assembly encoding test

It is expected to test assembly code for ARMv5, ARMv6 and ARMv7
in cmd/asm/internal/asm/endtoend_test.go. But actually the loop
in "func TestARMEndToEnd(t *testing.T)" runs three times all
for ARMv5.

This patch fixes that bug and adds a new armv6.s which is only tested
with GOARM=6.

fixes #20465

Change-Id: I5dbf00809a47ace2c195335e2c9bdd768479aada
Reviewed-on: https://go-review.googlesource.com/43930
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/internal/obj/arm: fix illegal forms of ARM VFP instruction
Ben Shi [Tue, 23 May 2017 11:15:41 +0000 (11:15 +0000)]
cmd/internal/obj/arm: fix illegal forms of ARM VFP instruction

"ADDF F0, R1, F2" is silently accepted by the arm assembler and
assembled to the same binary code of "ADDF F0, F1, F2". So does
"CMPF F0, R1".

"ABSF F0, F1, F2" is also silently accepted and assembled to a
different instruction.

This patch reports those illegal forms and adds test cases.

fix #20464

Change-Id: I88b80dc29de24c6266ac7bf7bce1578c5adbc68c
Reviewed-on: https://go-review.googlesource.com/43931
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: accept non-monotonic arena allocation on 32-bit
Austin Clements [Tue, 23 May 2017 21:07:26 +0000 (17:07 -0400)]
runtime: accept non-monotonic arena allocation on 32-bit

Currently, the heap arena allocator allocates monotonically increasing
addresses. This is fine on 64-bit where we stake out a giant block of
the address space for ourselves and start at the beginning of it, but
on 32-bit the arena starts at address 0 but we start allocating from
wherever the OS feels like giving us memory. We can generally hint the
OS to start us at a low address, but this doesn't always work.

As a result, on 32-bit, if the OS gives us an arena block that's lower
than the current block we're allocating from, we simply say "thanks
but no thanks", return the whole (256MB!) block of memory, and then
take a fallback path that mmaps just the amount of memory we need
(which may be as little as 8K).

We have to do this because mheap_.arena_used is *both* the highest
used address in the arena and the next address we allocate from.

Fix all of this by separating the second role of arena_used out into a
new field called arena_alloc. This lets us accept any arena block the
OS gives us. This also slightly changes the invariants around
arena_end. Previously, we ensured arena_used <= arena_end, but this
was related to arena_used's second role, so the new invariant is
arena_alloc <= arena_end. As a result, we no longer necessarily update
arena_end when we're updating arena_used.

Fixes #20259 properly. (Unlike the original fix, this one should not
be cherry-picked to Go 1.8.)

This is reasonably low risk. I verified several key properties of the
32-bit code path with both 4K and 64K physical pages using a symbolic
model and the change does not materially affect 64-bit (arena_used ==
arena_alloc on 64-bit). The only oddity is that we no longer call
setArenaUsed with racemap == false to indicate that we're creating a
hole in the address space, but this only happened in a 32-bit-only
code path, and the race detector require 64-bit, so this never
mattered anyway.

Change-Id: Ib1334007933e615166bac4159bf357ae06ec6a25
Reviewed-on: https://go-review.googlesource.com/44010
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
7 years agonet/http: revert CL 43779
Emmanuel Odeke [Thu, 25 May 2017 01:36:41 +0000 (19:36 -0600)]
net/http: revert CL 43779

CL 43779/commit 6a6c792eef55eded7fb3165a330ec2b239b83960
broke the builds at tip, and that CL doesn't account for
cases where Redirect is directly invoked with a full URL
that itself has a query string.

Updates #17841

Change-Id: Idb0486bae8625e1f9e033ca4cfcd87de95bc835c
Reviewed-on: https://go-review.googlesource.com/44100
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agovendor: update golang.org/x/net/nettest
David du Colombier [Thu, 25 May 2017 01:21:17 +0000 (03:21 +0200)]
vendor: update golang.org/x/net/nettest

Update golang.org/x/net/nettest to revision 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6.

Change-Id: Ib6505423910d34142d7b1bcb6792a5017df4da47
Reviewed-on: https://go-review.googlesource.com/44131
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: fix ppc64le c-archive init
Ian Lance Taylor [Wed, 24 May 2017 22:01:49 +0000 (15:01 -0700)]
runtime: fix ppc64le c-archive init

We weren't setting r0 to 0, as required by our generated code.

Before this patch, the misc/cgo/testcarchive tests failed on ppc64le.
After this patch, they work, so enable them.

Change-Id: I53b16746961da9f7c34f59030a1e40953c9c1e05
Reviewed-on: https://go-review.googlesource.com/44093
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agomisc/cgo/testcarchive: fix `go env` error message
Ian Lance Taylor [Wed, 24 May 2017 21:59:22 +0000 (14:59 -0700)]
misc/cgo/testcarchive: fix `go env` error message

Add a missing newline.  Don't panic on an unexpected error type.

Change-Id: I82a4b12c498fbfdf4972737329631c0c02540005
Reviewed-on: https://go-review.googlesource.com/44092
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocompress/bzip2: remove dead code in huffman.go
Joe Tsai [Wed, 24 May 2017 20:52:56 +0000 (13:52 -0700)]
compress/bzip2: remove dead code in huffman.go

The logic performs a series of shifts, which are useless given
that they are followed by an assignment that overrides the
value of the previous computation.

I suspect (but cannot prove) that this is leftover logic from an
original approach that attempted to store both the Huffman code
and the length within the same variable instead of using two
different variables as it currently does now.

Fixes #17949

Change-Id: Ibf6c807c6cef3b28bfdaf2b68d9bc13503ac21b2
Reviewed-on: https://go-review.googlesource.com/44091
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/compile: test for moving spills
Keith Randall [Wed, 24 May 2017 18:16:42 +0000 (11:16 -0700)]
cmd/compile: test for moving spills

Test that we really do move spills down to the dominator of
all the uses.

Also add a test where go1.8 would have moved the spill out of
the loop into two exit points, but go1.9 doesn't move the spill.
This is a case where the 1.9 spill moving code does not subsume
the 1.8 spill moving code.

Maybe we resurrect moving-spills-out-of-loops CL to fix this one.
(I suspect it wouldn't be worth the effort, but would be happy
to hear evidence otherwise.)

Update #20472

Change-Id: I7dbf8d65e7f4d675d14e5ecf502887cebda35d2a
Reviewed-on: https://go-review.googlesource.com/44038
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agovendor: add golang.org/x/net/nettest
Joe Tsai [Fri, 24 Feb 2017 02:16:11 +0000 (18:16 -0800)]
vendor: add golang.org/x/net/nettest

Adds golang.org/x/net/nettest at revision 9773060888fba93b172cedcd70127db1ab739bd1.
This allows us to test net.Conn implementations for compliance.

Updates #18170

Change-Id: I8d3d3430b0a1abc83513180a677c39ee39303f5a
Reviewed-on: https://go-review.googlesource.com/37404
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodoc: document go1.8.3
Chris Broadfoot [Wed, 24 May 2017 18:05:04 +0000 (11:05 -0700)]
doc: document go1.8.3

Change-Id: I5d55c3b1011dd10552d8e740fb65886306d91b5c
Reviewed-on: https://go-review.googlesource.com/44035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agotime: update docs to clarify goroutine-safety expectations of Time
Nicholas Maniscalco [Tue, 11 Apr 2017 20:27:41 +0000 (13:27 -0700)]
time: update docs to clarify goroutine-safety expectations of Time

Fixes #19935

Change-Id: I28e4cd6924f1b965a429a6a5ebfc4c0f952e8ae6
Reviewed-on: https://go-review.googlesource.com/40390
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet/http: Don't write 'Connection: close' header multiple times.
Filip Gruszczyński [Sat, 11 Mar 2017 21:38:14 +0000 (13:38 -0800)]
net/http: Don't write 'Connection: close' header multiple times.

When writing the 'Connection: close' header based on response Close
attribute we also check if it is already in the headers scheduled
to be written and skip if necessary.

Fixes #19499

Change-Id: I92357344a37ae385454ec8006114fa4cfa585810
Reviewed-on: https://go-review.googlesource.com/38076
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 agonet/http: deep copy Request.URL also in Request.WithContext's copy
Emmanuel Odeke [Fri, 21 Apr 2017 17:49:19 +0000 (11:49 -0600)]
net/http: deep copy Request.URL also in Request.WithContext's copy

Despite the previously known behavior of Request.WithContext
shallow copying a request, usage of the request inside server.ServeHTTP
mutates the request's URL. This CL implements deep copying of the URL.

Fixes #20068

Change-Id: I86857d7259e23ac624d196401bf12dde401c42af
Reviewed-on: https://go-review.googlesource.com/41308
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet/http: permit incoming CONNECT requests without Host headers
Brad Fitzpatrick [Tue, 23 May 2017 23:42:47 +0000 (23:42 +0000)]
net/http: permit incoming CONNECT requests without Host headers

Apparently they exist in the wild. See:
https://github.com/golang/go/issues/18215#issuecomment-301182496
(Facebook / iOS)

Fixes #18215

Change-Id: I9ddad3896b5d784cb3f5b3ee9c6819081a4a2702
Reviewed-on: https://go-review.googlesource.com/44004
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agostrings: simplify indexFunc
Michael Darakananda [Tue, 8 Nov 2016 06:54:30 +0000 (17:54 +1100)]
strings: simplify indexFunc

A for-range loop is simpler and also generally faster nowadays:

TrimASCII/1:1-4      69.2ns ± 1%  72.3ns ± 4%  +4.55%  (p=0.001 n=8+8)
TrimASCII/1:2-4       114ns ± 4%   104ns ± 3%  -8.71%  (p=0.000 n=9+8)
TrimASCII/1:4-4       112ns ± 1%   109ns ± 2%  -2.57%  (p=0.000 n=8+9)
TrimASCII/1:8-4       120ns ± 2%   118ns ± 4%    ~     (p=0.097 n=9+9)
TrimASCII/1:16-4      137ns ± 3%   132ns ± 3%  -3.82%  (p=0.001 n=9+9)
TrimASCII/16:1-4      129ns ± 1%   125ns ± 2%  -3.38%  (p=0.000 n=8+9)
TrimASCII/16:2-4      167ns ± 3%   159ns ± 1%  -4.99%  (p=0.000 n=9+8)
TrimASCII/16:4-4      165ns ± 2%   162ns ± 1%  -1.91%  (p=0.005 n=8+9)
TrimASCII/16:8-4      173ns ± 2%   170ns ± 1%  -1.29%  (p=0.018 n=9+9)
TrimASCII/16:16-4     188ns ± 2%   186ns ± 2%  -1.13%  (p=0.022 n=8+9)
TrimASCII/256:1-4    1.06µs ± 1%  0.98µs ± 2%  -7.64%  (p=0.000 n=8+9)
TrimASCII/256:2-4    1.08µs ± 1%  1.06µs ± 2%  -1.95%  (p=0.006 n=9+9)
TrimASCII/256:4-4    1.09µs ± 1%  1.07µs ± 3%    ~     (p=0.059 n=9+9)
TrimASCII/256:8-4    1.10µs ± 1%  1.07µs ± 2%  -2.63%  (p=0.000 n=9+8)
TrimASCII/256:16-4   1.10µs ± 1%  1.08µs ± 1%  -1.90%  (p=0.000 n=8+9)
TrimASCII/4096:1-4   15.8µs ± 1%  14.5µs ± 1%  -8.59%  (p=0.000 n=9+9)
TrimASCII/4096:2-4   15.6µs ± 1%  15.4µs ± 2%  -1.27%  (p=0.021 n=8+8)
TrimASCII/4096:4-4   15.6µs ± 1%  15.4µs ± 2%    ~     (p=0.094 n=9+9)
TrimASCII/4096:8-4   15.7µs ± 1%  15.8µs ± 6%    ~     (p=0.555 n=8+8)
TrimASCII/4096:16-4  15.7µs ± 2%  15.3µs ± 1%  -2.64%  (p=0.000 n=8+9)

Change-Id: I9b06689b67c0cf2c7ff446fc63a8c44cc5d6a246
Reviewed-on: https://go-review.googlesource.com/32891
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/dist: ensure android-implies-linux for file names in dist
David Chase [Mon, 20 Mar 2017 18:24:00 +0000 (14:24 -0400)]
cmd/dist: ensure android-implies-linux for file names in dist

This is one hurdle to building Go on Android; the runtime does
not build properly because *_linux.go files are excluded from
the "Building go_bootstrap" step when GOOS=android.

There are other hurdles; this is the first one.

Change-Id: I766e4bbf6ffc0d273888913f2516cf3e995a1786
Reviewed-on: https://go-review.googlesource.com/38308
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet/http: polish gzip case insensitive test
Emmanuel Odeke [Wed, 24 May 2017 01:40:52 +0000 (19:40 -0600)]
net/http: polish gzip case insensitive test

Avoid directly using the binary of the
gzipped encoded string in the handler.

Follow up of CL 37431.

Change-Id: Idcd04acb7940e67b7a35b2d6cb163d75b0e22e04
Reviewed-on: https://go-review.googlesource.com/44008
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet/http: make Transport respect non lower case Content-Encoding
Jan Berktold [Thu, 23 Feb 2017 14:53:27 +0000 (15:53 +0100)]
net/http: make Transport respect non lower case Content-Encoding

The existing Transport implementation does not detect gzip encoding
when the Content-Encoding header is not lower-case. This is not
compliant with RFC2616 section 3.5 "All content-coding values are
case-insensitive." and caused issues in the wild.

Fixes #19248

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

7 years agovendor: update golang.org/x/net/http2/hpack
Brad Fitzpatrick [Wed, 24 May 2017 00:36:23 +0000 (00:36 +0000)]
vendor: update golang.org/x/net/http2/hpack

Updates golang.org/x/net/http2/hpack to x/net git rev 4dbf598 for:

   http2/hpack: remove unused pair function from package
   https://golang.org/cl/43851

   http2/hpack: remove pair function and initialize directly
   https://golang.org/cl/43190

   http2/hpack: move initialization to a static table
   https://golang.org/cl/43090

Updates #6853

Change-Id: I933a094623143c7333a0da7867d5d2e41da05234
Reviewed-on: https://go-review.googlesource.com/44007
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet/http: update bundled x/net/http2
Brad Fitzpatrick [Wed, 24 May 2017 00:05:04 +0000 (00:05 +0000)]
net/http: update bundled x/net/http2

This updates the bundled copy of x/net/http2 to x/net git rev a8e8f92cd6 for:

    http2: remove extra goroutine stack from awaitGracefulShutdown
    https://golang.org/cl/43230

    http2: Discard DATA frames from the server after the response body is closed
    https://golang.org/cl/43810

Fixes #20302
Fixes #18471
Fixes #20448

Change-Id: I00972836deb2fe6049f631ee44901732a641b171
Reviewed-on: https://go-review.googlesource.com/44006
Reviewed-by: Tom Bergan <tombergan@google.com>
7 years agonet/http: Add Server.RegisterOnShutdown
Tom Bergan [Tue, 23 May 2017 23:03:21 +0000 (16:03 -0700)]
net/http: Add Server.RegisterOnShutdown

This will be used to allow http2 servers to register a shutdown function
so that net/http.Server.Shutdown will work when the http2 server is
configured via a manual call to http2.ConfigureServer. Currently, Shutdown
only works when the http2 server is configured automatically by the
net/http package.

Updates #20302
Updates #18471

Change-Id: Ifc2b5f3126126a106b49ea4a7e999279852b9cc9
Reviewed-on: https://go-review.googlesource.com/44003
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet/http/httptest: make ResponseRecorder.Result.Status match http.Transport
Brad Fitzpatrick [Tue, 23 May 2017 22:35:15 +0000 (22:35 +0000)]
net/http/httptest: make ResponseRecorder.Result.Status match http.Transport

Fixes #18438

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

7 years agomime/multipart: parse boundary with spaces properly
Michael Fraenkel [Tue, 24 Jan 2017 14:40:17 +0000 (07:40 -0700)]
mime/multipart: parse boundary with spaces properly

- spaces are allowed anywhere but the last character of a boundary

Fixes #18768

Change-Id: I36b054462533ff6dfc060e37e7a58777ae4b66fe
Reviewed-on: https://go-review.googlesource.com/35507
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: use pselect6 for usleep on linux/386
Austin Clements [Tue, 23 May 2017 21:54:24 +0000 (17:54 -0400)]
runtime: use pselect6 for usleep on linux/386

Commit 4dcba023c6 replaced select with pselect6 on linux/amd64 and
linux/arm, but it turns out the Android emulator uses linux/386. This
makes the equivalent change there, too.

Fixes #20409 more.

Change-Id: If542d6ade06309aab8758d5f5f6edec201ca7670
Reviewed-on: https://go-review.googlesource.com/44011
Run-TryBot: Austin Clements <austin@google.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 agocmd/cgo: support indirect macro expansion for string
Hiroshi Ioka [Fri, 21 Apr 2017 10:18:36 +0000 (19:18 +0900)]
cmd/cgo: support indirect macro expansion for string

Current code cannot handle string #define macros if those macros are
defined via other macros. This CL solve the issue.

Updates #18720

Change-Id: Ibed0773d10db3d545bb246b97e81c0d19e3af3d5
Reviewed-on: https://go-review.googlesource.com/41312
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 agocmd/go: include GOARM and GO386 in computed build ID
Brad Fitzpatrick [Tue, 23 May 2017 05:22:25 +0000 (05:22 +0000)]
cmd/go: include GOARM and GO386 in computed build ID

Now:
$ GOARCH=arm GOARM=5 go install -x cmd/go
... followed by:
$ GOARCH=arm GOARM= go install -x cmd/go

... actually does work. Previously the second "go install" would reuse
the cached binaries from the GOARM=5 command and not rebuild.
(Or vice versa from GOARM= to GOARM=5)

And do the same for GO386.

Fixes #9737

Change-Id: I9630aab34d06465d5033e6743dfe6592c8247aa0
Reviewed-on: https://go-review.googlesource.com/43855
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocrypto/rand: only read necessary bytes for Int
Wade Simmons [Tue, 23 May 2017 00:31:17 +0000 (20:31 -0400)]
crypto/rand: only read necessary bytes for Int

We only need to read the number of bytes required to store the value
"max - 1" to generate a random number in the range [0, max).

Before, there was an off-by-one error where an extra byte was read from
the io.Reader for inputs like "256" (right at the boundary for a byte).
There was a similar off-by-one error in the logic for clearing bits and
thus for any input that was a power of 2, there was a 50% chance the
read would continue to be retried as the mask failed to remove a bit.

Fixes #18165.

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

7 years agoruntime: remove unused copies of special stack guards
Austin Clements [Thu, 18 May 2017 18:50:12 +0000 (14:50 -0400)]
runtime: remove unused copies of special stack guards

There are two copies each of the stackPreempt/_StackPreempt and
stackFork/_StackFork constants. Remove the ones left over from C that
are no longer used.

Change-Id: I849604c72c11e4a0cb08e45e9817eb3f5a6ce8ba
Reviewed-on: https://go-review.googlesource.com/43638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>