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

33274 Commits

Author SHA1 Message Date
Ian Lance Taylor
6654e3e0a1 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>
2017-05-26 05:22:39 +00:00
Ben Shi
ffab6ab877 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>
2017-05-25 18:23:20 +00:00
Ben Shi
b8a4eb4bd8 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>
2017-05-25 14:32:35 +00:00
Austin Clements
13ae3b3a8d 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>
2017-05-25 14:26:19 +00:00
Emmanuel Odeke
a9d8d4df61 net/http: revert CL 43779
CL 43779/commit 6a6c792eef
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>
2017-05-25 01:55:18 +00:00
David du Colombier
00e6b34fed 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>
2017-05-25 01:34:15 +00:00
Ian Lance Taylor
daa0ddde93 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>
2017-05-24 22:28:33 +00:00
Ian Lance Taylor
994b7eebc7 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>
2017-05-24 22:27:16 +00:00
Joe Tsai
e0e4891827 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>
2017-05-24 21:56:48 +00:00
Keith Randall
67a782b8cc 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>
2017-05-24 21:36:06 +00:00
Joe Tsai
e1e2ca11c6 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>
2017-05-24 20:57:55 +00:00
Chris Broadfoot
01f322316f doc: document go1.8.3
Change-Id: I5d55c3b1011dd10552d8e740fb65886306d91b5c
Reviewed-on: https://go-review.googlesource.com/44035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-24 18:08:31 +00:00
Nicholas Maniscalco
4aa5d2eede 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>
2017-05-24 06:11:03 +00:00
Filip Gruszczyński
5dbdd79816 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>
2017-05-24 04:53:50 +00:00
Emmanuel Odeke
3b69c3bbed 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>
2017-05-24 04:34:52 +00:00
Brad Fitzpatrick
88a235042d 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>
2017-05-24 04:15:25 +00:00
Michael Darakananda
a5083bbf07 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>
2017-05-24 03:16:44 +00:00
David Chase
74e3be8f38 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>
2017-05-24 03:09:15 +00:00
Emmanuel Odeke
59096edb4a 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>
2017-05-24 02:44:51 +00:00
Jan Berktold
51b22130b5 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>
2017-05-24 01:20:11 +00:00
Brad Fitzpatrick
d4a8828eee 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>
2017-05-24 00:54:32 +00:00
Brad Fitzpatrick
e6e6cad632 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>
2017-05-24 00:35:03 +00:00
Tom Bergan
1a63f116c1 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>
2017-05-23 23:52:37 +00:00
Brad Fitzpatrick
6374a6607b 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>
2017-05-23 23:10:55 +00:00
Michael Fraenkel
a28ce75daa 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>
2017-05-23 22:56:44 +00:00
Austin Clements
e26b51b0d5 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>
2017-05-23 22:47:31 +00:00
Hiroshi Ioka
dd61aa55e8 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>
2017-05-23 22:19:51 +00:00
Brad Fitzpatrick
1b53f15ebb 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>
2017-05-23 21:39:36 +00:00
Wade Simmons
8a2553e380 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>
2017-05-23 21:02:14 +00:00
Austin Clements
9f03e89552 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>
2017-05-23 20:11:38 +00:00
Austin Clements
475425201a runtime: fix stackCache=0 debug mode
Setting stackCache to 0 to disable stack caches for debugging hasn't
worked for a long time. It causes stackalloc to fall back to full span
allocation, round sub-page stacks down to 0 pages, and blow up.

Fix this debug mode so it disables the per-P caches, but continues to
use the global stack pools for small stacks, which correctly handle
sub-page stacks. While we're here, rename stackCache to stackNoCache
so it acts like the rest of the stack allocator debug modes where "0"
is the right default value.

Fixes #17291.

Change-Id: If401c41cee3448513cbd7bb2e9334a8efab257a7
Reviewed-on: https://go-review.googlesource.com/43637
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-23 20:11:18 +00:00
Austin Clements
8a1c5b2e48 runtime: fix stackFromSystem returning memory
The stackFromSystem debug mode has two problems:

1) It rounds the stack allocation to _PageSize. If the physical page
size is >8K, this can cause unmapping the memory later to either
under-unmap or over-unmap.

2) It doesn't return the rounded-up allocation size to its caller, so
when we later unmap the memory, we may pass the wrong length.

Fix these problems by rounding the size up to the physical page size
and putting that rounded-up size in the returned stack bounds.

Fixes #17289.

Change-Id: I6b854af3b06bb16e3750798397bb5e2a722ec1cb
Reviewed-on: https://go-review.googlesource.com/43636
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-23 20:11:07 +00:00
Chris Broadfoot
e16944da0e doc: document go1.8.2 and go1.7.6
Change-Id: I2ed2e8c4890a65288cf3066ebe3c1d9a16fb4c05
Reviewed-on: https://go-review.googlesource.com/43990
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-23 17:39:14 +00:00
Austin Clements
e5a5c03f5b runtime: don't corrupt arena bounds on low mmap
If mheap.sysAlloc doesn't have room in the heap arena for an
allocation, it will attempt to map more address space with sysReserve.
sysReserve is given a hint, but can return any unused address range.
Currently, mheap.sysAlloc incorrectly assumes the returned region will
never fall between arena_start and arena_used. If it does,
mheap.sysAlloc will blindly accept the new region as the new
arena_used and arena_end, causing these to decrease and make it so any
Go heap above the new arena_used is no longer considered part of the
Go heap. This assumption *used to be* safe because we had all memory
between arena_start and arena_used mapped, but when we switched to an
arena_start of 0 on 32-bit, it became no longer safe.

Most likely, we've only recently seen this bug occur because we
usually start arena_used just above the binary, which is low in the
address space. Hence, the kernel is very unlikely to give us a region
before arena_used.

Since mheap.sysAlloc is a linear allocator, there's not much we can do
to handle this well. Hence, we fix this problem by simply rejecting
the new region if it isn't after arena_end. In this case, we'll take
the fall-back path and mmap a small region at any address just for the
requested memory.

Fixes #20259.

Change-Id: Ib72e8cd621545002d595c7cade1e817cfe3e5b1e
Reviewed-on: https://go-review.googlesource.com/43870
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-05-23 15:23:21 +00:00
Joe Richey joerichey@google.com
95d991d30c crypto/rand: use blocking getrandom call on Linux when supported
By changing getRandomLinux to immediately use the getrandom() syscall
without GRND_NONBLOCK, we now only fall back to reading from
/dev/urandom on Linux if the kernel does not support the getrandom()
syscall. This means reads for crypto/rand will now block if the kernel
has insufficient entropy on Linux kernels after v3.16.

Before, if the kernel had insufficient entropy, it would fall back to
reading from /dev/urandom. This would potentially return predictable
data.

Fixes #19274

Change-Id: I1cb081ce2f3096f18ad2820e52ecdbd993dc2afc
Reviewed-on: https://go-review.googlesource.com/43852
Reviewed-by: Filippo Valsorda <hi@filippo.io>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-23 04:54:42 +00:00
Alex Brainman
f3f29d1dea os/exec: ignore some pipe write errors on windows
This change is windows version of CL 12152.
It also extends test to cover scenarios reported on issue #20445.
Some source files copied and renamed to make code clearer.

Fixes #20445

Change-Id: Idd2f636f27c6bd5cfe98017ba2df911358263382
Reviewed-on: https://go-review.googlesource.com/43910
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-23 04:27:01 +00:00
Gustav Westling
5f4f7519b6 encoding/base32: add Encoding.WithPadding, StdPadding, NoPadding
Fixes #19478

Change-Id: I9fc186610d79fd003e7b5d88c0955286ebe7d3cf
Reviewed-on: https://go-review.googlesource.com/38634
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-22 22:50:17 +00:00
Albert Nigmatzianov
4cf19fb5a7 log: Prevent getting time if it's unnecessary
Small performance gain:
name              old time/op    new time/op    delta
Itoa-4              95.4ns ± 4%    95.6ns ± 3%    ~     (p=0.256 n=45+46)
Println-4            480ns ± 4%     476ns ± 5%  -0.87%  (p=0.003 n=45+45)
PrintlnNoFlags-4     316ns ± 3%     299ns ± 4%  -5.38%  (p=0.000 n=42+44)

name              old alloc/op   new alloc/op   delta
Itoa-4               0.00B          0.00B         ~     (all equal)
Println-4            21.0B ± 0%     21.0B ± 0%    ~     (all equal)
PrintlnNoFlags-4     21.0B ± 0%     21.0B ± 0%    ~     (all equal)

name              old allocs/op  new allocs/op  delta
Itoa-4                0.00           0.00         ~     (all equal)
Println-4             2.00 ± 0%      2.00 ± 0%    ~     (all equal)
PrintlnNoFlags-4      2.00 ± 0%      2.00 ± 0%    ~     (all equal)

Change-Id: Idcd03609a5a437a69ffa7004a673bf0b8d22e7ad
Reviewed-on: https://go-review.googlesource.com/38056
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-22 21:59:34 +00:00
Dhananjay Nakrani
d433de6e86 cmd/go: warn on -race with -covermode=set.
Fixes #20435.

Change-Id: I15576f36b26d01642c1187325baea82d3077e578
Reviewed-on: https://go-review.googlesource.com/43777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-22 19:59:28 +00:00
Steven Hartland
f6f1daa4b8 cmd/go: Document that -cover causes incorrect line numbers
Due to the fact that -cover injects additional code to the original
source, tests run with -cover will often have incorrect line numbers.

Also includes docs for -list regexp missed by ba8ff87

Updates #6329

Change-Id: I87f0618ac31e96071bca61055cc17c0cbdee208a
Reviewed-on: https://go-review.googlesource.com/38640
Reviewed-by: Rob Pike <r@golang.org>
2017-05-22 19:31:43 +00:00
Volker Dobler
c5e8ec5b6d net/http/cookiejar: increase test coverage
The jarKey function handles broken PublicSuffixList implementations but
no test verified it.

Change-Id: Ifb76de9e8c3941f3b08d3e43970056e023013457
Reviewed-on: https://go-review.googlesource.com/38357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-22 19:29:49 +00:00
Robert Griesemer
d79bb78a71 cmd/compile: report correct position in redeclaration errors
When restoring syms, we must also restore the original Lastlineno.
Bug introduced with https://golang.org/cl/41390/.

Fixes #20415.

Change-Id: Ie81d36279d717e330951b52f42dcee4b0025b9f0
Reviewed-on: https://go-review.googlesource.com/43811
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-05-22 19:20:11 +00:00
Volker Dobler
8f6d68ebaa net/http: send more cookie values in double quotes
According to RFC 6255 a cookie value may contain neither spaces " "
nor commas ",". But browsers seem to handle these pretty well and such
values are not uncommon in the wild so we do allow spaces and commas
in cookie values too. Up to now we use the double-quoted wire format
only for cookie values with leading and/or trailing spaces and commas.
Values with internal spaces/commas are sent without the optional double
quotes. This seems to be a problem for some agents.

This CL changes the behaviour for cookie values with spaces or commas:
Such values are always sent in double quotes. This should not have
any impact on existing agents and the increases of data transmitted
is negligible.

Fixes #18627

Change-Id: I575a98d589e048aa39d976a3c984550daaca730a
Reviewed-on: https://go-review.googlesource.com/37328
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-22 19:13:51 +00:00
Tristan Colgate
1611839b29 net/http/httputil: ReverseProxy should pass on unannounced Trailers
Trailers that are not announced in the Trailer must be passed on to
the downstream client.

Rather than iterate over each and find missing trailer values,
this re-adds all trailers to the headers if there is a disparity
between the number of announced trailers and the final number.

This fixes #20437

Change-Id: I867e85f45feff68616a9a9bd6f65f12d73825eb7
Reviewed-on: https://go-review.googlesource.com/43712
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-22 18:34:09 +00:00
Alberto Donizetti
bc495c5751 doc: mention that go tools is needed to access some tool
Change-Id: I020cd3d10a441ba4047800fdf4f93433c458398a
Reviewed-on: https://go-review.googlesource.com/43717
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-22 15:51:19 +00:00
Daniel Theophanes
1865a56e8d database/sql: allow Stmt Query and Exec methods to open a new conn
Query and Exec functions on DB first attempt to get a cached
connection before requesting the connection pool to ignore
the cache and get a new connection. This change aligns Stmt to
that behavior as well.

Fixes #20433

Change-Id: Idda5f61927289d7ad0882effa3a50ffc9efd88e6
Reviewed-on: https://go-review.googlesource.com/43790
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-22 15:02:35 +00:00
Steven Hartland
d79ec64fe1 mime/multipart: Allow ReadForm to process large non-file parts
Allow the memory limit passed into ReadForm to be used as the
memory limit for processing non-file form data as well as file
form data, rather than the existing behaviour of the memory limit
only applying to the file parts and the non-file parts being
arbitrarily limited to 10MB.

This ensures backwards compatibility while still providing the
user with control over the amount of non-file data that can be
processed instead of enforcing an arbitrary 10MB limit.

Change-Id: I53c09eae00147d3ff2d6bdfd4e50949267932c3d
Reviewed-on: https://go-review.googlesource.com/38195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-22 14:54:00 +00:00
Emmanuel Odeke
6a6c792eef net/http: make ServeMux preserve query string during redirects
Ensure that the implicitly created redirect
for
  "/route"
after
  "/route/"
has been registered doesn't lose the query string information.

Fixes #17841.

Change-Id: Ib7df9242fab8c9368a18fc0da678003d6bec63b8
Reviewed-on: https://go-review.googlesource.com/43779
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-22 14:49:43 +00:00
Ben Shi
5e79787935 cmd/internal/obj/arm: report invalid .S/.P/.W suffix in ARM instructions
Many instructions can not have a .S suffix, such as MULS, SWI, CLZ,
CMP, STREX and others. And so do .P and .W suffixes. Even wrong
assembly code is generated for some instructions with invalid
suffixes.

This patch tries to simplify .S/.W/.P checks. And a wrong assembly
test for arm is added.

fixes #20377

Change-Id: Iba1c99d9e6b7b16a749b4d93ca2102e17c5822fe
Reviewed-on: https://go-review.googlesource.com/43561
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-22 13:44:12 +00:00
Rob Phoenix
4bf6c566d3 net: add examples for ParseIP, IP.DefaultMask & IP.Mask
Further examples to support the net package.

Updates #5757

Change-Id: I9b65521d211f6c404b9103c1eaf22b0772eb242e
Reviewed-on: https://go-review.googlesource.com/43711
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2017-05-22 09:35:42 +00:00