]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
8 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>
8 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>

8 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>

8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>

8 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>

8 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>

8 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>
8 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>
8 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>
8 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>

8 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>
8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>
8 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>

8 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>
8 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>
8 years agocmd/go: adjust TestFileLineInErrorMessages
Alex Brainman [Thu, 25 Jun 2015 04:12:48 +0000 (14:12 +1000)]
cmd/go: adjust TestFileLineInErrorMessages

cmd/go sometimes returns relative path in the error message
(see shortPath function). Account for that during
TestFileLineInErrorMessages.

Fixes #11355

Change-Id: Ica79359eab48d669d307449fdd458764895fab2c
Reviewed-on: https://go-review.googlesource.com/11475
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agocmd/go: handle error when git remote origin doesn't exist
c9s [Fri, 29 May 2015 17:12:35 +0000 (01:12 +0800)]
cmd/go: handle error when git remote origin doesn't exist

- Let runOutput return the error message
- When `git config ...` returns empty buffer, it means the config key is
  correct, but there is no corresponding value.
- Return the correct error when the url of remote origin is not found.
- Update error message

Fixes: #10922
Change-Id: I3f8880f6717a4f079b840d1249174378d36bca1b
Reviewed-on: https://go-review.googlesource.com/10475
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agonet: relax IP interface address determination on linux
Mikio Hara [Tue, 23 Jun 2015 12:40:33 +0000 (21:40 +0900)]
net: relax IP interface address determination on linux

Linux allows to have a peer IP address on IP interface over ethernet
link encapsulation, though it only installs a static route with the peer
address as an on-link nexthop.

Fixes #11338.

Change-Id: Ie2583737e4c7cec39baabb89dd732463d3f10a61
Reviewed-on: https://go-review.googlesource.com/11352
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agocmd/asm: add tests for erroneous expressions
Rob Pike [Fri, 26 Jun 2015 03:39:09 +0000 (13:39 +1000)]
cmd/asm: add tests for erroneous expressions

Also add a couple more errors, such as modulo with a zero divisor.

Change-Id: If24c95477f7ae86cf4aef5b3460e9ec249ea5ae2
Reviewed-on: https://go-review.googlesource.com/11535
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agoarchive/tar: also skip header roundtrip test on nacl
Brad Fitzpatrick [Fri, 26 Jun 2015 22:13:52 +0000 (15:13 -0700)]
archive/tar: also skip header roundtrip test on nacl

Update #11426

Change-Id: I7abc4ed2241a7a3af6d57c934786f36de4f97b77
Reviewed-on: https://go-review.googlesource.com/11592
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
8 years agosync: don't run known-racy tests under the race detector
Brad Fitzpatrick [Fri, 26 Jun 2015 21:52:52 +0000 (14:52 -0700)]
sync: don't run known-racy tests under the race detector

Fixes the build from https://golang.org/cl/4117 (sync: simplify WaitGroup)

Change-Id: Icc2a7ba8acea26fd187d52cf1901bfebf8573f93
Reviewed-on: https://go-review.googlesource.com/11591
Reviewed-by: Austin Clements <austin@google.com>
8 years agoruntime: repeat bitmap for slice of GCprog n-1 times, not n times
Austin Clements [Fri, 26 Jun 2015 21:24:12 +0000 (17:24 -0400)]
runtime: repeat bitmap for slice of GCprog n-1 times, not n times

Currently, to write out the bitmap of a slice of a type with a GCprog,
we construct a new GCprog that executes the underlying type's GCprog
to write out the bitmap once and then repeats those bits n more times.
This results in n+1 repetitions of the bitmap, which is one more
repetition than it should be. This corrupts the bitmap of the heap
following the slice and may write past the mapped bitmap memory and
segfault.

Fix this by repeating the bitmap only n-1 more times.

Fixes #11430.

Change-Id: Ic24854363bffc5a755b66f257339f9309ada3aa5
Reviewed-on: https://go-review.googlesource.com/11570
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
8 years agodoc/go1.5.html: first pass over the small API changes
Rob Pike [Fri, 26 Jun 2015 01:52:21 +0000 (11:52 +1000)]
doc/go1.5.html: first pass over the small API changes

Change-Id: Ib80829e7cbfb319549a224dc18931ca884c8296a
Reviewed-on: https://go-review.googlesource.com/11532
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agoarchive/tar: disable new failing test on windows and plan9
Brad Fitzpatrick [Fri, 26 Jun 2015 21:31:35 +0000 (14:31 -0700)]
archive/tar: disable new failing test on windows and plan9

Update #11426

Change-Id: If406d2efcc81965825a63c76f5448d544ba2a740
Reviewed-on: https://go-review.googlesource.com/11590
Reviewed-by: Austin Clements <austin@google.com>
8 years agoruntime/race: enable tests that now pass
Dmitry Vyukov [Fri, 26 Jun 2015 16:09:23 +0000 (18:09 +0200)]
runtime/race: enable tests that now pass

These tests pass after cl/11417.

Change-Id: Id98088c52e564208ce432e9717eddd672c42c66d
Reviewed-on: https://go-review.googlesource.com/11551
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agosync: simplify WaitGroup
Dmitry Vyukov [Sun, 8 Feb 2015 15:11:35 +0000 (18:11 +0300)]
sync: simplify WaitGroup

A comment in waitgroup.go describes the following scenario
as the reason to have dynamically created semaphores:

// G1: Add(1)
// G1: go G2()
// G1: Wait() // Context switch after Unlock() and before Semacquire().
// G2: Done() // Release semaphore: sema == 1, waiters == 0. G1 doesn't run yet.
// G3: Wait() // Finds counter == 0, waiters == 0, doesn't block.
// G3: Add(1) // Makes counter == 1, waiters == 0.
// G3: go G4()
// G3: Wait() // G1 still hasn't run, G3 finds sema == 1, unblocked! Bug.

However, the scenario is incorrect:
G3: Add(1) happens concurrently with G1: Wait(),
and so there is no reasonable behavior of the program
(G1: Wait() may or may not wait for G3: Add(1) which
can't be the intended behavior).

With this conclusion we can:
1. Remove dynamic allocation of semaphores.
2. Remove the mutex entirely and instead pack counter and waiters
   into single uint64.

This makes the logic significantly simpler, both Add and Wait
do only a single atomic RMW to update the state.

benchmark                            old ns/op     new ns/op     delta
BenchmarkWaitGroupUncontended        30.6          32.7          +6.86%
BenchmarkWaitGroupActuallyWait       722           595           -17.59%
BenchmarkWaitGroupActuallyWait-2     396           319           -19.44%
BenchmarkWaitGroupActuallyWait-4     224           183           -18.30%
BenchmarkWaitGroupActuallyWait-8     134           106           -20.90%

benchmark                          old allocs     new allocs     delta
BenchmarkWaitGroupActuallyWait     2              1              -50.00%

benchmark                          old bytes     new bytes     delta
BenchmarkWaitGroupActuallyWait     48            16            -66.67%

Change-Id: I28911f3243aa16544e99ac8f1f5af31944c7ea3a
Reviewed-on: https://go-review.googlesource.com/4117
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agonet/http: escape path in implicit /tree→/tree/ ServeMux.Handle redirect
Mihai Borobocea [Fri, 24 Apr 2015 18:47:25 +0000 (21:47 +0300)]
net/http: escape path in implicit /tree→/tree/ ServeMux.Handle redirect

Fixes #10572

Change-Id: I764f3c226cf98ff39d9e553e4613d0ee108ef766
Reviewed-on: https://go-review.googlesource.com/9311
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agotesting/quick: improve function signature error.
Matt T. Proud [Sat, 20 Jun 2015 04:29:18 +0000 (06:29 +0200)]
testing/quick: improve function signature error.

This commit fixes a cosmetic defect whereby quick.Check reports that
the provided function returns too many values when it may, in fact,
return too few:

  func f() {}

  func TestFoo(t *testing.T) {
    if err := quick.Check(f, nil); err != nil {
      t.Fatal(err)
    }
  }
  // yields
  // $ go test -v foo_test.go
  // === RUN TestFoo
  // --- FAIL: TestFoo (0.00s)
  //  foo_test.go:76: function returns more than one value.

Change-Id: Ia209ff5b57375b30f8db425454e80798908e8ff4
Reviewed-on: https://go-review.googlesource.com/11281
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agounicode: upgrade to 8.0.0
Marcel van Lohuizen [Sun, 21 Jun 2015 18:21:04 +0000 (20:21 +0200)]
unicode: upgrade to 8.0.0

Not sure if I'm on time for 1.5; Unicode 8 just got released.

Straighforward upgrade. Only changed maketables.go to prevent it from adding
the Cherokee upper and lower case mappings. This change causes the caseOrbit
table to NOT change. Added tests to verify that the relevant functions still
produce the correct result, even for Cherokee.

Fixes #11309

Change-Id: I42850f5b3399bde125b002efc78eff96dbd86a08
Reviewed-on: https://go-review.googlesource.com/11286
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agotest: add test case for issue 8154
Dave Cheney [Mon, 8 Jun 2015 07:45:54 +0000 (17:45 +1000)]
test: add test case for issue 8154

Updates #8154

Change-Id: Ie9c731a91b008277e51c723eef6871bb0919fa4c
Reviewed-on: https://go-review.googlesource.com/10831
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agoruntime: slightly clean up softfloat code
Shenghou Ma [Fri, 1 May 2015 07:55:17 +0000 (03:55 -0400)]
runtime: slightly clean up softfloat code

Removes the remains of the old C based stepflt implementation.
Also removed goto usage.

Change-Id: Ida4742c49000fae4fea4649f28afde630ce4c577
Reviewed-on: https://go-review.googlesource.com/9600
Reviewed-by: Russ Cox <rsc@golang.org>
8 years agoruntime: reduce slice growth during append to 2x
Russ Cox [Thu, 25 Jun 2015 23:27:20 +0000 (19:27 -0400)]
runtime: reduce slice growth during append to 2x

The new inlined code for append assumed that it could pass the
desired new cap to growslice, not the number of new elements.
But growslice still interpreted the argument as the number of new elements,
making it always grow by >2x (more precisely, 2x+1 rounded up
to the next malloc block size). At the time, I had intended to change
the other callers to use the new cap as well, but it's too late for that.
Instead, introduce growslice_n for the old callers and keep growslice
for the inlined (common case) caller.

Fixes #11403.

Filed #11419 to merge them.

Change-Id: I1338b1e5b352f3be4e43641f44b652ef7195251b
Reviewed-on: https://go-review.googlesource.com/11541
Reviewed-by: Austin Clements <austin@google.com>
8 years agonet/url: don't escape star requests when writing requests
Brad Fitzpatrick [Thu, 25 Jun 2015 09:48:27 +0000 (11:48 +0200)]
net/url: don't escape star requests when writing requests

Includes a new net/http test too.

Fixes #11202

Change-Id: I61edc594f4de8eb6780b8dfa221269dd482e8f35
Reviewed-on: https://go-review.googlesource.com/11492
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>