]> Cypherpunks repositories - gostls13.git/log
gostls13.git
9 years agoruntime: use AddVectoredContinueHandler on Windows XP amd64
Alex Brainman [Mon, 6 Jul 2015 00:34:01 +0000 (10:34 +1000)]
runtime: use AddVectoredContinueHandler on Windows XP amd64

Recent change (CL 10370) unexpectedly broke TestRaiseException on
Windows XP amd64. I still do not know why. But reverting old
CL 8165 fixes the problem.

This effectively makes Windows XP amd64 use AddVectoredContinueHandler
instead of SetUnhandledExceptionFilter for exception handling. That is
what we do for all recent Windows versions too.

Fixes #11481

Change-Id: If2e8037711f05bf97e3c69f5a8d86af67c58f6fc
Reviewed-on: https://go-review.googlesource.com/11888
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agomath: Expm1 returns -1 with large negative argument.
Charlie Dorian [Wed, 1 Jul 2015 00:14:30 +0000 (20:14 -0400)]
math: Expm1 returns -1 with large negative argument.

Fixes #11442

Change-Id: I2053fe752c6a122924d28565f1338f73e00ed417
Reviewed-on: https://go-review.googlesource.com/11791
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/link/internal/ld: stricter object file decoding
Matthew Dempsky [Fri, 10 Jul 2015 21:38:35 +0000 (14:38 -0700)]
cmd/link/internal/ld: stricter object file decoding

Instead of silently truncating integers to their expected range, check
that they're within range and emit errors if not.  Intended to help
narrow down the cause of issue #11617.

Change-Id: Ia7b577270f8438ca7479262702371e26277f1ea7
Reviewed-on: https://go-review.googlesource.com/12050
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime, cmd/go: fix tests to work when GOROOT_FINAL is set
Ian Lance Taylor [Fri, 10 Jul 2015 12:20:20 +0000 (05:20 -0700)]
runtime, cmd/go: fix tests to work when GOROOT_FINAL is set

When GOROOT_FINAL is set when running all.bash, the tests are run
before the files are copied to GOROOT_FINAL.  The tests are run with
GOROOT set, so most work fine.  This fixes two cases that do not.

In cmd/go/go_test.go we were explicitly removing GOROOT from the
environment, causing tests that did not themselves explicitly set
GOROOT to fail.  There was no need to explicitly remove GOROOT, so
don't do it.  If people choose to run "go test cmd/go" with a bad
GOROOT, that is their own lookout.

In the runtime GDB test, the linker has told gdb to find the support
script in GOROOT_FINAL, which will fail.  Check for that case, and
skip the test when we see it.

Fixes #11652.

Change-Id: I4d3a32311e3973c30fd8a79551aaeab6789d0451
Reviewed-on: https://go-review.googlesource.com/12021
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime: clarify that NumCPU returns only available CPUs
Ian Lance Taylor [Fri, 10 Jul 2015 13:20:51 +0000 (06:20 -0700)]
runtime: clarify that NumCPU returns only available CPUs

Update #11609.

Change-Id: Ie363facf13f5e62f1af4a8bdc42a18fb36e16ebf
Reviewed-on: https://go-review.googlesource.com/12022
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agonet: fix misidentification of link-local, global unicast IP addresses
Mikio Hara [Sat, 4 Jul 2015 04:49:47 +0000 (13:49 +0900)]
net: fix misidentification of link-local, global unicast IP addresses

Don't treat IPv4-mapped link-local IP addresses as IPv6 link-local
addresses, an IPv4 broadcast address as a global unicast IP address.

Fixes #11585.

Change-Id: I6a7a0c0601f18638f5c624ab63e12ee40f77b182
Reviewed-on: https://go-review.googlesource.com/11883
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agonet: ensure that ResolveIPAddr(addr.String()) reproduces addr
Mikio Hara [Tue, 7 Jul 2015 03:10:15 +0000 (12:10 +0900)]
net: ensure that ResolveIPAddr(addr.String()) reproduces addr

Updates #6465.

Change-Id: I5babbcf4c92dae47c823a41628b01e4ceb2332eb
Reviewed-on: https://go-review.googlesource.com/11951
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/doc: submit to the punched card tyranny
Rob Pike [Fri, 10 Jul 2015 01:52:39 +0000 (11:52 +1000)]
cmd/doc: submit to the punched card tyranny

People use 80-column terminals because their grandparents used
punched cards. When I last used a punched card, in 1978, it seemed
antiquated even then. But today, people still set their terminal
widths to 80 to honor the struggles their fallen ancestors made to
endure this painful technology.

We must all stand and salute the 80 column flag, or risk the opprobium
of our peers.

For Pete's sake, I don't even use a fixed-width font. I don't even
believe in columns.

Fixes #11639 with extreme reluctance.

P.S. To avoid the horror of an automatically folded line of text, this commit message has been formatted to fit on an 80-column line, except for this postscript.

Change-Id: Ia2eb2dcf293dabe804c22ee5abb4bbb703f45c33
Reviewed-on: https://go-review.googlesource.com/12011
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agodebug/pe: truncate pe sections to their size in memory
Alex Brainman [Mon, 6 Jul 2015 05:52:33 +0000 (15:52 +1000)]
debug/pe: truncate pe sections to their size in memory

Section.Data returns disk section data, but those are rounded up to
some predefined value. Processing these as is confuses dwarf parser
because of garbage at the end. Truncate Section.Data as per memory
section description.

Sometimes dwarf sections have memory section size of 0
(for pe object files). Keep those to their disk size.

Fixes #11608

Change-Id: I8de0a2271201a24aa9ac8dac44f1e9c8a9285183
Reviewed-on: https://go-review.googlesource.com/11950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agonet: add mechanisms to force go or cgo lookup, and to debug default strategy
Brad Fitzpatrick [Thu, 25 Jun 2015 10:52:54 +0000 (12:52 +0200)]
net: add mechanisms to force go or cgo lookup, and to debug default strategy

GODEBUG=netdns=1 prints a one-time strategy decision. (cgo or go DNS lookups)
GODEBUG=netdns=2 prints the per-lookup strategy as a function of the hostname.

The new "netcgo" build tag forces cgo DNS lookups.

GODEBUG=netdns=go (or existing build tag "netgo") forces Go DNS resolution.
GODEBUG=netdns=cgo (or new build tag "netcgo") forces libc DNS resolution.

Options can be combined with e.g. GODEBUG=netdns=go+1 or GODEBUG=netdns=2+cgo.

Fixes #11322
Fixes #11450

Change-Id: I7a67e9f759fd0a02320e7803f9ded1638b19e861
Reviewed-on: https://go-review.googlesource.com/11584
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agoCONTRIBUTORS: add Ross Light's google.com email
Ross Light [Thu, 9 Jul 2015 17:13:09 +0000 (10:13 -0700)]
CONTRIBUTORS: add Ross Light's google.com email

Change-Id: Ide5b0c81405fbf6b83a6f02527d629898e0fcf02
Reviewed-on: https://go-review.googlesource.com/12000
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: make sysmon-triggered GC concurrent
Austin Clements [Wed, 8 Jul 2015 21:18:33 +0000 (14:18 -0700)]
runtime: make sysmon-triggered GC concurrent

sysmon triggers a GC if there has been no GC for two minutes.
Currently, this is a STW GC. There is no reason for this to be STW, so
make it concurrent.

Fixes #10261.

Change-Id: I92f3ac37272d5c2a31480ff1fa897ebad08775a9
Reviewed-on: https://go-review.googlesource.com/11955
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc: document the machine-independent changes to the assembler
Rob Pike [Wed, 8 Jul 2015 05:53:47 +0000 (15:53 +1000)]
doc: document the machine-independent changes to the assembler

The architecture-specific details will be updated and expanded in
a subsequent CL (or series thereof).

Update #10096

Change-Id: I59c6be1fcc123fe8626ce2130e6ffe71152c87af
Reviewed-on: https://go-review.googlesource.com/11954
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc: R13 is stack pointer on ARM, not 386
Rob Pike [Thu, 9 Jul 2015 05:06:15 +0000 (15:06 +1000)]
doc: R13 is stack pointer on ARM, not 386

Fix typo.

TBR=rsc

Change-Id: I85d1b46744a9a4524e7949e452cdebb53afe0740
Reviewed-on: https://go-review.googlesource.com/11959
Reviewed-by: Rob Pike <r@golang.org>
9 years agodoc: add -test.count and get -insecure to go1.5.html
Rob Pike [Thu, 9 Jul 2015 00:10:12 +0000 (10:10 +1000)]
doc: add -test.count and get -insecure to go1.5.html

Change-Id: Ie3d603a95826b9b6a7acd4825991f24c3c61408b
Reviewed-on: https://go-review.googlesource.com/11956
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/doc: suppress symbols for commands when showing package docs
Rob Pike [Wed, 8 Jul 2015 01:17:01 +0000 (11:17 +1000)]
cmd/doc: suppress symbols for commands when showing package docs

Change the default behavior when showing the package docs
for a command to elide the symbols. This makes

go doc somecommand

show the top-level package docs only and hide the symbols,
which are probably irrelevant to the user. This has no effect
on explicit requests for internals, such as

go doc somecommand.sometype

The new -cmd flag restores the old behavior.

Fixes #10733.

Change-Id: I4d363081fe7dabf76ec8e5315770ac3609592f80
Reviewed-on: https://go-review.googlesource.com/11953
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/asm: add copyright notices to tests
Rob Pike [Thu, 9 Jul 2015 02:49:01 +0000 (12:49 +1000)]
cmd/asm: add copyright notices to tests

They were missing from the inputs.
Unfortunately this means the .out files all have wrong line numbers,
but they are easy to update.

Change-Id: I254742f24ab803421f34d52d13b9afa93674edd6
Reviewed-on: https://go-review.googlesource.com/11958
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc/go1.5: mention net/http.Request.Cancel
Aaron Jacobs [Wed, 8 Jul 2015 00:05:39 +0000 (10:05 +1000)]
doc/go1.5: mention net/http.Request.Cancel

This was added in commit 8b4278ffb75e79c277bfa90c5e473bfad9f7c1bd.

Change-Id: I95279f2779c2bab2767e34389fb4324900c01e6c
Reviewed-on: https://go-review.googlesource.com/11952
Reviewed-by: Rob Pike <r@golang.org>
9 years agocmd/go: disable vendoredImportPath for code outside $GOPATH go1.5beta1
Russ Cox [Tue, 7 Jul 2015 21:51:20 +0000 (17:51 -0400)]
cmd/go: disable vendoredImportPath for code outside $GOPATH

It was crashing.
This fixes the build for
GO15VENDOREXPERIMENT=1 go test -short runtime

Fixes #11416.

Change-Id: I74a9114cdd8ebafcc9d2a6f40bf500db19c6e825
Reviewed-on: https://go-review.googlesource.com/11964
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/compile: allow static init for unsafe.Pointer(&x) where x is global
Russ Cox [Mon, 29 Jun 2015 16:49:25 +0000 (12:49 -0400)]
cmd/compile: allow static init for unsafe.Pointer(&x) where x is global

This avoids both a write barrier and then dynamic initialization
globals of the form

var x something
var xp = unsafe.Pointer(&x)

Using static initialization avoids emitting a relocation for &x,
which helps cgo.

Fixes #9411.

Change-Id: I0dbf480859cce6ab57ab805d1b8609c45b48f156
Reviewed-on: https://go-review.googlesource.com/11693
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

9 years agonet/http: fix MaxBytesReader at EOF
Brad Fitzpatrick [Thu, 25 Jun 2015 23:11:14 +0000 (16:11 -0700)]
net/http: fix MaxBytesReader at EOF

Fixes #10884

Change-Id: I7cab3c96548867612f579d2cd4ec736309787443
Reviewed-on: https://go-review.googlesource.com/11961
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/http: revert overly-strict part of earlier smuggling defense
Brad Fitzpatrick [Tue, 7 Jul 2015 19:19:44 +0000 (13:19 -0600)]
net/http: revert overly-strict part of earlier smuggling defense

The recent https://golang.org/cl/11810 is reportedly a bit too
aggressive.

Apparently some HTTP requests in the wild do contain both a
Transfer-Encoding along with a bogus Content-Length. Instead of
returning a 400 Bad Request error, we should just ignore the
Content-Length like we did before.

Change-Id: I0001be90d09f8293a34f04691f608342875ff5c4
Reviewed-on: https://go-review.googlesource.com/11962
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd/compile: initialize line number properly for temporaries
David Chase [Mon, 29 Jun 2015 20:30:19 +0000 (16:30 -0400)]
cmd/compile: initialize line number properly for temporaries

The expansion of structure, array, slice, and map literals
does not use the right line number in its introduced assignments
to temporaries, which leads to incorrect line number attribution
for expressions in those literals.

Inlining also incorrectly replaced the line numbers of args to
inlined functions.

This was revealed in CL 9721 because a now-avoided temporary
assignment introduced the correct line number.
I.e. before CL 9721
  "tmp_wrongline := expr"
was transformed to
  "tmp_rightline := expr; tmp_wrongline := tmp_rightline"

Also includes a repair to CL 10334 involving line numbers
where a spurious -1 remained (should have been 0, now is 0).

Fixes #11400.

Change-Id: I3a4687efe463977fa1e2c996606f4d91aaf22722
Reviewed-on: https://go-review.googlesource.com/11730
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: randomize scheduling in -race mode
Russ Cox [Wed, 1 Jul 2015 18:12:31 +0000 (14:12 -0400)]
runtime: randomize scheduling in -race mode

Basic randomization of goroutine scheduling for -race mode.
It is probably possible to do much better (there's a paper linked
in the issue that I haven't read, for example), but this suffices
to introduce at least some unpredictability into the scheduling order.
The goal here is to have _something_ for Go 1.5, so that we don't
start hitting more of these scheduling order-dependent bugs
if we change the scheduler order again in Go 1.6.

For #11372.

Change-Id: Idf1154123fbd5b7a1ee4d339e93f97635cc2bacb
Reviewed-on: https://go-review.googlesource.com/11795
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/go: ignore volume name case when checking vendor path
Daniel Theophanes [Mon, 22 Jun 2015 17:59:24 +0000 (10:59 -0700)]
cmd/go: ignore volume name case when checking vendor path

Fixes #11409

Change-Id: Ic1610e124b2d8b2b12310fc9538d5078cc7302a0
Reviewed-on: https://go-review.googlesource.com/11316
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: create executable when installing to working directory
Ross Light [Thu, 25 Jun 2015 16:56:08 +0000 (09:56 -0700)]
cmd/go: create executable when installing to working directory

Fixes #11065.

Change-Id: Idd854facd5fa78c0334f86740f351d404f9a5b2d
Reviewed-on: https://go-review.googlesource.com/11511
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: do not panic on invalid import path containing "/vendor/"
Daniel Theophanes [Mon, 29 Jun 2015 17:08:58 +0000 (10:08 -0700)]
cmd/go: do not panic on invalid import path containing "/vendor/"

Fixes #11414

Change-Id: I45a41b98554f00362d9222e9c68a441dbfc23cb8
Reviewed-on: https://go-review.googlesource.com/11700
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http/httputil: make ReverseProxy support Trailers
Brad Fitzpatrick [Mon, 6 Jul 2015 22:57:35 +0000 (15:57 -0700)]
net/http/httputil: make ReverseProxy support Trailers

Go's continuous build system depends on HTTP trailers for the buildlet
interface.

Andrew rewrote the makerelease tool to work in terms of Go's builder
system (now at x/build/cmd/release), but it previously could only
create GCE-based buildlets, which meant x/build/cmd/release couldn't
build the release for Darwin.

https://golang.org/cl/11901 added support for proxying buildlet
connections via the coordinator, but that exposed the fact that
httputil.ReverseProxy couldn't proxy Trailers. A fork of that code
also wasn't possible because net/http needlessly deleted the "Trailer"
response header in the Transport code.  This mistake goes back to
"release-branch.r56" and earlier but was never noticed because nobody
ever uses Trailers, and servers via ResponseWriter never had the
ability to even set trailers before this Go 1.5. Note that setting
trailers requires pre-declaring (in the response header) which
trailers you'll set later (after the response body). Because you could
never set them, before this release you could also never proxy them.

Change-Id: I2410a099921790dcd391675ae8610300efa19108
Reviewed-on: https://go-review.googlesource.com/11940
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agodoc: tools for go1.5.html
Rob Pike [Sun, 5 Jul 2015 23:01:32 +0000 (09:01 +1000)]
doc: tools for go1.5.html

Don't know why, but git deleted the previous version of this change.
This is the same change as https://go-review.googlesource.com/11884,
which I will now abandon, with a couple of fixes.

Almost all done now. Could use help with the TODOs.

Major missing piece is the trace command. Vendoring
section is also weak, but it's also undocumented elsewhere.

Change-Id: I5d8556b23aa6628eb7bf0e330d4dd8d4ac2157c5
Reviewed-on: https://go-review.googlesource.com/11887
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agodoc/go1.5.html: fix typo
Elias Naur [Sat, 4 Jul 2015 16:33:21 +0000 (18:33 +0200)]
doc/go1.5.html: fix typo

Change-Id: If33ffe1da23a8463fc5479f453422d280b736372
Reviewed-on: https://go-review.googlesource.com/11865
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/go: delete references to old tools (5a etc.) from cmd/go docs
Rob Pike [Sun, 5 Jul 2015 00:43:34 +0000 (10:43 +1000)]
cmd/go: delete references to old tools (5a etc.) from cmd/go docs

Don't talk about commands that no longer exist.

There are still references throughout the tree, mostly in comments,
but they provide a charming historical backdrop for the idle tourist.

Change-Id: I637ebdce05bbc7df5addcc46cb772d2bb9f3e073
Reviewed-on: https://go-review.googlesource.com/11885
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agomath/rand: improve NewZipf documentation
Josh Bleecher Snyder [Fri, 3 Jul 2015 18:11:42 +0000 (11:11 -0700)]
math/rand: improve NewZipf documentation

Change-Id: I78f0f9ac33db153c4a0d7f9866da20ebcd3d3639
Reviewed-on: https://go-review.googlesource.com/11872
Reviewed-by: Rob Pike <r@golang.org>
9 years agoimage/draw: fix double-draw when the dst is paletted.
Nigel Tao [Fri, 3 Jul 2015 01:34:18 +0000 (11:34 +1000)]
image/draw: fix double-draw when the dst is paletted.

The second (fallback) draw is a no-op, but it's a non-trivial amount of work.

Fixes #11550.

benchmark               old ns/op     new ns/op     delta
BenchmarkPaletted-4     16301219      7309568       -55.16%

Change-Id: Ic88c537b2b0c710cf517888f3dd15cb702dd142f
Reviewed-on: https://go-review.googlesource.com/11858
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agodoc: finish the small library changes in go1.5.html; start work on tools
Rob Pike [Thu, 2 Jul 2015 02:56:51 +0000 (12:56 +1000)]
doc: finish the small library changes in go1.5.html; start work on tools

Also add words about the assembler.

Change-Id: I9bd8cc88076f06b0eef36a07f57d1ad5d9261d8d
Reviewed-on: https://go-review.googlesource.com/11853
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/trace: log errors to console in AJAX handler
Dmitry Vyukov [Thu, 2 Jul 2015 18:33:30 +0000 (20:33 +0200)]
cmd/trace: log errors to console in AJAX handler

Fixes #11508

Change-Id: I72e83893b76f75685d6edfe65ca6691d97539226
Reviewed-on: https://go-review.googlesource.com/11864
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoRevert "net, internal/syscall/unix: add SocketConn, SocketPacketConn"
Mikio Hara [Thu, 2 Jul 2015 06:02:03 +0000 (15:02 +0900)]
Revert "net, internal/syscall/unix: add SocketConn, SocketPacketConn"

This reverts commit 6f7961da28232c609f7c51b3bed7f15db7dd33e1.

Russ suggests changing the frozon syscall package and obviously it's a
better solution. Perhaps he will also let me know the way how to get the
project owners to agree later.

Fixes #11492.

Change-Id: I98f9f366b72b85db54b4acfc3a604b62fb6d783c
Reviewed-on: https://go-review.googlesource.com/11854
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agomime/multipart: fix bug when body contains prefix of the boundary
Brad Fitzpatrick [Tue, 30 Jun 2015 23:50:36 +0000 (16:50 -0700)]
mime/multipart: fix bug when body contains prefix of the boundary

Fixes #10616

Change-Id: I4ef25eb0be6ccf474976fdb5087dd2c62c66c510
Reviewed-on: https://go-review.googlesource.com/11811
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agointernal/trace: add comment for stable sort
Dmitry Vyukov [Thu, 2 Jul 2015 12:35:23 +0000 (14:35 +0200)]
internal/trace: add comment for stable sort

As per comments in cl/11834.

Change-Id: I285536b882fa9496e15d77d0d4c16ee913aca581
Reviewed-on: https://go-review.googlesource.com/11861
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocrypto: fix non-sentence in documentation for Decrypter
Rob Pike [Thu, 2 Jul 2015 02:42:55 +0000 (12:42 +1000)]
crypto: fix non-sentence in documentation for Decrypter

Comment change only.

Change-Id: I2e32c2b34d5a5659ead6d6082b06e1b039bf1147
Reviewed-on: https://go-review.googlesource.com/11852
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agointernal/trace: stable sort events
Dmitry Vyukov [Wed, 1 Jul 2015 14:41:27 +0000 (16:41 +0200)]
internal/trace: stable sort events

On some VMs two events can happen at the same time. For examples:
179827399 GoStart p=2 g=11 off=936359 g=11
179827399 GoUnblock p=2 g=0 off=936355 g=11
If we do non-stable sort, the events can be reordered making the trace inconsistent.
Do stable sort instead.

Batches are dumped in FIFO order, so if these same-time events are split into
separate batches, stable sort still works.

Events on different CPUs go into different batches and can be reordered.
But the intention is that causally-related events on different CPUs
will have larger (non-zero) time diff.

Update #11320

Change-Id: Id1df96af41dff68ea1782ab4b23d5afd63b890c9
Reviewed-on: https://go-review.googlesource.com/11834
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agodoc: add most major changes and most net changes to go1.5.html
Rob Pike [Wed, 1 Jul 2015 05:49:40 +0000 (15:49 +1000)]
doc: add most major changes and most net changes to go1.5.html

Change-Id: Ied305480f22b60767c4628e5a31236ac01eafc86
Reviewed-on: https://go-review.googlesource.com/11825
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoencoding/xml: minor changes
Roger Peppe [Wed, 1 Jul 2015 08:22:43 +0000 (09:22 +0100)]
encoding/xml: minor changes

Changes suggested by Nigel Tao in https://go-review.googlesource.com/#/c/11635
after that had been submitted.

Change-Id: I7b28e1c8488c8565399a8017453dc7ff1fd215e8
Reviewed-on: https://go-review.googlesource.com/11832
Reviewed-by: Nigel Tao <nigeltao@golang.org>
9 years agocmd/trace: fix time scale
Dmitry Vyukov [Thu, 18 Jun 2015 14:27:29 +0000 (16:27 +0200)]
cmd/trace: fix time scale

Integrate the latest trace-viewer changes.
It now handles nanoseconds without any issues (thanks to @egonelbre!).
So change timestamps from microseconds to nanoseconds.

Change-Id: I010f27effde7e80c9992e6f276f6912354d27df4
Reviewed-on: https://go-review.googlesource.com/11244
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Egon Elbre <egonelbre@gmail.com>
9 years agodoc: more library in go1.5.html
Rob Pike [Tue, 30 Jun 2015 22:48:19 +0000 (08:48 +1000)]
doc: more library in go1.5.html

Everything in the library but crypto and net.

Change-Id: I89b21b9621e6d338fa1891da0eabba5d7d2fe349
Reviewed-on: https://go-review.googlesource.com/11820
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodatabase/sql: make Register safe for concurrent use
Brad Fitzpatrick [Tue, 30 Jun 2015 00:56:20 +0000 (17:56 -0700)]
database/sql: make Register safe for concurrent use

Adding a mutex was easier than documenting it, and is consistent with
gob.

Fixes #9847

Change-Id: Ifa94c17e7c11643add81b35431ef840b794d78b1
Reviewed-on: https://go-review.googlesource.com/11682
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/http: harden Server against request smuggling
Brad Fitzpatrick [Tue, 30 Jun 2015 21:21:15 +0000 (14:21 -0700)]
net/http: harden Server against request smuggling

See RFC 7230.

Thanks to Régis Leroy for the report.

Change-Id: Ic1779bc2180900430d4d7a4938cac04ed73c304c
Reviewed-on: https://go-review.googlesource.com/11810
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agointernal/singleflight: deflake test
Brad Fitzpatrick [Tue, 30 Jun 2015 15:32:02 +0000 (08:32 -0700)]
internal/singleflight: deflake test

Fixes #11475

Change-Id: Ibaedbb732bb1b9f062bd5af7b866ec4758c724a7
Reviewed-on: https://go-review.googlesource.com/11770
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agogo/types: change {Type,Object,Selection}String to accept a Qualifier function
Alan Donovan [Tue, 30 Jun 2015 19:07:20 +0000 (15:07 -0400)]
go/types: change {Type,Object,Selection}String to accept a Qualifier function

The optional Qualifier function determines what prefix to attach to
package-level names, enabling clients to qualify packages in different
ways, for example, using only the package name instead of its complete
path, or using the locally appropriate name for package given a set of
(possibly renaming) imports.

Prior to this change, clients wanting this behavior had to copy
hundreds of lines of complex printing logic.

Fun fact: (*types.Package).Path and (*types.Package).Name are valid
Qualifier functions.

We provide the RelativeTo helper function to create Qualifiers so that
the old behavior remains a one-liner.

Fixes golang/go#11133

This CL is a copy of https://go-review.googlesource.com/#/c/11692/
to the golang.org/x/tools repository.

Change-Id: I26d0f3644d077a26bfe350989f9c545f018eefbf
Reviewed-on: https://go-review.googlesource.com/11790
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>

9 years agocmd/link: reject data size > 2 GB
Russ Cox [Mon, 29 Jun 2015 20:44:45 +0000 (16:44 -0400)]
cmd/link: reject data size > 2 GB

We can't address more than this on amd64 anyway.

Fixes #9862.

Change-Id: Ifb1abae558e2e1ee2dc953a76995f3f08c60b1df
Reviewed-on: https://go-review.googlesource.com/11715
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/compile: allow linker to drop string headers when not needed
Russ Cox [Mon, 29 Jun 2015 17:50:30 +0000 (13:50 -0400)]
cmd/compile: allow linker to drop string headers when not needed

Compiling a simple file containing a slice of 100,000 strings,
the size of the resulting binary dropped from 5,896,224 bytes
to 3,495,968 bytes, which is the expected 2,400,000 bytes,
give or take.

Fixes #7384.

Change-Id: I3e551b5a1395b523a41b33518d81a1bf28da0906
Reviewed-on: https://go-review.googlesource.com/11698
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/compile: fix race detector handling of OBLOCK nodes
Russ Cox [Mon, 29 Jun 2015 19:17:14 +0000 (15:17 -0400)]
cmd/compile: fix race detector handling of OBLOCK nodes

Fixes #7561 correctly.
Fixes #9137.

Change-Id: I7f27e199d7101b785a7645f789e8fe41a405a86f
Reviewed-on: https://go-review.googlesource.com/11713
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
9 years agonet/textproto: don't treat spaces as hyphens in header keys
Brad Fitzpatrick [Tue, 30 Jun 2015 16:22:41 +0000 (09:22 -0700)]
net/textproto: don't treat spaces as hyphens in header keys

This was originally done in https://codereview.appspot.com/5690059
(Feb 2012) to deal with bad response headers coming back from webcams,
but it presents a potential security problem with HTTP request
smuggling for request headers containing "Content Length" instead of
"Content-Length".

Part of overall HTTP hardening for request smuggling. See RFC 7230.

Thanks to Régis Leroy for the report.

Change-Id: I92b17fb637c9171c5774ea1437979ae2c17ca88a
Reviewed-on: https://go-review.googlesource.com/11772
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd/trace: sort procs
Dmitry Vyukov [Tue, 30 Jun 2015 12:09:41 +0000 (14:09 +0200)]
cmd/trace: sort procs

If you have more than 10 procs, then currently they are sorted alphabetically as
0, 10, 11, ..., 19, 2, 20, ...
Assign explicit order to procs so that they are sorted numerically.

Change-Id: I6d978d2cd439aa2fcbcf147842a643f9073eef75
Reviewed-on: https://go-review.googlesource.com/11750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http: harden, document func SetCookie and type Cookie
Brad Fitzpatrick [Tue, 30 Jun 2015 01:10:43 +0000 (18:10 -0700)]
net/http: harden, document func SetCookie and type Cookie

Fixes #9758

Change-Id: I3089ec06cddd74b547d8b10834d7478a04b02069
Reviewed-on: https://go-review.googlesource.com/11701
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/url: only record RawPath when it is needed
Russ Cox [Tue, 30 Jun 2015 15:28:29 +0000 (11:28 -0400)]
net/url: only record RawPath when it is needed

RawPath is a hint to the desired encoding of Path.
It is ignored when it is not a valid encoding of Path,
such as when Path has been changed but RawPath has not.
It is not ignored but also not useful when it matches
the url package's natural choice of encoding.
In this latter case, set it to the empty string.
This should help drive home the point that clients
cannot in general depend on it being present and
that they should use the EncodedPath method instead.

This also reduces the impact of the change on tests,
especially tests that use reflect.DeepEqual on parsed URLs.

Change-Id: I437c51a33b85439a31c307caf1436118508ea196
Reviewed-on: https://go-review.googlesource.com/11760
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/compile/internal/gc: give OASWB name
Dmitry Vyukov [Tue, 30 Jun 2015 11:58:54 +0000 (13:58 +0200)]
cmd/compile/internal/gc: give OASWB name

Change-Id: Iacb84421215ca80c7add2818118b2af1a650fd58
Reviewed-on: https://go-review.googlesource.com/11639
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoencoding/xml: fix xmlns= behavior
Roger Peppe [Mon, 29 Jun 2015 11:36:48 +0000 (12:36 +0100)]
encoding/xml: fix xmlns= behavior

When an xmlns="..." attribute was explicitly generated,
it was being ignored because the name space on the
attribute was assumed to have been explicitly set (to the empty
name space) and it's not possible to have an element in the
empty name space when there is a non-empty name space set.

We fix this by recording when a default name space has been
explicitly set and setting the name space of the element to that
so printer.defineNS can do its work correctly.

We do not attempt to add our own xmlns="..." attribute
when one is explicitly set.

We also add tests for EncodeElement, as that's the only way
to attain coverage of some of the changed behaviour.
Some other test coverage is also increased, although
more work remains to be done in this area.

This change was jointly developed with Martin Hilton (mhilton on github).

Fixes #11431.

Change-Id: I7b85e06eea5b18b2c15ec16dcbd92a8e1d6a9a4e
Reviewed-on: https://go-review.googlesource.com/11635
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: use GOOS and GOARCH from build context for "go generate"
Andrew Gerrand [Tue, 30 Jun 2015 05:35:01 +0000 (15:35 +1000)]
cmd/go: use GOOS and GOARCH from build context for "go generate"

Fixes #11438

Change-Id: Iedd31918aa5187fc3fdaed71c8dad82075559084
Reviewed-on: https://go-review.googlesource.com/11667
Reviewed-by: Rob Pike <r@golang.org>
9 years agoimage/gif: accept LZW encodings that do not have an explicit end marker.
Nigel Tao [Mon, 29 Jun 2015 06:43:25 +0000 (16:43 +1000)]
image/gif: accept LZW encodings that do not have an explicit end marker.

The spec says this is invalid, but it matches giflib's behavior.

Fixes #9856 (together with https://go-review.googlesource.com/11661).

Change-Id: I05701f62a9e5e724a2d85c6b87ae4111e537146b
Reviewed-on: https://go-review.googlesource.com/11663
Reviewed-by: Rob Pike <r@golang.org>
9 years agocompress/lzw: return the partial decoding for a truncated input.
Nigel Tao [Mon, 29 Jun 2015 06:22:54 +0000 (16:22 +1000)]
compress/lzw: return the partial decoding for a truncated input.

This is needed by issue #9856.

Change-Id: Idad570a7e55ad903aab55372d390bc746c4e19cf
Reviewed-on: https://go-review.googlesource.com/11661
Reviewed-by: Rob Pike <r@golang.org>
9 years agoarchive/tar: move round-trip reading into common os file
Alex Brainman [Mon, 29 Jun 2015 06:42:28 +0000 (16:42 +1000)]
archive/tar: move round-trip reading into common os file

Fixes #11426

Change-Id: I77368b0e852149ed4533e139cc43887508ac7f78
Reviewed-on: https://go-review.googlesource.com/11662
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http: add a Request.Cancel channel.
Aaron Jacobs [Mon, 29 Jun 2015 00:07:31 +0000 (10:07 +1000)]
net/http: add a Request.Cancel channel.

This allows for "race free" cancellation, in the sense discussed in
issue #11013: in contrast to Transport.CancelRequest, the cancellation
will not be lost if the user cancels before the request is put into the
transport's internal map.

Fixes #11013.

Change-Id: I0b5e7181231bdd65d900e343f764b4d1d7c422cd
Reviewed-on: https://go-review.googlesource.com/11601
Run-TryBot: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/compile: reject large floating point exponents without math/big
Russ Cox [Mon, 29 Jun 2015 03:25:38 +0000 (23:25 -0400)]
cmd/compile: reject large floating point exponents without math/big

For #11326 (but not a fix).

Change-Id: Ic51814f5cd7357427c3fd990a5522775d05e7987
Reviewed-on: https://go-review.googlesource.com/11673
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agoio: tweak Reader comment
Russ Cox [Mon, 29 Jun 2015 14:58:54 +0000 (10:58 -0400)]
io: tweak Reader comment

I think this has the same meaning as before,
but the text is tighter, and it makes some people happy.

Fixes #10182.

Change-Id: I7ee1eae4bcd6ee4a5898ea948648939e6bde5f01
Reviewed-on: https://go-review.googlesource.com/11674
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agopath/filepath: document and test behavior of SkipDir on files
Russ Cox [Mon, 29 Jun 2015 15:53:51 +0000 (11:53 -0400)]
path/filepath: document and test behavior of SkipDir on files

This behavior is not what we might have designed from the start,
but it has been present since Go 1. Rather than make a visible
behavioral change that might cause programs to work differently
in Go ≤1.4 vs Go ≥1.5, document what SkipDir on a non-directory
has always meant. If code doesn't want this meaning, it is easy
enough not to return SkipDir on non-directories.

Fixes #10533.

Change-Id: Ic0612f032044bc7c69bf62583a02037e4b47530b
Reviewed-on: https://go-review.googlesource.com/11690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agocmd/link: detect -X setting non-string variable
Russ Cox [Mon, 29 Jun 2015 17:03:11 +0000 (13:03 -0400)]
cmd/link: detect -X setting non-string variable

Fixes #9621.

Change-Id: Ib9c6001378364af899f57fd4b89fb23af2042923
Reviewed-on: https://go-review.googlesource.com/11694
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

9 years agodoc: finish listing the non-crypto non-net small API changes
Rob Pike [Mon, 29 Jun 2015 09:51:56 +0000 (19:51 +1000)]
doc: finish listing the non-crypto non-net small API changes

Change-Id: I5791639e71874ce13fac836a0c6014e20ee7417e
Reviewed-on: https://go-review.googlesource.com/11664
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agogo/types: go/types: add an API test of the Scope type
Alan Donovan [Mon, 29 Jun 2015 20:13:09 +0000 (16:13 -0400)]
go/types: go/types: add an API test of the Scope type

Also: make (*Scope).Innermost work for Package scopes.

This change is identical to http://go-review.googlesource.com/#/c/11691/,
except for minor changes required by the use of testImporter.

Change-Id: Id07e66f78987f7242c2e642dfd6ee613676e10e5
Reviewed-on: https://go-review.googlesource.com/11714
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agocmd/link: fix -s with external linking
Russ Cox [Mon, 29 Jun 2015 17:12:10 +0000 (13:12 -0400)]
cmd/link: fix -s with external linking

This code used to only be run for ELF, with the predictable
result that using -s with external linking broke on Windows and OS X.
Moving it here should fix Windows and does fix OS X.

CL 10835 also claims to fix the crash on Windows.
I don't know whether it does so correctly, but regardless,
this CL should make that one a no-op.

Fixes #10254.

Change-Id: I2e7b45ab0c28568ddbb1b50581dcc157ae0e7ffe
Reviewed-on: https://go-review.googlesource.com/11695
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/compile: enable PAUTO capture variables on arch != 6
Russ Cox [Mon, 29 Jun 2015 17:56:27 +0000 (13:56 -0400)]
cmd/compile: enable PAUTO capture variables on arch != 6

Fixes #9865.

Change-Id: I8ce5b1708ed938910c59899706e470271c2e7e9d
Reviewed-on: https://go-review.googlesource.com/11699
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocrypto/rsa: check for primes ≤ 1 in Validate
Adam Langley [Sat, 27 Jun 2015 21:50:39 +0000 (14:50 -0700)]
crypto/rsa: check for primes ≤ 1 in Validate

Change 7c7126cfeb82894229b9c3d5109e4b04e6cfde0c removed the primality
checking in Validate to save CPU time. That check happened to be
filtering out private keys with primes that were zero or one. Without
that filtering, such primes cause a panic when trying to use such a
private key.

This change specifically checks for and rejects primes ≤ 1 in Validate.

Fixes #11233.

Change-Id: Ie6537edb8250c07a45aaf50dab43227002ee7386
Reviewed-on: https://go-review.googlesource.com/11611
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http/httptest: increase test Server's key size
Brad Fitzpatrick [Mon, 29 Jun 2015 18:37:13 +0000 (11:37 -0700)]
net/http/httptest: increase test Server's key size

Fixes #10725

Change-Id: Ic8685dc238a0ffc95fafb512a8587d2eb5fe9d5f
Reviewed-on: https://go-review.googlesource.com/11720
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd/go: 'go env' print GO15VENDOREXPERIMENT in Go1.5
Tom Heng [Mon, 29 Jun 2015 13:55:13 +0000 (21:55 +0800)]
cmd/go: 'go env' print GO15VENDOREXPERIMENT in Go1.5

Fixes #11410

Change-Id: I9d01be3e01f74f4b12a516aba8a5d20d9b277ec6
Reviewed-on: https://go-review.googlesource.com/11539
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agosync: disable flaky WaitGroup misuse test in short mode
Brad Fitzpatrick [Mon, 29 Jun 2015 18:40:13 +0000 (11:40 -0700)]
sync: disable flaky WaitGroup misuse test in short mode

Update #11443

Change-Id: Icb7ea291a837dcf2799a791a2ba780fd2a5e712b
Reviewed-on: https://go-review.googlesource.com/11721
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
9 years agocmd/go: disable TestIssue10952 without external network
Russ Cox [Mon, 29 Jun 2015 17:58:18 +0000 (13:58 -0400)]
cmd/go: disable TestIssue10952 without external network

Should fix arm64 build failure.

Change-Id: Ib35e4a69a1082e461a1eddf3265544a1d2ff98e5
Reviewed-on: https://go-review.googlesource.com/11710
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/compile: allow unnamed constants to set line number
Russ Cox [Mon, 29 Jun 2015 03:12:21 +0000 (23:12 -0400)]
cmd/compile: allow unnamed constants to set line number

Fixes #8836.

Change-Id: Idda9f4a987e03b3bdf5e8fdb984fe56d6f84aa59
Reviewed-on: https://go-review.googlesource.com/11672
Reviewed-by: David Chase <drchase@google.com>
9 years agoruntime: fix broken arm builds
Russ Cox [Mon, 29 Jun 2015 17:32:09 +0000 (13:32 -0400)]
runtime: fix broken arm builds

Change-Id: I08de33aacb3fc932722286d69b1dd70ffe787c89
Reviewed-on: https://go-review.googlesource.com/11697
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/link: record missing pcdata tables correctly
Russ Cox [Mon, 29 Jun 2015 02:26:35 +0000 (22:26 -0400)]
cmd/link: record missing pcdata tables correctly

The old code was recording the current table output offset,
so the table from the next function would be used instead of
the runtime realizing that there was no table at all.

Add debug constant in runtime to check this for every function
at startup. It's too expensive to do that by default, but we can
do the last five functions. The end of the table is usually where
the C symbols end up, so that's where the problems typically are.

Fixes #10747.
Fixes #11396.

Change-Id: I13592e78017969fc22979fa902e19e1b151d41b1
Reviewed-on: https://go-review.googlesource.com/11657
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

9 years agoruntime: reset mark state before checkmark and gctrace=2 mark
Austin Clements [Fri, 26 Jun 2015 17:56:58 +0000 (13:56 -0400)]
runtime: reset mark state before checkmark and gctrace=2 mark

Currently we fail to reset the live heap accounting state before the
checkmark mark and before the gctrace=2 extra mark. As a result, if
either are enabled, at the end of GC it thinks there are 0 bytes of
live heap, which causes the GC controller to initiate a new GC
immediately, regardless of the true heap size.

Fix this by factoring this state reset into a function and calling it
before all three possible marks.

This function should be merged with gcResetGState, but doing so
requires some additional cleanup, so it will wait for after the
freeze. Filed #11427 for this cleanup.

Fixes #10492.

Change-Id: Ibe46348916fc8368fac6f086e142815c970a6f4d
Reviewed-on: https://go-review.googlesource.com/11561
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: don't free stack spans during GC
Austin Clements [Mon, 22 Jun 2015 14:24:50 +0000 (10:24 -0400)]
runtime: don't free stack spans during GC

Memory for stacks is manually managed by the runtime and, currently
(with one exception) we free stack spans immediately when the last
stack on a span is freed. However, the garbage collector assumes that
spans can never transition from non-free to free during scan or mark.
This disagreement makes it possible for the garbage collector to mark
uninitialized objects and is blocking us from re-enabling the bad
pointer test in the garbage collector (issue #9880).

For example, the following sequence will result in marking an
uninitialized object:

1. scanobject loads a pointer slot out of the object it's scanning.
   This happens to be one of the special pointers from the heap into a
   stack. Call the pointer p and suppose it points into X's stack.

2. X, running on another thread, grows its stack and frees its old
   stack.

3. The old stack happens to be large or was the last stack in its
   span, so X frees this span, setting it to state _MSpanFree.

4. The span gets reused as a heap span.

5. scanobject calls heapBitsForObject, which loads the span containing
   p, which is now in state _MSpanInUse, but doesn't necessarily have
   an object at p. The not-object at p gets marked, and at this point
   all sorts of things can go wrong.

We already have a partial solution to this. When shrinking a stack, we
put the old stack on a queue to be freed at the end of garbage
collection. This was done to address exactly this problem, but wasn't
a complete solution.

This commit generalizes this solution to both shrinking and growing
stacks. For stacks that fit in the stack pool, we simply don't free
the span, even if its reference count reaches zero. It's fine to reuse
the span for other stacks, and this enables that. At the end of GC, we
sweep for cached stack spans with a zero reference count and free
them. For larger stacks, we simply queue the stack span to be freed at
the end of GC. Ideally, we would reuse these large stack spans the way
we can small stack spans, but that's a more invasive change that will
have to wait until after the freeze.

Fixes #11267.

Change-Id: Ib7f2c5da4845cc0268e8dc098b08465116972a71
Reviewed-on: https://go-review.googlesource.com/11502
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: remove unused _GCsweep state
Austin Clements [Thu, 25 Jun 2015 16:24:44 +0000 (12:24 -0400)]
runtime: remove unused _GCsweep state

We don't use this state. _GCoff means we're sweeping in the
background. This makes it clear in the next commit that _GCoff and
only _GCoff means sweeping.

Change-Id: I416324a829ba0be3794a6cf3cf1655114cb6e47c
Reviewed-on: https://go-review.googlesource.com/11501
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/cgo: fix a problem with 'go build -compiler gccgo'
Russ Cox [Mon, 29 Jun 2015 03:04:05 +0000 (23:04 -0400)]
cmd/cgo: fix a problem with 'go build -compiler gccgo'

Port of https://golang.org/cl/154360045 to Git.
Original author is Xia Bin <snyh@snyh.org> (already a contributor).

Fixes #8945.

Change-Id: I28bcaf3348794202ca59fbc3466bd7b9670030e4
Reviewed-on: https://go-review.googlesource.com/11658
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: always clear stack barriers on G exit
Austin Clements [Wed, 24 Jun 2015 21:13:24 +0000 (17:13 -0400)]
runtime: always clear stack barriers on G exit

Currently the runtime fails to clear a G's stack barriers in gfput if
the G's stack allocation is _FixedStack bytes. This causes the runtime
to panic if the following sequence of events happens:

1) The runtime installs stack barriers on a G.

2) The G exits by calling runtime.Goexit. Since this does not
   necessarily return through the stack barriers installed on the G,
   there may still be untriggered stack barriers left on the G's stack
   in recorded in g.stkbar.

3) The runtime calls gfput to add the exiting G to the free pool. If
   the G's stack allocation is _FixedStack bytes, we fail to clear
   g.stkbar.

4) A new G starts and allocates the G that was just added to the free
   pool.

5) The new G begins to execute and overwrites the stack slots that had
   stack barriers in them.

6) The garbage collector enters mark termination, attempts to remove
   stack barriers from the new G, and finds that they've been
   overwritten.

Fix this by clearing the stack barriers in gfput in the case where it
reuses the stack.

Fixes #11256.

Change-Id: I377c44258900e6bcc2d4b3451845814a8eeb2bcf
Reviewed-on: https://go-review.googlesource.com/11461
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoencoding/binary: update protobuf documentation link
Dmitry Savintsev [Mon, 29 Jun 2015 11:09:06 +0000 (13:09 +0200)]
encoding/binary: update protobuf documentation link

Updated the protobuf documentation URL (code.google.com deprecated)
to avoid a redirect.

Change-Id: I134f6e4a2bf2bba699942883bf6347bc61700bcb
Reviewed-on: https://go-review.googlesource.com/11634
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agofmt: restore padding for %x on byte slices and strings
Rob Pike [Sat, 27 Jun 2015 01:07:30 +0000 (11:07 +1000)]
fmt: restore padding for %x on byte slices and strings

Also improve the documentation. A prior fix in this release
changed the properties for empty strings and slices, incorrectly.
Previous behavior is now restored and better documented.

Add lots of tests.

The behavior is that when using a string-like format (%s %q %x %X)
a byte slice is equivalent to a string, and printed as a unit. The padding
applies to the entire object. (The space and sharp flags apply
elementwise.)

Fixes #11422.
Fixes #10430.

Change-Id: I758f0521caf71630437e43990ec6d6c9a92655e3
Reviewed-on: https://go-review.googlesource.com/11600
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc: fix typo in faq
Rob Pike [Mon, 29 Jun 2015 05:43:42 +0000 (15:43 +1000)]
doc: fix typo in faq

Change-Id: Id2cfa63d4c749503f729097654d7cbd2b252f192
Reviewed-on: https://go-review.googlesource.com/11660
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agodoc: update FAQ for Go 1.5
Rob Pike [Mon, 29 Jun 2015 03:27:41 +0000 (13:27 +1000)]
doc: update FAQ for Go 1.5

Change-Id: I4befb21d0811819ce0a5721421a2f6df7a9b62fa
Reviewed-on: https://go-review.googlesource.com/11605
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agonet/http: fix now-flaky TransportAndServerSharedBodyRace test
Brad Fitzpatrick [Sat, 27 Jun 2015 03:51:13 +0000 (20:51 -0700)]
net/http: fix now-flaky TransportAndServerSharedBodyRace test

TestTransportAndServerSharedBodyRace got flaky after
issue #9662 was fixed by https://golang.org/cl/11412, which made
servers hang up on clients when a Handler stopped reading its body
early.

This test was affected by a race between the the two goroutines in the
test both only reading part of the request, which was an unnecessary
detail for what the test was trying to test (concurrent Read/Close
races on an *http.body)

Also remove an unused remnant from an old test from which this one was
derived. And make the test not deadlock when it fails. (which was why
the test was showing up as 2m timeouts on the dashboard)

Fixes #11418

Change-Id: Ic83d18aef7e09a9cd56ac15e22ebed75713026cb
Reviewed-on: https://go-review.googlesource.com/11610
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agosyscall: return error instead of panicking in windows StartProcess
Alex Brainman [Mon, 29 Jun 2015 01:19:33 +0000 (11:19 +1000)]
syscall: return error instead of panicking in windows StartProcess

Fixes #11417

Change-Id: Iacea829a48b39df0a4f751b06b19e918fbb713d0
Reviewed-on: https://go-review.googlesource.com/11604
Reviewed-by: Rob Pike <r@golang.org>
9 years agocmd/link/internal/ld: exclude only real container symbols from symtab
Keith Randall [Sat, 27 Jun 2015 19:57:06 +0000 (12:57 -0700)]
cmd/link/internal/ld: exclude only real container symbols from symtab

It looks like the test for whether symbols contain subsymbols is wrong.
In particular, symbols in C libraries are mistakenly considered container
symbols.

Fix the test so only symbols which actually have a subsymbol
are excluded from the symtab.  When linking cgo programs the list
of containers is small, something like:

container _/home/khr/sandbox/symtab/misc/cgo/test(.text)<74>
container _/home/khr/sandbox/symtab/misc/cgo/test/issue8828(.text)<75>
container _/home/khr/sandbox/symtab/misc/cgo/test/issue9026(.text)<76>
container runtime/cgo(.text)<77>

I'm not sure this is the right fix.  In particular I can't reproduce
the original problem.  Anyone have a repro they can try and see if
this fix works?

Fixes #10747
Fixes #11396

Change-Id: Id8b016389d33348b4a791fdcba0f9db8ae71ebf3
Reviewed-on: https://go-review.googlesource.com/11652
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoencoding/asn1: don't parse invalid UTF-8.
Adam Langley [Sat, 13 Jun 2015 20:50:02 +0000 (13:50 -0700)]
encoding/asn1: don't parse invalid UTF-8.

Invalid UTF-8 triggers an error when marshaling but, previously, not
when unmarshaling. This means that ASN.1 structures were not
round-tripping.

This change makes invalid UTF-8 in a string marked as UTF-8 to be an
error when Unmarshaling.

Fixes #11126.

Change-Id: Ic37be84d21dc5c03983525e244d955a8b1e1ff14
Reviewed-on: https://go-review.googlesource.com/11056
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoencoding/asn1: be stricter by reserialising parsed times.
Adam Langley [Sun, 14 Jun 2015 17:48:13 +0000 (10:48 -0700)]
encoding/asn1: be stricter by reserialising parsed times.

The time package does normalisation of times: for example day zero is
converted to the last day of the previous month and the 31st of February
is moved into March etc. This makes the ASN.1 parsing a little
worryingly lax.

This change causes the parser to reserialise parsed times to ensure that
they round-trip correctly and thus were not normalised.

Fixes #11134.

Change-Id: I3988bb95153a7b33d64ab861fbe51b1a34a359e9
Reviewed-on: https://go-review.googlesource.com/11094
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: store syscall parameters in m not on stack
Alex Brainman [Fri, 22 May 2015 00:58:57 +0000 (10:58 +1000)]
runtime: store syscall parameters in m not on stack

Stack can move during callback, so libcall struct cannot be stored on stack.
asmstdcall updates return values and errno in libcall struct parameter, but
these could be at different location when callback returns.
Store these in m, so they are not affected by GC.

Fixes #10406

Change-Id: Id01c9d2b4b44530494e6d9e9e1c875261ce477cd
Reviewed-on: https://go-review.googlesource.com/10370
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: reset read-only flag during TestIssue10952
Alex Brainman [Mon, 29 Jun 2015 00:14:24 +0000 (10:14 +1000)]
cmd/go: reset read-only flag during TestIssue10952

git sets read-only flag on all its repo files on Windows.
os.Remove cannot delete these files.

Fixes windows build

Change-Id: Icaf72470456b88a1c26295caecd4e0d3dc22a1b6
Reviewed-on: https://go-review.googlesource.com/11602
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 years agobuiltin: remove errant space in hyphenated adjective phrase
Brad Fitzpatrick [Sun, 28 Jun 2015 19:21:42 +0000 (12:21 -0700)]
builtin: remove errant space in hyphenated adjective phrase

Change-Id: I67947e0e3189093e830120941ee49f9f32086f0e
Reviewed-on: https://go-review.googlesource.com/11615
Reviewed-by: Rob Pike <r@golang.org>
9 years agonet/http: fix race on postPendingDial test hook
Todd Neal [Thu, 18 Jun 2015 12:26:39 +0000 (07:26 -0500)]
net/http: fix race on postPendingDial test hook

The race occurs rarely, but by putting some delays and more reads/writes
of prePendingDial/postPendingDial in the handlePendingDial function I
could reproduce it.

Fixes #11136

Change-Id: I8da9e66c88fbda049eaaaaffa2717264ef327768
Reviewed-on: https://go-review.googlesource.com/11250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agohtml/template: prevent panic while escaping pipelines
Didier Spezia [Mon, 8 Jun 2015 20:04:14 +0000 (20:04 +0000)]
html/template: prevent panic while escaping pipelines

AFAIK, the documentation does not explicitly state whether
variables can store a callable entity or not. I believe the
current implementation in text/template assumes they cannot
though. The call builtin function is supposed to be used for
this purpose.

Template "{{0|$}}" should generate an error at runtime,
instead of a panic.

Similarly, template "{{0|(nil)}}" should not generate
a panic.

This CL aborts the sanitization process for a given pipeline
when no identifier can be derived from the selected node.
It happens with malformed pipelines.

We now have the following errors:

{{ 0 | $ }}
template: foo:1:10: executing "foo" at <$>: can't give argument to non-function $

{{ 0 | (nil) }}
template: foo:1:11: executing "foo" at <nil>: nil is not a command

Fixes #11118
Fixes #11356

Change-Id: Idae52f806849f4c9ab7aca1b4bb4b59a74723d0e
Reviewed-on: https://go-review.googlesource.com/10823
Reviewed-by: Rob Pike <r@golang.org>
9 years agocmd/link: no dwarf on darwin/arm
David Crawshaw [Mon, 22 Jun 2015 23:59:59 +0000 (19:59 -0400)]
cmd/link: no dwarf on darwin/arm

Partial revert of cl/10284 to get -buildmode=c-archive working for
darwin/arm.

Manually tested with iostest.bash while builder is offline.

Change-Id: I98e4e209765666e320e680e11151fce59e2afde9
Reviewed-on: https://go-review.googlesource.com/11306
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>

9 years agocmd/go: ignore custom import check when there is no import comment
Ross Light [Thu, 4 Jun 2015 18:45:50 +0000 (11:45 -0700)]
cmd/go: ignore custom import check when there is no import comment

Fixes #10952

Change-Id: I56ab6a806bd3741cffd9d2a53929a6d043626a26
Reviewed-on: https://go-review.googlesource.com/10693
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: fetch git submodules in `go get`
Tamir Duberstein [Wed, 6 May 2015 21:54:50 +0000 (17:54 -0400)]
cmd/go: fetch git submodules in `go get`

Change createCmd, downloadCmd, tagSyncCmd, tagSyncDefault to allow
multiple commands.

When using the vendoring experiment, fetch git submodules in `go get`,
and update them in `go get -u`.

This is a reincarnation of https://codereview.appspot.com/142180043.

For #7764.

Change-Id: I8248efb851130620ef762a765ab8716af430572a
Reviewed-on: https://go-review.googlesource.com/9815
Reviewed-by: Russ Cox <rsc@golang.org>