1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00
Commit Graph

20716 Commits

Author SHA1 Message Date
Russ Cox
c5bafc8281 runtime: make NumGoroutine and Stack agree not to include system goroutines
Before, NumGoroutine counted system goroutines and Stack (usually) didn't show them,
which was inconsistent and confusing.

To resolve which way they should be consistent, it seems like

	package main
	import "runtime"
	func main() { println(runtime.NumGoroutine()) }

should print 1 regardless of internal runtime details. Make it so.

Fixes #11706.

Change-Id: I6bfe26a901de517728192cfb26a5568c4ef4fe47
Reviewed-on: https://go-review.googlesource.com/18343
Reviewed-by: Austin Clements <austin@google.com>
2016-01-08 15:25:00 +00:00
Russ Cox
20d745c57c encoding/base64: fix streaming decode of padding-free base64
Fixes #13384.

Change-Id: Id9e827acddc8de139f93c5de0c6486bc4334c7d4
Reviewed-on: https://go-review.googlesource.com/18330
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-08 15:07:45 +00:00
Ian Lance Taylor
8971d61835 os/signal: clarify signal doc
Based on comments from Thomas Bushnell.

Update #9896.

Change-Id: I603b1382d17dff00b5d18f17f8b5d011503e9e4c
Reviewed-on: https://go-review.googlesource.com/18365
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-08 15:01:09 +00:00
David du Colombier
161f2e85ee os: fix rename on Plan 9
Rename should remove newname if the file already exists
and is not a directory.

Fixes #13844.

Change-Id: I85a5cc28e8d161637a8bc1de33f4a637d9154cd1
Reviewed-on: https://go-review.googlesource.com/18291
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-08 14:22:47 +00:00
Brad Fitzpatrick
0421e78f05 net/http: fix too-strict validation of server header values
As Andy Balholm noted in #11207:

"RFC2616 §4.2 says that a header's field-content can consist of *TEXT,
and RFC2616 §2.2 says that TEXT is <any OCTET except CTLs, but
including LWS>, so that would mean that bytes greater than 128 are
allowed."

This is a partial rollback of the strictness from
https://golang.org/cl/11207 (added in the Go 1.6 dev cycle, only
released in Go 1.6beta1)

Fixes #11207

Change-Id: I3a752a7941de100e4803ff16a5d626d5cfec4f03
Reviewed-on: https://go-review.googlesource.com/18374
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-08 06:01:23 +00:00
Robert Griesemer
ee566d53ad go/doc: don't drop "factory" functions with dot-imported result types
Fixes #13742.

Change-Id: I7c8b51b60e31402bf708bf8d70e07fd06295e8ce
Reviewed-on: https://go-review.googlesource.com/18393
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-08 04:10:51 +00:00
Ian Lance Taylor
d91ec5bb40 cmd/cgo, runtime: recognize unsafe.Pointer(&s[0]) in cgo pointer checks
It's fairly common to call cgo functions with conversions to
unsafe.Pointer or other C types.  Apply the simpler checking of address
expressions when possible when the address expression occurs within a
type conversion.

Change-Id: I5187d4eb4d27a6542621c396cad9ee4b8647d1cd
Reviewed-on: https://go-review.googlesource.com/18391
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-08 03:56:30 +00:00
Russ Cox
e84dad3f6e time: restore old error text for day out of range
Go 1.5 and earlier said "day out of range".
As part of working on this code it morphed into "day of month out of range".
To avoid churn in the output restore the old text.

This fixes some tests reported privately.

Change-Id: If179676cd49f9a471a9441fec2f5220c85eb0799
Reviewed-on: https://go-review.googlesource.com/18386
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-08 03:15:20 +00:00
Russ Cox
6b9298a2c5 net: LookupAddr("127.0.0.1") is "localhost" not "localhost."
Fixes #13564.

Change-Id: I30c827ef4a112fee21b8493a67d0227109e35072
Reviewed-on: https://go-review.googlesource.com/18384
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-08 03:14:47 +00:00
Brad Fitzpatrick
acc7161320 net/http: document GODEBUG settings, update bundled http2
Document the three GODEBUG environment variables in the package doc.

Updates the bundled http2 to x/net git rev 415f1917
for https://golang.org/cl/18372.

Fixes #13611

Change-Id: I3116c5d7de70d3d15242d7198f3758b1fb7d94b9
Reviewed-on: https://go-review.googlesource.com/18373
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-08 00:56:28 +00:00
Brad Fitzpatrick
40a26c9281 net/http: add some tests around sending & receiving star requests
I thought there was still work to do in http2 for this, but I guess
not: the work for parsing them is in net/url (used by http2) and the
handling of OPTIONS * is already in net/http serverHandler, also used
by http2.

But keep the tests.

Change-Id: I566dd0a03cf13c9ea8e735c6bd32d2c521ed503b
Reviewed-on: https://go-review.googlesource.com/18368
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-07 23:06:17 +00:00
Matthew Dempsky
27691fa467 cmd/compile: recognize !typedbool is typed
Adding the evconst(n) call for OANDAND and OOROR in
golang.org/cl/18262 was originally just to parallel the above iscmp
branch, but upon further inspection it seemed odd that removing it
caused test/fixedbugs/issue6671.go's

    var b mybool
    // ...
    b = bool(true) && true // ERROR "cannot use"

to start failing (i.e., by not emitting the expected "cannot use"
error).

The problem is that evconst(n)'s settrue and setfalse paths always
reset n.Type to idealbool, even for logical operators where n.Type
should preserve the operand type.  Adding the evconst(n) call for
OANDAND/OOROR inadvertantly worked around this by turning the later
evconst(n) call at line 2167 into a noop, so the "n.Type = t"
assignment at line 739 would preserve the operand type.

However, that means evconst(n) was still clobbering n.Type for ONOT,
so declarations like:

    const _ bool = !mybool(true)

were erroneously accepted.

Update #13821.

Change-Id: I18e37287f05398fdaeecc0f0d23984e244f025da
Reviewed-on: https://go-review.googlesource.com/18362
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-07 21:43:47 +00:00
Austin Clements
3f22adecc7 runtime: fix sigprof stack barrier locking
f90b48e intended to require the stack barrier lock in all cases of
sigprof that walked the user stack, but got it wrong. In particular,
if sp < gp.stack.lo || gp.stack.hi < sp, tracebackUser would be true,
but we wouldn't acquire the stack lock. If it then turned out that we
were in a cgo call, it would walk the stack without the lock.

In fact, the whole structure of stack locking is sigprof is somewhat
wrong because it assumes the G to lock is gp.m.curg, but all three
gentraceback calls start from potentially different Gs.

To fix this, we lower the gcTryLockStackBarriers calls much closer to
the gentraceback calls. There are now three separate trylock calls,
each clearly associated with a gentraceback and the locked G clearly
matches the G from which the gentraceback starts. This actually brings
the sigprof logic closer to what it originally was before stack
barrier locking.

This depends on "runtime: increase assumed stack size in
externalthreadhandler" because it very slightly increases the stack
used by sigprof; without this other commit, this is enough to blow the
profiler thread's assumed stack size.

Fixes #12528 (hopefully for real this time!).

For the 1.5 branch, though it will require some backporting. On the
1.5 branch, this will *not* require the "runtime: increase assumed
stack size in externalthreadhandler" commit: there's no pcvalue cache,
so the used stack is smaller.

Change-Id: Id2f6446ac276848f6fc158bee550cccd03186b83
Reviewed-on: https://go-review.googlesource.com/18328
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-07 19:40:38 +00:00
Austin Clements
fdf9b3c994 runtime: increase assumed stack size in externalthreadhandler
On Windows, externalthreadhandler currently sets the assumed stack
size for the profiler thread and the ctrlhandler threads to 8KB. The
actual stack size is determined by the SizeOfStackReserve field in the
binary set by the linker, which is currently at least 64KB (and
typically 128KB).

It turns out the profiler thread is running within a few words of the
8KB-(stack guard) bound set by externalthreadhandler. If it overflows
this bound, morestack crashes unceremoniously with an access
violation, which we then fail to handle, causing the whole process to
exit without explanation.

To avoid this problem and give us some breathing room, increase the
assumed stack size in externalthreadhandler to 32KB (there's some
unknown amount of stack already in use, so it's not safe to increase
this all the way to the reserve size).

We also document the relationships between externalthreadhandler and
SizeOfStackReserve to make this more obvious in the future.

Change-Id: I2f9f9c0892076d78e09827022ff0f2bedd9680a9
Reviewed-on: https://go-review.googlesource.com/18304
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
2016-01-07 19:40:32 +00:00
Austin Clements
b50b24837d runtime: don't ignore success of cgo profiling tracebacks
If a sigprof happens during a cgo call, we traceback from the entry
point of the cgo call. However, if the SP is outside of the G's stack,
we'll then ignore this traceback, even if it was successful, and
overwrite it with just _ExternalCode.

Fix this by accepting any successful traceback, regardless of whether
we got it from a cgo entry point or from regular Go code.

Fixes #13466.

Change-Id: I5da9684361fc5964f44985d74a8cdf02ffefd213
Reviewed-on: https://go-review.googlesource.com/18327
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-07 19:40:26 +00:00
Russ Cox
ebf1f0fcbe net: document ":port" syntax in Dial, Listen, ListenPacket
Change-Id: Ideb4bd9ffb1b5f1aef7d94ff791a262f54a650d5
Reviewed-on: https://go-review.googlesource.com/18344
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-07 19:14:43 +00:00
Russ Cox
cd91c3b036 runtime: add pointer to net and net/http for more GODEBUG settings
net has GODEBUG text already.
net/http still needs it (leaving for Brad).

For #13611.

Change-Id: Icea1027924a23a687cbbe4001985e8c6384629d7
Reviewed-on: https://go-review.googlesource.com/18346
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-07 19:14:12 +00:00
Brad Fitzpatrick
305b4baf41 net/http: update bundled http2, fixes TestConcurrentReadWriteReqBody_h2
Updates http2 to x/net git rev 520af5de654d for
https://golang.org/cl/18370

Fixes #13659

Change-Id: I920eaff6036ac22c500a97449826c6b12f873d7f
Reviewed-on: https://go-review.googlesource.com/18371
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-07 06:07:06 +00:00
Michael McGreevy
002e658a91 net/http: Minor fix to error messages in test.
Change-Id: I995ac0559f89110662d79d136d710ef3a0bb1505
Reviewed-on: https://go-review.googlesource.com/18351
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-07 05:00:50 +00:00
Brad Fitzpatrick
67fa7970c5 net/http: update bundled http2; fixes TestTransportAndServerSharedBodyRace_h2
Update bundled http2 to git rev d1ba260648 (https://golang.org/cl/18288).

Fixes the flaky TestTransportAndServerSharedBodyRace_h2.

Also adds some debugging to TestTransportAndServerSharedBodyRace_h2
which I hope won't ever be necessary again, but I know will be.

Fixes #13556

Change-Id: Ibcf2fc23ec0122dcac8891fdc3bd7f8acddd880e
Reviewed-on: https://go-review.googlesource.com/18289
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-07 01:49:37 +00:00
Tamir Duberstein
24ef1d60f0 cmd/dist: improve isGitRepo to handle git "worktree"s
Simply checking the exit code of `git rev-parse --git-dir` should
suffice here, but that requires deviating from the infrastructure
provided by `run`, so I've left that for a future change.

Originally by Tamir Duberstein but updated by iant & rsc to add
the filepath.Join logic.

Fixes #11211 (again).

Change-Id: I6d29b5ae39ba456088ae1fb5d41014cb91c86897
Reviewed-on: https://go-review.googlesource.com/18323
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-07 01:23:05 +00:00
Russ Cox
fb142ee9b9 cmd/go: for go get -insecure, skip TLS certificate checking
The flag is already named -insecure. Make it more so.

If we're willing to accept HTTP, it's not much worse to accept
HTTPS man-in-the-middle attacks too. This allows servers
with self-signed certificates to work.

Fixes #13197.

Change-Id: Ia5491410bc886da0a26ef3bce4bf7d732f5e19e4
Reviewed-on: https://go-review.googlesource.com/18324
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-07 01:22:59 +00:00
Mikio Hara
c063e342f8 net/http, net/http/httputil: fix nits found by vet
Change-Id: Idf02428591f61dc58f654fdaf0e3a55f8b8a1060
Reviewed-on: https://go-review.googlesource.com/18350
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-07 01:01:33 +00:00
Russ Cox
4aedbf5be4 archive/zip: fix reading, writing of zip64 archives
Read zip files that contain only 64-bit header offset, not 64-bit sizes.
Fixes #13367.

Read zip files that contain completely unexpected Extra fields,
provided we do not need to find 64-bit size or header offset information there.
Fixes #13166.

Write zip file entries with 0xFFFFFFFF uncompressed data bytes
correctly (must use zip64 header, since that's the magic indicator).
Fixes new TestZip64EdgeCase. (Noticed while working on the CL.)

Change-Id: I84a22b3995fafab8052b99de8094a9f35a25de5b
Reviewed-on: https://go-review.googlesource.com/18317
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-07 00:44:04 +00:00
Russ Cox
5d8442aeaa os: document that Rename overwrites existing file
Fixes #13673.

Change-Id: I60d1603ca0dfd2ae136117e0f89cee4b6fc6c3d3
Reviewed-on: https://go-review.googlesource.com/18332
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-07 00:41:10 +00:00
Russ Cox
dba926d7a3 go/build: allow @ in #cgo directives for OS X
Fixes #13720.

Change-Id: I2e48454696f37db419370630f913590c435cd9f0
Reviewed-on: https://go-review.googlesource.com/18331
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-01-07 00:38:58 +00:00
Ian Lance Taylor
70c9a8187a runtime: set new m signal mask to program startup mask
We were setting the signal mask of a new m to the signal mask of the m
that created it.  That failed when that m happened to be the one created
by ensureSigM, which sets its signal mask to only include the signals
being caught by os/signal.Notify.

Fixes #13164.
Update #9896.

Change-Id: I705c196fe9d11754e10bab9e9b2e7530ecdfa367
Reviewed-on: https://go-review.googlesource.com/18064
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 23:14:46 +00:00
Ian Lance Taylor
a7cad52e04 runtime: preserve signal stack when calling Go on C thread
When calling a Go function on a C thread, if the C thread already has an
alternate signal stack, use that signal stack instead of installing a
new one.

Update #9896.

Change-Id: I62aa3a6a4a1dc4040fca050757299c8e6736987c
Reviewed-on: https://go-review.googlesource.com/18108
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 23:11:42 +00:00
Brad Fitzpatrick
62c280ac1c runtime/pprof: skip TestStackBarrierProfiling on dragonfly too
Just saw a few dragonfly failures here.

I'm tempted to preemptively add plan9 here too, but I'll wait until
I see it fail.

Change-Id: Ic99fc088dbfd1aa21f509148aee98ccfe7f640bf
Reviewed-on: https://go-review.googlesource.com/18306
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 22:15:37 +00:00
Russ Cox
4220659867 cmd/go: do not force use of git master branch (again)
This time with a test.
Also adjust another test to skip when hg is not present,
and delete no longer needed fixDetachedHead code.

Fixes #9032 (again).

Change-Id: I481717409e1d44b524f83c70a8dc377699d1a2a5
Reviewed-on: https://go-review.googlesource.com/18334
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 21:57:20 +00:00
Russ Cox
b598a7fc5d net: check /etc/hosts for modifications every 5 seconds, not 5 minutes
But also cache the previous parsed form and don't reread if the
size and modification time are both unchanged from before.

On systems with stable /etc/hosts this should result in more stat calls
but only a single parsing of /etc/hosts.

On systems with variable /etc/hosts files (like some Docker systems)
this should result in quicker adoption of changes.

Fixes #13340.

Change-Id: Iba93b204be73d6d903cd17c58038a4fcfd0952b9
Reviewed-on: https://go-review.googlesource.com/18258
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 21:42:19 +00:00
Brad Fitzpatrick
fb394017f1 net/http: fix flaky TestTransportCancelBeforeResponseHeaders test
Add a couple more cases where we convert random network I/O errors
into errRequestCanceled if the request was forcefully aborted.

It failed ~1/1000 times without -race, or very easily with -race.
(due to -race randomizing some scheduling)

Fixes #11894

Change-Id: Ib1c123ce1eebdd88642da28a5948ca4f30581907
Reviewed-on: https://go-review.googlesource.com/18287
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 21:01:08 +00:00
Brad Fitzpatrick
af768fdd34 net/http: add mechanism for marking flaky http tests
This shouldn't need to exist in general, but in practice I want something
like this a few times per year.

Change-Id: I9c220e58be44b7726f75d776f714212c570cf8bb
Reviewed-on: https://go-review.googlesource.com/18286
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 21:00:48 +00:00
Brad Fitzpatrick
194a5c3e61 net/http: update bundled http2, add test for Transport's User-Agent behavior
Adds a test that both http1 and http2's Transport send a default
User-Agent, with the same behavior.

Updates bundled http2 to golang.org/x/net git rev 1ade16a545 (for
https://go-review.googlesource.com/18285)

The http1 behavior changes slightly: if req.Header["User-Agent"] is
defined at all, even if it's nil or a zero-length slice, then the
User-Agent header is omitted. This is a slight behavior change for
http1, but is consistent with how http1 & http2 do optional headers
elsewhere (such as "Date", "Content-Type"). The old behavior (set it
explicitly to "", aka []string{""}) still works as before. And now
there are even tests.

Fixes #13685

Change-Id: I5786a6913b560de4a5f1f90e595fe320ff567adf
Reviewed-on: https://go-review.googlesource.com/18284
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06 18:53:46 +00:00
Robert Griesemer
a4f10bddc3 go/importer: always handle forward-declared imports in export data
The textual export data generated by gc sometimes contains forward
references of packages. In rare cases such forward-referenced packages
were not created when needed because no package name was present.

Create unnamed packages in this case and set the name later when it
becomes known.

Fixes #13566.

Change-Id: I193e0ec712e874030b194ab8ecb3fca140f7997a
Reviewed-on: https://go-review.googlesource.com/18301
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-06 18:19:53 +00:00
Russ Cox
f034b62c85 testing: move comment inside T.Parallel
This was supposed to be in CL 18204 but I submitted from the web
instead of my computer and lost this final edit.

Change-Id: I41598e936bb088d77f5e44752eda74222a4208c7
Reviewed-on: https://go-review.googlesource.com/18310
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 17:59:55 +00:00
Russ Cox
aec2f0cf85 net: fix timeout test bug
This was supposed to be in CL 18205 but I submitted via the web
instead of from my computer, so it got lost.
May deflake some things.

Change-Id: I880fb74b5943b8a17f952a82639c60126701187a
Reviewed-on: https://go-review.googlesource.com/18259
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 17:59:46 +00:00
Russ Cox
13ba968d75 runtime/pprof: point to new docs about kernel bugs
Change-Id: I8ee338c1244fc4e2fb75deec752a7f83239c33ea
Reviewed-on: https://go-review.googlesource.com/18257
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 17:59:35 +00:00
Russ Cox
6866f5e143 cmd/dist: assume amd64 on OS X, don't run sysctl
Fixes #13425.

Change-Id: I82f49d07841e89fc4f3fde9ea41e710a634579d0
Reviewed-on: https://go-review.googlesource.com/18313
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 17:59:25 +00:00
Russ Cox
39c3e0f642 time: document that RFC1123 is wrong for times in UTC
Fixes #13781.

Change-Id: Icfac8f2bfc3a4106f646409cfdc053df1e0cd76a
Reviewed-on: https://go-review.googlesource.com/18314
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06 17:59:15 +00:00
Russ Cox
901810ae55 os/exec: document that examples assume Unix
Fixes #13693.

Change-Id: Ieb89d8a8874ee8c6b304de99dceb07193c26b60e
Reviewed-on: https://go-review.googlesource.com/18315
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 17:58:48 +00:00
Russ Cox
bb91a7e2fd test/bench/shootout: delete
We don't use these for benchmarking anymore.
Now we have the go1 dir and the benchmarks subrepo.
Some have problematic copyright notices, so move out of main repo.

Preserved in golang.org/x/exp/shootout.

Fixes #12688.
Fixes #13584.

Change-Id: Ic0b71191ca1a286d33d7813aca94bab1617a1c82
Reviewed-on: https://go-review.googlesource.com/18320
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06 17:58:27 +00:00
Russ Cox
91ba9f45c2 Revert "cmd/dist: improve isGitRepo to handle git "worktree"s"
This reverts commit ab096d587f.

Change-Id: Icf366aa43acc41b4f8474edae0297e554368bf14
Reviewed-on: https://go-review.googlesource.com/18321
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 17:39:43 +00:00
Russ Cox
7f0b4a879b crypto/dsa: adjust GenerateParameters comment
Fixes #13725.

Change-Id: I5fe46851b238fc9ab301da8f8fc37bd1b7871748
Reviewed-on: https://go-review.googlesource.com/18316
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 16:58:21 +00:00
Alex Brainman
a8f8d550e8 internal/syscall/windows/registry: adjust TestGetMUIStringValue
Do not check DaylightName if DynamicDaylightTimeDisabled is false.

Fixes #13502

Change-Id: I03e01ec0afdeb0037a5d3ee243674e5a6b559da5
Reviewed-on: https://go-review.googlesource.com/17998
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 16:13:50 +00:00
Tamir Duberstein
ab096d587f cmd/dist: improve isGitRepo to handle git "worktree"s
Simply checking the exit code of `git rev-parse --git-dir` should
suffice here, but that requires deviating from the infrastructure
provided by `run`, so I've left that for a future change.

Fixes #11211.

Change-Id: I7cbad86a8a06578f52f66f734f5447b597ddc962
Reviewed-on: https://go-review.googlesource.com/18213
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 15:04:13 +00:00
Matthew Dempsky
be20948e27 cmd/compile: recognize bool(true) as a constant expression
Fixes #13821.

Change-Id: I4a28a92d137edac3061537af25ac9d7aba411a66
Reviewed-on: https://go-review.googlesource.com/18262
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 14:38:33 +00:00
Ian Lance Taylor
e24b2445b4 os/signal: Stop restores original signal handling
Since Stop was introduced, it would revert to the system default for the
signal, rather than to the default Go behavior.  Change it to revert to
the default Go behavior.

Change-Id: I345467ece0e49e31b2806d6fce2f1937b17905a6
Reviewed-on: https://go-review.googlesource.com/18229
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 14:25:39 +00:00
Andrew Gerrand
91f997be72 net/http: better documentation for Transport
Mention that:
- connection pooling is enabled by default,
- the Transport is safe for concurrent use, and
- the Client type should be used for high-level stuff.

Change-Id: Idfd8cc852e733c44211e77cf0e22720b1fdca39b
Reviewed-on: https://go-review.googlesource.com/18273
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 06:08:34 +00:00
Brad Fitzpatrick
c799e4a577 net/http/pprof: stop profiling if client's connection closes
Fixes #13833

Change-Id: If0bd5f7dcfc39d34680d11eb998050f0900d5a26
Reviewed-on: https://go-review.googlesource.com/18283
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 05:51:38 +00:00
Brad Fitzpatrick
a4f27c4225 net/http: update bundled copied of x/net/http2 to git rev 961116aee
Update net/http's copy of http2 (sync as of x/net git rev 961116aee,
aka https://golang.org/cl/18266)

Also adds some CONNECT tests for #13717 (mostly a copy of http2's
version of test, but in the main repo it also tests that http1 behaves
the same)

Fixes #13668
Fixes #13717

Change-Id: I7db93fe0b7c42bd17a43ef32953f2d20620dd3ea
Reviewed-on: https://go-review.googlesource.com/18269
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 05:50:07 +00:00
Ian Lance Taylor
934e055f41 runtime: call msanwrite on object passed to runtime/cgo
Avoids an msan error when runtime/cgo is explicitly rebuilt with
-fsanitize=memory.

Fixes #13815.

Change-Id: I70308034011fb308b63585bcd40b0d1e62ec93ef
Reviewed-on: https://go-review.googlesource.com/18263
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 04:04:42 +00:00
Brad Fitzpatrick
17ce03725c crypto/hmac: update link to FIPS HMAC spec
Thanks to Kevin Kirsche (github kkirsche).

Change-Id: Ia0017371f56065a5e88d1ebb800a6489136ee9b1
Reviewed-on: https://go-review.googlesource.com/18280
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-06 02:17:06 +00:00
Adam Langley
9338f39459 crypto/x509: handle ECC private keys with the wrong length.
SEC-1 says: “The component privateKey is the private key defined to be
the octet string of length ⌊log₂(n)/8⌋ (where n is the order of the
curve)”.

Previously the code for parsing ECC private keys would panic (on
non-amd64) when the private was too long. It would also pass a too-short
private key to crypto/elliptic, possibly resulting in undesirable
behaviour.

This change makes the parsing function handle both too much and too
little padding because GnuTLS does the former and OpenSSL did the latter
until 30cd4ff294252c4b6a4b69cbef6a5b4117705d22. It also causes
serialisation to pad private keys correctly.

Fixes #13699

Change-Id: If9c2faeaeb45af8a4d7770d784f3d2633e7f8290
Reviewed-on: https://go-review.googlesource.com/18094
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 02:16:54 +00:00
Kevin Vu
aaabe3d849 cmd/compile/internal/gc: fix initialization logic
Also add relevant test.

Fixes #13343.

Change-Id: Ib1e65af1d643d501de89adee3618eddbf6c69c9e
Reviewed-on: https://go-review.googlesource.com/18159
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-06 02:10:52 +00:00
Tamir Duberstein
7e24e89944 cmd/dist: correct run's comment
Change-Id: I45b026f4b4bf23b222a81669280cbe245048022b
Reviewed-on: https://go-review.googlesource.com/18212
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 02:02:07 +00:00
Michael Hudson-Doyle
ae8e55860b cmd/go: special case shared library name when passed "$prefix/..."
Before golang.org/cl/13921, "go install -buildmode=shared prefix/..." created a
file called "libprefix.so", which was obviously a problem when prefix was
something like "." or "../".  However, now it expands the ... into all the
matched packages, joins them with -, which can clearly be a very long name
indeed. Because I plan to build shared libraries for Ubuntu by running commands
exactly like "go install -buildmode=shared prefix/...", this special cases this
to produce the old behaviour (but de-relativises prefix first).

Fixes #13714

Change-Id: I4fd8d4934279f9a18cc70a13e4ef3e23f6abcb6e
Reviewed-on: https://go-review.googlesource.com/18114
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06 01:46:39 +00:00
David Benjamin
7f96e266ec encoding/asn1: fix off-by-one in parseBase128Int.
parseBase128Int compares |shifted| with four, seemingly to ensure the result
fits in an int32 on 32-bit platforms where int is 32-bit. However, there is an
off-by-one in this logic, so it actually allows five shifts, making the maximum
tag number or OID component 2^35-1.

Fix this so the maximum is 2^28-1 which should be plenty for OID components and
tag numbers while not overflowing on 32-bit platforms.

Change-Id: If825b30cc53a0fc08e68ea1a24d265e7eb1a13a4
Reviewed-on: https://go-review.googlesource.com/18225
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 01:41:27 +00:00
Brad Fitzpatrick
ddc25081d2 log/syslog: document that syslog is frozen
Try to reduce feature request bug reports.

Change-Id: I713bb715d25d23e084b054aea8e1c3197dde90d4
Reviewed-on: https://go-review.googlesource.com/18222
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-05 22:56:07 +00:00
Brad Fitzpatrick
7de71c8526 net/http: make Client use Request.Cancel for timeouts instead of CancelRequest
In the beginning, there was no way to cancel an HTTP request.

We later added Transport.CancelRequest to cancel an in-flight HTTP
request by breaking its underlying TCP connection, but it was hard to
use correctly and didn't work in all cases. And its error messages
were terrible. Some of those issues were fixed over time, but the most
unfixable problem was that it didn't compose well. All RoundTripper
implementations had to choose to whether to implement CancelRequest
and both decisions had negative consequences.

In Go 1.5 we added Request.Cancel, which composed well, worked in all
phases, had nice error messages, etc. But we forgot to use it in the
implementation of Client.Timeout (a timeout which spans multiple
requests and reading request bodies).

In Go 1.6 (upcoming), we added HTTP/2 support, but now Client.Timeout
didn't work because the http2.Transport didn't have a CancelRequest
method.

Rather than add a CancelRequest method to http2, officially deprecate
it and update the only caller (Client, for Client.Cancel) to use
Request.Cancel instead.

The http2 Client timeout tests are enabled now.

For compatibility, we still use CancelRequest in Client if we don't
recognize the RoundTripper type. But documentation has been updated to
tell people that CancelRequest is deprecated.

Fixes #13540

Change-Id: I15546b90825bb8b54905e17563eca55ea2642075
Reviewed-on: https://go-review.googlesource.com/18260
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-05 22:55:22 +00:00
Brad Fitzpatrick
7fa9846749 net/http: tighten protocol between Transport.roundTrip and persistConn.readLoop
In debugging the flaky test in #13825, I discovered that my previous
change to tighten and simplify the communication protocol between
Transport.roundTrip and persistConn.readLoop in
https://golang.org/cl/17890 wasn't complete.

This change simplifies it further: the buffered-vs-unbuffered
complexity goes away, and we no longer need to re-try channel reads in
the select case. It was trying to prioritize channels in the case that
two were readable in the select. (it was only failing in the race builder
because the race builds randomize select scheduling)

The problem was that in the bodyless response case we had to return
the idle connection before replying to roundTrip. But putIdleConn
previously both added it to the free list (which we wanted), but also
closed the connection, which made the caller goroutine
(Transport.roundTrip) have two readable cases: pc.closech, and the
response. We guarded against similar conditions in the caller's select
for two readable channels, but such a fix wasn't possible here, and would
be overly complicated.

Instead, switch to unbuffered channels. The unbuffered channels were only
to prevent goroutine leaks, so address that differently: add a "callerGone"
channel closed by the caller on exit, and select on that during any unbuffered
sends.

As part of the fix, split putIdleConn into two halves: a part that
just returns to the freelist, and a part that also closes. Update the
four callers to the variants each wanted.

Incidentally, the connections were closing on return to the pool due
to MaxIdleConnsPerHost (somewhat related: #13801), but this bug
could've manifested for plenty of other reasons.

Fixes #13825

Change-Id: I6fa7136e2c52909d57a22ea4b74d0155fdf0e6fa
Reviewed-on: https://go-review.googlesource.com/18282
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-05 22:33:16 +00:00
Austin Clements
59ca8789fb runtime/pprof: skip TestStackBarrierProfiling
This test triggers a large number of usleep(100)s. linux/arm, openbsd,
and solaris have very poor timer resolution on the builders, so
usleep(100) actually gives up the whole scheduling quantum. On Linux
and OpenBSD (and probably Solaris), profiling signals are only
generated when a process completes a whole scheduling quantum, so this
test often gets zero profiling signals and fails.

Until we figure out what to do about this, skip this test on these
platforms.

Updates #13405.

Change-Id: Ica94e4a8ae7a8df3e5a840504f83ee2ec08727df
Reviewed-on: https://go-review.googlesource.com/18252
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
2016-01-05 18:48:19 +00:00
Ian Lance Taylor
2c67c8c303 runtime: fix exit status when killed by signal
Previously, when a program died because of a SIGHUP, SIGINT, or SIGTERM
signal it would exit with status 2.  This CL fixes the runtime to exit
with a status indicating that the program was killed by a signal.

Change-Id: Ic2982a2562857edfdccaf68856e0e4df532af136
Reviewed-on: https://go-review.googlesource.com/18156
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-01-05 18:00:33 +00:00
Ian Lance Taylor
81b35117d9 runtime: set SIGCONT to _SigNotify + _SigDefault
Use the current ability to say that we don't do anything with SIGCONT by
default, but programs can catch it using signal.Notify if they want.

Fixes #8953.

Change-Id: I67d40ce36a029cbc58a235cbe957335f4a58e1c5
Reviewed-on: https://go-review.googlesource.com/18185
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-05 17:44:46 +00:00
David Chase
ab5d2bf92f cmd/compile: suppress export of Note field within exported bodies
Added a format option to inhibit output of .Note field in
printing, and enabled that option during export.
Added test.

Fixes #13777.

Change-Id: I739f9785eb040f2fecbeb96d5a9ceb8c1ca0f772
Reviewed-on: https://go-review.googlesource.com/18217
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2016-01-05 15:42:12 +00:00
Russ Cox
d731315cdb net: run all timeout tests in parallel
For #10571.

Change-Id: I9a42226078b9c52dbe0c65cb101b5f452233e911
Reviewed-on: https://go-review.googlesource.com/18205
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-05 14:19:39 +00:00
Russ Cox
906f979119 cmd/dist: wait for pending tests before exiting
When 'go tool dist test' stops, it was intended that it first wait for
pending background tests, like a failed compilation waits for pending
background compiles. But these three lines prevented that.
Fix by deleting them. (The actual loop already contains the correct
logic to avoid running the others and to wait for what's left.)

Change-Id: I4e945495ada903fb0af567910626241bc1c52ba6
Reviewed-on: https://go-review.googlesource.com/18232
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-05 14:18:38 +00:00
Brad Fitzpatrick
4b0bc7c3a1 net/http: relax recently-updated rules and behavior of CloseNotifier
The CloseNotifier implementation and documentation was
substantially changed in https://golang.org/cl/17750 but it was a bit
too aggressive.

Issue #13666 highlighted that in addition to breaking external
projects, even the standard library (httputil.ReverseProxy) didn't
obey the new rules about not using CloseNotifier until the
Request.Body is fully consumed.

So, instead of fixing httputil.ReverseProxy, dial back the rules a
bit. It's now okay to call CloseNotify before consuming the request
body. The docs now say CloseNotifier may wait to fire before the
request body is fully consumed, but doesn't say that the behavior is
undefined anymore. Instead, we just wait until the request body is
consumed and start watching for EOF from the client then.

This CL also adds a test to ReverseProxy (using a POST request) that
would've caught this earlier.

Fixes #13666

Change-Id: Ib4e8c29c4bfbe7511f591cf9ffcda23a0f0b1269
Reviewed-on: https://go-review.googlesource.com/18144
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-05 04:39:11 +00:00
Matthew Dempsky
66f1f89dc0 cmd/internal/obj: fix PCSP table at runtime.morestack calls
Fixes #13346.

Change-Id: Ic903ee90575e8dbe23905d0678d3295745d1d47f
Reviewed-on: https://go-review.googlesource.com/18154
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-05 01:48:31 +00:00
Ian Lance Taylor
b80ea53200 os: remove unused import to fix build
Change-Id: Ia8c1c77590115a5ffda144962436d489ed77a423
Reviewed-on: https://go-review.googlesource.com/18227
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-05 01:21:26 +00:00
Ian Lance Taylor
58c73de7d0 os, runtime: better EPIPE behavior for command line programs
Old behavior: 10 consecutive EPIPE errors on any descriptor cause the
program to exit with a SIGPIPE signal.

New behavior: an EPIPE error on file descriptors 1 or 2 cause the
program to raise a SIGPIPE signal.  If os/signal.Notify was not used to
catch SIGPIPE signals, this will cause the program to exit with SIGPIPE.
An EPIPE error on a file descriptor other than 1 or 2 will simply be
returned from Write.

Fixes #11845.
Update #9896.

Change-Id: Ic85d77e386a8bb0255dc4be1e4b3f55875d10f18
Reviewed-on: https://go-review.googlesource.com/18151
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-05 00:32:50 +00:00
Ian Lance Taylor
a7d2b4d7ce runtime: disable a signal by restoring the original disposition
Fixes #13034.
Fixes #13042.
Update #9896.

Change-Id: I189f381090223dd07086848aac2d69d2c00d80c4
Reviewed-on: https://go-review.googlesource.com/18062
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-05 00:25:50 +00:00
Aaron Jacobs
6c8a141a6d cmd/go: update out of date help text about vendoring
Change-Id: I2b61f3b3ecf28d8f6a8dff94d194b6d3d450ea22
Reviewed-on: https://go-review.googlesource.com/17996
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-04 20:50:18 +00:00
Russ Cox
7f4443d5fa testing: add clear panic for duplicate call to t.Parallel
Change-Id: I155633b58e1823344a26c3edf11f5626fae080ee
Reviewed-on: https://go-review.googlesource.com/18204
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-04 20:10:17 +00:00
Russ Cox
9d549b5b62 runtime/pprof: shorten a few tests
For #10571.

Change-Id: I4bdad64e2dfd692ef2adccf2e5e82e9b1996a8ea
Reviewed-on: https://go-review.googlesource.com/18206
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
2016-01-04 20:10:10 +00:00
Russ Cox
83746fd55a cmd/link: use current GOROOT for source file paths for standard library
This CL changes the source file information in the
standard library's .a files to say "$GOROOT/src/runtime/chan.go"
(with a literal "$GOROOT") instead of spelling out the actual directory.
The linker then substitutes the actual $GOROOT (or $GOROOT_FINAL)
as appropriate.

If people download a binary distribution to an alternate location,
following the instructions at https://golang.org/doc/install#install,
the code before this CL would end up with source paths pointing to
/usr/local/go no matter where the actual sources were.
Now the source paths for built binaries will point to the actual sources
(hopefully).

The source line information in distributed binaries is not affected:
those will still say /usr/local/go. But binaries people build themselves
(their own programs, not the go distribution programs) will be correct.

Fixing this path also fixes the lookup of the runtime-gdb.py file.

Fixes #5533.

Change-Id: I03729baae3fbd8cd636e016275ee5ad2606e4663
Reviewed-on: https://go-review.googlesource.com/18200
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-04 20:09:57 +00:00
Brad Fitzpatrick
28b95edff2 net/http: deflake tests in full mode after t.Parallel additions
https://golang.org/cl/18087 added a bunch of t.Parallel calls, which
aren't compatible with the afterTest func. But in short mode, afterTest
is a no-op. To keep all.bash (short mode) fast, conditionally set
t.Parallel when in short mode, but keep it unset for compatibility with
afterFunc otherwise.

Fixes #13804

Change-Id: Ie841fbc2544e1ffbee43ba1afbe895774e290da0
Reviewed-on: https://go-review.googlesource.com/18143
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-04 19:23:17 +00:00
Ian Lance Taylor
fa8384dfb9 runtime: remove now-unused test string constants
Change-Id: I491197e1505d02cd107a8788e5377cf1d0a9828c
Reviewed-on: https://go-review.googlesource.com/18157
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-04 19:07:26 +00:00
Ian Lance Taylor
956535f5cb runtime: implement setsigstack for Solaris
Change-Id: I0280d478b7d0a59d8e2082aa87fab6d7d9f36a18
Reviewed-on: https://go-review.googlesource.com/18158
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2016-01-04 16:33:58 +00:00
Ian Lance Taylor
3fd19fdc51 runtime: treat SIGTSTP/SIGCANCEL on Solaris as we do on GNU/Linux
Change-Id: I617abd53f5fc883b972a1ef090886b85607e00bb
Reviewed-on: https://go-review.googlesource.com/18155
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2016-01-02 17:34:25 +00:00
Alex Brainman
ca47157395 os: change Open(C:) to open current directory on C:
Open(`C:`) currently opens root directory on C:. Change that to open
current directory on C:. Just like cmd.exe's "dir C:" command does.
Just like FindFirstFile("C:*") Windows API does. It is also consistent
with what filepath.Join("C:", "a") currently does.

Fixes #13763

Change-Id: I60b6e7d80215d110bbbb6265c9f32717401638c6
Reviewed-on: https://go-review.googlesource.com/18184
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
2015-12-31 00:20:54 +00:00
Evan Shaw
e35901fd65 database/sql: fix doc typos
Change-Id: I374dabed6bf9783839d637e9d7fd6f4e61c7eecf
Reviewed-on: https://go-review.googlesource.com/18183
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-30 07:27:12 +00:00
Hiroshi Ioka
4601776901 os: fix race condition between (*os.File).Stat and os.Chdir on windows
Fixes #13752

Change-Id: I53cfc4ecae90c35b6f1074f3be08489c408a6464
Reviewed-on: https://go-review.googlesource.com/18181
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-30 06:37:08 +00:00
Russ Cox
8d5ff2e182 runtime: move test programs out of source code, coalesce
Now there are just three programs to compile instead of many,
and repeated tests can reuse the compilation result instead of
rebuilding it.

Combined, these changes reduce the time spent testing runtime
during all.bash on my laptop from about 60 to about 30 seconds.
(All.bash itself runs in 5½ minutes.)

For #10571.

Change-Id: Ie2c1798b847f1a635a860d11dcdab14375319ae9
Reviewed-on: https://go-review.googlesource.com/18085
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
2015-12-29 21:16:59 +00:00
Brad Fitzpatrick
a699320512 net/http: update docs on Request.Proto, ProtoMajor, ProtoMinor
Change-Id: I4a6928b4674b6aaab3611cad7526347923a0015f
Reviewed-on: https://go-review.googlesource.com/18153
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-29 18:54:39 +00:00
Russ Cox
f034ee8c22 cmd/dist: apply final edits from CL 18199.
I broke the rule: never click the Submit button on the web.

Change-Id: If81a5cc31c1f28664960bad124cc596f5cab1222
Reviewed-on: https://go-review.googlesource.com/18203
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-29 17:25:06 +00:00
Russ Cox
d513ee774c cmd/dist: run shards of test dir in parallel
Saves 15 seconds from all.bash on my laptop (3:20 -> 3:05).

Change-Id: Ic5dc3c7804e78b584789dd856a3dada94000a8e2
Reviewed-on: https://go-review.googlesource.com/18199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 17:18:04 +00:00
Russ Cox
b6473ff132 cmd/dist: run wiki, shootout etc tests only on builders
These find approximately nothing.
Takes 5% off my all.bash run time.

For #10571.

Change-Id: I21d3a844af756eb37f59bba0064f24995626da0d
Reviewed-on: https://go-review.googlesource.com/18198
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 16:26:50 +00:00
Russ Cox
baa928a782 cmd/dist: run various one-off tests in parallel
Takes 15% off my all.bash run time
(after this and earlier CLs, now down to 3½ from 5½ minutes).

For #10571.

Change-Id: Iac316ffb730c9ff0a0faa7cc3b82ed4f7e6d4361
Reviewed-on: https://go-review.googlesource.com/18088
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-29 15:50:04 +00:00
Russ Cox
f41378e225 cmd/dist: run limited tests in race and libgcc=none modes
Mostly we just care that the test binaries link and start up.
No need to run the full test suites.

Takes 12% off my all.bash run time.

For #10571.

Change-Id: I01af618f3d51deb841ea638424e1389a2df7d746
Reviewed-on: https://go-review.googlesource.com/18086
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-29 15:48:04 +00:00
Russ Cox
04d732b4c2 build: shorten a few packages with long tests
Takes 3% off my all.bash run time.

For #10571.

Change-Id: I8f00f523d6919e87182d35722a669b0b96b8218b
Reviewed-on: https://go-review.googlesource.com/18087
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-29 15:46:44 +00:00
Russ Cox
f70f277875 cmd/dist: make test default to --no-rebuild
I'm tired of having to remember it on every command.
Rebuilding everything is the wrong default.

This CL updates the build script, but the builders may
(or may not) need work, depending on whether they
rebuild using the test command (I doubt it).

Change-Id: I21f202a2f13e73df3f6bd54ae6a317c467b68151
Reviewed-on: https://go-review.googlesource.com/18084
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 15:20:00 +00:00
Mikio Hara
6766a293ef os: add missing copyright notice
Change-Id: I496b701e2fcc944c764002643c7b0b2ce9e08806
Reviewed-on: https://go-review.googlesource.com/18182
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-12-29 09:02:28 +00:00
Austin Clements
c7c7c7031d runtime: fix, simplify, and improve scan state in goroutine header
Currently goroutineheader goes through some convolutions to *almost*
print the scan state of a G. However, the code path that would print
the scan state of the G refers to gStatusStrings where it almost
certainly meant to refer to gScanStatusStrings (which is unused), so
it winds up printing the regular status string without the scan state
either way. Furthermore, if the G is in _Gwaiting, we override the
status string and lose where this would indicate the scan state if it
worked.

This commit fixes this so the runtime prints the scan state. However,
rather than using a parallel list of status strings, this simply adds
a conditional print if the scan bit is set. This lets us remove the
string list, prints the scan state even in _Gwaiting, and lets us
strip off the scan bit at the beginning of the function, which
simplifies the rest of it.

Change-Id: Ic0adbe5c05abf4adda93da59f93b578172b28e3d
Reviewed-on: https://go-review.googlesource.com/18092
Reviewed-by: Keith Randall <khr@golang.org>
2015-12-28 01:12:24 +00:00
Ian Lance Taylor
f7e51c1320 runtime: adjust gsignal stack to current signal stack
If non-Go code calls sigaltstack before a signal is received, use
sigaltstack to determine the current signal stack and set the gsignal
stack to use it.  This makes the Go runtime more robust in the face of
non-Go code.  We still can't handle a disabled signal stack or a signal
triggered with SA_ONSTACK clear, but we now give clear errors for those
cases.

Fixes #7227.
Update #9896.

Change-Id: Icb1607e01fd6461019b6d77d940e59b3aed4d258
Reviewed-on: https://go-review.googlesource.com/18102
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-12-24 17:00:04 +00:00
Nigel Tao
e4dcf5c8c2 image/color: have NYCbCrA.RGBA work in 16-bit color.
This makes NYCbCrA consistent with YCbCr.

Fixes #13706.

Change-Id: Ifced84372e4865925fa6efef9ca2f1de43da70e0
Reviewed-on: https://go-review.googlesource.com/18115
Reviewed-by: Rob Pike <r@golang.org>
2015-12-24 06:55:33 +00:00
Jonathan Boulle
5b5e19ea65 net/http: fix typo in docstring
s/activitiy/activity

Change-Id: Ib2bbc929b38b1993000da57daed2d795f4a93997
Reviewed-on: https://go-review.googlesource.com/18131
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-24 01:28:11 +00:00
Rob Pike
54641818c9 crypto/cipher: fix typo from last change
s/encrypt/decrypt/

The text is unsafe to cut and paste...

Change-Id: Iab19ddf8182d087e9a4b4d34a9eeabd1d2aa02d6
Reviewed-on: https://go-review.googlesource.com/18104
Reviewed-by: Rob Pike <r@golang.org>
2015-12-22 23:26:12 +00:00
Rob Pike
4e6750af81 crypto/cipher: improve documentation for AEAD
Give a link to the wikipedia page describing the mechanism and
explain better how to use the same buffer for input and output.

Change-Id: If6dfd6cf9c6dff0517cb715f60a11349dbdd91e0
Reviewed-on: https://go-review.googlesource.com/18103
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-22 21:45:53 +00:00
Mikio Hara
11ac72a116 net: fix race in TestTCPStress
Fixes #13704.

Change-Id: I7afef5058fa88b0de41213cf46219b684369f47f
Reviewed-on: https://go-review.googlesource.com/18111
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-22 03:39:39 +00:00
Mikio Hara
f80f6e4580 net/internal/socktest: simplify log message format
This change replaces the existing log format separated by commas and
spaces with space-separated one.

Change-Id: I9a4b38669025430190c9a1a6b5c82b862866559d
Reviewed-on: https://go-review.googlesource.com/17999
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-22 03:38:51 +00:00
David Symonds
8567fb7a0a net/http: add new HTTP 451 status code, Unavailable For Legal Reasons.
Approved by the IETF.

https://datatracker.ietf.org/doc/draft-ietf-httpbis-legally-restricted-status/

Change-Id: I688597bb5f7ef7c7a9be660a4fcd2ef02d9dc9f4
Reviewed-on: https://go-review.googlesource.com/18112
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Symonds <dsymonds@golang.org>
2015-12-22 02:14:22 +00:00
Robert Griesemer
d6a203ecab cmd/compile: const name and label name may match
Fixes #13684.

Change-Id: I3977119b6eb1d6b7dc2ea1e7d6656a8f0d421bc1
Reviewed-on: https://go-review.googlesource.com/18060
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-12-21 20:21:28 +00:00
Mikio Hara
97f854cd7b net: make use of IPv4 for parsing routing information on windows
In general the package net deals IPv4 addresses as IPv6 IPv4-mapped
addresses internally for the dual stack era, when we need to support
various techniques on IPv4/IPv6 translation.

This change makes windows implementation follow the same pattern which
BSD variants and Linux do.

Updates #13544.

Also fixes an unintentionally formatted line by accident by gofmt.

Change-Id: I4953796e751fd8050c73094468a0d7b0d33f5516
Reviewed-on: https://go-review.googlesource.com/17992
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-19 10:00:04 +00:00
Alex Brainman
2cf5f04ffd net: adjust TestInterfaceHardwareAddrWithGetmac
CL skips interfaces that are not listed on getmac output.

Fixes #13606

Change-Id: Ic25c9dc95e8eeff4d84b78e99131a4f97020164c
Reviewed-on: https://go-review.googlesource.com/17994
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
2015-12-19 09:05:38 +00:00
Ian Lance Taylor
fbdfa99246 runtime: for c-archive/c-shared, don't install unnecessary signal handlers
Only install signal handlers for synchronous signals that become
run-time panics.  Set the SA_ONSTACK flag for other signal handlers as
needed.

Fixes #13028.
Update #12465.
Update #13034.
Update #13042.

Change-Id: I28375e70641f60630e10f3c86e24b6e4f8a35cc9
Reviewed-on: https://go-review.googlesource.com/17903
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-18 22:27:38 +00:00
Ian Lance Taylor
f40c05eea4 runtime: write sigsetstack for Darwin, fix sigaction arg
It turns out that the second argument for sigaction on Darwin has a
different type than the first argument.  The second argument is the user
visible sigaction struct, and does not have the sa_tramp field.

I base this on
  http://www.opensource.apple.com/source/Libc/Libc-1081.1.3/sys/sigaction.c
not to mention actual testing.

While I was at it I removed a useless memclr in setsig, a relic of the C
code.

This CL is Darwin-specific changes.  The tests for this CL are in
https://golang.org/cl/17903 .

Change-Id: I61fe305c72311df6a589b49ad7b6e49b6960ca24
Reviewed-on: https://go-review.googlesource.com/18015
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-12-18 20:56:10 +00:00
Russ Cox
57337da169 testing: use debug.SetTraceback("all") to show all goroutines at test timeout
Fixes #13681.

Change-Id: I308930f4d9200fbe0f09cd08c38392ca1bb0db67
Reviewed-on: https://go-review.googlesource.com/18044
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-12-18 20:51:32 +00:00
Russ Cox
bb0567b304 runtime/debug: add SetTraceback
Programs that call panic to crash after detecting a serious problem
may wish to use SetTraceback to force printing of all goroutines first.

Change-Id: Ib23ad9336f405485aabb642ca73f454a14c8baf3
Reviewed-on: https://go-review.googlesource.com/18043
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-18 20:51:14 +00:00
Austin Clements
ea5b9d5bd3 debug/elf: rename Chdr64.Reserved to _
This future-proofs the Chdr64 structure against later versions of ELF
defining this field and declutters the documentation without changing
the layout of the struct.

This structure does not exist in the current release, so this change
is safe.

Change-Id: I239aad7243ddaf063a1f8cd521d8a50b30413281
Reviewed-on: https://go-review.googlesource.com/18028
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-18 20:41:26 +00:00
Russ Cox
5b085482ae cmd/go: ignore XML errors after Go <meta> tags
Fixes #13683.

Change-Id: I26afb3ac346beb95624f9032d94a29b5bc7853ef
Reviewed-on: https://go-review.googlesource.com/18051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-18 19:51:06 +00:00
Joe Tsai
5270b57e51 bytes: document that buffer is reused in Truncate and Reset
Fixes #13671

Change-Id: Ic752de6a3030ff25474717505fa05895054217e7
Reviewed-on: https://go-review.googlesource.com/18029
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 19:40:58 +00:00
Brad Fitzpatrick
b73e247a8e net/http: document that Server.TLSNextProto has automatic HTTP/2 also
Copy the same sentence from Transport.TLSNextProto.

Change-Id: Ib67bf054e891a68be8ba466a8c52968363374d16
Reviewed-on: https://go-review.googlesource.com/18031
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 18:30:39 +00:00
Russ Cox
ab74f5944e cmd/go: do not skip dirs with syntax errors in wildcard matching (like ./...)
Fixes #11407.

Change-Id: If35a8e04a3abf8acf955250c909dde57131b6bb8
Reviewed-on: https://go-review.googlesource.com/17971
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-18 17:21:29 +00:00
Austin Clements
d446ba99a4 runtime: document stack barrier synchronization rules
Change-Id: I545e53561f37bceabd26d814d272cecc3ff19847
Reviewed-on: https://go-review.googlesource.com/18024
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 17:08:52 +00:00
Austin Clements
f90b48e0d3 runtime: require the stack barrier lock to traceback cgo and libcalls
Currently, if sigprof determines that the G is in user code (not cgo
or libcall code), it will only traceback the G stack if it can acquire
the stack barrier lock. However, it has no such restriction if the G
is in cgo or libcall code. Because cgo calls count as syscalls, stack
scanning and stack barrier installation can occur during a cgo call,
which means sigprof could attempt to traceback a G in a cgo call while
scanstack is installing stack barriers in that G's stack. As a result,
the following sequence of events can cause the sigprof traceback to
panic with "missed stack barrier":

1. M1: G1 performs a Cgo call (which, on Windows, is any system call,
   which could explain why this is easier to reproduce on Windows).

2. M1: The Cgo call puts G1 into _Gsyscall state.

3. M2: GC starts a scan of G1's stack. It puts G1 in to _Gscansyscall
   and acquires the stack barrier lock.

4. M3: A profiling signal comes in. On Windows this is a global
   (though I don't think this matters), so the runtime stops M1 and
   calls sigprof for G1.

5. M3: sigprof fails to acquire the stack barrier lock (because the
   GC's stack scan holds it).

6. M3: sigprof observes that G1 is in a Cgo call, so it calls
   gentraceback on G1 with its Cgo transition point.

7. M3: gentraceback on G1 grabs the currently empty g.stkbar slice.

8. M2: GC finishes scanning G1's stack and installing stack barriers.

9. M3: gentraceback encounters one of the just-installed stack
   barriers and panics.

This commit fixes this by only allowing cgo tracebacks if sigprof can
acquire the stack barrier lock, just like in the regular user
traceback case.

For good measure, we put the same constraint on libcall tracebacks.
This case is probably already safe because, unlike cgo calls, libcalls
leave the G in _Grunning and prevent reaching a safe point, so
scanstack cannot run during a libcall. However, this also means that
sigprof will always acquire the stack barrier lock without contention,
so there's no cost to adding this constraint to libcall tracebacks.

Fixes #12528. For 1.5.3 (will require some backporting).

Change-Id: Ia5a4b8e3d66b23b02ffcd54c6315c81055c0cec2
Reviewed-on: https://go-review.googlesource.com/18023
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 17:08:39 +00:00
Austin Clements
a4a57bb4f9 runtime: prevent race between setNextBarrierPC and sigprof
Currently, setNextBarrierPC manipulates the stack barriers without
acquiring the stack barrier lock. This is mostly okay because
setNextBarrierPC also runs synchronously on the G and prevents safe
points, but this doesn't prevent a sigprof from occurring during a
setNextBarrierPC and performing a traceback.

Given that setNextBarrierPC simply sets one entry in the stack barrier
array, this is almost certainly safe in reality. However, given that
this depends on a subtle argument, which may not hold in the future,
and that setNextBarrierPC almost never happens, making it nowhere near
performance-critical, we can simply acquire the stack barrier lock and
be sure that the synchronization will work.

Updates #12528. For 1.5.3.

Change-Id: Ife696e10d969f190157eb1cbe762a2de2ebce079
Reviewed-on: https://go-review.googlesource.com/18022
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 17:08:32 +00:00
Ian Lance Taylor
ebf64bcc24 cmd/vet: add some checks for invalid pointer passing using cgo
Update #12416.

Change-Id: I21d97cbe211ccc8048e5a78ea4d89664f4d195ba
Reviewed-on: https://go-review.googlesource.com/17041
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 00:31:21 +00:00
Alan Donovan
a750149579 go/types: add link to tutorial
Change-Id: Ic4f4bc7ea7478908716b951815280e394c55310b
Reviewed-on: https://go-review.googlesource.com/17975
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-17 23:02:07 +00:00
Brad Fitzpatrick
8db371b3d5 api: create go1.6.txt
Change-Id: If2b30ab412d6799c8be01eb007462d6b58660ece
Reviewed-on: https://go-review.googlesource.com/18014
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-17 22:45:50 +00:00
Brad Fitzpatrick
4577cfcb0b src: remove reference to since-deleted dist -s flag
(Found while debugging release problems with go1.6beta1)

Updates #12002

Change-Id: Iec197a754205e7fd28be154f27f17f3315886364
Reviewed-on: https://go-review.googlesource.com/18011
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2015-12-17 22:03:56 +00:00
Brad Fitzpatrick
c70df74aab net/http: document ResponseWriter and Handler more; add test
Update docs on ResponseWriter and Handler around concurrency.

Also add a test.

The Handler docs were old and used "object" a lot. It was also too
ServeMux-centric.

Fixes #13050
Updates #13659 (new issue found in http2 while writing the test)

Change-Id: I25f53d5fa54f1c9d579d3d0f191bf3d94b1a251b
Reviewed-on: https://go-review.googlesource.com/17982
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 21:21:31 +00:00
Russ Cox
c7b1ef9918 cmd/link: reject non-package main toplevel.a file, remove dead code
The test for non-package main top-level inputs is done while parsing
the export data. Issue #13468 happened because we were not parsing
the export data when using compiler-generated archives
(that is, when using go tool compile -pack).

Fix this by parsing the export data even for archives.

However, that turns up a different problem: the export data check
reports (one assumes spurious) skew errors now, because it has
not been run since Go 1.2.
(Go 1.3 was the first release to use go tool compile -pack.)

Since the code hasn't run since Go 1.2, it can't be that important.
Since it doesn't work today, just delete it.

Figuring out how to make this code work with Robert's export
format was one of the largest remaining TODOs for that format.
Now we don't have to.

Fixes #13468 and makes the world a better place.

Change-Id: I40a4b284cf140d49d48b714bd80762d6889acdb9
Reviewed-on: https://go-review.googlesource.com/17976
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-17 20:59:51 +00:00
Russ Cox
2f08bd96a0 cmd/go: for go get -insecure, do not fall back to HTTP for non-200 responses
Since we allow non-200 responses from HTTPS in normal operation,
it seems odd to reject them in -insecure operation.

Fixes #13037 (again).

Change-Id: Ie232f7544ab192addfad407525888db6b967befe
Reviewed-on: https://go-review.googlesource.com/17945
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:28:14 +00:00
Russ Cox
a227351b62 cmd/go: fix processing of HTTPS 404 without -insecure
The change here is to move the closeBody call into the if block.
The logging adjustments are just arranging to tell the truth:
in particular if we're not in insecure mode and we get a non-200
error then we do not actually ignore the response
(except as caused by closing the body incorrectly).

As the comment below the change indicates, it is intentional that
we process non-200 pages. The code does process them, because
the if err != nil || status != 200 block does not return.
But that block does close the body, which depending on timing
can apparently poison the later read from the body.

See #13037's initial report:

	$ go get -v bosun.org/cmd/bosun/cache
	Fetching https://bosun.org/cmd/bosun/cache?go-get=1
	ignoring https fetch with status code 404
	Parsing meta tags from https://bosun.org/cmd/bosun/cache?go-get=1 (status code 404)
	import "bosun.org/cmd/bosun/cache": parsing bosun.org/cmd/bosun/cache: http: read on closed response body
	package bosun.org/cmd/bosun/cache: unrecognized import path "bosun.org/cmd/bosun/cache"

The log print about ignoring the https fetch is not strictly true,
since the next thing that happened was parsing the body of that fetch.
But the read on the closed response body failed during parsing.

Moving the closeBody to happen only when we're about to discard the
result and start over (that is, only in -insecure mode) fixes the parse.

At least it should fix the parse. I can't seem to break the parse anymore,
because of #13648 (close not barring future reads anymore),
but this way is clearly better than the old way. If nothing else the old code
closed the body twice when err != nil and -insecure was not given.

Fixes #13037.

Change-Id: Idf57eceb6d5518341a2f7f75eb8f8ab27ed4e0b4
Reviewed-on: https://go-review.googlesource.com/17944
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:28:00 +00:00
Russ Cox
9f0055a232 Revert "cmd/go: allow omitted user name in git ssh repo syntax"
This caused #13657.
Reverting fixes #13657.

I was trying to be helpful by fixing #12313,
but I don't need the fix myself.
Will leave for someone with more motivation.

This reverts commit 3e9f063670.

Change-Id: Ifc78a6196f23e0f58e3b9ad7340e207a2d5de0a6
Reviewed-on: https://go-review.googlesource.com/17977
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 20:25:42 +00:00
Brad Fitzpatrick
c052222b34 net/http: don't accept invalid bytes in server request headers
Fixes #11207

Change-Id: I7f00b638e749fbc7907dc1597347ea426367d13e
Reviewed-on: https://go-review.googlesource.com/17980
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 20:22:08 +00:00
Brad Fitzpatrick
18227bb7b6 net/http: be more consistent about Request.Method "" vs "GET"
Patch from Russ.

No bug identified, but I didn't search exhaustively. The new code is
easier to read.

Fixes #13621

Change-Id: Ifda936e4101116fa254ead950b5fe06adb14e977
Reviewed-on: https://go-review.googlesource.com/17981
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 20:21:44 +00:00
Russ Cox
761ac75a94 cmd/go: fix git submodule fetch
Thanks to @toxeus on GitHub for the test case.

Fixes #12612.

Change-Id: I0c32fbe5044f3552053460a5347c062568093dff
Reviewed-on: https://go-review.googlesource.com/17974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:18:18 +00:00
Brad Fitzpatrick
66fcf56729 net/http: update bundled http2, add tests reading response Body after Close
Updates to golang.org/x/net/http2 git rev 28273ec9 for
https://golang.org/cl/17937

Fixes #13648

Change-Id: I27c77524b2e4a172c5f8be08f6fbb0f2e2e4b200
Reviewed-on: https://go-review.googlesource.com/17938
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 19:49:13 +00:00
Ian Lance Taylor
54977cd3de cmd/go: runtime and runtime/internal packages depend on runtime/internal/sys
Fixes #13655.

Change-Id: I764019aecdd59743baa436b7339499e6c2126268
Reviewed-on: https://go-review.googlesource.com/17916
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 19:37:18 +00:00
Russ Cox
0cb68acea2 cmd/go: respect umask when creating executables
Also update many call sites where I forgot that the permission
argument is going to be masked by umask.

Fixes #12692.

Change-Id: I52b315b06236122ca020950447863fa396b68abd
Reviewed-on: https://go-review.googlesource.com/17950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 19:24:06 +00:00
Brad Fitzpatrick
807c6c58fc net: fix the build even harder
Should fix nacl.

Follow-up to
https://golang.org/cl/17936 (fix race) and
https://golang.org/cl/17914 (fix build) for
https://golang.org/cl/16953 (broke the build)

Third time's a charm.

Change-Id: I23930d5cff4235209546952ce2231f165ab5bf8a
Reviewed-on: https://go-review.googlesource.com/17939
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 18:43:12 +00:00
Russ Cox
d270a6794b runtime: disable gdb test when a GOROOT_FINAL move is pending
Fixes #13577.

Change-Id: I0bb8157d6210b0c7c09380c2163b7d7349495732
Reviewed-on: https://go-review.googlesource.com/17970
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 17:56:15 +00:00
Brad Fitzpatrick
cfc9fde54d net/http: updated bundled http2 to finish trailer support
This updates the bundled copy of x/net/http2 to git rev d2ecd08
for https://golang.org/cl/17912 (http2: send client trailers)
and enables the final Trailer test for http2.

Fixes #13557

Change-Id: Iaa15552b82bf7a2cb01b7787a2e1ec5ee680a9d3
Reviewed-on: https://go-review.googlesource.com/17935
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 17:50:30 +00:00
Alex Brainman
f172a28f24 net: include both ipv4 and ipv6 netsh output in TestInterfacesWithNetsh
Also include test for interface state (up or down).

Updates #13606

Change-Id: I03538d65525ddd9c2d0254761861c2df7fc5bd5a
Reviewed-on: https://go-review.googlesource.com/17850
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-17 17:41:41 +00:00
Brad Fitzpatrick
3ad3d5931b net: fix race in test
Fixes race builders, broken in https://golang.org/cl/16953

Change-Id: Id61171672b69d0ca412de4b44bf2c598fe557906
Reviewed-on: https://go-review.googlesource.com/17936
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 17:26:30 +00:00
Russ Cox
0d641c754f cmd/go: allow ~ as first char of path element in general git import paths
This makes go get gitserver/~user/repo.git/foo work.

Fixes #9193.

Change-Id: I8c9d4096903288f7f0e82d6ed1aa78bf038fb81a
Reviewed-on: https://go-review.googlesource.com/17952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:13:03 +00:00
Russ Cox
06b46c0d9c cmd/go: don't be clever about mtime precision in test
This doesn't happen enough in the tests to be worth debugging.
Empirically, I expect this to add 5 seconds to the overall 'go test -short cmd/go'
on systems with precise file systems, and nothing on systems without them
(like my Mac).

Fixes #12205.

Change-Id: I0a17cb37bdedcfc0f921c5ee658737f1698c153b
Reviewed-on: https://go-review.googlesource.com/17953
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 17:06:15 +00:00
Russ Cox
e357eb97a6 cmd/go: document that package documentation is ignored
Fixes #11801.

Change-Id: I2caeac7fdddc7f29015d6db8d4b3e296c8b9c423
Reviewed-on: https://go-review.googlesource.com/17954
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:04:55 +00:00
Russ Cox
aaa0bc1043 net/http: document a few ServeMux behaviors
Fixes #13639.
Fixes #11757.

Change-Id: Iecf9ebcd652c23c96477305a41082e5b63b41d83
Reviewed-on: https://go-review.googlesource.com/17955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:03:05 +00:00
Russ Cox
3e9f063670 cmd/go: allow omitted user name in git ssh repo syntax
No test because the code has no test.

Fixes #12313.

Change-Id: I2cfd0a0422c0cd76f0371c2d3bbbdf5bb3b3f1eb
Reviewed-on: https://go-review.googlesource.com/17951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:01:05 +00:00
Russ Cox
f9137c5373 cmd/go: document that tests run in the source directory
Fixes #13538.

Change-Id: I621bbe2befe838d16d3664d7a5e30d5d7cceae33
Reviewed-on: https://go-review.googlesource.com/17949
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:00:37 +00:00
Russ Cox
f474885f8a cmd/go: document where get writes, and not vendor directories
Fixes #12260.

Change-Id: I95c27aad6de8064b9a205d4ee507bce75926f16d
Reviewed-on: https://go-review.googlesource.com/17948
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:00:02 +00:00
Russ Cox
8fac7e3cc7 cmd/go: document that go generate accepts all build flags
Fixes #12544.

Change-Id: I5e2fd1fbb21816e9f6fb022e2664484a71093b04
Reviewed-on: https://go-review.googlesource.com/17947
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:59:46 +00:00
Ian Lance Taylor
ab39b8de7e os/signal: document signal handling
This is an attempt to document the current state of signal handling.
It's not intended to describe the best way to handle signals.  Future
changes to signal handling should update these docs as appropriate.

update #9896.

Change-Id: I3c50af5cc641357b57dfe90ae1c7883a7e1ec059
Reviewed-on: https://go-review.googlesource.com/17877
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 16:59:39 +00:00
Russ Cox
0a0f8bae27 cmd/go: document that -p applies to test binary execution
Fixes #11521.

Change-Id: I73615b881df4a0d5e2f5bc5059359d150ca8c105
Reviewed-on: https://go-review.googlesource.com/17946
Reviewed-by: Joe Shaw <joe@joeshaw.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:59:30 +00:00
Brad Fitzpatrick
7688f0d9fb cmd/pprof: fix scaling of "gigabyte" unit
Fixes #13654

Change-Id: Id2ce32c52efcfdbd66630725d62d2ca6bf0916d5
Reviewed-on: https://go-review.googlesource.com/17934
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 16:38:28 +00:00
mattn
7a48117899 os,internal/syscall/windows: use ReadFile/MultiByteToWideChar to read from console
Fixes #6303

Change-Id: Ib2cd15ac6106ef8e6b975943db8efc8d8ab21052
Reviewed-on: https://go-review.googlesource.com/4310
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 16:23:39 +00:00
Brad Fitzpatrick
8cdd7d14ac net: fix build
https://golang.org/cl/16953 broke the world.

Change-Id: I7cbd4105338ff896bd0c8f69a0b126b6272be2e5
Reviewed-on: https://go-review.googlesource.com/17914
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:06:58 +00:00
Brad Fitzpatrick
53a207131d net/http: document that ListenAndServe is a bit more than Listen+Serve
Document that ListenAndServe and ListenAndServeTLS also set TCP
keep-alives.

Fixes #12748

Change-Id: Iba2e8a58dd657eba326db49a6c872e2d972883a4
Reviewed-on: https://go-review.googlesource.com/17681
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 15:54:24 +00:00
Joe Tsai
7a2913c9f5 archive/tar: document how Reader.Read handles header-only files
Commit dd5e14a751 ensured that no data
could be read for header-only files regardless of what the Header.Size
said. We should document this fact in Reader.Read.

Updates #13647

Change-Id: I4df9a2892bc66b49e0279693d08454bf696cfa31
Reviewed-on: https://go-review.googlesource.com/17913
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 15:48:10 +00:00
Dan Peterson
5c0629b503 net: prefer error for original name on lookups
With certain names and search domain configurations the
returned error would be one encountered while querying a
generated name instead of the original name. This caused
confusion when a manual check of the same name produced
different results.

Now prefer errors encountered for the original name.

Also makes the low-level DNS connection plumbing swappable
in tests enabling tighter control over responses without
relying on the network.

Fixes #12712
Updates #13295

Change-Id: I780d628a762006bb11899caf20b5f97b462a717f
Reviewed-on: https://go-review.googlesource.com/16953
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 15:17:06 +00:00
Russ Cox
be7544be23 crypto/x509: handle CRLDistributionPoints without FullNames
Fixes #12910.

Change-Id: If446e5dce236483bbb898cc5959baf8371f05142
Reviewed-on: https://go-review.googlesource.com/17550
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2015-12-17 07:17:28 +00:00
Russ Cox
70cee781fc cmd/go: use tags when evaluating file system wildcards like ./...
Thanks to Albert Hafvenström for the diagnosis.

Fixes #11246.

Change-Id: I2b9e670c0ecf6aa01e5bf4d7a402619e93cc4f4a
Reviewed-on: https://go-review.googlesource.com/17942
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 05:46:29 +00:00
Russ Cox
37f2afa625 cmd/go: disable use of -linkmode=external in tests when CGO_ENABLED=0
If cgo is turned off, there may not be an external linker available.

Fixes #13450.

Change-Id: Idbf3f3f57b4bb3908b67264f96d276acc952102a
Reviewed-on: https://go-review.googlesource.com/17941
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 05:46:21 +00:00
Russ Cox
4378746a4b cmd/dist: show output from failed compiler execution
Maybe it will say something that helps the user understand the problem.

Note that we can't use os/exec.ExitError's new Stderr field because
cmd/dist is compiled with Go 1.4.

Fixes #13099.

Change-Id: I4b5910434bf324d1b85107002a64684d8ba14dc8
Reviewed-on: https://go-review.googlesource.com/17940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 03:14:11 +00:00
Ian Lance Taylor
fcbf04f9b9 cmd/cgo: gccgo support for cgoCheckPointer
This uses weak declarations so that it will work with current versions
of gccgo that do not support pointer checking.

Change-Id: Ia34507e3231ac60517cb6834f0b673764715a256
Reviewed-on: https://go-review.googlesource.com/17429
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 03:01:38 +00:00
Joe Tsai
2ae895c0ce archive/tar: spell license correctly in example
Change-Id: Ice85d161f026a991953bd63ecc6ec80f8d06dfbd
Reviewed-on: https://go-review.googlesource.com/17901
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 02:46:41 +00:00
Brad Fitzpatrick
64de502caa net/http: update Response.Trailer doc
I updated this in the previous commit (https://golang.org/cl/17931)
but noticed a typo. and it still wasn't great.

The Go 1.5 text was too brief to know how to use it:

    // Trailer maps trailer keys to values, in the same
    // format as the header.

Change-Id: I33c49b6a4a7a3596735a4cc7865ad625809da900
Reviewed-on: https://go-review.googlesource.com/17932
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 02:46:04 +00:00
Russ Cox
8350e06556 cmd/go: add -args to 'go test' to resolve -v ambiguity
The new flag -args stops flag processing, leaving the rest of the command line
to be passed to the underlying test binary verbatim. Thus, both of these pass
a literal -v -n on the test binary command line, without putting the go command
into verbose mode or disabling execution of commands:

	go test . -args -v -n
	go test -args -v -n

Also try to make the documentation a bit clearer.

Fixes #7221.
Fixes #12177.

Change-Id: Ief9e830a6fbb9475d96011716a86e2524a35eceb
Reviewed-on: https://go-review.googlesource.com/17775
Reviewed-by: Rob Pike <r@golang.org>
2015-12-17 01:59:58 +00:00
Russ Cox
5c596b51fd Revert "cmd/dist: fix build after "go test" argument order change"
No longer needed - the change to 'go test' was rolled back.

This reverts commit 2c96e5d2fc.

Change-Id: Ibe9c5f48e3e4cbbbde2f5c8c516b2987ebba55ae
Reviewed-on: https://go-review.googlesource.com/17776
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-12-17 01:43:47 +00:00
Russ Cox
e5ba367c10 go/build: disable test on nacl (and a few others, unnecessarily)
Fixes build.

Change-Id: Ia71fc031cc8eb575e5ab5323ff4084147d143744
Reviewed-on: https://go-review.googlesource.com/17867
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 01:43:05 +00:00
Brad Fitzpatrick
691e63b7fe net/http: update bundled copy of http2, enable TestTrailersServerToClient tests
This CL updates the bundled copy of x/net/http2 to include
https://golang.org/cl/17930 and enables the previously-skipped tests
TestTrailersServerToClient_h2 and TestTrailersServerToClient_Flush_h2.

It also updates the docs on http.Response.Trailer to describe how to
use it. No change in rules. Just documenting the old unwritten rules.
(there were tests locking in the behavior, and misc docs and examples
scattered about, but not on http.Response.Trailer itself)

Updates #13557

Change-Id: I6261d439f6c0d17654a1a7928790e8ffed16df6c
Reviewed-on: https://go-review.googlesource.com/17931
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-12-17 01:29:43 +00:00
Adam Langley
40ac3690ef crypto/rsa: check CRT result.
This change adds a check after computing an RSA signature that the
signature is correct. This prevents an error in the CRT computation from
leaking the private key. See references in the linked bug.

benchmark                  old ns/op     new ns/op     delta
BenchmarkRSA2048Sign-3     5713305       6225215       +8.96%

Fixes #12453

Change-Id: I1f24e0b542f7c9a3f7e7ad4e971db3dc440ed3c1
Reviewed-on: https://go-review.googlesource.com/17862
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 00:00:33 +00:00
Alex Brainman
f33f9b2cee net: make windows (*netFD).connect work like its unix version
CL 17821 used syscall.CancelIoEx to cancel outstanding connect
call, but did not check for syscall.CancelIoEx return value.
Also I am worried about introducing race here. We should use
proper tools available for us instead. For example, we could
use fd.setWriteDeadline just like unix version does. Do that.

Change-Id: Idb9a03c8c249278ce3e2a4c49cc32445d4c7b065
Reviewed-on: https://go-review.googlesource.com/17920
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
2015-12-16 23:51:38 +00:00
Shenghou Ma
a766d8e59c cmd/cgo: map C unsigned char back to _Ctype_uchar in error messages
Fixes #13635.

Change-Id: Icab4a45567f435f002a8f6c85db9538acf054a70
Reviewed-on: https://go-review.googlesource.com/17863
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 22:13:17 +00:00
Brad Fitzpatrick
e8e786c20d net/http: updated bundled copy of x/net/http2
Updates to x/net/http2 git rev c24de9d5

Change-Id: I3d929ae38dca1a93e9a262d4eaaafee1d36fa839
Reviewed-on: https://go-review.googlesource.com/17896
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 21:00:35 +00:00
Russ Cox
03c8164849 cmd/compile: fix magic multiply smashing AX
Fixes #12411.

Change-Id: I2202a754c7750e3b2119e3744362c98ca0d2433e
Reviewed-on: https://go-review.googlesource.com/17818
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:58:17 +00:00
Russ Cox
63a6f305ef cmd/compile: diagnose invalid switch interface{} case earlier
Fixes #11737.

Change-Id: Id231b502ac5a44035dc3a02515b43bf665cb1e87
Reviewed-on: https://go-review.googlesource.com/17816
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:58:00 +00:00
Russ Cox
91c8e5f80b cmd/compile: fix export type conversion loss in inlined func body
Fixes #12677.

Change-Id: I72012f55615fcf5f4a16c054706c9bcd82e49ccd
Reviewed-on: https://go-review.googlesource.com/17817
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:30:04 +00:00
Russ Cox
a40281112c Revert "cmd/go: fix processing of flags for test binaries."
This broke a number of common "go test" invocations.
Will fix the original concern differently.

This reverts commit 6acb4d944d.

Fixes #13583.

Change-Id: If582b81061df28173c698bed1d7d8283b0713cae
Reviewed-on: https://go-review.googlesource.com/17773
Reviewed-by: Rob Pike <r@golang.org>
2015-12-16 20:25:59 +00:00
Brad Fitzpatrick
654daac3bc net/http: split Trailers tests into two halves
The old test was in client_test.go but was a mix of four things:

- clients writing trailers
- servers reading trailers
- servers writing trailers
- clients reading trailers

It definitely wasn't just about clients.

This moves it into clientserver_test.go and separates it into two
halves:

- servers writing trailers + clients reading trailers
- clients writing trailers + servers reading trailers

Which still isn't ideal, but is much better, and easier to read.

Updates #13557

Change-Id: I8c3e58a1f974c1b10bb11ef9b588cfa0f73ff5d9
Reviewed-on: https://go-review.googlesource.com/17895
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-16 20:25:46 +00:00
Russ Cox
6bcec09ceb math/big: additional Montgomery cleanup
Also fix bug reported in CL 17510.

Found during fix of #13515 in CL 17672, but separate from the fix.

Change-Id: I4b1024569a98f5cfd2ebb442ec3d64356164d284
Reviewed-on: https://go-review.googlesource.com/17673
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-16 20:25:29 +00:00
Russ Cox
0abf443513 runtime: remove incorrect TODO added in CL 16035
I've already turned away one attempt to remove this field.
As the comment above the struct says, many tools know the layout.
The field cannot simply be removed.

It was one thing to remove the fields name, but the TODO should
not have been added.

Change-Id: If40eacf0eb35835082055e129e2b88333a0731b9
Reviewed-on: https://go-review.googlesource.com/17741
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:23:15 +00:00
Russ Cox
bdd5d6e257 cmd/go: tiny cleanup
Change-Id: I65084e518c735f1e50d191a612cd32533b241685
Reviewed-on: https://go-review.googlesource.com/17742
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 20:22:28 +00:00
Russ Cox
0c428a5617 go/build: support vendor directories in Import
This fix, plus a one-line change to golang.org/x/tools/go/loader,
is sufficient to let that loader package process source code
using vendored packages. For example,

	GOPATH="" ssadump net/http # uses vendored http2

used to fail, not able to find net/http's import of the vendored
copy of golang.org/x/net/http2/hpack.

This CL plus the fix to loader (CL 17727) suffices to get ssadump working,
as well as - I expect - most other source code processing built
on golang.org/x/tools/go/loader.

Fixes #12278.

Change-Id: I83715e757419171159f67d49bb453636afdd91f0
Reviewed-on: https://go-review.googlesource.com/17726
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:22:18 +00:00
Brad Fitzpatrick
6e11f45ebd net/http: make Server validate Host headers
Fixes #11206 (that we accept invalid bytes)
Fixes #13624 (that we don't require a Host header in HTTP/1.1 per spec)

Change-Id: I4138281d513998789163237e83bb893aeda43336
Reviewed-on: https://go-review.googlesource.com/17892
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-16 19:52:07 +00:00
Brad Fitzpatrick
c2fb457ef7 net/url: fix RFC typo in comments
Change-Id: I04ed7e5ab992c1eb3528432797026d0c7d2818f1
Reviewed-on: https://go-review.googlesource.com/17894
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-16 19:19:36 +00:00
Austin Clements
5de3ff2648 runtime: accept NumGC==0 in TestMemStats
TestMemStats currently requires that NumGC != 0, but GC may
legitimately not have run (for example, if this test runs first, or
GOGC is set high, etc). Accept NumGC == 0 and instead sanity check
NumGC by making sure that all pause times after NumGC are 0.

Fixes #11989.

Change-Id: I4203859fbb83292d59a509f2eeb24d6033e7aabc
Reviewed-on: https://go-review.googlesource.com/17830
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-12-16 18:54:50 +00:00
Robert Griesemer
65cd1ba682 cmd/compile: re-vendor math/big so we use latest version in compiler
This simply copies the current version of math/big into the
compiler directory. The change was created automatically by
running cmd/compile/internal/big/vendor.bash. No other manual
changes.

Change-Id: Ica225d196b3ac10dfd9d4dc1e4e4ef0b22812ff9
Reviewed-on: https://go-review.googlesource.com/17900
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 18:35:23 +00:00
Brad Fitzpatrick
1fe3933920 net/http: fix Transport race returning bodyless responses and reusing conns
The Transport had a delicate protocol between its readLoop goroutine
and the goroutine calling RoundTrip. The basic concern is that the
caller's RoundTrip goroutine wants to wait for either a
connection-level error (the conn dying) or the response. But sometimes
both happen: there's a valid response (without a body), but the conn
is also going away. Both goroutines' logic dealing with this had grown
large and complicated with hard-to-follow comments over the years.

Simplify and document. Pull some bits into functions and do all
bodyless stuff in one place (it's special enough), rather than having
a bunch of conditionals scattered everywhere. One test is no longer
even applicable since the race it tested is no longer possible (the
code doesn't exist).

The bug that this fixes is that when the Transport reads a bodyless
response from a server, it was returning that response before
returning the persistent connection to the idle pool. As a result,
~1/1000 of serial requests would end up creating a new connection
rather than re-using the just-used connection due to goroutine
scheduling chance. Instead, this now adds bodyless responses'
connections back to the idle pool first, then sends the response to
the RoundTrip goroutine, but making sure that the RoundTrip goroutine
is outside of its select on the connection dying.

There's a new buffered channel involved now, which is a minor
complication, but it's much more self-contained and well-documented
than the previous complexity. (The alternative of making the
responseAndError channel itself unbuffered is too invasive and risky
at this point; it would require a number of changes to avoid
deadlocked goroutines in error cases)

In any case, flakes look to be gone now. We'll see if trybots agree.

Fixes #13633

Change-Id: I95a22942b2aa334ae7c87331fddd751d4cdfdffc
Reviewed-on: https://go-review.googlesource.com/17890
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 17:50:32 +00:00
Russ Cox
1babba2e4c cmd/compile: fix -race nit
Fixes #13264.

Change-Id: I74b941164610921a03814733fea08631f18b6178
Reviewed-on: https://go-review.googlesource.com/17815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 17:20:26 +00:00
Shenghou Ma
86f1944e86 cmd/dist, runtime: make runtime version available as runtime.buildVersion
So that there is a uniformed way to retrieve Go version from a Go
binary, starting from Go 1.4 (see https://golang.org/cl/117040043)

Updates #13507.

Change-Id: Iaa2b14fca2d8c4d883d3824e2efc82b3e6fe2624
Reviewed-on: https://go-review.googlesource.com/17459
Reviewed-by: Keith Randall <khr@golang.org>
2015-12-16 05:42:40 +00:00
Ian Lance Taylor
68c6aad58b runtime: change SIGEMT on linux/mips64 to throw
This matches SIGEMT on other systems that use it (SIGEMT is not used
for most linux systems).

Change-Id: If394c06c9ed1cb3ea2564385a8edfbed8b5566d1
Reviewed-on: https://go-review.googlesource.com/17874
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-12-16 02:08:02 +00:00
Mikio Hara
1dc2e7b165 net: retighten test harnesses for dial cancelation
Updates #11225.

Change-Id: I6c33d577f144643781f370ba2ab0997d1c1a3820
Reviewed-on: https://go-review.googlesource.com/17880
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 01:05:47 +00:00
Robert Griesemer
3cc24aa9ab go/constant: use Float.Rat method instead of doing it manually
Also fixed conversion bug and added corresponding test case.

Change-Id: I26f143fbc8d40a6d073ecb095e61b461495f3d68
Reviewed-on: https://go-review.googlesource.com/17872
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-12-16 00:24:11 +00:00
Brad Fitzpatrick
24a83d3545 net: add Dialer.Cancel to cancel pending dials
Dialer.Cancel is a new optional <-chan struct{} channel whose closure
indicates that the dial should be canceled. It is compatible with the
x/net/context and http.Request.Cancel types.

Tested by hand with:

package main

    import (
            "log"
            "net"
            "time"
    )

    func main() {
            log.Printf("start.")
            var d net.Dialer
            cancel := make(chan struct{})
            time.AfterFunc(2*time.Second, func() {
                    log.Printf("timeout firing")
                    close(cancel)
            })
            d.Cancel = cancel
            c, err := d.Dial("tcp", "192.168.0.1:22")
            if err != nil {
                    log.Print(err)
                    return
            }
            log.Fatalf("unexpected connect: %v", c)
    }

Which says:

    2015/12/14 22:24:58 start.
    2015/12/14 22:25:00 timeout firing
    2015/12/14 22:25:00 dial tcp 192.168.0.1:22: operation was canceled

Fixes #11225

Change-Id: I2ef39e3a540e29fe6bfec03ab7a629a6b187fcb3
Reviewed-on: https://go-review.googlesource.com/17821
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-15 21:15:15 +00:00
Brad Fitzpatrick
479c47e478 net/http: maybe deflake TestCancelRequestMidBody_h2 on linux-noopt builder
This might deflake it. Or it'll at least give us more debugging clues.

Fixes #13626 maybe

Change-Id: Ie8cd0375d60dad033ec6a64830a90e7b9152a3d9
Reviewed-on: https://go-review.googlesource.com/17825
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-15 21:07:46 +00:00
Brad Fitzpatrick
99fb19194c net/http: rework CloseNotifier implementation, clarify expectations in docs
CloseNotifier wasn't well specified previously. This CL simplifies its
implementation, clarifies the public documentation on CloseNotifier,
clarifies internal documentation on conn, and fixes two CloseNotifier
bugs in the process.

The main change, though, is tightening the rules and expectations for using
CloseNotifier:

* the caller must consume the Request.Body first (old rule, unwritten)
* the received value is the "true" value (old rule, unwritten)
* no promises for channel sends after Handler returns (old rule, unwritten)
* a subsequent pipelined request fires the CloseNotifier (new behavior;
  previously it never fired and thus effectively deadlocked as in #13165)
* advise that it should only be used without HTTP/1.1 pipelining (use HTTP/2
  or non-idempotent browsers). Not that browsers actually use pipelining.

The main implementation change is that each Handler now gets its own
CloseNotifier channel value, rather than sharing one between the whole
conn. This means Handlers can't affect subsequent requests. This is
how HTTP/2's Server works too. The old docs never clarified a behavior
either way. The other side effect of each request getting its own
CloseNotifier channel is that one handler can't "poison" the
underlying conn preventing subsequent requests on the same connection
from using CloseNotifier (this is #9763).

In the old implementation, once any request on a connection used
ClosedNotifier, the conn's underlying bufio.Reader source was switched
from the TCPConn to the read side of the pipe being fed by a
never-ending copy. Since it was impossible to abort that never-ending
copy, we could never get back to a fresh state where it was possible
to return the underlying TCPConn to callers of Hijack. Now, instead of
a never-ending Copy, the background goroutine doing a Read from the
TCPConn (or *tls.Conn) only reads a single byte. That single byte
can be in the request body, a socket timeout error, io.EOF error, or
the first byte of the second body. In any case, the new *connReader
type stitches sync and async reads together like an io.MultiReader. To
clarify the flow of Read data and combat the complexity of too many
wrapper Reader types, the *connReader absorbs the io.LimitReader
previously used for bounding request header reads.  The
liveSwitchReader type is removed. (an unused switchWriter type is also
removed)

Many fields on *conn are also documented more fully.

Fixes #9763 (CloseNotify + Hijack together)
Fixes #13165 (deadlock with CloseNotify + pipelined requests)

Change-Id: I40abc0a1992d05b294d627d1838c33cbccb9dd65
Reviewed-on: https://go-review.googlesource.com/17750
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-15 21:01:53 +00:00
Austin Clements
01baf13ba5 runtime: only trigger forced GC if GC is not running
Currently, sysmon triggers a forced GC solely based on
memstats.last_gc. However, memstats.last_gc isn't updated until mark
termination, so once sysmon starts triggering forced GC, it will keep
triggering them until GC finishes. The first of these actually starts
a GC; the remainder up to the last print "GC forced", but gcStart
returns immediately because gcphase != _GCoff; then the last may start
another GC if the previous GC finishes (and sets last_gc) between
sysmon triggering it and gcStart checking the GC phase.

Fix this by expanding the condition for starting a forced GC to also
require that no GC is currently running. This, combined with the way
forcegchelper blocks until the GC cycle is started, ensures sysmon
only starts one GC when the time exceeds the forced GC threshold.

Fixes #13458.

Change-Id: Ie6cf841927f6085136be3f45259956cd5cf10d23
Reviewed-on: https://go-review.googlesource.com/17819
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 20:13:19 +00:00
Austin Clements
50d8d4e834 runtime: simplify sigprof traceback interlocking
The addition of stack barrier locking to copystack subsumes the
partial fix from commit bbd1a1c for SIGPROF during copystack. With the
stack barrier locking, this commit simplifies the rule in sigprof to:
the user stack can be traced only if sigprof can acquire the stack
barrier lock.

Updates #12932, #13362.

Change-Id: I1c1f80015053d0ac7761e9e0c7437c2aba26663f
Reviewed-on: https://go-review.googlesource.com/17192
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 20:12:17 +00:00
Matthew Dempsky
22a204dd0f cmd/compile: change dead code into assert
After fixing #13587, I noticed that the "OAS2FUNC in disguise" block
looked like it probably needed write barriers too.  However, testing
revealed the multi-value "return f()" case was already being handled
correctly.

It turns out this block is dead code due to "return f()" already being
transformed into "t1, t2, ..., tN := f(); return t1, t2, ..., tN" by
orderstmt when f is a multi-valued function.

Updates #13587.

Change-Id: Icde46dccc55beda2ea5fd5fcafc9aae26cec1552
Reviewed-on: https://go-review.googlesource.com/17759
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-12-15 18:52:01 +00:00
Austin Clements
2bacae815b runtime: update triggerRatio in setGCPercent
Currently, runtime/debug.SetGCPercent does not adjust the controller
trigger ratio. As a result, runtime reductions of GOGC don't take full
effect until after one more concurrent cycle has happened, which
adjusts the trigger ratio to account for the new gcpercent.

Fix this by lowering the trigger ratio if necessary in setGCPercent.

Change-Id: I4d23e0c58d91939b86ac60fa5d53ef91d0d89e0c
Reviewed-on: https://go-review.googlesource.com/17813
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 17:58:38 +00:00
Austin Clements
1e1ea66991 runtime: print gctrace before releasing worldsema
Currently we drop worldsema and then print the gctrace. We did this so
that if stderr is a pipe or a blocked terminal, blocking on printing
the gctrace would not block another GC from starting. However, this is
a bit of a fool's errand because a blocked runtime print will block
the whole M/P, so after GOMAXPROCS GC cycles, the whole system will
freeze. Furthermore, now this is much less of an issue because
allocation will block indefinitely if it can't start a GC (whereas it
used to be that allocation could run away). Finally, this allows
another GC cycle to start while the previous cycle is printing the
gctrace, which leads to races on reading various statistics to print
them and the next GC cycle overwriting those statistics.

Fix this by moving the release of worldsema after the gctrace print.

Change-Id: I3d044ea0f77d80f3b4050af6b771e7912258662a
Reviewed-on: https://go-review.googlesource.com/17812
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 17:58:30 +00:00
Austin Clements
ff5c945382 runtime: reset sweep stats before starting the world
Currently we reset the sweep stats just after gcMarkTermination starts
the world and releases worldsema. However, background sweeping can
start the moment we start the world and, in fact, pause sweeping can
start the moment we release worldsema (because another GC cycle can
start up), so these need to be cleared before starting the world.

Change-Id: I95701e3de6af76bb3fbf2ee65719985bf57d20b2
Reviewed-on: https://go-review.googlesource.com/17811
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 17:58:22 +00:00
Austin Clements
87d939dee8 runtime: fix (sometimes major) underestimation of heap_live
Currently, we update memstats.heap_live from mcache.local_cachealloc
whenever we lock the heap (e.g., to obtain a fresh span or to release
an unused span). However, under the right circumstances,
local_cachealloc can accumulate allocations up to the size of
the *entire heap* without flushing them to heap_live. Specifically,
since span allocations from an mcentral don't lock the heap, if a
large number of pages are held in an mcentral and the application
continues to use and free objects of that size class (e.g., the
BinaryTree17 benchmark), local_cachealloc won't be flushed until the
mcentral runs out of spans.

This is a problem because, unlike many of the memory statistics that
are purely informative, heap_live is used to determine when the
garbage collector should start and how hard it should work.

This commit eliminates local_cachealloc, instead atomically updating
heap_live directly. To control contention, we do this only when
obtaining a span from an mcentral. Furthermore, we make heap_live
conservative: allocating a span assumes that all free slots in that
span will be used and accounts for these when the span is
allocated, *before* the objects themselves are. This is important
because 1) this triggers the GC earlier than necessary rather than
potentially too late and 2) this leads to a conservative GC rate
rather than a GC rate that is potentially too low.

Alternatively, we could have flushed local_cachealloc when it passed
some threshold, but this would require determining a threshold and
would cause heap_live to underestimate the true value rather than
overestimate.

Fixes #12199.

name                      old time/op    new time/op    delta
BinaryTree17-12              2.88s ± 4%     2.88s ± 1%    ~     (p=0.470 n=19+19)
Fannkuch11-12                2.48s ± 1%     2.48s ± 1%    ~     (p=0.243 n=16+19)
FmtFprintfEmpty-12          50.9ns ± 2%    50.7ns ± 1%    ~     (p=0.238 n=15+14)
FmtFprintfString-12          175ns ± 1%     171ns ± 1%  -2.48%  (p=0.000 n=18+18)
FmtFprintfInt-12             159ns ± 1%     158ns ± 1%  -0.78%  (p=0.000 n=19+18)
FmtFprintfIntInt-12          270ns ± 1%     265ns ± 2%  -1.67%  (p=0.000 n=18+18)
FmtFprintfPrefixedInt-12     235ns ± 1%     234ns ± 0%    ~     (p=0.362 n=18+19)
FmtFprintfFloat-12           309ns ± 1%     308ns ± 1%  -0.41%  (p=0.001 n=18+19)
FmtManyArgs-12              1.10µs ± 1%    1.08µs ± 0%  -1.96%  (p=0.000 n=19+18)
GobDecode-12                7.81ms ± 1%    7.80ms ± 1%    ~     (p=0.425 n=18+19)
GobEncode-12                6.53ms ± 1%    6.53ms ± 1%    ~     (p=0.817 n=19+19)
Gzip-12                      312ms ± 1%     312ms ± 2%    ~     (p=0.967 n=19+20)
Gunzip-12                   42.0ms ± 1%    41.9ms ± 1%    ~     (p=0.172 n=19+19)
HTTPClientServer-12         63.7µs ± 1%    63.8µs ± 1%    ~     (p=0.639 n=19+19)
JSONEncode-12               16.4ms ± 1%    16.4ms ± 1%    ~     (p=0.954 n=19+19)
JSONDecode-12               58.5ms ± 1%    57.8ms ± 1%  -1.27%  (p=0.000 n=18+19)
Mandelbrot200-12            3.86ms ± 1%    3.88ms ± 0%  +0.44%  (p=0.000 n=18+18)
GoParse-12                  3.67ms ± 2%    3.66ms ± 1%  -0.52%  (p=0.001 n=18+19)
RegexpMatchEasy0_32-12       100ns ± 1%     100ns ± 0%    ~     (p=0.257 n=19+18)
RegexpMatchEasy0_1K-12       347ns ± 1%     347ns ± 1%    ~     (p=0.527 n=18+18)
RegexpMatchEasy1_32-12      83.7ns ± 2%    83.1ns ± 2%    ~     (p=0.096 n=18+19)
RegexpMatchEasy1_1K-12       509ns ± 1%     505ns ± 1%  -0.75%  (p=0.000 n=18+19)
RegexpMatchMedium_32-12      130ns ± 2%     129ns ± 1%    ~     (p=0.962 n=20+20)
RegexpMatchMedium_1K-12     39.5µs ± 2%    39.4µs ± 1%    ~     (p=0.376 n=20+19)
RegexpMatchHard_32-12       2.04µs ± 0%    2.04µs ± 1%    ~     (p=0.195 n=18+17)
RegexpMatchHard_1K-12       61.4µs ± 1%    61.4µs ± 1%    ~     (p=0.885 n=19+19)
Revcomp-12                   540ms ± 2%     542ms ± 4%    ~     (p=0.552 n=19+17)
Template-12                 69.6ms ± 1%    71.2ms ± 1%  +2.39%  (p=0.000 n=20+20)
TimeParse-12                 357ns ± 1%     357ns ± 1%    ~     (p=0.883 n=18+20)
TimeFormat-12                379ns ± 1%     362ns ± 1%  -4.53%  (p=0.000 n=18+19)
[Geo mean]                  62.0µs         61.8µs       -0.44%

name              old time/op  new time/op  delta
XBenchGarbage-12  5.89ms ± 2%  5.81ms ± 2%  -1.41%  (p=0.000 n=19+18)

Change-Id: I96b31cca6ae77c30693a891cff3fe663fa2447a0
Reviewed-on: https://go-review.googlesource.com/17748
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 16:16:08 +00:00
Austin Clements
4ad64cadf8 runtime: trace sweep completion in gcpacertrace mode
Change-Id: I7991612e4d064c15492a39c19f753df1db926203
Reviewed-on: https://go-review.googlesource.com/17747
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 16:15:59 +00:00
Austin Clements
c1cbe5b577 runtime: check for spanBytesAlloc underflow
Change-Id: I5e6739ff0c6c561195ed9891fb90f933b81e7750
Reviewed-on: https://go-review.googlesource.com/17746
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 16:15:47 +00:00
Austin Clements
6383fb6152 runtime: deduct correct sweep credit
deductSweepCredit expects the size in bytes of the span being
allocated, but mCentral_CacheSpan passes the size of a single object
in the span. As a result, we don't sweep enough on that call and when
mCentral_CacheSpan later calls reimburseSweepCredit, it's very likely
to underflow mheap_.spanBytesAlloc, which causes the next call to
deductSweepCredit to think it owes a huge number of pages and finish
off the whole sweep.

In addition to causing the occasional allocation that triggers the
full sweep to be potentially extremely expensive relative to other
allocations, this can indirectly slow down many other allocations.
deductSweepCredit uses sweepone to sweep spans, which returns
fully-unused spans to the heap, where these spans are freed and
coalesced with neighboring free spans. On the other hand, when
mCentral_CacheSpan sweeps a span, it does so with the intent to
immediately reuse that span and, as a result, will not return the span
to the heap even if it is fully unused. This saves on the cost of
locking the heap, finding a span, and initializing that span. For
example, before this change, with GOMAXPROCS=1 (or the background
sweeper disabled) BinaryTree17 returned roughly 220K spans to the heap
and allocated new spans from the heap roughly 232K times. After this
change, it returns 1.3K spans to the heap and allocates new spans from
the heap 39K times. (With background sweeping these numbers are
effectively unchanged because the background sweeper sweeps almost all
of the spans with sweepone; however, parallel sweeping saves more than
the cost of allocating spans from the heap.)

Fixes #13535.
Fixes #13589.

name                      old time/op    new time/op    delta
BinaryTree17-12              3.03s ± 1%     2.86s ± 4%  -5.61%  (p=0.000 n=18+20)
Fannkuch11-12                2.48s ± 1%     2.49s ± 1%    ~     (p=0.060 n=17+20)
FmtFprintfEmpty-12          50.7ns ± 1%    50.9ns ± 1%  +0.43%  (p=0.025 n=15+16)
FmtFprintfString-12          174ns ± 2%     174ns ± 2%    ~     (p=0.539 n=19+20)
FmtFprintfInt-12             158ns ± 1%     158ns ± 1%    ~     (p=0.300 n=18+20)
FmtFprintfIntInt-12          269ns ± 2%     269ns ± 2%    ~     (p=0.784 n=20+18)
FmtFprintfPrefixedInt-12     233ns ± 1%     234ns ± 1%    ~     (p=0.389 n=18+18)
FmtFprintfFloat-12           309ns ± 1%     310ns ± 1%  +0.25%  (p=0.048 n=18+18)
FmtManyArgs-12              1.10µs ± 1%    1.10µs ± 1%    ~     (p=0.259 n=18+19)
GobDecode-12                7.81ms ± 1%    7.72ms ± 1%  -1.17%  (p=0.000 n=19+19)
GobEncode-12                6.56ms ± 0%    6.55ms ± 1%    ~     (p=0.433 n=17+19)
Gzip-12                      318ms ± 2%     317ms ± 1%    ~     (p=0.578 n=19+18)
Gunzip-12                   42.1ms ± 2%    42.0ms ± 0%  -0.45%  (p=0.007 n=18+16)
HTTPClientServer-12         63.9µs ± 1%    64.0µs ± 1%    ~     (p=0.146 n=17+19)
JSONEncode-12               16.4ms ± 1%    16.4ms ± 1%    ~     (p=0.271 n=19+19)
JSONDecode-12               58.1ms ± 1%    58.0ms ± 1%    ~     (p=0.152 n=18+18)
Mandelbrot200-12            3.85ms ± 0%    3.85ms ± 0%    ~     (p=0.126 n=19+18)
GoParse-12                  3.71ms ± 1%    3.64ms ± 1%  -1.86%  (p=0.000 n=20+18)
RegexpMatchEasy0_32-12       100ns ± 2%     100ns ± 1%    ~     (p=0.588 n=20+20)
RegexpMatchEasy0_1K-12       346ns ± 1%     347ns ± 1%  +0.27%  (p=0.014 n=17+20)
RegexpMatchEasy1_32-12      82.9ns ± 3%    83.5ns ± 3%    ~     (p=0.096 n=19+20)
RegexpMatchEasy1_1K-12       506ns ± 1%     506ns ± 1%    ~     (p=0.530 n=19+19)
RegexpMatchMedium_32-12      129ns ± 2%     129ns ± 1%    ~     (p=0.566 n=20+19)
RegexpMatchMedium_1K-12     39.4µs ± 1%    39.4µs ± 1%    ~     (p=0.713 n=19+20)
RegexpMatchHard_32-12       2.05µs ± 1%    2.06µs ± 1%  +0.36%  (p=0.008 n=18+20)
RegexpMatchHard_1K-12       61.6µs ± 1%    61.7µs ± 1%    ~     (p=0.286 n=19+20)
Revcomp-12                   538ms ± 1%     541ms ± 2%    ~     (p=0.081 n=18+19)
Template-12                 71.5ms ± 2%    71.6ms ± 1%    ~     (p=0.513 n=20+19)
TimeParse-12                 357ns ± 1%     357ns ± 1%    ~     (p=0.935 n=19+18)
TimeFormat-12                352ns ± 1%     352ns ± 1%    ~     (p=0.293 n=19+20)
[Geo mean]                  62.0µs         61.9µs       -0.21%

name              old time/op  new time/op  delta
XBenchGarbage-12  5.83ms ± 2%  5.86ms ± 3%    ~     (p=0.247 n=19+20)

Change-Id: I790bb530adace27ccf25d372f24a11954b88443c
Reviewed-on: https://go-review.googlesource.com/17745
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-15 16:15:38 +00:00