1
0
mirror of https://github.com/golang/go synced 2024-10-05 03:11:22 -06:00
Commit Graph

19086 Commits

Author SHA1 Message Date
Russ Cox
8b99bb7b8c runtime: fix broken arm builds
Change-Id: I08de33aacb3fc932722286d69b1dd70ffe787c89
Reviewed-on: https://go-review.googlesource.com/11697
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 17:33:23 +00:00
Russ Cox
434e0bc0a0 cmd/link: record missing pcdata tables correctly
The old code was recording the current table output offset,
so the table from the next function would be used instead of
the runtime realizing that there was no table at all.

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

Fixes #10747.
Fixes #11396.

Change-Id: I13592e78017969fc22979fa902e19e1b151d41b1
Reviewed-on: https://go-review.googlesource.com/11657
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-06-29 16:07:14 +00:00
Austin Clements
1b917484a8 runtime: reset mark state before checkmark and gctrace=2 mark
Currently we fail to reset the live heap accounting state before the
checkmark mark and before the gctrace=2 extra mark. As a result, if
either are enabled, at the end of GC it thinks there are 0 bytes of
live heap, which causes the GC controller to initiate a new GC
immediately, regardless of the true heap size.

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

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

Fixes #10492.

Change-Id: Ibe46348916fc8368fac6f086e142815c970a6f4d
Reviewed-on: https://go-review.googlesource.com/11561
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:58:29 +00:00
Austin Clements
d57056ba26 runtime: don't free stack spans during GC
Memory for stacks is manually managed by the runtime and, currently
(with one exception) we free stack spans immediately when the last
stack on a span is freed. However, the garbage collector assumes that
spans can never transition from non-free to free during scan or mark.
This disagreement makes it possible for the garbage collector to mark
uninitialized objects and is blocking us from re-enabling the bad
pointer test in the garbage collector (issue #9880).

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

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

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

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

4. The span gets reused as a heap span.

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

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

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

Fixes #11267.

Change-Id: Ib7f2c5da4845cc0268e8dc098b08465116972a71
Reviewed-on: https://go-review.googlesource.com/11502
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:33:40 +00:00
Austin Clements
f73b2fca84 runtime: remove unused _GCsweep state
We don't use this state. _GCoff means we're sweeping in the
background. This makes it clear in the next commit that _GCoff and
only _GCoff means sweeping.

Change-Id: I416324a829ba0be3794a6cf3cf1655114cb6e47c
Reviewed-on: https://go-review.googlesource.com/11501
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:33:31 +00:00
Russ Cox
4e61c516f4 cmd/cgo: fix a problem with 'go build -compiler gccgo'
Port of https://golang.org/cl/154360045 to Git.
Original author is Xia Bin <snyh@snyh.org> (already a contributor).

Fixes #8945.

Change-Id: I28bcaf3348794202ca59fbc3466bd7b9670030e4
Reviewed-on: https://go-review.googlesource.com/11658
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-29 15:15:59 +00:00
Austin Clements
840965f8d7 runtime: always clear stack barriers on G exit
Currently the runtime fails to clear a G's stack barriers in gfput if
the G's stack allocation is _FixedStack bytes. This causes the runtime
to panic if the following sequence of events happens:

1) The runtime installs stack barriers on a G.

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

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

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

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

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

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

Fixes #11256.

Change-Id: I377c44258900e6bcc2d4b3451845814a8eeb2bcf
Reviewed-on: https://go-review.googlesource.com/11461
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:02:30 +00:00
Dmitry Savintsev
fac7b86a9b encoding/binary: update protobuf documentation link
Updated the protobuf documentation URL (code.google.com deprecated)
to avoid a redirect.

Change-Id: I134f6e4a2bf2bba699942883bf6347bc61700bcb
Reviewed-on: https://go-review.googlesource.com/11634
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 14:28:01 +00:00
Rob Pike
a76c1a5c7f fmt: restore padding for %x on byte slices and strings
Also improve the documentation. A prior fix in this release
changed the properties for empty strings and slices, incorrectly.
Previous behavior is now restored and better documented.

Add lots of tests.

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

Fixes #11422.
Fixes #10430.

Change-Id: I758f0521caf71630437e43990ec6d6c9a92655e3
Reviewed-on: https://go-review.googlesource.com/11600
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 07:17:23 +00:00
Brad Fitzpatrick
1bab3a16db net/http: fix now-flaky TransportAndServerSharedBodyRace test
TestTransportAndServerSharedBodyRace got flaky after
issue #9662 was fixed by https://golang.org/cl/11412, which made
servers hang up on clients when a Handler stopped reading its body
early.

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

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

Fixes #11418

Change-Id: Ic83d18aef7e09a9cd56ac15e22ebed75713026cb
Reviewed-on: https://go-review.googlesource.com/11610
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-29 05:19:36 +00:00
Alex Brainman
0bafe0e5b2 syscall: return error instead of panicking in windows StartProcess
Fixes #11417

Change-Id: Iacea829a48b39df0a4f751b06b19e918fbb713d0
Reviewed-on: https://go-review.googlesource.com/11604
Reviewed-by: Rob Pike <r@golang.org>
2015-06-29 03:54:33 +00:00
Keith Randall
214c7a2c43 cmd/link/internal/ld: exclude only real container symbols from symtab
It looks like the test for whether symbols contain subsymbols is wrong.
In particular, symbols in C libraries are mistakenly considered container
symbols.

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

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

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

Fixes #10747
Fixes #11396

Change-Id: Id8b016389d33348b4a791fdcba0f9db8ae71ebf3
Reviewed-on: https://go-review.googlesource.com/11652
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:54:09 +00:00
Adam Langley
0a6df4a87b encoding/asn1: don't parse invalid UTF-8.
Invalid UTF-8 triggers an error when marshaling but, previously, not
when unmarshaling. This means that ASN.1 structures were not
round-tripping.

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

Fixes #11126.

Change-Id: Ic37be84d21dc5c03983525e244d955a8b1e1ff14
Reviewed-on: https://go-review.googlesource.com/11056
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:50:49 +00:00
Adam Langley
fdd921c9f4 encoding/asn1: be stricter by reserialising parsed times.
The time package does normalisation of times: for example day zero is
converted to the last day of the previous month and the 31st of February
is moved into March etc. This makes the ASN.1 parsing a little
worryingly lax.

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

Fixes #11134.

Change-Id: I3988bb95153a7b33d64ab861fbe51b1a34a359e9
Reviewed-on: https://go-review.googlesource.com/11094
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:50:41 +00:00
Alex Brainman
85d4d46f3c runtime: store syscall parameters in m not on stack
Stack can move during callback, so libcall struct cannot be stored on stack.
asmstdcall updates return values and errno in libcall struct parameter, but
these could be at different location when callback returns.
Store these in m, so they are not affected by GC.

Fixes #10406

Change-Id: Id01c9d2b4b44530494e6d9e9e1c875261ce477cd
Reviewed-on: https://go-review.googlesource.com/10370
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:45:45 +00:00
Alex Brainman
3b7841b3af cmd/go: reset read-only flag during TestIssue10952
git sets read-only flag on all its repo files on Windows.
os.Remove cannot delete these files.

Fixes windows build

Change-Id: Icaf72470456b88a1c26295caecd4e0d3dc22a1b6
Reviewed-on: https://go-review.googlesource.com/11602
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-06-29 01:49:05 +00:00
Brad Fitzpatrick
d0ed87d15c builtin: remove errant space in hyphenated adjective phrase
Change-Id: I67947e0e3189093e830120941ee49f9f32086f0e
Reviewed-on: https://go-review.googlesource.com/11615
Reviewed-by: Rob Pike <r@golang.org>
2015-06-28 21:41:38 +00:00
Todd Neal
7511806ec2 net/http: fix race on postPendingDial test hook
The race occurs rarely, but by putting some delays and more reads/writes
of prePendingDial/postPendingDial in the handlePendingDial function I
could reproduce it.

Fixes #11136

Change-Id: I8da9e66c88fbda049eaaaaffa2717264ef327768
Reviewed-on: https://go-review.googlesource.com/11250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-28 16:14:07 +00:00
Didier Spezia
ca91de7ca0 html/template: prevent panic while escaping pipelines
AFAIK, the documentation does not explicitly state whether
variables can store a callable entity or not. I believe the
current implementation in text/template assumes they cannot
though. The call builtin function is supposed to be used for
this purpose.

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

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

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

We now have the following errors:

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

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

Fixes #11118
Fixes #11356

Change-Id: Idae52f806849f4c9ab7aca1b4bb4b59a74723d0e
Reviewed-on: https://go-review.googlesource.com/10823
Reviewed-by: Rob Pike <r@golang.org>
2015-06-27 22:44:33 +00:00
David Crawshaw
58578de0dc cmd/link: no dwarf on darwin/arm
Partial revert of cl/10284 to get -buildmode=c-archive working for
darwin/arm.

Manually tested with iostest.bash while builder is offline.

Change-Id: I98e4e209765666e320e680e11151fce59e2afde9
Reviewed-on: https://go-review.googlesource.com/11306
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-06-27 21:32:38 +00:00
Ross Light
64078bf3cf cmd/go: ignore custom import check when there is no import comment
Fixes #10952

Change-Id: I56ab6a806bd3741cffd9d2a53929a6d043626a26
Reviewed-on: https://go-review.googlesource.com/10693
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 19:06:56 +00:00
Tamir Duberstein
a444da033c cmd/go: fetch git submodules in go get
Change createCmd, downloadCmd, tagSyncCmd, tagSyncDefault to allow
multiple commands.

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

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

For #7764.

Change-Id: I8248efb851130620ef762a765ab8716af430572a
Reviewed-on: https://go-review.googlesource.com/9815
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 18:52:53 +00:00
Alex Brainman
ebfc5be5b9 cmd/go: adjust TestFileLineInErrorMessages
cmd/go sometimes returns relative path in the error message
(see shortPath function). Account for that during
TestFileLineInErrorMessages.

Fixes #11355

Change-Id: Ica79359eab48d669d307449fdd458764895fab2c
Reviewed-on: https://go-review.googlesource.com/11475
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 18:43:45 +00:00
c9s
29ff86b05b cmd/go: handle error when git remote origin doesn't exist
- Let runOutput return the error message
- When `git config ...` returns empty buffer, it means the config key is
  correct, but there is no corresponding value.
- Return the correct error when the url of remote origin is not found.
- Update error message

Fixes: #10922

Change-Id: I3f8880f6717a4f079b840d1249174378d36bca1b
Reviewed-on: https://go-review.googlesource.com/10475
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 18:43:15 +00:00
Mikio Hara
258bf65d8b net: relax IP interface address determination on linux
Linux allows to have a peer IP address on IP interface over ethernet
link encapsulation, though it only installs a static route with the peer
address as an on-link nexthop.

Fixes #11338.

Change-Id: Ie2583737e4c7cec39baabb89dd732463d3f10a61
Reviewed-on: https://go-review.googlesource.com/11352
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 00:39:30 +00:00
Rob Pike
aea348a3af cmd/asm: add tests for erroneous expressions
Also add a couple more errors, such as modulo with a zero divisor.

Change-Id: If24c95477f7ae86cf4aef5b3460e9ec249ea5ae2
Reviewed-on: https://go-review.googlesource.com/11535
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 23:33:39 +00:00
Brad Fitzpatrick
2b3b7dc1a9 archive/tar: also skip header roundtrip test on nacl
Update #11426

Change-Id: I7abc4ed2241a7a3af6d57c934786f36de4f97b77
Reviewed-on: https://go-review.googlesource.com/11592
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-26 22:36:38 +00:00
Brad Fitzpatrick
603dc4171a sync: don't run known-racy tests under the race detector
Fixes the build from https://golang.org/cl/4117 (sync: simplify WaitGroup)

Change-Id: Icc2a7ba8acea26fd187d52cf1901bfebf8573f93
Reviewed-on: https://go-review.googlesource.com/11591
Reviewed-by: Austin Clements <austin@google.com>
2015-06-26 22:07:29 +00:00
Austin Clements
d231cb8249 runtime: repeat bitmap for slice of GCprog n-1 times, not n times
Currently, to write out the bitmap of a slice of a type with a GCprog,
we construct a new GCprog that executes the underlying type's GCprog
to write out the bitmap once and then repeats those bits n more times.
This results in n+1 repetitions of the bitmap, which is one more
repetition than it should be. This corrupts the bitmap of the heap
following the slice and may write past the mapped bitmap memory and
segfault.

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

Fixes #11430.

Change-Id: Ic24854363bffc5a755b66f257339f9309ada3aa5
Reviewed-on: https://go-review.googlesource.com/11570
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-26 21:52:51 +00:00
Brad Fitzpatrick
48025d2ce0 archive/tar: disable new failing test on windows and plan9
Update #11426

Change-Id: If406d2efcc81965825a63c76f5448d544ba2a740
Reviewed-on: https://go-review.googlesource.com/11590
Reviewed-by: Austin Clements <austin@google.com>
2015-06-26 21:43:51 +00:00
Dmitry Vyukov
77132c810d runtime/race: enable tests that now pass
These tests pass after cl/11417.

Change-Id: Id98088c52e564208ce432e9717eddd672c42c66d
Reviewed-on: https://go-review.googlesource.com/11551
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:54:11 +00:00
Dmitry Vyukov
03a48ebe1c sync: simplify WaitGroup
A comment in waitgroup.go describes the following scenario
as the reason to have dynamically created semaphores:

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

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

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

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

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

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

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

Change-Id: I28911f3243aa16544e99ac8f1f5af31944c7ea3a
Reviewed-on: https://go-review.googlesource.com/4117
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:48:29 +00:00
Mihai Borobocea
450988b5a2 net/http: escape path in implicit /tree→/tree/ ServeMux.Handle redirect
Fixes #10572

Change-Id: I764f3c226cf98ff39d9e553e4613d0ee108ef766
Reviewed-on: https://go-review.googlesource.com/9311
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:32:40 +00:00
Matt T. Proud
e6ad56c711 testing/quick: improve function signature error.
This commit fixes a cosmetic defect whereby quick.Check reports that
the provided function returns too many values when it may, in fact,
return too few:

  func f() {}

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

Change-Id: Ia209ff5b57375b30f8db425454e80798908e8ff4
Reviewed-on: https://go-review.googlesource.com/11281
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:03:32 +00:00
Marcel van Lohuizen
fe15da62f7 unicode: upgrade to 8.0.0
Not sure if I'm on time for 1.5; Unicode 8 just got released.

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

Fixes #11309

Change-Id: I42850f5b3399bde125b002efc78eff96dbd86a08
Reviewed-on: https://go-review.googlesource.com/11286
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:01:29 +00:00
Shenghou Ma
21a4c93166 runtime: slightly clean up softfloat code
Removes the remains of the old C based stepflt implementation.
Also removed goto usage.

Change-Id: Ida4742c49000fae4fea4649f28afde630ce4c577
Reviewed-on: https://go-review.googlesource.com/9600
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:51:22 +00:00
Russ Cox
32fddadd98 runtime: reduce slice growth during append to 2x
The new inlined code for append assumed that it could pass the
desired new cap to growslice, not the number of new elements.
But growslice still interpreted the argument as the number of new elements,
making it always grow by >2x (more precisely, 2x+1 rounded up
to the next malloc block size). At the time, I had intended to change
the other callers to use the new cap as well, but it's too late for that.
Instead, introduce growslice_n for the old callers and keep growslice
for the inlined (common case) caller.

Fixes #11403.

Filed #11419 to merge them.

Change-Id: I1338b1e5b352f3be4e43641f44b652ef7195251b
Reviewed-on: https://go-review.googlesource.com/11541
Reviewed-by: Austin Clements <austin@google.com>
2015-06-26 17:49:33 +00:00
Brad Fitzpatrick
1284d7d403 net/url: don't escape star requests when writing requests
Includes a new net/http test too.

Fixes #11202

Change-Id: I61edc594f4de8eb6780b8dfa221269dd482e8f35
Reviewed-on: https://go-review.googlesource.com/11492
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:43:29 +00:00
Steve Streeting
379d8327cb net/http: don't overwrite Authorization headers when URL has username
Fixes #11399

Change-Id: I3be7fbc86c5f62761f47122632f3e11b56cb6be6
Reviewed-on: https://go-review.googlesource.com/11510
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:32:12 +00:00
Aamir Khan
0d1ceef945 net/http: change default user agent string
Default user agent in use - "Go 1.1 package http" doesn't conform to RFC 7231.
See http://tools.ietf.org/html/rfc7231#section-5.5.3

Use a valid user-agent string instead.

Fixes #9792

Change-Id: I80249709800dcdbf6f2e97a63fab05656898e6aa
Reviewed-on: https://go-review.googlesource.com/9385
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:29:35 +00:00
Matt Layher
9139089ee5 net/http: add comment to exported ErrNoCookie and ErrNoLocation values
All other exported errors in net/http are commented.  This change adds
documentation to ErrNoCookie and ErrNoLocation to explain where they are
returned, and why.

Change-Id: I21fa0d070dd35256681ad0714000f238477d4af1
Reviewed-on: https://go-review.googlesource.com/11044
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:28:07 +00:00
Austin Clements
e0e47e22ce reflect: test repeats with large scalar tails
This adds a GC bitmap test of a type with many pointer bits and a
large scalar tail, such as the one in issue #11286. This test would
have failed prior to the fix in a8ae93f. This test is a more direct
version of the test introduced in that commit (which was distilled
from the failing test in the issue).

Change-Id: I2e716cd1000b49bde237f5da6d857e8983fe7e7a
Reviewed-on: https://go-review.googlesource.com/11423
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:26:09 +00:00
Austin Clements
4b287553a4 reflect: test GC bits for slices
Currently we test bitmap repetitions constructed by the compiler (for
small arrays) and repetitions performed by GC programs (large arrays
and reflect-constructed arrays), but we don't test dynamic repetitions
performed by the runtime for slice backing stores. Add tests that
parallel the array tests using slices.

Change-Id: If4425941a33cc5b20178dd819a7371e347e47585
Reviewed-on: https://go-review.googlesource.com/11422
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:26:00 +00:00
Todd Neal
37469a7bcb net/http: Fix test that occasionally fails
The consecutive calls to Head would sometimes get different
connections depending on if the readLoop had finished executing
and placed its connection on the idle list or not.  This change
ensures that readLoop completes before we make our second connection.

Fixes #11250

Change-Id: Ibdbc4d3d0aba0162452f6dec5928355a37dda70a
Reviewed-on: https://go-review.googlesource.com/11170
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:22:53 +00:00
Ian Lance Taylor
61cd48b1ce debug/elf: change R_ARM_REL32 to R_ARM_ABS32 in applyRelocationsARM
The original version of applyRelocationsARM was added in
http://golang.org/cl/7266.  It was added to fix the ARM build, which
had been broken by http://golang.org/cl/6780.

Before CL 6780, there was no relocation processing for ARM.  CL 6780
changed the code to require relocation processing for every supported
target.  CL 7266 fixed the ARM build by adding a relocation processing
function, but in fact no actual processing was done.  The code only
looked for REL32 relocations, but ARM debug info has no such
relocations.  The test case added in CL 7266 doesn't have any either.

This didn't matter because no relocation processing was required on
ARM, at least not for GCC-generated debug info.  GCC generates ABS32
relocations, but only against section symbols which have the value 0.
Therefore, the addition done by correct handling of ABS32 doesn't
change anything.

Clang, however, generates ABS32 relocations against local symbols,
some of which have non-zero values.  For those, we need to handle
ABS32 relocations.

This patch corrects the CL 7266 to look for ABS32 relocations instead
of REL32 relocations.  The code was already written to correctly
handle ABS32 relocations, it just mistakenly said REL32.

This is the ARM equivalent of https://golang.org/cl/96680045, which
fixed the same problem in the same way for clang on 386.

With this patch, clang-3.5 can be used to build Go on ARM GNU/Linux.

Fixes #8980.

Change-Id: I0c2d72eadfe6373bde99cd03eee40de6a582dda1
Reviewed-on: https://go-review.googlesource.com/11222
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-06-26 16:17:54 +00:00
Adam Langley
4ec946ce95 crypto/x509: don't panic when decrypting invalid PEM data.
If an encrypted PEM block contained ciphertext that was not a multiple
of the block size then the code would panic. This change tests for that
case and returns an error.

Fixes #11215.

Change-Id: I7b700f99e20810c4f545519b1e9d766b4640e8a7
Reviewed-on: https://go-review.googlesource.com/11097
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 16:16:51 +00:00
Dmitry Savintsev
c248aaef70 crypto/ecdsa, crypto/x509: update SEC1 ECC link in comments
Updated the document URL in comments to avoid dead link
Old: http://www.secg.org/download/aid-780/sec1-v2.pdf
New: http://www.secg.org/sec1-v2.pdf

Change-Id: If13d0da4c0e7831b2bd92c45116c2412a2a965f5
Reviewed-on: https://go-review.googlesource.com/11550
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 16:08:22 +00:00
Todd Neal
765c0f37ed cmd/compile: fix half multiply issue
In walkdiv, an OMUL node was created and passed to typecheck,
before the op was changed back to OHMUL.  In some instances,
the node that came back was an evaluated literal constant that
occurred with a full multiply.  The end result was a literal node
with a non-shifted value and an OHMUL op. This change causes code
to be generated for the OHMUL.

Fixes #11358
Fixes #11369

Change-Id: If42a98c6830d07fe065d5ca57717704fb8cfbd33
Reviewed-on: https://go-review.googlesource.com/11400
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 15:55:22 +00:00
Dmitry Vyukov
cd0a8ed48a cmd/compile: add instrumentation of OKEY
Instrument operands of OKEY.
Also instrument OSLICESTR. Previously it was not needed
because of preceeding bounds checks (which were instrumented).
But the preceeding bounds checks have disappeared.

Change-Id: I3b0de213e23cbcf5b8ef800abeded5eeeb3f8287
Reviewed-on: https://go-review.googlesource.com/11417
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 15:54:03 +00:00
Vincent Batts
f271f928d9 archive/tar: fix round-trip attributes
The issue was identified while
working with round trip FileInfo of the headers of hardlinks. Also,
additional test cases for hard link handling.
(review carried over from http://golang.org/cl/165860043)

Fixes #9027

Change-Id: I9e3a724c8de72eb1b0fbe0751a7b488894911b76
Reviewed-on: https://go-review.googlesource.com/6790
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 15:51:06 +00:00
Aaron Jacobs
8628688304 Fix several out of date references to 4g/5g/6g/8g/9g.
Change-Id: Ifb8e4e13c7778a7c0113190051415e096f5db94f
Reviewed-on: https://go-review.googlesource.com/11390
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-26 03:38:21 +00:00
Andrew Gerrand
895df143a2 math: explain OEIS link
Fixes #10236

Change-Id: Ife85513efda48af81c267b753da2ac7317cdfe75
Reviewed-on: https://go-review.googlesource.com/11479
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-26 01:25:58 +00:00
Brad Fitzpatrick
bf5e19fbaf net/http: tolerate old buggy user agents, per RFC 2616 section 4.1
Some old buggy browsers sent extra CRLF(s) after POST bodies. Skip
over them before reading subsequent requests.

Fixes #10876

Change-Id: I62eacf2b3e985caffa85aee3de39d8cd3548130b
Reviewed-on: https://go-review.googlesource.com/11491
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-25 22:31:26 +00:00
Dmitry Vyukov
055e1a3ae7 runtime/race: fix test driver
At some point it silently stopped recognizing test output.
Meanwhile two tests degraded...

Change-Id: I90a0325fc9aaa16c3ef16b9c4c642581da2bb10c
Reviewed-on: https://go-review.googlesource.com/11416
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-25 11:36:07 +00:00
Brad Fitzpatrick
1045351cef net/http: bound the number of bytes read seeking EOF in Handler's Body.Close
If a client sent a POST with a huge request body, calling
req.Body.Close in the handler (which is implicit at the end of a
request) would end up consuming it all.

Put a cap on that, using the same threshold used elsewhere for similar
cases.

Fixes #9662

Change-Id: I26628413aa5f623a96ef7c2609a8d03c746669e5
Reviewed-on: https://go-review.googlesource.com/11412
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 07:05:07 +00:00
Todd Neal
4e834cff4f fmt: handle negative width/prec when supplied as an argument
Negative width arguments now left align the way a minus-width in the
format string aligns. The minus in the format string overrides the sign
of the argument as in C.

Precision behavior is modified to include an error if the argument is
negative.  This differs from a negative precision in a format string
which just terminates the format.

Additional checks for large magnitude widths and precisions are added to
make the runtime behavior (failure, but with different error messages),
more consistent between format string specified width/precision and
argument specified width/precision.

Fixes #11376

Change-Id: I8c7ed21088e9c18128a45d4c487c5ab9fafd13ef
Reviewed-on: https://go-review.googlesource.com/11405
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
2015-06-25 05:34:02 +00:00
Matthew Dempsky
2bcdb5a5d9 net/http: sync Get and Head's documentation
Instead of ambiguously referring to "the Client's CheckRedirect
function" in Head, describe the default behavior like for Get as users
aren't expected to change DefaultClient.CheckRedirect.

While here, use consistent punctuation for the Get and Head Client
method documentation.

Change-Id: I9e7046c73b0d0bc4de002234924d9e7c59aceb41
Reviewed-on: https://go-review.googlesource.com/11362
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-25 05:07:40 +00:00
Brad Fitzpatrick
190313e696 net/http: document that Hijack's net.Conn might have left-over timeouts set
Fixes #8296

Change-Id: I71b330a0f961d46ae4ed81d5f3f5ce5bf708a29a
Reviewed-on: https://go-review.googlesource.com/11411
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 03:01:52 +00:00
Keith Randall
dbe9ab69d9 cmd/compile/internal/gc: make sure nonzero-sized objects have nonzero alignment
See issue #11354.

Change-Id: I6817d499e6c02e4a9c83f80bc66a2bee368a69ec
Reviewed-on: https://go-review.googlesource.com/11406
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-25 02:22:58 +00:00
Brad Fitzpatrick
f81f6d6ee8 net/http: don't always require certFile, keyFile in Server.ListenAndServerTLS
The ListenAndServerTLS function still requires the certFile and
keyFile, but the Server.ListenAndServerTLS method doesn't need to
require the certFile and keyFile if the Server.TLSConfig.Certificates
are already populated.

Fixes #8599

Change-Id: Id2e3433732f93e2619bfd78891f775d89f1d651e
Reviewed-on: https://go-review.googlesource.com/11413
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 01:44:47 +00:00
Brad Fitzpatrick
2917ab2049 net/http: document that FormValue returns the empty string
Fixes #8137

Change-Id: Icd94bbe430a3ef333248425449b5fc678edb0343
Reviewed-on: https://go-review.googlesource.com/11410
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 01:17:32 +00:00
Russ Cox
33ce9c19d7 text/template: make zero Template work again
Fixes #11379.

Change-Id: Idbb5c3faad472b77e9867dd2d4551fef5e4ac5f1
Reviewed-on: https://go-review.googlesource.com/11421
Reviewed-by: Rob Pike <r@golang.org>
2015-06-24 22:27:33 +00:00
Russ Cox
66130907d1 cmd/compile: handle copy in escape analysis
Somehow we missed this!
Fixes #11387.

Change-Id: Ida08fe52eff7da2ef7765b4cf35a39a301420c43
Reviewed-on: https://go-review.googlesource.com/11460
Reviewed-by: David Chase <drchase@google.com>
2015-06-24 22:22:55 +00:00
Russ Cox
a9e536442e runtime: set m.procid always on Linux
For debuggers and other program inspectors.

Fixes #9914.

Change-Id: I670728cea28c045e6eaba1808c550ee2f34d16ff
Reviewed-on: https://go-review.googlesource.com/11341
Reviewed-by: Austin Clements <austin@google.com>
2015-06-24 21:50:39 +00:00
Didier Spezia
c68f2f8996 go/format: fix //line corner case when formatting statements
The code formatting mechanism can be applied to partial Go code,
such as a list of statements. The statements are wrapped into a
function definition (to be parsed fine), and unwrapped after formatting.

When the statements contain //line annotations, it may fail,
because not all comments are flushed by the printer before the final '}'.
Formatting "\ta()\n//line :1" results in "\ta() }\n\n//line", which
is wrong.

Tweaked the wrapping/unwrapping code to make sure comments are flushed
before the '}'.

Fixes #11276

Change-Id: Id15c80279b0382ee9ed939cca1647f525c4929f5
Reviewed-on: https://go-review.googlesource.com/11282
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-24 21:45:49 +00:00
Dmitry Vyukov
77082481d4 runtime/race: make test more robust
The test is flaky on builders lately. I don't see any issues other than
usage of very small sleeps. So increase the sleeps. Also take opportunity
to refactor the code.
On my machine this change significantly reduces failure rate with GOMAXPROCS=2.
I can't reproduce the failure with GOMAXPROCS=1.

Fixes #10726

Change-Id: Iea6f10cf3ce1be5c112a2375d51c13687a8ab4c9
Reviewed-on: https://go-review.googlesource.com/9803
Reviewed-by: Austin Clements <austin@google.com>
2015-06-24 17:53:25 +00:00
Brad Fitzpatrick
703166ea14 net/url: validate ports in URLs and bytes after IPv6 literals
Fixes #11208

Change-Id: I35cc94129577b2a977fd35aafb0a5fb02c534a7c
Reviewed-on: https://go-review.googlesource.com/11414
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-24 16:20:45 +00:00
Russ Cox
222b23aae9 net: make LookupIP("1.2.3.4") behavior consistent
To date, the behavior has depended on whether we're using cgo and
in turn what the host resolver does. Most host resolvers will "resolve"
IP addresses, but the non-cgo pure Go path has not.
This CL makes resolution of IP addresses always work, even if we're not using cgo
and even if the host resolver does not "resolve" IP addresses.

Fixes #11335.

Change-Id: I19e82be968154d94904bb2f72e9c17893019a909
Reviewed-on: https://go-review.googlesource.com/11420
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-24 15:16:36 +00:00
Carlos C
0dccee6061 text/scanner: add runnable example for package
Change-Id: I42a952b04a56fb888fa7d5d9c2b56cbdd3434034
Reviewed-on: https://go-review.googlesource.com/11246
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-24 07:22:28 +00:00
Andrew Gerrand
5bf1853e59 cmd/go: don't fetch from insecure repositories without -insecure
Fixes #9637
Fixes #10120

Change-Id: I3728239089efb94d04cd4115c9f840afd7badeaf
Reviewed-on: https://go-review.googlesource.com/9715
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-24 06:36:07 +00:00
Robert Griesemer
eb30fda83e go/types: in string(x) conversions, x must be of integer type
Port of https://go-review.googlesource.com/11365

Fixes #11357.

Change-Id: Icd20fa038696a8853d1d14477e1c1132938b3e2e
Reviewed-on: https://go-review.googlesource.com/11368
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-23 21:06:07 +00:00
Robert Griesemer
4ba1f25888 go/types: better error message for certain unary/binary expression errors
Port of https://go-review.googlesource.com/11363.

Fixes #11367.

Change-Id: Ie0a82bcfab782c514d1947e7a6b190e286afd159
Reviewed-on: https://go-review.googlesource.com/11367
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-23 21:05:46 +00:00
Austin Clements
a8ae93fd26 runtime: fix heap bitmap repeating with large scalar tails
When heapBitsSetType repeats a source bitmap with a scalar tail
(typ.ptrdata < typ.size), it lays out the tail upon reaching the end
of the source bitmap by simply increasing the number of bits claimed
to be in the incoming bit buffer. This causes later iterations to read
the appropriate number of zeros out of the bit buffer before starting
on the next repeat of the source bitmap.

Currently, however, later iterations of the loop continue to read bits
from the source bitmap *regardless of the number of bits currently in
the bit buffer*. The bit buffer can only hold 32 or 64 bits, so if the
scalar tail is large and the padding bits exceed the size of the bit
buffer, the read from the source bitmap on the next iteration will
shift the incoming bits into oblivion when it attempts to put them in
the bit buffer. When the buffer does eventually shift down to where
these bits were supposed to be, it will contain zeros. As a result,
words that should be marked as pointers on later repetitions are
marked as scalars, so the garbage collector does not trace them. If
this is the only reference to an object, it will be incorrectly freed.

Fix this by adding logic to drain the bit buffer down if it is large
instead of reading more bits from the source bitmap.

Fixes #11286.

Change-Id: I964432c4b9f1cec334fc8c3da0ff16460203feb6
Reviewed-on: https://go-review.googlesource.com/11360
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-23 18:37:17 +00:00
Austin Clements
eabdd05892 runtime: document memory ordering for h_spans
h_spans can be accessed concurrently without synchronization from
other threads, which means it needs the appropriate memory barriers on
weakly ordered machines. It happens to already have the necessary
memory barriers because all accesses to h_spans are currently
protected by the heap lock and the unlocks happen in exactly the
places where release barriers are needed, but it's easy to imagine
that this could change in the future. Document the fact that we're
depending on the barrier implied by the unlock.

Related to issue #9984.

Change-Id: I1bc3c95cd73361b041c8c95cd4bb92daf8c1f94a
Reviewed-on: https://go-review.googlesource.com/11361
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-23 18:28:46 +00:00
Robert Griesemer
ef4a17bc80 go/types: add missing test for constant shifts
Port of https://go-review.googlesource.com/11344 to std repo.

Fixes #11325.

Change-Id: I634beaf77cbaeb09de50aa1410e8c53fc37b19df
Reviewed-on: https://go-review.googlesource.com/11317
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-23 18:03:49 +00:00
Rob Pike
989b372a5c cmd/asm: fix shifts again, this time for sure
There are two conditions to worry about:

1) The shift count cannot be negative. Since the evaluator uses unsigned
arithmetic throughout, this means checking that the high bit of
the shift count is always off, which is done by converting to int64
and seeing if the result is negative.

2) For right shifts, the value cannot be negative. We don't want a
high bit in the value because right shifting a value depends on the
sign, and for clarity we always want unsigned shifts.

Next step is to build some testing infrastructure for the parser.

Change-Id: I4c46c79989d02c107fc64954403fc18613763f1d
Reviewed-on: https://go-review.googlesource.com/11326
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-23 06:44:54 +00:00
Andrew Bonventre
4bba6729f8 image/gif: set default loop count to 0 when app ext. is not present
It was otherwise not being preserved across
specific Decode->Encode->Decode calls.

Fixes #11287

Change-Id: I40602da7fa39ec67403bed52ff403f361c6171bb
Reviewed-on: https://go-review.googlesource.com/11256
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-23 05:50:50 +00:00
Rob Pike
f2662f2c93 text/template: explain better the semantics of ParseFiles
Documentation change only.

Fixes #11247.

Change-Id: Ib412de2d643292dbe42b56dee955bdb877aee81b
Reviewed-on: https://go-review.googlesource.com/11329
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-06-23 03:18:52 +00:00
Todd Neal
c8aea7b18f net/http: Remove unused code
This appears to be some legacy which is no longer used.

Change-Id: I469beb59a90853e8de910158f179b32f1aa14c7d
Reviewed-on: https://go-review.googlesource.com/11304
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
2015-06-22 22:54:35 +00:00
Rob Pike
cb3e2bf0ba cmd/doc: fix copy/paste error in test
Some of those consts were supposed to be vars.

Caught by Ingo Oeser.

Change-Id: Ifc12e4a8ee61ebf5174e4ad923956c546dc096e2
Reviewed-on: https://go-review.googlesource.com/11296
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 22:29:35 +00:00
Rob Pike
58d177c63e cmd/asm: fix handling of negative shifts.
The change that "fixed" LSH was incorrect, and the fix for RSH was poor.
Make both use a correct, simple test: if the 64-bit value as a signed
integer is negative, it's an error.

Really fixes #11278.

Change-Id: I72cca03d7ad0d64fd649fa33a9ead2f31bd2977b
Reviewed-on: https://go-review.googlesource.com/11325
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 20:42:22 +00:00
Rob Pike
98c9e9e74f cmd/vet: refer info about -printfuncs to the -printf flag
And vice versa.

The flags are tightly coupled so make the connection clear.

Change-Id: I505f76be631ffa6e489a441c2f3c717aa09ec802
Reviewed-on: https://go-review.googlesource.com/11324
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 20:42:01 +00:00
Rick Hudson
1ab9176e54 runtime: remove race and increase precision in pointer validation.
This CL removes the single and racy use of mheap.arena_end outside
of the bookkeeping done in mHeap_init and mHeap_Alloc.
There should be no way for heapBitsForSpan to see a pointer to
an invalid span. This CL makes the check for this more precise by
checking that the pointer is between mheap_.arena_start and
mheap_.arena_used instead of mheap_.arena_end.

Change-Id: I1200b54353ee1eda002d92645fd8d26048600ceb
Reviewed-on: https://go-review.googlesource.com/11342
Reviewed-by: Austin Clements <austin@google.com>
2015-06-22 20:37:23 +00:00
Russ Cox
ffbed5c22a net/http: fix tests for recent URL.RawPath addition
Change-Id: I35d20ed958c32d464b2c9d849403b6e3f99b6482
Reviewed-on: https://go-review.googlesource.com/11343
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-22 19:01:21 +00:00
Austin Clements
9a3112bcae runtime: one more Map{Bits,Spans} before arena_used update
In order to avoid a race with a concurrent write barrier or garbage
collector thread, any update to arena_used must be preceded by mapping
the corresponding heap bitmap and spans array memory. Otherwise, the
concurrent access may observe that a pointer falls within the heap
arena, but then attempt to access unmapped memory to look up its span
or heap bits.

Commit d57c889 fixed all of the places where we updated arena_used
immediately before mapping the heap bitmap and spans, but it missed
the one place where we update arena_used and depend on later code to
update it again and map the bitmap and spans. This creates a window
where the original race can still happen. This commit fixes this by
mapping the heap bitmap and spans before this arena_used update as
well. This code path is only taken when expanding the heap reservation
on 32-bit over a hole in the address space, so these extra mmap calls
should have negligible impact.

Fixes #10212, #11324.

Change-Id: Id67795e6c7563eb551873bc401e5cc997aaa2bd8
Reviewed-on: https://go-review.googlesource.com/11340
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-22 18:54:38 +00:00
Austin Clements
2a331ca8bb runtime: document relaxed access to arena_used
The unsynchronized accesses to mheap_.arena_used in the concurrent
part of the garbage collector look like a problem waiting to happen.
In fact, they are safe, but the reason is somewhat subtle and
undocumented. This commit documents this reasoning.

Related to issue #9984.

Change-Id: Icdbf2329c1aa11dbe2396a71eb5fc2a85bd4afd5
Reviewed-on: https://go-review.googlesource.com/11254
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-22 18:37:20 +00:00
Russ Cox
874a605af0 net/url: add RawPath field, a hint at the desired encoding of Path
Historically we have declined to try to provide real support for URLs
that contain %2F in the path, but they seem to be popping up more
often, especially in (arguably ill-considered) REST APIs that shoehorn
entire paths into individual path elements.

The obvious thing to do is to introduce a URL.RawPath field that
records the original encoding of Path and then consult it during
URL.String and URL.RequestURI. The problem with the obvious thing
is that it breaks backward compatibility: if someone parses a URL
into u, modifies u.Path, and calls u.String, they expect the result
to use the modified u.Path and not the original raw encoding.

Split the difference by treating u.RawPath as a hint: the observation
is that there are many valid encodings of u.Path. If u.RawPath is one
of them, use it. Otherwise compute the encoding of u.Path as before.

If a client does not use RawPath, the only change will be that String
selects a different valid encoding sometimes (the original passed
to Parse).

This ensures that, for example, HTTP requests use the exact
encoding passed to http.Get (or http.NewRequest, etc).

Also add new URL.EscapedPath method for access to the actual
escaped path. Clients should use EscapedPath instead of
reading RawPath directly.

All the old workarounds remain valid.

Fixes #5777.
Might help #9859.
Fixes #7356.
Fixes #8767.
Fixes #8292.
Fixes #8450.
Fixes #4860.
Fixes #10887.
Fixes #3659.
Fixes #8248.
Fixes #6658.
Reduces need for #2782.

Change-Id: I77b88f14631883a7d74b72d1cf19b0073d4f5473
Reviewed-on: https://go-review.googlesource.com/11302
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-22 16:45:18 +00:00
Russ Cox
794c01b8b4 cmd/go: fix test for issue 8181
The test was translated from shell incorrectly,
and it depended on having hg installed, which
may not be the case.

Moved repo to GitHub, updated code, and fixed
go list ... command to be expected to succeed.

Fixes test for #8181.

Change-Id: I7f3e8fb20cd16cac5ed24de6fd952003bc5e08d4
Reviewed-on: https://go-review.googlesource.com/11301
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-22 16:44:46 +00:00
Carlos C
1be335b608 encoding/csv: add examples for package
Change-Id: I3463826aa760aa5984dec4fc043b95fd2a5120ac
Reviewed-on: https://go-review.googlesource.com/11240
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 11:11:37 +00:00
Rob Pike
71859efceb cmd/asm: remove needless check for negative right shift
In the parser, the shift value is always a uint64.

Change-Id: I9b50295a9f7d174ed1f6f9baf78ec0ed43db417f
Reviewed-on: https://go-review.googlesource.com/11322
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 06:57:19 +00:00
Jeff R. Allen
626188dd31 net/textproto: skip zero-length keys
A header of ": value" results in an empty key. Do not add
it to the headers, because RFC7230 (section 3.2) says that
field-names are tokens, which are one or more characters.

Fixes #11205.

Change-Id: I883be89da1489dc84f98523786b019d1d0169d46
Reviewed-on: https://go-review.googlesource.com/11242
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-22 02:48:27 +00:00
Rob Pike
3cab4760d5 cmd/asm: remove pointless check for negative uint
Fixes #11278.

Change-Id: Ic46fda0f42cefedc3f6085c0e77e67616ce4955e
Reviewed-on: https://go-review.googlesource.com/11297
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-21 03:11:01 +00:00
Rob Pike
13c44d27b7 cmd/doc: add test for constructor, fix build
Most important: skip test on darwin/arm64 for unclear reasons.

First cut at the test missed this feature of go doc: when asking for
the docs for a type, include any function that looks like it constructs
a that type as a return value.

Change-Id: I124e7695e5d365e2b12524b541a9a4e6e0300fbc
Reviewed-on: https://go-review.googlesource.com/11295
Reviewed-by: Rob Pike <r@golang.org>
2015-06-20 10:35:38 +00:00
Ian Lance Taylor
79d4d6eca4 syscall: skip non-root user namespace test if kernel forbids
Some Linux kernels apparently have a sysctl that prohibits
nonprivileged processes from creating user namespaces.  If we see a
failure for that reason, skip the test.

Fixes #11261.

Change-Id: I82dfcaf475eea4eaa387941373ce7165df4848ad
Reviewed-on: https://go-review.googlesource.com/11269
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-06-20 00:52:38 +00:00
Rob Pike
2f2908bec3 cmd/doc: fix test on nacl
nacl is really giving a hard time. avoid all external dependencies in the test.
Worked with trybots, failed in the build. No explanation, but this should fix it.

TBR=rsc

Change-Id: Icb644286dbce88f17ee3d96ad90efba34a80a92d
Reviewed-on: https://go-review.googlesource.com/11291
Reviewed-by: Rob Pike <r@golang.org>
2015-06-19 22:13:20 +00:00
Rob Pike
d0652e7f82 cmd/doc: add test
Refactor main a bit to make it possible to run tests without an exec every time.
(Makes a huge difference in run time.)

Add a silver test. Not quite golden, since it looks for pieces rather than the
full output, and also includes tests for what should not appear.

Fixes #10920.

Change-Id: I6a4951cc14e61763379754a10b0cc3484d30c267
Reviewed-on: https://go-review.googlesource.com/11272
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
2015-06-19 21:56:59 +00:00
Srdjan Petrovic
cc6554f750 cmd/link/internal/ld, cmd/go: -buildmode=c-shared support for darwin/amd64
All of the heavy-lifting was done by minux@, with his external-linking support
for darwin/arm64: golang.org/cl/8781

Change-Id: I7c9fbc19246f418c065c92fb2c13c00026ff0f82
Reviewed-on: https://go-review.googlesource.com/11127
Run-TryBot: Srdjan Petrovic <spetrovic@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-19 20:28:01 +00:00
Russ Cox
dc89350fed cmd/go: fix build
Change-Id: Ia13d1fa450e88e278b81048b99686395ca474c99
Reviewed-on: https://go-review.googlesource.com/11259
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-19 20:05:31 +00:00
Robert Griesemer
1eb8c4aa44 math/big: fix GCD in presence of aliasing
Fixes #11284.

Change-Id: I4ecc4e4cd3c1b3467b43e4ba9666ea6db5fb61a5
Reviewed-on: https://go-review.googlesource.com/11268
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-19 19:53:45 +00:00
Russ Cox
183cc0cd41 cmd/go: add preliminary support for vendor directories
When GO15VENDOREXPERIMENT=1 is in the environment,
this CL changes the resolution of import paths according to
the Go 1.5 vendor proposal:

	If there is a source directory d/vendor, then,
	when compiling a source file within the subtree rooted at d,
	import "p" is interpreted as import "d/vendor/p" if that exists.

	When there are multiple possible resolutions,
	the most specific (longest) path wins.

	The short form must always be used: no import path can
	contain “/vendor/” explicitly.

	Import comments are ignored in vendored packages.

The goal of these changes is to allow authors to vendor (copy) external
packages into their source trees without any modifications to the code.
This functionality has been achieved in tools like godep, nut, and gb by
requiring GOPATH manipulation. This alternate directory-based approach
eliminates the need for GOPATH manipulation and in keeping with the
go command's use of directory layout-based configuration.

The flag allows experimentation with these vendoring semantics once
Go 1.5 is released, without forcing them on by default. If the experiment
is deemed a success, the flag will default to true in Go 1.6 and then be
removed in Go 1.7.

For more details, see the original proposal by Keith Rarick at
https://groups.google.com/d/msg/golang-dev/74zjMON9glU/dGhnoi2IMzsJ.

Change-Id: I2c6527e777d14ac6dc43c53e4b3ff24f3279216e
Reviewed-on: https://go-review.googlesource.com/10923
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-19 19:05:01 +00:00
Russ Cox
7bcc6a1615 cmd/compile: add -importmap option
The -importmap option takes an argument of the form old=new
and specifies that import "old" should be interpreted as if it said
import "new". The option may be repeated to specify multiple mappings.

This option is here to support the go command's new -vendor flag.

Change-Id: I31b4ed4249b549982a720bf61bb230462b33c59b
Reviewed-on: https://go-review.googlesource.com/10922
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-19 18:50:12 +00:00
Austin Clements
f5d494bbdf runtime: ensure GC sees type-safe memory on weak machines
Currently its possible for the garbage collector to observe
uninitialized memory or stale heap bitmap bits on weakly ordered
architectures such as ARM and PPC. On such architectures, the stores
that zero newly allocated memory and initialize its heap bitmap may
move after a store in user code that makes the allocated object
observable by the garbage collector.

To fix this, add a "publication barrier" (also known as an "export
barrier") before returning from mallocgc. This is a store/store
barrier that ensures any write done by user code that makes the
returned object observable to the garbage collector will be ordered
after the initialization performed by mallocgc. No barrier is
necessary on the reading side because of the data dependency between
loading the pointer and loading the contents of the object.

Fixes one of the issues raised in #9984.

Change-Id: Ia3d96ad9c5fc7f4d342f5e05ec0ceae700cd17c8
Reviewed-on: https://go-review.googlesource.com/11083
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Martin Capitanio <capnm9@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-19 15:29:50 +00:00
Nigel Tao
75ce33068d image/gif: re-enable some invalid-palette tests.
These tests were broken by https://go-review.googlesource.com/#/c/11227/
which fixed the LZW encoder to reject invalid input.

For TestNoPalette, the LZW encoder with a litWidth of 2 now rejects an
input byte of 128, so we change 128 to 3, as 3 <= (1<<2 - 1).

For TestPixelOutsidePaletteRange, the LZW encoder similarly rejects an
input byte of 255. Prior to golang.org/cl/11227, the encoder (again with
a litWidth of 2) accepted the 255 input byte, but masked it with (1<<2 -
1), so that the 255 test case was effectively the same as the 3 test
case. After that LZW CL, the 255 input byte is simply invalid, so we
remove it as a test case. The test still tests pixels outside of the
palette range, since 3 >= the length of the global palette, which is 2.

Change-Id: I50be9623ace016740e34801549c15f83671103eb
Reviewed-on: https://go-review.googlesource.com/11273
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-06-19 06:14:38 +00:00
Carlos C
a3c0730435 html: add examples to the functions
Change-Id: I129d70304ae4e4694d9217826b18b341e3834d3c
Reviewed-on: https://go-review.googlesource.com/11201
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-19 05:15:22 +00:00
Alex Brainman
9d968cb47b runtime: rename cgocall_errno and asmcgocall_errno into cgocall and asmcgocall
Change-Id: I5917bea8bb35b0e725dcc56a68f3a70137cfc180
Reviewed-on: https://go-review.googlesource.com/9387
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-19 01:47:11 +00:00
Ian Lance Taylor
1a040c9230 cmd/cgo: static variables in the preamble may not be referenced
This is a documentation fix that reflects the current reality.

Fixes #9673.

Change-Id: Ie436b277dfd1b68b13c67813d29c238d2c23b820
Reviewed-on: https://go-review.googlesource.com/11221
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-19 01:08:43 +00:00
Ian Lance Taylor
679fd5b447 cmd/go: do not permit importing a main package
Fixes #4210.

Change-Id: Id981814a6e55a57403ce7a8ac45ab3ba081a3a86
Reviewed-on: https://go-review.googlesource.com/10925
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-19 01:06:36 +00:00
Ian Lance Taylor
18d9a8d05f cmd/go: format temporary Go files in testsuite
Indent the temporary file source code embedded in go_test.go, so that
we don't have temporary Go code in the first column.

No real changes to the tests, just formatting.

Change-Id: I416b4a812c8db452ea61afe63a00989ec598c228
Reviewed-on: https://go-review.googlesource.com/10926
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-19 00:53:56 +00:00
Andrey Petrov
9f3a2d5f9a doc: clarify duplicate symbol condition in cgo
Spell out what will happen if a declaration and definition is included
in the same file, should help people who run into duplicate symbol
errors and search for relevant keywords.

This edit is based on opening issue #11263 erroneously.

Change-Id: I0645a9433b8668d2ede9b9a3f6550d802c26388b
Reviewed-on: https://go-review.googlesource.com/11247
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-19 00:48:42 +00:00
Mikio Hara
2f3d103f55 os: fix nits found by vet
Change-Id: I97812575ff9c69301a5ce2e1c814b40e1da32a55
Reviewed-on: https://go-review.googlesource.com/11271
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-19 00:44:13 +00:00
Mikio Hara
3269683250 os: skip TestStartProcess and TestHostname on android
Updates #11268.

Change-Id: Ib0cabd1c1806e884df9e40f6a9a1cdecf2f76823
Reviewed-on: https://go-review.googlesource.com/11223
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-19 00:32:01 +00:00
Jeff R. Allen
82020f8659 image/gif: return an error on missing palette
A frame that tries to use the global palette when it has
not been given should result in an error, not an image
with no palette at all.

Fixes #11150.

Change-Id: If0c3a201a0ac977eee2b7a5dc68930c0c5787f40
Reviewed-on: https://go-review.googlesource.com/11064
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-18 22:44:26 +00:00
Nigel Tao
682ecea9a0 image/gif: (temporarily) disable broken tests.
The compress/lzw encoder now rejects too-large input bytes, as of
https://go-review.googlesource.com/#/c/11227/, so we can't generate bad
GIFs programatically.

Change-Id: I0b32ce8e1f1776cd6997869db61e687430464e45
Reviewed-on: https://go-review.googlesource.com/11270
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-18 22:39:09 +00:00
Nigel Tao
ccec934814 compress/lzw: reject writing bytes that don't fit into litWidth.
Fixes #11142.

Change-Id: Id772c4364c47776d6afe86b0939b9c6281e85edc
Reviewed-on: https://go-review.googlesource.com/11227
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 22:17:11 +00:00
Andrew Gerrand
0c247bf41b math/big: refine Fibonacci example
Change-Id: Id9e8c3f89e021b9f389ab3c8403e6a8450fa9f5f
Reviewed-on: https://go-review.googlesource.com/11231
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-18 22:16:16 +00:00
Jeff R. Allen
2a5745d81e compress/lzw: mention relation between litWidth and input bytes
Add sentences to the docs explaining the limit on input
bytes implicit in the choice of litWidth, and the fact that
compress and decompress litWidth must match.

Fixes #11142.

Change-Id: I20cfb4df35739f7bfeb50b92c78249df3d47942c
Reviewed-on: https://go-review.googlesource.com/11063
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-18 22:09:37 +00:00
Rick Hudson
90a19961f2 runtime: reduce latency by aggressively ending mark phase
Some latency regressions have crept into our system over the past few
weeks. This CL fixes those by having the mark phase more aggressively
blacken objects so that the mark termination phase, a STW phase, has less
work to do. Three approaches were taken when the mark phase believes
it has no more work to do, ie all the work buffers are empty.
If things have gone well the mark phase is correct and there is
in fact little or no work. In that case the following items will
take very little time. If the mark phase is wrong this CL will
ferret that work out and give the mark phase a chance to deal with
it concurrently before mark termination begins.

When the mark phase first appears to be out of work, it does three things:
1) It switches from allocating white to allocating black to reduce the
number of unmarked objects reachable only from stacks.
2) It flushes and disables per-P GC work caches so all work must be in
globally visible work buffers.
3) It rescans the global roots---the BSS and data segments---so there
are fewer objects to blacken during mark termination. We do not rescan
stacks at this point, though that could be done in a later CL.
After these steps, it again drains the global work buffers.

On a lightly loaded machine the garbage benchmark has reduced the
number of GC cycles with latency > 10 ms from 83 out of 4083 cycles
down to 2 out of 3995 cycles. Maximum latency was reduced from
60+ msecs down to 20 ms.

Change-Id: I152285b48a7e56c5083a02e8e4485dd39c990492
Reviewed-on: https://go-review.googlesource.com/10590
Reviewed-by: Austin Clements <austin@google.com>
2015-06-18 21:38:46 +00:00
Andrew Gerrand
e6d2112ba9 internal/testenv: skip network tests only when -short is specified
Change-Id: I157879f5204d543eb3fc81c212d563b146473ba8
Reviewed-on: https://go-review.googlesource.com/11232
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 21:10:44 +00:00
ALTree
ee1ef8fe67 math/big: Add small complete example of big.Float usage
Updates #11241

Change-Id: I573be85d0cfcf410f6125ecd2be8a3d292c40bbb
Reviewed-on: https://go-review.googlesource.com/11245
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-18 21:08:41 +00:00
Robert Griesemer
2e7831a1d1 go/parser: document that parser accepts a wider language than specified
See also issue #11271.

Change-Id: I34175f46ce137b14ca483500f673b0f8ee1f2108
Reviewed-on: https://go-review.googlesource.com/11262
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-18 20:31:26 +00:00
Michael Matloob
32f2f72c47 cmd/compile: provide better error when method called without receiver
When a method is called using the Type.Method(receiver, args...) syntax
without the receiver, or enough arguments, provide the more helpful
error message "not enough arguments in call to method expression
Type.Method" instead of the old message "not enough arguments in call
to Type.Method".

Fixes #8385

Change-Id: Id5037eb1ee5fa93687d4a6557b4a8233b29e9df2
Reviewed-on: https://go-review.googlesource.com/2193
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 19:37:38 +00:00
Shenghou Ma
3925a7c5db all: switch to the new deprecation convention
While we're at it, move some misplaced comment blocks around.

Change-Id: I1847d7f1ca1dbb8e5de737203c4ed6c66e112508
Reviewed-on: https://go-review.googlesource.com/10188
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 19:16:23 +00:00
Shenghou Ma
526b501713 time: correct unrepresentable Unix time comment
It's easy for someone who wants a time bigger than any
valid time to reach for time.Unix(1<<63-1, 0), so it
makes sense to explicit say such value is not valid.

Fixes #10906 (again).

Change-Id: If71e32472ae40d86c30e629b982406040a73c4c7
Reviewed-on: https://go-review.googlesource.com/10266
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 18:21:59 +00:00
Davies Liu
1e0760354c hash/crc32: speedup crc32 of IEEE using slicingBy8
The Slicing-By-8 [1] algorithm has much performance improvements than
current approach. This patch only uses it for IEEE, which is the most
common case in practice.

There is the benchmark on Mac OS X 10.9:

benchmark                     old MB/s     new MB/s     speedup
BenchmarkIEEECrc1KB           349.40       353.03       1.01x
BenchmarkIEEECrc4KB           351.55       934.35       2.66x
BenchmarkCastagnoliCrc1KB     7037.58      7392.63      1.05x

This algorithm need 8K lookup table, so it's enabled only for block
larger than 4K.

We can see about 2.6x improvement for IEEE.

Change-Id: I7f786d20f0949245e4aa101d7921669f496ed0f7
Reviewed-on: https://go-review.googlesource.com/1863
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 18:14:24 +00:00
Josh Bleecher Snyder
d1e7980d1b log: fix flaky test
Fixes #11272.

Change-Id: I78d666c20f4f7cb7116d37fd66b5f8b7d66c53c4
Reviewed-on: https://go-review.googlesource.com/11234
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-18 18:08:17 +00:00
Giulio Iotti
9490fbf755 xml: add check of version in document declaration
Check that if a version is declared, for example
in '<?xml version="XX" ?>', version must be '1.0'.

Change-Id: I16ba9f78873a5f31977dcf75ac8e671fe6c08280
Reviewed-on: https://go-review.googlesource.com/8961
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 18:06:01 +00:00
Peter Waldschmidt
a13606e619 encoding/json: Remove extra allocation in scanner.
When the scanner receives a non-whitespace character in stateEndTop,
it creates an error message and caches it to return on the next
transition. nextValue() uses the scanner to sub-scan for a value
inside a larger JSON structure. Since stateEndTop is triggered
*after* the ending byte, whatever character immediately follows the
sub-value gets pulled into the scanner's state machine as well.
Even though it is not used and doesn't cause an error, it does
cause the state machine to allocate an error that will never be used.

The fix is to probe the state machine with whitespace after
scanEndObject or scanEndArray to see if the next character would
result in a scanEnd state transition. If so, we can return right
away without processing the next character and avoid triggering
an allocation.

benchmark                       old ns/op     new ns/op     delta
BenchmarkCodeEncoder            17022194      16611336      -2.41%
BenchmarkCodeMarshal            18443250      18090144      -1.91%
BenchmarkCodeDecoder            61502053      61010936      -0.80%
BenchmarkCodeUnmarshal          61410829      60363605      -1.71%
BenchmarkCodeUnmarshalReuse     59124836      58361772      -1.29%
BenchmarkUnmarshalString        602           603           +0.17%
BenchmarkUnmarshalFloat64       535           537           +0.37%
BenchmarkUnmarshalInt64         482           482           +0.00%
BenchmarkIssue10335             1206          799           -33.75%
BenchmarkSkipValue              17605751      18355391      +4.26%
BenchmarkEncoderEncode          612           604           -1.31%

benchmark                  old MB/s     new MB/s     speedup
BenchmarkCodeEncoder       114.00       116.82       1.02x
BenchmarkCodeMarshal       105.21       107.27       1.02x
BenchmarkCodeDecoder       31.55        31.81        1.01x
BenchmarkCodeUnmarshal     31.60        32.15        1.02x
BenchmarkSkipValue         111.63       107.07       0.96x

benchmark                  old allocs     new allocs     delta
BenchmarkIssue10335        11             4              -63.64%
BenchmarkEncoderEncode     2              2              +0.00%

benchmark                  old bytes     new bytes     delta
BenchmarkIssue10335        376           272           -27.66%
BenchmarkEncoderEncode     40            40            +0.00%

Fixes #10335

Change-Id: I3d4f2b67f7a038adfb33ba48bb6b680f528baf18
Reviewed-on: https://go-review.googlesource.com/9074
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 17:59:42 +00:00
Egon Elbre
4f4da07ea0 cmd/go: suggest running 'go help gopath' with problematic GOPATH
Suggest running 'go help gopath' when the running 'go install .'
and the folder is outside of GOPATH.

Added link to 'https://golang.org/doc/code.html' in gopath help
for more information.

Example output:

% go install .
go install: no install location for directory f:\x\badmessage outside GOPATH
        please run 'go help gopath' for more information

% go help gopath
... SNIP ...
See https://golang.org/doc/code.html for an example.

Fixes #8457

Change-Id: I0ef6ee3c65bb12af2168eafeb757258aa3835664
Reviewed-on: https://go-review.googlesource.com/9258
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 17:34:26 +00:00
Shenghou Ma
01187f756e build: fix clean scripts
Fixes #10734.

Change-Id: I7a2c580b87749225668fbd7a005412c8eee6824d
Reviewed-on: https://go-review.googlesource.com/9823
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 16:13:13 +00:00
Michael Gehring
7733a7cad8 archive/tar: add missing error checks
Check for errors when reading the headers following the pax headers.

Fixes #11169.

Change-Id: Ifec4a949ec8df8b49fa7cb7a67eb826fe2282ad8
Reviewed-on: https://go-review.googlesource.com/11031
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 16:02:34 +00:00
Dmitry Vyukov
1b269463a5 cmd/trace: gracefully handle empty profiles
Return a meaningful message when a profile is empty.
Also rename "IO blocking" to "Network blocking",
currently only network blocking is captured.

Fixes #11098

Change-Id: Ib6f1292b8ade4805756fcb6696ba1fca8f9f39a9
Reviewed-on: https://go-review.googlesource.com/11243
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-18 14:46:49 +00:00
Dmitry Vyukov
e72f5f67a1 runtime: fix tracing of syscallexit
There were two issues.
1. Delayed EvGoSysExit could have been emitted during TraceStart,
while it had not yet emitted EvGoInSyscall.
2. Delayed EvGoSysExit could have been emitted during next tracing session.

Fixes #10476
Fixes #11262

Change-Id: Iab68eb31cf38eb6eb6eee427f49c5ca0865a8c64
Reviewed-on: https://go-review.googlesource.com/9132
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 13:59:55 +00:00
Nigel Tao
62f169cb38 compress/lzw: be consistent with error message prefixes.
All the other error messages in this package are "lzw: etc".

Change-Id: Ie359a8912d213f92b15f02abc953127380503048
Reviewed-on: https://go-review.googlesource.com/11228
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-06-18 05:31:38 +00:00
Alex Brainman
2858b73843 runtime: remove cgocall and asmcgocall
In preparation for rename of cgocall_errno into cgocall and
asmcgocall_errno into asmcgocall in the fllowinng CL.
rsc requested CL 9387 to be split into two parts. This is first part.

Change-Id: I7434f0e4b44dd37017540695834bfcb1eebf0b2f
Reviewed-on: https://go-review.googlesource.com/11166
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-18 04:42:53 +00:00
Mikio Hara
24db235deb net: fix build on android
Change-Id: Ib6d0b2947748dec98cad2e6abb6812cac46a9897
Reviewed-on: https://go-review.googlesource.com/11220
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-18 00:45:12 +00:00
Robert Griesemer
3cc7b27383 go/internal/gccgoimporter: enable tests on Plan9
Work-around issue #11265 and re-enable tests for Plan9.

Change-Id: I3aabb674a149b8eb936f948dd4cda5fd81454646
Reviewed-on: https://go-review.googlesource.com/11194
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-18 00:19:08 +00:00
Robert Griesemer
8fa1a69f0b go/types: use testenv.MustHaveGoBuild to exclude some builds
Replace custom solution with new (internal) library call.

Change-Id: I53b26a1caf0684b9f5d8d749b10d9f3ba18a3001
Reviewed-on: https://go-review.googlesource.com/11193
Reviewed-by: Damien Neil <dneil@google.com>
2015-06-17 23:24:35 +00:00
Robert Griesemer
bc7a3a62cf go/importer: implement support for gccgo
Change-Id: I0e1aab2fe2340a1fbb7f377dbd7a72ea6f0477d8
Reviewed-on: https://go-review.googlesource.com/11153
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-17 23:04:15 +00:00
Robert Griesemer
289e282966 go/internal/gccgoimporter: adjust to std repo libraries (fix build)
Change-Id: Ia9cbe3bfaa3e66c93d568d8beeed624b113d51a2
Reviewed-on: https://go-review.googlesource.com/11152
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-17 23:03:57 +00:00
Robert Griesemer
f6ae5f96c7 go/internal/gccgoimporter: unmodified copy of x/tools/go/gccgoimporter
This change will brake the build. The immediately following change
contains the necessary adjustments to make it work again. We're
doing this in two steps to expose the manual changes applied.

Change-Id: I225947da23e190b12e12cbd0c5e6e91628de7f53
Reviewed-on: https://go-review.googlesource.com/11151
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-17 23:03:13 +00:00
Robert Griesemer
bbf79575a5 math/big: incorporate feedback by josharian (Example_fibonacci)
Change-Id: I376ff39594b532a5490f13e3985b7a6ff4b6761d
Reviewed-on: https://go-review.googlesource.com/11191
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-17 20:29:35 +00:00
Russ Cox
cfa3eda587 runtime: fix race in scanvalid assertion
Change-Id: I389b2e10fe667eaa55f87b71b1e004994694d4a3
Reviewed-on: https://go-review.googlesource.com/11173
Reviewed-by: Austin Clements <austin@google.com>
2015-06-17 20:12:37 +00:00
ALTree
f0fee976aa math/big: Added small complete example of big.Int usage
Updates #11241

Change-Id: I9639c4f66cf805a57b087c9f648d3918df105d86
Reviewed-on: https://go-review.googlesource.com/11034
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-17 19:42:06 +00:00
Mikio Hara
e38bcb58d7 net: fix build on netbsd
Change-Id: Ia5c6d9fb114be65d7c20c7eb97ed696977051031
Reviewed-on: https://go-review.googlesource.com/11167
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-17 18:17:50 +00:00
Russ Cox
3c60e6e8cf runtime: fix races in stack scan
This fixes a hang during runtime.TestTraceStress.
It also fixes double-scan of stacks, which leads to
stack barrier installation failures.

Both of these have shown up as flaky failures on the dashboard.

Fixes #10941.

Change-Id: Ia2a5991ce2c9f43ba06ae1c7032f7c898dc990e0
Reviewed-on: https://go-review.googlesource.com/11089
Reviewed-by: Austin Clements <austin@google.com>
2015-06-17 17:56:26 +00:00
Russ Cox
1fc114c797 cmd/addr2line: simplify windows test
Change-Id: I0fcc35f43bc6059e6203af6134319cfc060c4b9a
Reviewed-on: https://go-review.googlesource.com/11085
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-17 14:23:20 +00:00
Russ Cox
08e25fc1ba cmd/compile: introduce //go:systemstack annotation
//go:systemstack means that the function must run on the system stack.

Add one use in runtime as a demonstration.

Fixes #9174.

Change-Id: I8d4a509cb313541426157da703f1c022e964ace4
Reviewed-on: https://go-review.googlesource.com/10840
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
2015-06-17 14:23:00 +00:00
Yongjian Xu
e3dc59f33d runtime: fix typos in os_linux_arm.go
Change-Id: I750900e0aed9ec528fea3f442c35196773e3ba5e
Reviewed-on: https://go-review.googlesource.com/11163
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-17 08:51:59 +00:00
Jeremy Jackins
7354978950 doc: replace references to {5..9}{g,l} with go tool compile and go tool link
I updated some references to 6g, 6l and friends that I came across, as those
programs don't exist anymore. I also fixed some echos in make.rc to match other make.* scripts while I was there.

Change-Id: Ib84532cd4688cf65174dd9869e5d42af98a20a48
Reviewed-on: https://go-review.googlesource.com/11162
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-17 04:05:50 +00:00
Joe Tsai
b03129aa27 compress/flate: make library RFC1951 compliant
Corrected several issues:
 * RFC1951 section 3.2.7 dictates that it is okay for the HDist tree to have a
single code of zero bits. Furthermore, the behavior of the C zlib library
permits empty trees even when there are more than one codes.
 * RFC1951 section 3.2.5 shows that HLit codes 286 and 287 are invalid. Thus,
Go's implementation should choke on inputs using these codes.
 * RFC1951 section 3.2.5 and 3.2.7 are ambiguous about whether the number of
HDist codes can be greater than 30. The C zlib library (which is the canonical
reference implementation) performs this check here:
62d6112a79/inflate.c (L906)

In addition, a number of test cases were added to the unit tests that exercises
these edge cases. The test cases listed in TestStreams will either fail or
succeed in a manner matching the behaviour of the C zlib version. Given that the
C zlib implementation is the reference for the world, Go's implementation should
match C zlib behaviour.

Fixes #11030

Change-Id: Ic24e4e40ce5832c7e1930249246e86d34bfedaa6
Reviewed-on: https://go-review.googlesource.com/11000
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-17 03:21:49 +00:00
David Chase
5be61b18d4 cmd/compile: run escape analysis after method wrapper generation
Also modified test/run.go to ignore messages prefixed <autogenerated>
because those cannot be described with "// ERROR ...", and backed out
patch from issue #9537 because it is no longer necessary.  The reasons
described in the 9537 discussion for why escape analysis cannot run
late no longer hold, happily.

Fixes #11053.

Change-Id: Icb14eccdf2e8cde3d0f8fb8a216b765400a96385
Reviewed-on: https://go-review.googlesource.com/11088
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-06-17 02:36:45 +00:00
Alex Brainman
6428a8b437 cmd/dist: add new misc/cgo/testsovar test
This change reintroduces CL 8523. CL 8523 was reverted because
it broke darwin and netbsd builds. Now that this test is part
of "go tool dist test" command we could skip OSes that fail.

Updates #10360

Change-Id: Iaaeb5b800126492f36415a439c333a218fe4ab67
Reviewed-on: https://go-review.googlesource.com/11119
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-17 02:33:40 +00:00
Alex Brainman
8e723109de cmd/go: vary executable names in tests
So the tests don't interfere with each other on windows.

Fixes #11217

Change-Id: I4b3936bc64c95c7274298d6f137b24a28876b625
Reviewed-on: https://go-review.googlesource.com/11138
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-17 01:26:40 +00:00
Mikio Hara
99f5f796d9 net: allow LookupAddr to use getnameinfo when cgo is enabled
This change allows LookupAddr to use getnameinfo through cgo for working
together with various name services other than DNS.

Fixes #7855.

Change-Id: I5b3b4aefe3d1b904541c3350865734d8cbb1c1c4
Reviewed-on: https://go-review.googlesource.com/3420
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-17 00:28:31 +00:00
Robert Griesemer
d3e8a3614c go/types: don't export gcCompatibilityMode flag
This flag is not needed in the std repo because we don't have
tests requiring it. Remove it before it's frozen into the API.

Change-Id: I18b861eea146ad67e7a3c26ee8be681d8065ef12
Reviewed-on: https://go-review.googlesource.com/11150
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-16 22:35:08 +00:00
Michael Hudson-Doyle
a5f57d7950 cmd/link: when reading symbols from a shared library, allow duplicates when they are both in bss
This makes the behaviour match what happens when duplicate symbols are read
from regular object files and fixes errors about cgoAlwaysFalse when linking
an executable that uses cgo against a shared library.

Change-Id: Ibb8cd8fe3f7813cde504b7483f1e857868d7e063
Reviewed-on: https://go-review.googlesource.com/11117
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-16 22:33:36 +00:00
David du Colombier
b1be121791 os: skip TestHostname on Plan 9
TestHostname was re-enabled in CL 10753.
However, on Plan 9 the hostname is not obtained
by executing a "hostname" command, but by reading
the #c/sysname file.

Change-Id: I80c0e303f4983fe39ceb300ad64e2c4a8392b695
Reviewed-on: https://go-review.googlesource.com/11033
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-16 22:07:01 +00:00
Austin Clements
7387121ddb runtime: account for stack guard when shrinking the stack
Currently, when shrinkstack computes whether the halved stack
allocation will have enough room for the stack, it accounts for the
stack space that's actively in use but fails to leave extra room for
the stack guard space. As a result, *if* the minimum stack size is
small enough or the guard large enough, it may shrink the stack and
leave less than enough room to run nosplit functions. If the next
function called after the stack shrink is a nosplit function, it may
overflow the stack without noticing and overwrite non-stack memory.

We don't think this is happening under normal conditions right now.
The minimum stack allocation is 2K and the guard is 640 bytes. The
"worst case" stack shrink is from 4K (4048 bytes after stack barrier
array reservation) to 2K (2016 bytes after stack barrier array
reservation), which means the largest "used" size that will qualify
for shrinking is 4048/4 - 8 = 1004 bytes. After copying, that leaves
2016 - 1004 = 1012 bytes of available stack, which is significantly
more than the guard space.

If we were to reduce the minimum stack size to 1K or raise the guard
space above 1012 bytes, the logic in shrinkstack would no longer leave
enough space.

It's also possible to trigger this problem by setting
firstStackBarrierOffset to 0, which puts stack barriers in a debug
mode that steals away *half* of the stack for the stack barrier array
reservation. Then, the largest "used" size that qualifies for
shrinking is (4096/2)/4 - 8 = 504 bytes. After copying, that leaves
(2096/2) - 504 = 8 bytes of available stack; much less than the
required guard space. This causes failures like those in issue #11027
because func gc() shrinks its own stack and then immediately calls
casgstatus (a nosplit function), which overflows the stack and
overwrites a free list pointer in the neighboring span. However, since
this seems to require the special debug mode, we don't think it's
responsible for issue #11027.

To forestall all of these subtle issues, this commit modifies
shrinkstack to correctly account for the guard space when considering
whether to halve the stack allocation.

Change-Id: I7312584addc63b5bfe55cc384a1012f6181f1b9d
Reviewed-on: https://go-review.googlesource.com/10714
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-16 21:17:53 +00:00
Austin Clements
5250279eb9 runtime: detect and print corrupted free lists
Issues #10240, #10541, #10941, #11023, #11027 and possibly others are
indicating memory corruption in the runtime. One of the easiest places
to both get corruption and detect it is in the allocator's free lists
since they appear throughout memory and follow strict invariants. This
commit adds a check when sweeping a span that its free list is sane
and, if not, it prints the corrupted free list and panics. Hopefully
this will help us collect more information on these failures.

Change-Id: I6d417bcaeedf654943a5e068bd76b58bb02d4a64
Reviewed-on: https://go-review.googlesource.com/10713
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
2015-06-16 21:17:47 +00:00
Russ Cox
142e434006 runtime: implement GOTRACEBACK=crash for linux/386
Change-Id: I401ce8d612160a4f4ee617bddca6827fa544763a
Reviewed-on: https://go-review.googlesource.com/11087
Reviewed-by: Austin Clements <austin@google.com>
2015-06-16 20:47:47 +00:00
Mikio Hara
0266bc8494 cmd/go: fix build
Change-Id: I2cd58a665d9df26583128c633c443325dcc3f288
Reviewed-on: https://go-review.googlesource.com/11131
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-16 19:26:07 +00:00
Russ Cox
7bc3e58806 all: extract "can I exec?" check from tests into internal/testenv
Change-Id: I7b54be9d8b50b39e01c6be21f310ae9a10404e9d
Reviewed-on: https://go-review.googlesource.com/10753
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-16 18:07:36 +00:00
Mikio Hara
047f07a285 net: remove obsolete TestLookupHost
The motivation of TestLookupHost was to test codepaths on LookupHost,
LookupIP when we set CGO_ENABLED=1. Now we have serveral tests on those
APIs and their codepaths such as TestLookupGooglePublicDNSAddr,
TestCgoLookupIP, TestGoLookupIP, and the test using the ambiguous source
"localhost" is unnecessary.

Fixes #11182.

Change-Id: I397c823e1648114d91a229b316477bff2948b4f9
Reviewed-on: https://go-review.googlesource.com/11057
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-16 17:37:29 +00:00
David Crawshaw
9585bb29c8 go/types: disable example on darwin/arm
Sadly examples cannot use the new internal/testenv, so this is
extends the crude build tag restriction in this file.

Change-Id: I49646ca71e45074a917813ae8e612cc715c78be8
Reviewed-on: https://go-review.googlesource.com/11086
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-16 17:36:14 +00:00
Mikio Hara
515e53a051 net: skip TestProtocolDialError on solaris
Unfortunately there's no simple, easy way to make Dial{TCP,UDP} fail
consistently across all platforms. Fow now we skip the test on Solaris.

Change-Id: Ib3c55f670ac6a174fe9ea682dac7aab96b1e9dfb
Reviewed-on: https://go-review.googlesource.com/11058
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-16 17:35:46 +00:00
Shenghou Ma
d00e7ad640 cmd/compile: show compiler panics when -d panic=1
Fixes #10683.

Change-Id: I4cce3f298b787c736dbabe544a11a9215bcd3671
Reviewed-on: https://go-review.googlesource.com/10336
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-16 16:50:21 +00:00
Paul Marks
0d8366e2d6 net: add sequential and RFC 6555-compliant TCP dialing.
dialSerial connects to a list of addresses in sequence.  If a
timeout is specified, then each address gets an equal fraction of the
remaining time, with a magic constant (2 seconds) to prevent
"dial a million addresses" from allotting zero time to each.

Normally, net.Dial passes the DNS stub resolver's output to dialSerial.
If an error occurs (like destination/port unreachable), it quickly skips
to the next address, but a blackhole in the network will cause the
connection to hang until the timeout elapses.  This is how UNIXy clients
traditionally behave, and is usually sufficient for non-broken networks.

The DualStack flag enables dialParallel, which implements Happy Eyeballs
by racing two dialSerial goroutines, giving the preferred family a
head start (300ms by default).  This allows clients to avoid long
timeouts when the network blackholes IPv4 xor IPv6.

Fixes #8453
Fixes #8455
Fixes #8847

Change-Id: Ie415809c9226a1f7342b0217dcdd8f224ae19058
Reviewed-on: https://go-review.googlesource.com/8768
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-16 02:38:21 +00:00
Michael Hudson-Doyle
12b05bf8fd cmd/go: support -buildmode=shared with gccgo
Change-Id: Id93b8ab42fa311ce32209734ec9a0813f8736e25
Reviewed-on: https://go-review.googlesource.com/9914
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-06-16 01:43:29 +00:00
Robert Griesemer
7322ef5d2a go/types: fix Eval to use correct file set when evaluating an expression
This is https://go-review.googlesource.com/10999 which we could not apply
in x/tools/go/types because we must not rely on 1.5 features in that repo
yet.

Change-Id: I9a57cdb7ad4051df278d1fbed90c736df50f426f
Reviewed-on: https://go-review.googlesource.com/11125
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-15 20:11:58 +00:00
Robert Griesemer
d63c42df25 go/types: port recent x/tools/go/types fixes
The main change is:

golang.org/cl/10800  add pos parameter to Eval; remove New, EvalNode

followed by several cleanups/follow-up fixes:

golang.org/cl/10992  remove global vars in test
golang.org/cl/10994  remove unused scope parameter from NewSignature
golang.org/cl/10995  provide full source file extent to file scope
golang.org/cl/10996  comment fix in resolver.go
golang.org/cl/11004  updated cmd/vet
golang.org/cl/11042  be robust in the presence of incorrect/missing position info

Fixes #9980.

Change-Id: Id4aff688f6a399f76bf92b84c7e793b8da8baa48
Reviewed-on: https://go-review.googlesource.com/11122
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-15 20:11:37 +00:00
Brad Fitzpatrick
4965a77f1d cmd/go: fix typo
Change-Id: I171a1125e25b13c934c2cd545bd03f49f642910d
Reviewed-on: https://go-review.googlesource.com/11113
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-15 20:08:24 +00:00
Ian Lance Taylor
6f0e427298 syscall: fix TestCloneNEWUSERAndRemapNoRootDisableSetgroups the right way
The problem was not the kernel version as I thought before, it was
that the test used the same number for both the UID and the GID.
Thanks to Chris Siebenmann for debugging this.

Fixes #11220.

Change-Id: Ib5077e182497155e84044683209590ee0f7c9dde
Reviewed-on: https://go-review.googlesource.com/11124
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-06-15 19:55:22 +00:00
Russ Cox
4dab6d01f1 cmd/go: make -a apply to the standard library, like in Go 1.3
This CL adds a very long comment explaining how isStale and
the new build IDs work. As part of writing the comment I realized:

// When the go command makes the wrong build decision and does not
// rebuild something it should, users fall back to adding the -a flag.
// Any common use of the -a flag should be considered prima facie evidence
// that isStale is returning an incorrect false result in some important case.
// Bugs reported in the behavior of -a itself should prompt the question
// ``Why is -a being used at all? What bug does that indicate?''

The two uses of -a that are most commonly mentioned in bugs filed
against the go command are:

	go install -a ./...
	go build -tags netgo -a myprog

Both of these commands now do the right thing without needing -a.

The -a exception we introduced in Go 1.4 was for the first form, and
it broke the second form. Again, neither needs -a anymore, so restore
the old, simpler, easier to explain, less surprising meaning used in Go 1.3:
if -a is given, rebuild EVERYTHING.

See the comment for more justification and history.

Summary of recent CLs (to link bugs to this one):

Fixes #3036. Now 'go install ./...' works.
Fixes #6534. Now 'go install ./...' works.
Fixes #8290. Now 'go install ./...' works.
Fixes #9369. Now 'go build -tags netgo myprog' works.
Fixes #10702. Now using one GOPATH with Go 1.5 and Go 1.6 works.
  (Each time you switch, everything needed gets rebuilt.
  Switching from Go 1.4 to Go 1.5 will rebuild properly.
  Switching from Go 1.5 back to Go 1.4 still needs -a when
  invoking the Go 1.4 go command.)

Change-Id: I19f9eb5286efaa50de7c8326602e94604ab572eb
Reviewed-on: https://go-review.googlesource.com/10761
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-15 19:38:11 +00:00
Russ Cox
3ab9ff1107 cmd/go: include Go toolchain information in build ID
This causes packages and binaries built by Go 1.5 to look
out of date to Go 1.6 and vice versa, so that when you flip
between different Go versions but keep the same GOPATH,
the right rebuilding happens at each flip.

Go 1.4 binaries will also look out of date to Go 1.5,
but Go 1.5 binaries will not look out of date to Go 1.4
(since Go 1.4 doesn't have anything like this).
People flipping between Go 1.4 and Go 1.5 will still
need to use go install -a every time to flip to Go 1.4,
but not when they flip back to Go 1.5.

Fixes #6534.
Fixes #10702.

Change-Id: I0ae7f268f822d483059a938a4f22846ff9275b4c
Reviewed-on: https://go-review.googlesource.com/10760
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-15 18:57:35 +00:00
Russ Cox
43aac4f9e7 runtime: raise maxmem to 512 GB
A workaround for #10460.

Change-Id: I607a556561d509db6de047892f886fb565513895
Reviewed-on: https://go-review.googlesource.com/10819
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-06-15 18:31:25 +00:00
Srdjan Petrovic
85b333dbf8 cmd/go: force-overwrite destination files when installing cgo headers
Fixes #11131

When running 'go install -buildmode=c-shared', under the circumstances
described in issue #11131, the install command would fail trying to
install cgo headers if they have already been installed (by a previous
call to 'go install -buildmode=c-shared').

Since it's safe to overwrite said headers (according to iant@), this CL
introduces a parameter to builder's 'copy' and 'move' functions that,
if set to 'true', would force the overwriting of already installed
files.

This parameter value is set to 'true' only when installing cgo headers,
for now.

Change-Id: I5bda17ee757066a8e5d2b39f2e8f3a389eb1e4a2
Reviewed-on: https://go-review.googlesource.com/10870
Run-TryBot: Srdjan Petrovic <spetrovic@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-15 18:29:39 +00:00
Rob Pike
1f9026c0bd testing: don't print CPU count for tests, only benchmarks
The number of CPUs is of value when benchmarking but mostly
noise when testing. The recent change to default to the number
of CPUs available has made the tests noisier and confusing.

Fixes #11200

Change-Id: Ifc87d9ccb4177d73e304fb7ffcef4367bd163c9e
Reviewed-on: https://go-review.googlesource.com/11121
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-15 18:11:06 +00:00
Russ Cox
2c2770c3d4 cmd/cgo: make sure pointers passed to C escape to heap
Fixes #10303.

Change-Id: Ia68d3566ba3ebeea6e18e388446bd9b8c431e156
Reviewed-on: https://go-review.googlesource.com/10814
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-15 17:39:53 +00:00
Russ Cox
a3b9797baa runtime: gofmt
Change-Id: I539bdc438f694610a7cd373f7e1451171737cfb3
Reviewed-on: https://go-review.googlesource.com/11084
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-15 17:36:34 +00:00
Russ Cox
d5b40b6ac2 runtime: add GODEBUG gcshrinkstackoff, gcstackbarrieroff, and gcstoptheworld variables
While we're here, update the documentation and delete variables with no effect.

Change-Id: I4df0d266dff880df61b488ed547c2870205862f0
Reviewed-on: https://go-review.googlesource.com/10790
Reviewed-by: Austin Clements <austin@google.com>
2015-06-15 17:31:04 +00:00
Russ Cox
80ec711755 runtime: use type-based write barrier for remote stack write during chansend
A send on an unbuffered channel to a blocked receiver is the only
case in the runtime where one goroutine writes directly to the stack
of another. The garbage collector assumes that if a goroutine is
blocked, its stack contains no new pointers since the last time it ran.
The send on an unbuffered channel violates this, so it needs an
explicit write barrier. It has an explicit write barrier, but not one that
can handle a write to another stack. Use one that can (based on type bitmap
instead of heap bitmap).

To make this work, raise the limit for type bitmaps so that they are
used for all types up to 64 kB in size (256 bytes of bitmap).
(The runtime already imposes a limit of 64 kB for a channel element size.)

I have been unable to reproduce this problem in a simple test program.

Could help #11035.

Change-Id: I06ad994032d8cff3438c9b3eaa8d853915128af5
Reviewed-on: https://go-review.googlesource.com/10815
Reviewed-by: Austin Clements <austin@google.com>
2015-06-15 16:50:30 +00:00
Andrew Gerrand
d14e9e6323 cmd/go: stop early in disallowInternal on erroneous packages
Fixes #11201

Change-Id: I80d8fcfcb5c856aaf9d0e73d756d86018e2bec3b
Reviewed-on: https://go-review.googlesource.com/11110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-15 04:27:27 +00:00
Ian Lance Taylor
0ee92cf9c5 syscall: correct comment on where compileCallback is defined
Fixes #11216.

Change-Id: Iad1f4894c2258909484eaf975b08e0f47a82788e
Reviewed-on: https://go-review.googlesource.com/11098
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-15 03:10:52 +00:00
Dmitry Vyukov
202de394f2 cmd/trace: fix panic in goroutine profile
In generateTrace we check that event timestamp is within the interesting range.
Then later in traceContext.time we double check event time.
However, for some events (e.g. emitSlice) we convert time of ev.Link (slice end) rather than ev itself (slice begin).
Slice end can be outside of the interesting time range, and so traceContext.time crashes.
Remove the check in traceContext.time, check in generateTrace loop is sufficient.

Change-Id: If94e93b5653c5816c0a8dcdd920f15df97616835
Reviewed-on: https://go-review.googlesource.com/11100
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-14 21:57:24 +00:00
Dmitry Vyukov
9a8750b276 misc/trace: update trace viewer
Update to tip to fix #11003 (not possible to select events in chromium).
Fixed #11003

Change-Id: Ibba5d39ca809cfd5cb79c9e6d152b00899d49e08
Reviewed-on: https://go-review.googlesource.com/11062
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-14 20:58:23 +00:00
Michael Gehring
48d865ace1 archive/zip: fix returned error on truncated data descriptor
Return io.ErrUnexpectedEOF instead of io.EOF when reading a truncated
data descriptor.

Fixes #11146.

Change-Id: Ia1905955165fd38af3c557d1fa1703ed8be893e2
Reviewed-on: https://go-review.googlesource.com/11070
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-14 20:54:01 +00:00
Adam Langley
6a34206ca9 crypto/tls: fix parsing of SNI extension.
The previous code had a brain fart: it took one of the length prefixes
as an element count, not a length. This didn't actually affect anything
because the loop stops as soon as it finds a hostname element, and the
hostname element is always the first and only element. (No other element
types have ever been defined.)

This change fixes the parsing in case SNI is ever changed in the future.

Fixes #10793.

Change-Id: Iafdf3381942bc22b1f33595315c53dc6cc2e9f0f
Reviewed-on: https://go-review.googlesource.com/11059
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-14 17:55:53 +00:00
Michael Matloob
71e83b8855 regexp: small correction to test comment
s/Backtrace/Backtrack/

Change-Id: I062aab18f23f2bc2110cf7210c2e7264747e02cf
Reviewed-on: https://go-review.googlesource.com/11091
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-14 17:09:13 +00:00
Ian Lance Taylor
6b24da6ae8 syscall: skip TestCloneNEWUSERAndRemapNoRootDisableSetgroups before 3.19
The test fails on Ubuntu Trusty for some reason, probably because of
some set of kernel patches.

Change-Id: I52f7ca50b96fea5725817c9e9198860d419f9313
Reviewed-on: https://go-review.googlesource.com/11055
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-06-14 01:52:54 +00:00
Robert Griesemer
a84ac5b507 go/types: exclude some example tests for arm64, nacl (fix build)
TBR: bradfitz, adonovan

Change-Id: Ifc8574494848503c979d11e2766ba8da0f374068
Reviewed-on: https://go-review.googlesource.com/11043
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-14 00:11:38 +00:00
Mikio Hara
22829bd766 net: don't return non-nil interface values as Source, Addr in OpError
Fixes #10992.

Change-Id: Ia376e4de118993b43e5813da57ab25fea8122048
Reviewed-on: https://go-review.googlesource.com/10476
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-13 23:39:03 +00:00
Kyle Isom
38e3427b2f encoding/asn1: check bounds when parsing tag and length
This was found while fuzzing another program, triggering a panic in
x509.ParseECPrivateKey.

Fixes #11154

Change-Id: Ief35ead38adf14caec4d37b9eacf8a92e67cd1e6
Reviewed-on: https://go-review.googlesource.com/10712
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-06-13 19:59:16 +00:00
Rob Pike
a1fe3b5046 fmt: scanning widths apply after leading spaces
When scanning with a width, as in %5s, C skips leading spaces
brefore counting the 5 characters. We should do the same.

Reword the documentation about widths to make this clear.

Fixes #9444

Change-Id: I443a6441adcf1c834057ef3977f9116a987a79cd
Reviewed-on: https://go-review.googlesource.com/10997
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-13 04:33:26 +00:00
Josh Bleecher Snyder
ff8f3f0fa1 cmd/vet: extend copylocks to anonymous functions
Running -copylocks over a large corpus generates 1507 warnings.
Of those, only 3 are from the new anonymous function check,
but they are all bugs.

Fixes #10927.

Change-Id: I2672f6871036bed711beec5f88bc39aa8b3b6a94
Reviewed-on: https://go-review.googlesource.com/11051
Reviewed-by: Rob Pike <r@golang.org>
2015-06-13 03:07:43 +00:00
Robert Griesemer
cb2d02c803 go/parser: add ParseExprFrom function
This is needed for code that relies on having the correct file set
when parsing an expression only. There's currently no other way to
get to the file set otherwise or to invoke the parser correctly to
work on an expression only with a given file set.

Change-Id: I325f174cb34b69284e627f59fe8334efa4eaa45c
Reviewed-on: https://go-review.googlesource.com/10998
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-12 23:46:32 +00:00
Alexander Morozov
f5c60ff2da syscall: add GidMappingsEnableSetgroups to Linux SysProcAttr
Linux 3.19 made a change in the handling of setgroups and the 'gid_map' file to
address a security issue.
The upshot of the 3.19 changes is that in order to update the 'gid_maps' file,
use of the setgroups() system call in this user namespace must first be disabled
by writing "deny" to one of the /proc/PID/setgroups files for this namespace.

Also added tests for remapping uid_map and gid_map inside new user
namespace.

Fixes #10626

Change-Id: I4d2539acbab741a37092d277e10f31fc39a8feb7
Reviewed-on: https://go-review.googlesource.com/10670
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-12 23:38:59 +00:00
Alan Donovan
368f0ee6c4 go/types: add Example of API usage
Change-Id: I9d3253b80508d733053789d6cb9645e029bf52e4
Reviewed-on: https://go-review.googlesource.com/10927
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-12 22:34:24 +00:00
Michael Gehring
5acba80aa2 archive/tar: fix slice bounds out of range
Sanity check the pax-header size field before using it.

Fixes #11167.

Change-Id: I9d5d0210c3990e6fb9434c3fe333be0d507d5962
Reviewed-on: https://go-review.googlesource.com/10954
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-06-12 21:35:47 +00:00
Rob Pike
57f4b43078 fmt: require newlines to match when scanning with a format
The documentation says that newlines behave like this:

Scan etc.: newlines are spaces.
Scanln etc.: newlines terminate the scan.
Scanf etc.: newlines must match in input and format.

The code did not implement this behavior in all cases,
especially for Scanf. Make it behave:

- Fix the handling of spaces and newlines in ss.Advance.
The code is longer but now behaves as it should.

- Delete the reuse of the current ss in newScanState.
There is really no need, since it's only used in recursive
calls to Scan etc., and the flags are likely wrong. Simpler
just to allocate a new one every time, and likelier to
be correct.

Fixes #10862.

Change-Id: If060ac021017346723b0d62de4e5a305da898f68
Reviewed-on: https://go-review.googlesource.com/10991
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-12 20:14:14 +00:00
Damien Neil
ab89378cb7 encoding/csv: skip blank lines when FieldsPerRecord >= 0
Fixes #11050.

Change-Id: Ie5d16960a1f829af947d82a63fe414924cd02ff6
Reviewed-on: https://go-review.googlesource.com/10666
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-12 18:21:12 +00:00
Michael Gehring
4105265c66 mime: add mime.types paths for BSDs
Change-Id: I22ac23e7e180071de4443291e0a644675200d642
Reviewed-on: https://go-review.googlesource.com/10950
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-12 15:51:21 +00:00
Alexandre Cesaro
0d0ce8a2af cmd/go: fix documentation
The command "go tool pprof help" does not work:

    $ go tool pprof help
    open help: no such file or directory

The right command is "go tool pprof -h".

Change-Id: Icef5d4ab76774905854e46665ac1166d26d35f46
Reviewed-on: https://go-review.googlesource.com/10970
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-12 13:23:14 +00:00
Alex Brainman
202ef487fe cmd/dist: convert testso test into Go
I would like to re-apply reverted http://golang.org/cl/8523.
Reverted tests still fail in some environments (see issue #10360).
It is easier to run tests selectively when in Go.
This CL prepares for the changes.

Updates #10360

Change-Id: Iefeb1d71cb3d1cfa653a6ccd9f6e35686c0c5b24
Reviewed-on: https://go-review.googlesource.com/10608
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-12 04:33:50 +00:00
Alex Brainman
117506aab6 cmd/go: clean up after 'go build' even on windows
This CL makes CL 10682 work on windows.

Fixes #9645 (again)

Change-Id: Ie9b9af8b041c483a236b46adad4a50aa6e598c92
Reviewed-on: https://go-review.googlesource.com/10930
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-12 02:15:43 +00:00
Ian Lance Taylor
06ef022ba3 cmd/go: add some parallelism to the testsuite
As these tests were originally in bash, they are not designed to be
particularly hermetic.  This CL adds various protective mechanisms to
try to catch cases where the tests can not run in parallel.

Change-Id: I983bf7b6ffba04eda58b4939eb89b0bdfcda8eff
Reviewed-on: https://go-review.googlesource.com/10911
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-11 18:39:14 +00:00
Ian Lance Taylor
9850886fe9 cmd/go: in testsuite, sleep for less than one second if possible
Examine the mtime of an existing file to guess a length of time to
sleep to ensure a different mtime.

Change-Id: I9e8b5c9486f5c3c8bd63125e3ed4763ce1ba767d
Reviewed-on: https://go-review.googlesource.com/10932
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-11 18:36:37 +00:00
Russ Cox
d57c889ae8 runtime: wait to update arena_used until after mapping bitmap
This avoids a race with gcmarkwb_m that was leading to faults.

Fixes #10212.

Change-Id: I6fcf8d09f2692227063ce29152cb57366ea22487
Reviewed-on: https://go-review.googlesource.com/10816
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-06-11 18:15:21 +00:00
Brad Fitzpatrick
a788c913fa cmd/vet: skip another test on Android
Forgot this one in my previous commit.

Change-Id: Ief089e99bdad24b3bcfb075497dc259d06cc727c
Reviewed-on: https://go-review.googlesource.com/10913
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-11 16:30:56 +00:00
Chris Broadfoot
239ec73e66 cmd/go: reject relative paths that don't start with a dot (.)
Change-Id: Idc4a7fdb561ba5b3b52094d895deaf3fcdf475bf
Reviewed-on: https://go-review.googlesource.com/10716
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-11 16:13:37 +00:00
Brad Fitzpatrick
0beb931c76 cmd/go, cmd/vet: skip tests on Android
Might get the Android build passing, or at least going further.

Change-Id: I08f97156a687abe5a3d95203922f4ffd84fbb212
Reviewed-on: https://go-review.googlesource.com/10924
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-11 14:33:40 +00:00
Ainar Garipov
7f9f70e5b6 all: fix misprints in comments
These were found by grepping the comments from the go code and feeding
the output to aspell.

Change-Id: Id734d6c8d1938ec3c36bd94a4dbbad577e3ad395
Reviewed-on: https://go-review.googlesource.com/10941
Reviewed-by: Aamir Khan <syst3m.w0rm@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-11 14:18:57 +00:00
David du Colombier
15c8ab00e8 cmd/go: remove Stat workaround for Plan 9
This issue was fixed in CL 10900.

Change-Id: I88f107cb73c8a515f39e02506ddd2ad1e286b1fb
Reviewed-on: https://go-review.googlesource.com/10940
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-11 14:03:14 +00:00
David du Colombier
bd8e3d028e os: fix error returned by dirstat on Plan 9
When the Stat or Fstat system calls return -1,
dirstat incorrectly returns ErrShortStat.

However, the error returned by Stat or Fstat
could be different. For example, when the
file doesn't exist, they return "does not exist".

Dirstat should return the error returned by
the system call.

Fixes #10911.
Fixes #11132.

Change-Id: Icf242d203d256f12366b1e277f99b1458385104a
Reviewed-on: https://go-review.googlesource.com/10900
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-11 05:47:07 +00:00
Patrick Mezard
d574b59fc7 os: fix a race between Process.signal() and wait() on Windows
Process.handle was accessed without synchronization while wait() and
signal() could be called concurrently.

A first solution was to add a Mutex in Process but it was probably too
invasive given Process.handle is only used on Windows.

This version uses atomic operations to read the handle value. There is
still a race between isDone() and the value of the handle, but it only
leads to slightly incorrect error codes. The caller may get a:

  errors.New("os: process already finished")

instead of:

  syscall.EINVAL

which sounds harmless.

Fixes #9382

Change-Id: Iefcc687a1166d5961c8f27154647b9b15a0f748a
Reviewed-on: https://go-review.googlesource.com/9904
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-11 01:33:25 +00:00
Ian Lance Taylor
dc32b7f0fd cmd/go: rewrite testsuite from bash to Go
Change-Id: I8473e3f7653d5389d5fcd94862f0831049b8266e
Reviewed-on: https://go-review.googlesource.com/10809
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-10 20:34:56 +00:00
Brad Fitzpatrick
1f029fa6d3 archive/zip: clarify that CreateHeader takes ownership of FileHeader
Fixes #11144

Change-Id: I1da0b72ef00a84c9b5751be0e72ad07d664bc98b
Reviewed-on: https://go-review.googlesource.com/10883
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-10 19:56:37 +00:00
Ainar Garipov
4da658cf96 encoding/csv: fix comment in parseRecord
Change-Id: I82edd9364e1b4634006f5e043202a69f383dcdbe
Reviewed-on: https://go-review.googlesource.com/10826
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-10 14:26:10 +00:00
Alex Brainman
ab08f79af3 cmd/link: stop linker crashing with -s flag on windows
Update #10254

Change-Id: I3ddd26607813ca629e3ab62abf87dc5ab453e36f
Reviewed-on: https://go-review.googlesource.com/10835
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-10 06:49:23 +00:00
Yongjian Xu
93e57a22d5 runtime: correct a drifted comment in referencing m->locked.
Change-Id: Ida4b98aa63e57594fa6fa0b8178106bac9b3cd19
Reviewed-on: https://go-review.googlesource.com/10837
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-10 06:15:20 +00:00
Josh Bleecher Snyder
442959ec47 cmd/compile: fix builtin generation
This was a refactoring bug during
'go tool compile', CL 10289.

Change-Id: Ibfd333be39ec72bba331fdf352df619cc21851a9
Reviewed-on: https://go-review.googlesource.com/10849
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-09 21:26:39 +00:00
Carl Jackson
50e657fbfa crypto/cipher: Support unusual GCM nonce lengths
GCM is traditionally used with a 96-bit nonce, but the standard allows
for nonces of any size. Non-standard nonce sizes are required in some
protocols, so add support for them in crypto/cipher's GCM
implementation.

Change-Id: I7feca7e903eeba557dcce370412b6ffabf1207ab
Reviewed-on: https://go-review.googlesource.com/8946
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-06-09 18:46:13 +00:00
Josh Bleecher Snyder
a44becef4a cmd/compile: use generated temps in bool codegen
Bool codegen was generating a temp for function calls
and other complex expressions, but was not using it.

This was a refactoring bug introduced by CL 7853.
The cmp code used to do (in short):

	l, r := &n1, &n2

It was changed to:

	l, r := nl, nr

But the requisite assignments:

	nl, nr = &n1, &n2

were only introduced on one of two code paths.

Fixes #10654.

Change-Id: Ie8de0b3a333842a048d4308e02911bb10c6915ce
Reviewed-on: https://go-review.googlesource.com/10844
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-09 17:38:26 +00:00
Adam Langley
c72b8aa3b3 crypto/tls: don't require an explicit client-auth EKU.
Previously we enforced both that the extended key usages of a client
certificate chain allowed for client authentication, and that the
client-auth EKU was in the leaf certificate.

This change removes the latter requirement. It's still the case that the
chain must be compatible with the client-auth EKU (i.e. that a parent
certificate isn't limited to another usage, like S/MIME), but we'll now
accept a leaf certificate with no EKUs for client-auth.

While it would be nice if all client certificates were explicit in their
intended purpose, I no longer feel that this battle is worthwhile.

Fixes #11087.

Change-Id: I777e695101cbeba069b730163533e2977f4dc1fc
Reviewed-on: https://go-review.googlesource.com/10806
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-06-09 15:48:24 +00:00
Shenghou Ma
b39487b68d go/build: add big endian variant of arm and arm64 to goarch list
Change-Id: Icda8475a7879d49e3b8b873303eb0bed5dd5a238
Reviewed-on: https://go-review.googlesource.com/10792
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-09 09:56:10 +00:00
Mikio Hara
aff7a573d1 net: disable dualstack listener tests on dragonfly
Change-Id: Ia7914156e4369113dea7c17b3aa51096e25f1901
Reviewed-on: https://go-review.googlesource.com/10834
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-09 08:21:21 +00:00
Brad Fitzpatrick
10425507fd cmd/dist: move guts of race.bash into dist
After a little build coordinator change, this will get us sharding of
the race builder.

Update #11074

Change-Id: I4c55267563b6f5e213def7dd6707c837ae2106bf
Reviewed-on: https://go-review.googlesource.com/10845
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-09 05:22:37 +00:00
Hyang-Ah (Hana) Kim
c9778ec302 cmd/link/internal/ld: include table of contents of c-archive output.
Change-Id: If11621985c0a5a1f2133cdc974f37fd944b93e5e
Reviewed-on: https://go-review.googlesource.com/10808
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-09 00:55:11 +00:00
Josh Bleecher Snyder
494ff188f8 cmd/compile: early typecheck top level OAS2 nodes
Fixes #10977.

Change-Id: I706c953c16daad48595c7fae2d82124614dfc3ad
Reviewed-on: https://go-review.googlesource.com/10780
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-09 00:25:02 +00:00
Håvard Haugen
7089ea4e47 testing/quick: probabilistically generate nil pointers
The documentation for quick.Value says that it "returns an arbitrary
value of the given type." In spite of this, nil values for pointers were
never generated, which seems more like an oversight than an intentional
choice.

The lack of nil values meant that testing recursive type like

  type Node struct {
  	Next *Node
  }

with testing/quick would lead to a stack overflow since the data
structure would never terminate.

This change may break tests that don't check for nil with pointers
returned from quick.Value. Two such instances were found in the standard
library, one of which was in the testing/quick package itself.

Fixes #8818.

Change-Id: Id390dcce649d12fbbaa801ce6f58f5defed77e60
Reviewed-on: https://go-review.googlesource.com/10821
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-06-08 21:19:13 +00:00
Robert Griesemer
13e2412876 cmd/vet: remove dependency on types.New
- remove TODO on non-existing fmt.Formatter type
  (type exists now)
- guard uses of imported types against nil

Change-Id: I9ae8e5a448e73c84dec1606ea9d9ed5ddeee8dc6
Reviewed-on: https://go-review.googlesource.com/10777
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-08 20:52:07 +00:00
Russ Cox
433c0bc769 runtime: avoid fault in heapBitsBulkBarrier
Change-Id: I0512e461de1f25cb2a1cb7f23e7a77d00700667c
Reviewed-on: https://go-review.googlesource.com/10803
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-08 20:24:00 +00:00
Alex Brainman
a58e731287 cmd/vet: fix tests on windows
Add .exe to exectable name, so it can be executed on windows.
Use proper windows paths when searching vet output.
Replace Skip with Skipf.

Fixes build

Change-Id: Ife40d8f5ab9d7093ca61c50683a358d4d6a3ba34
Reviewed-on: https://go-review.googlesource.com/10742
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Patrick Mézard <patrick@mezard.eu>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-08 15:14:39 +00:00
Austin Clements
b0532a96a8 runtime: fix write-barrier-enabled phase list in gcmarkwb_m
Commit 1303957 was supposed to enable write barriers during the
concurrent scan phase, but it only enabled *calls* to the write
barrier during this phase. It failed to update the redundant list of
write-barrier-enabled phases in gcmarkwb_m, so it still wasn't greying
objects during the scan phase.

This commit fixes this by replacing the redundant list of phases in
gcmarkwb_m with simply checking writeBarrierEnabled. This is almost
certainly redundant with checks already done in callers, but the last
time we tried to remove these redundant checks everything got much
slower, so I'm leaving it alone for now.

Fixes #11105.

Change-Id: I00230a3cb80a008e749553a8ae901b409097e4be
Reviewed-on: https://go-review.googlesource.com/10801
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-08 05:13:15 +00:00
Austin Clements
306f8f11ad runtime: unwind stack barriers when writing above the current frame
Stack barriers assume that writes through pointers to frames above the
current frame will get write barriers, and hence these frames do not
need to be re-scanned to pick up these changes. For normal writes,
this is true. However, there are places in the runtime that use
typedmemmove to potentially write through pointers to higher frames
(such as mapassign1). Currently, typedmemmove does not execute write
barriers if the destination is on the stack. If there's a stack
barrier between the current frame and the frame being modified with
typedmemmove, and the stack barrier is not otherwise hit, it's
possible that the garbage collector will never see the updated pointer
and incorrectly reclaim the object.

Fix this by making heapBitsBulkBarrier (which lies behind typedmemmove
and its variants) detect when the destination is in the stack and
unwind stack barriers up to the point, forcing mark termination to
later rescan the effected frame and collect these pointers.

Fixes #11084. Might be related to #10240, #10541, #10941, #11023,
 #11027 and possibly others.

Change-Id: I323d6cd0f1d29fa01f8fc946f4b90e04ef210efd
Reviewed-on: https://go-review.googlesource.com/10791
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-07 17:57:47 +00:00
Austin Clements
1303957dbf runtime: enable write barriers during concurrent scan
Currently, write barriers are only enabled after completion of the
concurrent scan phase, as we enter the concurrent mark phase. However,
stack barriers are installed during the scan phase and assume that
write barriers will track changes to frames above the stack
barriers. Since write barriers aren't enabled until after stack
barriers are installed, we may miss modifications to the stack that
happen after installing the stack barriers and before enabling write
barriers.

Fix this by enabling write barriers during the scan phase.

This commit intentionally makes the minimal change to do this (there's
only one line of code change; the rest are comment changes). At the
very least, we should consider eliminating the ragged barrier that's
intended to synchronize the enabling of write barriers, but now just
wastes time. I've included a large comment about extensions and
alternative designs.

Change-Id: Ib20fede794e4fcb91ddf36f99bd97344d7f96421
Reviewed-on: https://go-review.googlesource.com/10795
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-07 17:55:33 +00:00
Austin Clements
6f6403eddf runtime: fix checkmarks to rescan stacks
Currently checkmarks mode fails to rescan stacks because it sees the
leftover state bits indicating that the stacks haven't changed since
the last scan. As a result, it won't detect lost marks caused by
failing to scan stacks correctly during regular garbage collection.

Fix this by marking all stacks dirty before performing the checkmark
phase.

Change-Id: I1f06882bb8b20257120a4b8e7f95bb3ffc263895
Reviewed-on: https://go-review.googlesource.com/10794
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-07 17:55:12 +00:00
Alex Brainman
5dbe071cb5 database/sql: refer correct issue in TestErrBadConnReconnect comment
Change-Id: I283ab238b60d3a47e86296e1fbfc73ba121bef19
Reviewed-on: https://go-review.googlesource.com/10745
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-06 02:17:49 +00:00
Austin Clements
16310571d1 cmd/asm: drop legacy RETURN mnemonic on ppc64
Change-Id: I999b57ef5535c18e02cc27c9bc9f896d73126b50
Reviewed-on: https://go-review.googlesource.com/10674
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-06 00:11:13 +00:00
Austin Clements
9389a86b01 cmd/compile: use obj.ARET instead of ppc64.ARETURN
obj.ARET is the portable return mnemonic. ppc64.ARETURN is a legacy
alias.

This was done with
    sed -i s/ppc64\.ARETURN/obj.ARET/ cmd/compile/**/*.go
    sed -i s/ARETURN/obj.ARET/ cmd/internal/obj/ppc64/obj9.go

Change-Id: I4d8e83ff411cee764774a40ef4c7c34dcbca4e43
Reviewed-on: https://go-review.googlesource.com/10673
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-06 00:07:31 +00:00
Austin Clements
2774b37306 all: use RET instead of RETURN on ppc64
All of the architectures except ppc64 have only "RET" for the return
mnemonic. ppc64 used to have only "RETURN", but commit cf06ea6
introduced RET as a synonym for RETURN to make ppc64 consistent with
the other architectures. However, that commit was never followed up to
make the code itself consistent by eliminating uses of RETURN.

This commit replaces all uses of RETURN in the ppc64 assembly with
RET.

This was done with
    sed -i 's/\<RETURN\>/RET/' **/*_ppc64x.s
plus one manual change to syscall/asm.s.

Change-Id: I3f6c8d2be157df8841d48de988ee43f3e3087995
Reviewed-on: https://go-review.googlesource.com/10672
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-06-06 00:07:23 +00:00
Robert Griesemer
11b9928185 cmd/go: update documentation: use 'go doc' rather than 'godoc'
Change-Id: I318c1ef75b18d4687f13499ac225dde2d053505e
Reviewed-on: https://go-review.googlesource.com/10776
Reviewed-by: Rob Pike <r@golang.org>
2015-06-05 21:33:52 +00:00
Robert Griesemer
a544a3a6f7 cmd/go: use new vet location
Change-Id: I7d96ebcca5954152edb821bb41b6047a1c622949
Reviewed-on: https://go-review.googlesource.com/10731
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-06-05 20:09:36 +00:00
Robert Griesemer
d64cdde357 go/types: remove unused return value
Port of https://go-review.googlesource.com/10773 from x/tools.

Change-Id: I6aba6a63a5448b8fcbcc7f072c627c27965dbe20
Reviewed-on: https://go-review.googlesource.com/10774
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-05 18:51:23 +00:00
Alan Donovan
232331f0c7 runtime: add blank assignment to defeat "declared but not used" error from go/types
gc should ideally consider this an error too; see golang/go#8560.

Change-Id: Ieee71c4ecaff493d7f83e15ba8c8a04ee90a4cf1
Reviewed-on: https://go-review.googlesource.com/10757
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-05 18:05:16 +00:00
Robert Griesemer
a9c14d1ab5 go/types: remove MethodSetCache - not needed
In x/tools, MethodSetCache was moved from x/tools/go/types to
x/tools/go/types/typeutil. Mirror that change.

Change-Id: Ib838a9518371473c83fa4abc2778d42f33947c98
Reviewed-on: https://go-review.googlesource.com/10771
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-05 17:48:49 +00:00
Austin Clements
7529314ed3 runtime: use correct SP when installing stack barriers
Currently the stack barriers are installed at the next frame boundary
after gp.sched.sp + 1024*2^n for n=0,1,2,... However, when a G is in a
system call, we set gp.sched.sp to 0, which causes stack barriers to
be installed at *every* frame. This easily overflows the slice we've
reserved for storing the stack barrier information, and causes a
"slice bounds out of range" panic in gcInstallStackBarrier.

Fix this by using gp.syscallsp instead of gp.sched.sp if it's
non-zero. This is the same logic that gentraceback uses to determine
the current SP.

Fixes #11049.

Change-Id: Ie40eeee5bec59b7c1aa715a7c17aa63b1f1cf4e8
Reviewed-on: https://go-review.googlesource.com/10755
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-05 15:53:07 +00:00
Brad Fitzpatrick
24de40a846 cmd/dist: add more logging details when go list std cmd fails
Change-Id: I12e6990b46ea9c733a5718dc5ca67f1fcd2dec66
Reviewed-on: https://go-review.googlesource.com/10754
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 15:19:29 +00:00
Russ Cox
95919328ac cmd/vet: skip exec tests on systems that can't exec
Change-Id: I09257b8f5482cba10b5f4d3813c778d6e9e74d40
Reviewed-on: https://go-review.googlesource.com/10752
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-05 14:35:13 +00:00
Alexis Imperial-Legrand
3e2fc94f04 debug/gosym: avoid calling the shell in test
Change-Id: I95bf62c0f2d77dd67515921e6aefa511cce8d95d
Reviewed-on: https://go-review.googlesource.com/10633
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 14:06:13 +00:00
Russ Cox
48f2d30d43 cmd/go: fix detection of ELF binaries
Change-Id: I0e6f1a39b3d6b15d05891c8b25ab6644356bde5f
Reviewed-on: https://go-review.googlesource.com/10751
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-05 13:59:30 +00:00
Aaron Jacobs
4b6284a7d9 flag: Describe the ErrorHandling enum values.
ContinueOnError is particularly confusing, because it causes
FlagSet.Parse to return as soon as it sees an error. I gather that the
intent is "continue the program" rather than "continue parsing",
compared to exiting or panicking.

Change-Id: I27370ce1f321ea4debcee5b03faff3532495c71a
Reviewed-on: https://go-review.googlesource.com/10740
Reviewed-by: Rob Pike <r@golang.org>
2015-06-05 13:53:26 +00:00
Rob Pike
bbc4351eca cmd/go: add -tags option to go vet
Actually add all build flags, so we also get things like -race.

Fixes #10228.

Change-Id: I5f77dda9d1ee3208e1833702f12f68c2731c4b22
Reviewed-on: https://go-review.googlesource.com/10697
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-05 05:39:36 +00:00
Russ Cox
cd9f417dbb cmd/compile: document Node fields used by each Op
Change-Id: If969d7a06c83447ee38da30f1477a6cf4bfa1a03
Reviewed-on: https://go-review.googlesource.com/10691
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-05 05:01:24 +00:00
Russ Cox
aefa6cd1f9 cmd/link: delete dead flags
Also fix the interaction between -buildmode and -shared.
It's okay for -shared to change the default build mode,
but it's not okay for it to silently override an explicit -buildmode=exe.

Change-Id: Id40f93d140cddf75b19e262b3ba4856ee09a07ba
Reviewed-on: https://go-review.googlesource.com/10315
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-05 04:55:53 +00:00
Russ Cox
12795c02f3 cmd/link: deprecate -X name value in favor of -X name=value
People invoking the linker directly already have to change their scripts
to use the new "go tool link", so this is a good time to make the -X flag
behave like all other Go flags and take just a single argument.

The old syntax will continue to be accepted (it is rewritten into the new
syntax before flag parsing). Maybe some day we will be able to retire it.

Even if we never retire the old syntax, having the new syntax at least
makes the rewriting much less of a kludge.

Change-Id: I91e8df94f4c22b2186e81d7f1016b8767d777eac
Reviewed-on: https://go-review.googlesource.com/10310
Reviewed-by: Rob Pike <r@golang.org>
2015-06-05 04:55:41 +00:00
Russ Cox
630930c35e cmd/compile, cmd/link: add docs
These are the Go 1.4 docs but refreshed for Go 1.5.
The most sigificant change is that all references to the Plan 9 toolchain are gone.
The tools no longer bear any meaningful resemblance.

Change-Id: I44f5cadb832a982323d7fee0b77673e55d761b35
Reviewed-on: https://go-review.googlesource.com/10298
Reviewed-by: Rob Pike <r@golang.org>
2015-06-05 04:42:35 +00:00
Russ Cox
3ffcbb633e runtime: default GOMAXPROCS to NumCPU(), not 1
See golang.org/s/go15gomaxprocs for details.

Change-Id: I8de5df34fa01d31d78f0194ec78a2474c281243c
Reviewed-on: https://go-review.googlesource.com/10668
Reviewed-by: Rob Pike <r@golang.org>
2015-06-05 04:38:04 +00:00
Russ Cox
14da5bef5f cmd/pprof: use copy of svgpan library instead of link to remote site
Fixes #10375.

Change-Id: I78dc3e12035d130c405bdb284b0cceea19f084f6
Reviewed-on: https://go-review.googlesource.com/10690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-05 04:36:00 +00:00
Russ Cox
fddc3ca11c testing: add -test.count flag to run tests and benchmarks multiple times
The flag is available from the go test command as -count:

% go test -run XXX -bench . -count 3
PASS
BenchmarkSprintfEmpty      	30000000	        54.0 ns/op
BenchmarkSprintfEmpty      	30000000	        51.9 ns/op
BenchmarkSprintfEmpty      	30000000	        53.8 ns/op
BenchmarkSprintfString     	10000000	       238 ns/op
BenchmarkSprintfString     	10000000	       239 ns/op
BenchmarkSprintfString     	10000000	       234 ns/op
BenchmarkSprintfInt        	10000000	       232 ns/op
BenchmarkSprintfInt        	10000000	       226 ns/op
BenchmarkSprintfInt        	10000000	       225 ns/op
...

If -cpu is set, each test is run n times for each cpu value.

Original by r (CL 10663).

Change-Id: If3dfbdf21698952daac9249b5dbca66f5301e91b
Reviewed-on: https://go-review.googlesource.com/10669
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-05 04:31:10 +00:00
Russ Cox
de305a197f cmd/go: read new non-ELF build ID in binaries
Fixes #11048.
Fixes #11075.

Change-Id: I81f5ef1e1944056ce5494c91aa4a4a63c758f566
Reviewed-on: https://go-review.googlesource.com/10709
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 04:08:51 +00:00
Russ Cox
9ae3c560b9 cmd/link: implement -buildid for non-ELF binaries
Non-ELF binary formats are much less flexible and typically do not
have a good place to store the build ID.

We store it as raw bytes at the beginning of the text segment.

The only system I know of that will be upset about this is NaCl,
and NaCl is an ELF system and does not use this.

For #11048.

Change-Id: Iaa7ace703c4cf36392e752eea9b55e2ce49e9826
Reviewed-on: https://go-review.googlesource.com/10708
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 04:06:46 +00:00
Russ Cox
16ebe9f72e cmd/go: use ELF note instead of binary stamp on ELF systems
Other binary formats to follow.

For #11048.

Change-Id: Ia2d8b47c99c99d171c014b7cfd23c1c7ada5231c
Reviewed-on: https://go-review.googlesource.com/10707
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 04:06:08 +00:00
Russ Cox
ac1f48e2f6 cmd/link: add -buildid flag to write Go build ID to ELF output, same as cmd/compile
Other binary formats to follow.

Using our own note instead of the GNU build ID note because
we are not the GNU project, and I can't guarantee that the semantics
of our note and the semantics of the GNU note will match forever.
(Also they don't match today.)

For #11048.

Change-Id: Iec7e5a2e49d52b6d3a51b0aface2de7c77a45491
Reviewed-on: https://go-review.googlesource.com/10706
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 04:02:26 +00:00
Russ Cox
a2c50ece2b cmd/link: add -h flag, for debugging, same as cmd/compile
Change-Id: I3c9b05879fe0b6e94b63e9b65e4411ba2a917134
Reviewed-on: https://go-review.googlesource.com/10705
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 04:00:11 +00:00
Russ Cox
7e27625e25 cmd/go, cmd/link: use "Go" not "GO" as ELF note identifier
Change-Id: I038e892725836ab7718f7638e8ad5712953f2cb5
Reviewed-on: https://go-review.googlesource.com/10704
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 03:59:46 +00:00
Russ Cox
a9267db56a cmd/go: simplify ELF note reading and enable during bootstrap
The bootstrap restriction is to avoid needing cgo for package net.
There's no problem with building debug/elf and debug/dwarf,
so do that.

An upcoming CL is going to add more note processing code,
and it simplifies things not to have to think about the code being
missing half the time.

Change-Id: I0e2f120ac23f14db6ecfcec7bfe254a69abcf7b6
Reviewed-on: https://go-review.googlesource.com/10703
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-05 03:53:14 +00:00
Robert Griesemer
09a3a092af cmd/go: fix fmt.Errorf call sites (latent bug)
Change-Id: I4ff42113c5dda553d6f3d58f0e4836dce7c84710
Reviewed-on: https://go-review.googlesource.com/10730
Reviewed-by: Rob Pike <r@golang.org>
2015-06-04 23:06:13 +00:00
Rob Pike
ea92f42cc8 cmd/doc: do not show unexported constants
The go/doc package doesn't remove unexported entries from const
and var blocks, so we must trim them ourselves.

Fixes #11008

Change-Id: Ibd60d87e09333964e2588340a2ca2b8804bbaa28
Reviewed-on: https://go-review.googlesource.com/10643
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-04 21:51:49 +00:00
Robert Griesemer
a7d2d4835b cmd/vet: adjust vet to use go/types and friends from std repo
- s|"golang.org/x/tools/go/exact"|"go/constant"|
- s|"golang.org/x/tools/go/types"|"go/types"|
- removed import of gcimporter
- import "go/importer" instead
- trivial adjustments to make use of go/importer
- adjusted import paths for whitelist.go

Change-Id: I43488ff44c329cd869c92dcc31193fb31bebfd29
Reviewed-on: https://go-review.googlesource.com/10695
Reviewed-by: Rob Pike <r@golang.org>
2015-06-04 21:24:52 +00:00
Robert Griesemer
1b8b2c1551 cmd/vet: move cmd/vet into std repo
cp -r x/tools/cmd/vet cmd/vet without any changes.
The next change will adjust the source to use std
repo go/types and friends.

This may (temporarily) break the build; the next
commit (immediately following) will fix it. We do
it in two commits so that we can see the manual
changes.

Change-Id: Ic45dab7066f13923e21f8c61200c8c3fd447b171
Reviewed-on: https://go-review.googlesource.com/10694
Reviewed-by: Rob Pike <r@golang.org>
2015-06-04 21:22:13 +00:00
David Crawshaw
ebcc7ec148 cmd/dist: use -tags=lldb for iOS tests
As of golang.org/cl/9154, running go test will override a previous
go install -a -tags=lldb std with the tag-less version of stdlib. So
we pass -tags=lldb into the relevant go test commands.

Change-Id: I1c718289d7212373a9383eff53a643f06598f5ed
Reviewed-on: https://go-review.googlesource.com/10701
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-04 20:56:48 +00:00
Brad Fitzpatrick
d751be9f98 net/http: the Set-Cookie Expiration time zone should be GMT, not UTC
Per RFC 6265.

Change-Id: I2b6b145f5d057f96509332509d722602ed9e2bbd
Reviewed-on: https://go-review.googlesource.com/10711
Reviewed-by: Brett Slatkin <bslatkin@google.com>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-04 20:41:53 +00:00
Brad Fitzpatrick
ec745fc4cb test: make test/run.go support sharding
Also modifies 'dist test' to use that sharding, and removes some old
temporary stuff from dist test which are no longer required.

'dist test' now also supports running a list of tests given in
arguments, mutually exclusive with the existing -run=REGEXP flag. The
hacky fast paths for avoiding the 1 second "go list" latency are now
removed and only apply to the case where partial tests are run via
args, instead of regex.  The build coordinator will use both styles
for awhile. (the statically-sharded ARM builders on scaleway will
continue to use regexps, but the dynamically-shared builders on GCE
will use the list of tests)

Updates #10029

Change-Id: I557800a54dfa6f3b5100ef4c26fe397ba5189813
Reviewed-on: https://go-review.googlesource.com/10688
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-04 19:45:29 +00:00
Josh Bleecher Snyder
54789eff38 cmd/internal/obj/arm64: make function prologue more predictable
Static branch prediction guesses that forward branches aren't taken.
Since stacks are rarely grown, make the forward branch mean grow.

While we're here, remove the debug-only instruction
saving the frame size in the temp register.

Sample disassembly for

func f() {
	_ = [128]byte{}
}

Before:

0x4008248         ldr        x1, [x28, #0x10]
0x400824c         sub        x2, sp, #0x90
0x4008250         cmp        x2, x1
0x4008254         b.hi       0x4008268
0x4008258         mov        x3, x30
0x400825c         movz       x27, #0x90
0x4008260         bl         runtime.morestack_noctxt
0x4008264         b          main.f
0x4008268         sub        sp, sp, #0x90
0x400826c         add        x16, sp, #0x10
0x4008270         str        xzr, [x16]
0x4008274         str        xzr, [x16, #0x8]
0x4008278         str        xzr, [x16, #0x10]
0x400827c         str        xzr, [x16, #0x18]
0x4008280         str        xzr, [x16, #0x20]
0x4008284         str        xzr, [x16, #0x28]
0x4008288         str        xzr, [x16, #0x30]
0x400828c         str        xzr, [x16, #0x38]
0x4008290         str        xzr, [x16, #0x40]
0x4008294         str        xzr, [x16, #0x48]
0x4008298         str        xzr, [x16, #0x50]
0x400829c         str        xzr, [x16, #0x58]
0x40082a0         str        xzr, [x16, #0x60]
0x40082a4         str        xzr, [x16, #0x68]
0x40082a8         str        xzr, [x16, #0x70]
0x40082ac         str        xzr, [x16, #0x78]
0x40082b0         add        sp, sp, #0x90
0x40082b4         ret

After:

0x4004bc8         ldr        x1, [x28, #0x10]
0x4004bcc         sub        x2, sp, #0x90
0x4004bd0         cmp        x2, x1
0x4004bd4         b.ls       0x4004c28
0x4004bd8         sub        sp, sp, #0x90
0x4004bdc         add        x16, sp, #0x10
0x4004be0         str        xzr, [x16]
0x4004be4         str        xzr, [x16, #0x8]
0x4004be8         str        xzr, [x16, #0x10]
0x4004bec         str        xzr, [x16, #0x18]
0x4004bf0         str        xzr, [x16, #0x20]
0x4004bf4         str        xzr, [x16, #0x28]
0x4004bf8         str        xzr, [x16, #0x30]
0x4004bfc         str        xzr, [x16, #0x38]
0x4004c00         str        xzr, [x16, #0x40]
0x4004c04         str        xzr, [x16, #0x48]
0x4004c08         str        xzr, [x16, #0x50]
0x4004c0c         str        xzr, [x16, #0x58]
0x4004c10         str        xzr, [x16, #0x60]
0x4004c14         str        xzr, [x16, #0x68]
0x4004c18         str        xzr, [x16, #0x70]
0x4004c1c         str        xzr, [x16, #0x78]
0x4004c20         add        sp, sp, #0x90
0x4004c24         ret
0x4004c28         mov        x3, x30
0x4004c2c         bl         runtime.morestack_noctxt
0x4004c30         b          main.f

Updates #10587.

Package sort benchmarks using an iPhone 6:

name            old time/op  new time/op  delta
SearchWrappers   355ns ± 1%   328ns ± 1%  -7.57%  (p=0.000 n=25+19)
SortString1K     580µs ± 1%   577µs ± 1%  -0.48%  (p=0.000 n=25+25)
StableString1K  1.04ms ± 0%  1.04ms ± 0%    ~     (p=0.851 n=24+25)
SortInt1K        251µs ± 1%   247µs ± 1%  -1.52%  (p=0.000 n=23+25)
StableInt1K      267µs ± 2%   261µs ± 2%  -2.02%  (p=0.000 n=25+25)
SortInt64K      23.8ms ± 1%  23.6ms ± 0%  -0.97%  (p=0.000 n=25+23)
StableInt64K    22.8ms ± 0%  22.4ms ± 1%  -1.76%  (p=0.000 n=24+25)
Sort1e2          123µs ± 1%   124µs ± 1%    ~     (p=0.256 n=23+23)
Stable1e2        248µs ± 1%   247µs ± 1%  -0.69%  (p=0.000 n=23+25)
Sort1e4         24.3ms ± 2%  24.6ms ± 5%  +1.36%  (p=0.017 n=22+25)
Stable1e4       77.2ms ± 6%  76.2ms ± 5%  -1.36%  (p=0.020 n=25+25)
Sort1e6          3.95s ± 8%   3.95s ± 8%    ~     (p=0.863 n=25+25)
Stable1e6        15.7s ± 1%   15.5s ± 1%  -1.11%  (p=0.000 n=22+23)

Change-Id: I377b3817af2ed27ddeecf24edef97fad91fc1afc
Reviewed-on: https://go-review.googlesource.com/10500
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-06-04 16:54:22 +00:00
Josh Bleecher Snyder
5353cde080 runtime, cmd/internal/obj/arm: improve arm function prologue
When stack growth is not needed, as it usually is not,
execute only a single conditional branch
rather than three conditional instructions.
This adds 4 bytes to every function,
but might speed up execution in the common case.

Sample disassembly for

func f() {
	_ = [128]byte{}
}

Before:

TEXT main.f(SB) x.go
	x.go:3	0x2000	e59a1008	MOVW 0x8(R10), R1
	x.go:3	0x2004	e59fb028	MOVW 0x28(R15), R11
	x.go:3	0x2008	e08d200b	ADD R11, R13, R2
	x.go:3	0x200c	e1520001	CMP R1, R2
	x.go:3	0x2010	91a0300e	MOVW.LS R14, R3
	x.go:3	0x2014	9b0118a9	BL.LS runtime.morestack_noctxt(SB)
	x.go:3	0x2018	9afffff8	B.LS main.f(SB)
	x.go:3	0x201c	e52de084	MOVW.W R14, -0x84(R13)
	x.go:4	0x2020	e28d1004	ADD $4, R13, R1
	x.go:4	0x2024	e3a00000	MOVW $0, R0
	x.go:4	0x2028	eb012255	BL 0x4a984
	x.go:5	0x202c	e49df084	RET #132
	x.go:5	0x2030	eafffffe	B 0x2030
	x.go:5	0x2034	ffffff7c	?

After:

TEXT main.f(SB) x.go
	x.go:3	0x2000	e59a1008	MOVW 0x8(R10), R1
	x.go:3	0x2004	e59fb02c	MOVW 0x2c(R15), R11
	x.go:3	0x2008	e08d200b	ADD R11, R13, R2
	x.go:3	0x200c	e1520001	CMP R1, R2
	x.go:3	0x2010	9a000004	B.LS 0x2028
	x.go:3	0x2014	e52de084	MOVW.W R14, -0x84(R13)
	x.go:4	0x2018	e28d1004	ADD $4, R13, R1
	x.go:4	0x201c	e3a00000	MOVW $0, R0
	x.go:4	0x2020	eb0124dc	BL 0x4b398
	x.go:5	0x2024	e49df084	RET #132
	x.go:5	0x2028	e1a0300e	MOVW R14, R3
	x.go:5	0x202c	eb011b0d	BL runtime.morestack_noctxt(SB)
	x.go:5	0x2030	eafffff2	B main.f(SB)
	x.go:5	0x2034	eafffffe	B 0x2034
	x.go:5	0x2038	ffffff7c	?

Updates #10587.

package sort benchmarks on an iPhone 6:

name            old time/op  new time/op  delta
SortString1K     569µs ± 0%   565µs ± 1%  -0.75%  (p=0.000 n=23+24)
StableString1K   872µs ± 1%   870µs ± 1%  -0.16%  (p=0.009 n=23+24)
SortInt1K        317µs ± 2%   316µs ± 2%    ~     (p=0.410 n=26+26)
StableInt1K      343µs ± 1%   339µs ± 1%  -1.07%  (p=0.000 n=22+23)
SortInt64K      30.0ms ± 1%  30.0ms ± 1%    ~     (p=0.091 n=25+24)
StableInt64K    30.2ms ± 0%  30.0ms ± 0%  -0.69%  (p=0.000 n=22+22)
Sort1e2          147µs ± 1%   146µs ± 0%  -0.48%  (p=0.000 n=25+24)
Stable1e2        290µs ± 1%   286µs ± 1%  -1.30%  (p=0.000 n=23+24)
Sort1e4         29.5ms ± 2%  29.7ms ± 1%  +0.71%  (p=0.000 n=23+23)
Stable1e4       88.7ms ± 4%  88.6ms ± 8%  -0.07%  (p=0.022 n=26+26)
Sort1e6          4.81s ± 7%   4.83s ± 7%    ~     (p=0.192 n=26+26)
Stable1e6        18.3s ± 1%   18.1s ± 1%  -0.76%  (p=0.000 n=25+23)
SearchWrappers   318ns ± 1%   344ns ± 1%  +8.14%  (p=0.000 n=23+26)

package sort benchmarks on a first generation rpi:

name            old time/op  new time/op  delta
SearchWrappers  4.13µs ± 0%  3.95µs ± 0%   -4.42%  (p=0.000 n=15+13)
SortString1K    5.81ms ± 1%  5.82ms ± 2%     ~     (p=0.400 n=14+15)
StableString1K  9.69ms ± 1%  9.73ms ± 0%     ~     (p=0.121 n=15+11)
SortInt1K       3.30ms ± 2%  3.66ms ±19%  +10.82%  (p=0.000 n=15+14)
StableInt1K     5.97ms ±15%  4.17ms ± 8%  -30.05%  (p=0.000 n=15+15)
SortInt64K       319ms ± 1%   295ms ± 1%   -7.65%  (p=0.000 n=15+15)
StableInt64K     343ms ± 0%   332ms ± 0%   -3.26%  (p=0.000 n=12+13)
Sort1e2         3.36ms ± 2%  3.22ms ± 4%   -4.10%  (p=0.000 n=15+15)
Stable1e2       6.74ms ± 1%  6.43ms ± 2%   -4.67%  (p=0.000 n=15+15)
Sort1e4          247ms ± 1%   247ms ± 1%     ~     (p=0.331 n=15+14)
Stable1e4        864ms ± 0%   820ms ± 0%   -5.15%  (p=0.000 n=14+15)
Sort1e6          41.2s ± 0%   41.2s ± 0%   +0.15%  (p=0.000 n=13+14)
Stable1e6         192s ± 0%    182s ± 0%   -5.07%  (p=0.000 n=14+14)

Change-Id: I8a9db77e1d4ea1956575895893bc9d04bd81204b
Reviewed-on: https://go-review.googlesource.com/10497
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-04 16:35:12 +00:00
Josh Bleecher Snyder
f4b48de3ad cmd/internal/obj/x86: make function prologue more predictable
Static branch prediction guesses that forward branches aren't taken.
Since stacks are rarely grown, make the forward branch mean grow.

Sample disassembly for

func f() {
	_ = [128]byte{}
}

Before:

TEXT main.f(SB) x.go
	x.go:3	0x2000	65488b0c25a0080000	GS MOVQ GS:0x8a0, CX
	x.go:3	0x2009	483b6110		CMPQ 0x10(CX), SP
	x.go:3	0x200d	7707			JA 0x2016
	x.go:3	0x200f	e88c410400		CALL runtime.morestack_noctxt(SB)
	x.go:3	0x2014	ebea			JMP main.f(SB)
	x.go:3	0x2016	4881ec80000000		SUBQ $0x80, SP
	x.go:4	0x201d	488d3c24		LEAQ 0(SP), DI
	x.go:4	0x2021	31c0			XORL AX, AX
	x.go:4	0x2023	e8cc640400		CALL 0x484f4
	x.go:5	0x2028	4881c480000000		ADDQ $0x80, SP
	x.go:5	0x202f	c3			RET

After:

TEXT main.f(SB) x.go
	x.go:3	0x2000	65488b0c25a0080000	GS MOVQ GS:0x8a0, CX
	x.go:3	0x2009	483b6110		CMPQ 0x10(CX), SP
	x.go:3	0x200d	761a			JBE 0x2029
	x.go:3	0x200f	4881ec80000000		SUBQ $0x80, SP
	x.go:4	0x2016	488d3c24		LEAQ 0(SP), DI
	x.go:4	0x201a	31c0			XORL AX, AX
	x.go:4	0x201c	e813740400		CALL 0x49434
	x.go:5	0x2021	4881c480000000		ADDQ $0x80, SP
	x.go:5	0x2028	c3			RET
	x.go:3	0x2029	e8224f0400		CALL runtime.morestack_noctxt(SB)
	x.go:3	0x202e	ebd0			JMP main.f(SB)

Updates #10587.

Sample benchmarks on a 2.8 GHz Intel Core i7:

package sort

name            old mean              new mean              delta
SearchWrappers   134ns × (0.99,1.01)   132ns × (0.99,1.01)  -1.73% (p=0.000 n=15+14)
SortString1K     215µs × (0.99,1.01)   213µs × (0.99,1.01)  -0.61% (p=0.020 n=14+15)
StableString1K   311µs × (0.99,1.02)   309µs × (0.99,1.02)    ~    (p=0.077 n=14+15)
SortInt1K        103µs × (0.99,1.02)   100µs × (0.98,1.01)  -3.34% (p=0.000 n=15+15)
StableInt1K      102µs × (0.99,1.01)    98µs × (0.97,1.04)  -3.53% (p=0.000 n=15+15)
SortInt64K      10.1ms × (0.98,1.02)   9.7ms × (0.99,1.01)  -3.86% (p=0.000 n=14+15)
StableInt64K    8.70ms × (0.99,1.01)  8.44ms × (0.99,1.03)  -2.93% (p=0.000 n=14+15)
Sort1e2         51.2µs × (1.00,1.01)  48.9µs × (0.99,1.02)  -4.48% (p=0.000 n=13+15)
Stable1e2        100µs × (0.99,1.02)    99µs × (0.99,1.01)  -1.15% (p=0.000 n=14+13)
Sort1e4         11.1ms × (0.99,1.02)  10.4ms × (0.99,1.01)  -6.02% (p=0.000 n=15+14)
Stable1e4       30.6ms × (0.99,1.01)  30.3ms × (0.99,1.02)  -1.02% (p=0.001 n=15+14)
Sort1e6          1.75s × (0.99,1.02)   1.66s × (0.98,1.03)  -4.95% (p=0.000 n=14+15)
Stable1e6        6.31s × (0.99,1.01)   6.26s × (0.99,1.01)  -0.79% (p=0.002 n=15+15)

package regexp

name                          old mean              new mean              delta
Literal                        131ns × (0.99,1.01)   130ns × (0.99,1.03)  -1.07% (p=0.004 n=14+15)
NotLiteral                    2.13µs × (0.99,1.01)  2.01µs × (0.99,1.03)  -5.71% (p=0.000 n=14+14)
MatchClass                    3.15µs × (0.99,1.01)  3.04µs × (0.99,1.02)  -3.40% (p=0.000 n=15+15)
MatchClass_InRange            2.92µs × (0.99,1.01)  2.77µs × (0.99,1.02)  -5.05% (p=0.000 n=13+15)
ReplaceAll                    2.17µs × (0.99,1.02)  2.06µs × (0.99,1.01)  -5.19% (p=0.000 n=15+13)
AnchoredLiteralShortNonMatch   116ns × (0.99,1.02)   113ns × (0.99,1.01)  -2.75% (p=0.000 n=15+14)
AnchoredLiteralLongNonMatch    125ns × (0.99,1.01)   127ns × (0.98,1.02)  +1.49% (p=0.000 n=15+15)
AnchoredShortMatch             178ns × (0.99,1.02)   175ns × (0.99,1.01)  -1.62% (p=0.000 n=15+13)
AnchoredLongMatch              328ns × (0.99,1.00)   341ns × (0.99,1.01)  +3.73% (p=0.000 n=12+15)
OnePassShortA                  773ns × (0.99,1.02)   752ns × (0.99,1.01)  -2.78% (p=0.000 n=15+13)
NotOnePassShortA               794ns × (0.99,1.03)   780ns × (0.99,1.02)  -1.75% (p=0.001 n=15+15)
OnePassShortB                  608ns × (0.99,1.01)   591ns × (0.99,1.02)  -2.86% (p=0.000 n=15+14)
NotOnePassShortB               576ns × (0.99,1.01)   571ns × (0.99,1.02)  -0.74% (p=0.035 n=15+15)
OnePassLongPrefix              131ns × (0.99,1.02)   130ns × (0.99,1.02)  -1.32% (p=0.003 n=15+15)
OnePassLongNotPrefix           503ns × (0.99,1.02)   481ns × (0.99,1.01)  -4.34% (p=0.000 n=15+13)
MatchEasy0_32                  102ns × (0.98,1.01)   101ns × (0.99,1.02)    ~    (p=0.907 n=15+14)
MatchEasy0_1K                  617ns × (0.99,1.02)   634ns × (0.98,1.02)  +2.77% (p=0.000 n=15+15)
MatchEasy0_32K                10.9µs × (0.99,1.01)  11.1µs × (0.99,1.01)  +1.59% (p=0.000 n=15+15)
MatchEasy0_1M                  406µs × (0.99,1.02)   410µs × (0.99,1.02)  +1.01% (p=0.000 n=14+15)
MatchEasy0_32M                13.4ms × (0.99,1.01)  13.7ms × (0.99,1.02)  +1.64% (p=0.000 n=12+15)
MatchEasy1_32                 83.7ns × (0.98,1.02)  83.0ns × (0.98,1.02)    ~    (p=0.190 n=15+15)
MatchEasy1_1K                 1.46µs × (0.99,1.02)  1.39µs × (0.99,1.02)  -4.83% (p=0.000 n=15+15)
MatchEasy1_32K                49.4µs × (0.99,1.01)  49.4µs × (0.99,1.01)    ~    (p=0.205 n=15+15)
MatchEasy1_1M                 1.72ms × (0.99,1.02)  1.75ms × (0.99,1.01)  +1.34% (p=0.000 n=15+15)
MatchEasy1_32M                55.5ms × (0.99,1.01)  56.1ms × (0.99,1.02)  +1.10% (p=0.002 n=15+15)
MatchMedium_32                1.37µs × (0.99,1.04)  1.33µs × (0.99,1.01)  -2.87% (p=0.000 n=15+15)
MatchMedium_1K                41.1µs × (0.99,1.02)  40.4µs × (0.99,1.02)  -1.59% (p=0.000 n=15+15)
MatchMedium_32K               1.71ms × (0.99,1.01)  1.75ms × (0.99,1.02)  +2.36% (p=0.000 n=14+15)
MatchMedium_1M                54.5ms × (0.99,1.01)  56.1ms × (0.99,1.01)  +2.94% (p=0.000 n=13+15)
MatchMedium_32M                1.75s × (0.99,1.01)   1.80s × (0.99,1.01)  +2.77% (p=0.000 n=15+15)
MatchHard_32                  2.12µs × (0.99,1.02)  2.06µs × (0.99,1.01)  -2.60% (p=0.000 n=15+14)
MatchHard_1K                  64.4µs × (0.98,1.02)  62.2µs × (0.99,1.01)  -3.33% (p=0.000 n=15+15)
MatchHard_32K                 2.74ms × (0.99,1.01)  2.75ms × (0.99,1.01)    ~    (p=0.310 n=15+14)
MatchHard_1M                  87.1ms × (0.99,1.02)  88.2ms × (0.99,1.01)  +1.36% (p=0.000 n=14+15)
MatchHard_32M                  2.79s × (0.99,1.02)   2.83s × (0.99,1.02)  +1.26% (p=0.004 n=15+14)

go1 benchmarks

name                   old time/op    new time/op    delta
BinaryTree17              3.34s ± 3%     3.28s ± 2%  -1.86%  (p=0.000 n=67+66)
Fannkuch11                2.50s ± 1%     2.51s ± 1%  +0.24%  (p=0.016 n=63+66)
FmtFprintfEmpty          50.3ns ± 1%    50.2ns ± 2%  -0.30%  (p=0.001 n=62+67)
FmtFprintfString          178ns ± 1%     166ns ± 1%  -7.10%  (p=0.000 n=62+59)
FmtFprintfInt             168ns ± 1%     161ns ± 2%  -4.41%  (p=0.000 n=66+64)
FmtFprintfIntInt          292ns ± 1%     282ns ± 2%  -3.55%  (p=0.000 n=62+60)
FmtFprintfPrefixedInt     245ns ± 2%     239ns ± 2%  -2.24%  (p=0.000 n=66+65)
FmtFprintfFloat           338ns ± 2%     326ns ± 1%  -3.42%  (p=0.000 n=64+59)
FmtManyArgs              1.14µs ± 1%    1.10µs ± 2%  -3.55%  (p=0.000 n=62+62)
GobDecode                8.88ms ± 2%    8.74ms ± 1%  -1.55%  (p=0.000 n=66+62)
GobEncode                6.84ms ± 2%    6.61ms ± 2%  -3.32%  (p=0.000 n=61+67)
Gzip                      356ms ± 2%     352ms ± 2%  -1.07%  (p=0.000 n=67+66)
Gunzip                   90.6ms ± 2%    89.8ms ± 1%  -0.83%  (p=0.000 n=65+64)
HTTPClientServer         82.6µs ± 2%    82.5µs ± 2%    ~     (p=0.832 n=65+63)
JSONEncode               17.5ms ± 2%    16.8ms ± 2%  -3.77%  (p=0.000 n=63+63)
JSONDecode               63.3ms ± 2%    59.0ms ± 2%  -6.85%  (p=0.000 n=64+63)
Mandelbrot200            3.85ms ± 1%    3.85ms ± 1%    ~     (p=0.127 n=65+62)
GoParse                  3.75ms ± 2%    3.66ms ± 2%  -2.39%  (p=0.000 n=66+64)
RegexpMatchEasy0_32       100ns ± 2%     100ns ± 1%  -0.65%  (p=0.000 n=62+64)
RegexpMatchEasy0_1K       342ns ± 1%     341ns ± 1%  -0.43%  (p=0.000 n=65+64)
RegexpMatchEasy1_32      82.8ns ± 2%    82.8ns ± 2%    ~     (p=0.977 n=63+64)
RegexpMatchEasy1_1K       511ns ± 2%     506ns ± 2%  -1.01%  (p=0.000 n=63+64)
RegexpMatchMedium_32      139ns ± 1%     134ns ± 3%  -3.27%  (p=0.000 n=59+60)
RegexpMatchMedium_1K     41.8µs ± 2%    40.5µs ± 2%  -3.05%  (p=0.000 n=62+64)
RegexpMatchHard_32       2.13µs ± 1%    2.09µs ± 1%  -2.22%  (p=0.000 n=60+65)
RegexpMatchHard_1K       64.4µs ± 3%    62.8µs ± 2%  -2.58%  (p=0.000 n=65+59)
Revcomp                   531ms ± 2%     529ms ± 1%  -0.28%  (p=0.022 n=61+61)
Template                 73.2ms ± 1%    73.1ms ± 1%    ~     (p=0.794 n=66+63)
TimeParse                 369ns ± 1%     352ns ± 1%  -4.68%  (p=0.000 n=65+66)
TimeFormat                374ns ± 2%     348ns ± 2%  -7.01%  (p=0.000 n=66+64)

Change-Id: Ib190b5bb48a3e9087711d9e3383621d3103dd342
Reviewed-on: https://go-review.googlesource.com/10367
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-04 16:32:23 +00:00
Hajime Hoshi
2db587c029 encoding/xml: Reset the parent stack before printing a chardata or comment field in a struct
This CL resets the parent stack when printing a character or comment field struct.
In the case of XML elements, the previous parents stack must be considered. However,
charadata or comment fields can't be printed in other fields so it seems required to reset
the parent stack each time a chardata or comment field is printed.

Fixes #5072

Change-Id: I84f61c9bfce94133cd0c076c11211b9be5b4b1ac
Reviewed-on: https://go-review.googlesource.com/9910
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: roger peppe <rogpeppe@gmail.com>
2015-06-04 07:16:25 +00:00
Russ Cox
227fb116be cmd/go: clean up after 'go build' during 'go install'
If 'go install' (with no arguments, meaning the current directory)
succeeds, remove the executable written by 'go build', if present.
This avoids leaving a stale binary behind during a sequence like:

	go build
	<test, mostly works, make small change>
	go install

Before this CL, the current directory still has the stale binary
from 'go build'. If $PATH contains dot, running the name of
the program will find this stale binary instead of the new,
installed one.

Remove the 'go build' target during 'go install', both to clean
up the directory and to avoid accidentally running the stale binary.

Another way to view this CL is that it makes the go command
behave as if 'go install' is implemented by 'go build' followed by
moving the resulting binary to the install location.

See #9645 for discussion and objections.

Fixes #9645.

Change-Id: Ide109572f96bbb5a35be45dda17738317462a7d4
Reviewed-on: https://go-review.googlesource.com/10682
Reviewed-by: Rob Pike <r@golang.org>
2015-06-04 04:12:32 +00:00
Russ Cox
119daba94e cmd/go: always rebuild GOPATH code that looks out of date
We used to put a rebuilding barrier between GOPATHs, so that if
you had GOPATH=dir1:dir2 and you had "p" in dir1/src/p
and "q" in dir2/src/q, with "p" importing "q", then when you
ran 'go install p', it would see that it was working in dir1
and (since nothing from dir2 was explicitly mentioned)
would assume that everything in dir2 is up-to-date, provided
it is built at all.

This has the confusing behavior that if "q" hasn't been built ever,
then if you update sources in q and run 'go install p', the right
thing happens (q is rebuilt and then p), but after that, if you update
sources in q and run 'go install p', nothing happens: the installed
q is assumed up-to-date.

People using code conventions with multiple GOPATH entries
(for example, with commands in one place and libraries in another,
or vendoring conventions that try to avoid rewriting import paths)
run into this without realizing it and end up with incorrect build
results.

The original motivation here was to avoid rebuild standard packages
since a system-installed GOROOT might be unwritable.
The change introduced to separate GOROOT also separated
individual GOPATH entries. Later changes added a different, more
aggressive earlier shortcut for GOROOT in release settings,
so the code here is now only applying to (and confusing)
multiple GOPATH entries. Remove it.

Fixes #10509.

Change-Id: I687a3baa81eff4073b0d67f9acbc5a3ab192eda5
Reviewed-on: https://go-review.googlesource.com/9155
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-04 04:11:17 +00:00
Russ Cox
7b87631e8c cmd/go: detect when package or binary is stale due to removed source file
The go command uses file modification times to decide when a
package is out of date: if the .a file is older than a source file,
the .a file needs to be rebuilt. This scheme breaks down when
multiple source files compile into a single .a file: if one source file
is removed but no other changes are made, there is no indication
that the .a file is out of date.

The fix is to store a value called a build ID in the package archive itself.
The build ID is a hash of the names of all source files compiled into the package.
A later go command can read the build ID out of the package archive
and compare to the build ID derived from the list of source files it now
sees in the directory. If the build IDs differ, the file list has changed,
and the package must be rebuilt.

There is a cost here: when scanning a package directory, in addition
to reading the beginning of every source file for build tags and imports,
the go command now also reads the beginning of the associated
package archive, for the build ID. This is at most a doubling in the
number of files read. On my 2012 MacBook Pro, the time for
'go list std' increases from about 0.215 seconds to about 0.23 seconds.

For executable binaries, the approach is the same except that the
build ID information is stored in a trailer at the end of the executable file.
It remains to be seen if anything objects to the trailer.
I don't expect problems except maybe on Plan 9.

Fixes #3895.

Change-Id: I21b4ebf5890c1a39e4a013eabe1ddbb5f3510c04
Reviewed-on: https://go-review.googlesource.com/9154
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-04 04:11:03 +00:00
Russ Cox
81d5810be9 cmd/compile: merge Node.Opt and Node.Val behind access methods
$ sizeof -p cmd/compile/internal/gc Node
Node 144
$

Change-Id: I688e3790964fe42f48c19f697ec38094a92fe1c1
Reviewed-on: https://go-review.googlesource.com/10531
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-04 03:58:41 +00:00
Russ Cox
a53710ffcb cmd/compile: cleanups for Node trimming sequence
Suggested during code reviews of last 15 CLs (or so).

Change-Id: If780f6eb47a7a31df133c64d5dcf0eaf04d8447b
Reviewed-on: https://go-review.googlesource.com/10675
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-04 03:58:27 +00:00
Josh Bleecher Snyder
ca19e55f9a cmd/link: make stkcheck more flexible
stkcheck is flow-insensitive: It processes calls in PC order.
Since morestack was always the first call in a function,
it was a safe, conservative approximation to simply adjust stack
space as we went, recognizing morestack when it showed up.

Subsequent CLS will rearrange the function prologue;
morestack may no longer be the first call in a function.

Introducing flow-sensitivity to stkcheck would allow this,
and possibly allow a smaller stackguard.
It is also a high risk change and possibly expensive.

Instead, assume that all calls to morestack occur as
part of the function prologue, no matter where they
are located in the program text.

Updates #10587.

Change-Id: I4dcdd4256a980fc4bc433a68a10989ff57f7034f
Reviewed-on: https://go-review.googlesource.com/10496
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-04 03:14:23 +00:00
Russ Cox
73d109c509 cmd/internal/gc: accept map literals with omitted key type
Fixes #10209.

Change-Id: I248434f9195c868befd1ed8a6000a9cac72d1df8
Reviewed-on: https://go-review.googlesource.com/10263
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-04 02:31:38 +00:00
Brad Fitzpatrick
03410f6758 runtime: fix TestFixedGOROOT to properly restore the GOROOT env var after test
Otherwise subsequent tests won't see any modified GOROOT.

With this CL I can move my GOROOT, set GOROOT to the new location, and
the runtime tests pass. Previously the crash_tests would instead look
for the GOROOT baked into the binary, instead of the env var:

--- FAIL: TestGcSys (0.01s)
        crash_test.go:92: building source: exit status 2
                go: cannot find GOROOT directory: /home/bradfitz/go
--- FAIL: TestGCFairness (0.01s)
        crash_test.go:92: building source: exit status 2
                go: cannot find GOROOT directory: /home/bradfitz/go
--- FAIL: TestGdbPython (0.07s)
        runtime-gdb_test.go:64: building source exit status 2
                go: cannot find GOROOT directory: /home/bradfitz/go
--- FAIL: TestLargeStringConcat (0.01s)
        crash_test.go:92: building source: exit status 2
                go: cannot find GOROOT directory: /home/bradfitz/go

Update #10029

Change-Id: If91be0f04d3acdcf39a9e773a4e7905a446bc477
Reviewed-on: https://go-review.googlesource.com/10685
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-03 23:33:48 +00:00
Robert Griesemer
1e48683708 src/cmd/compile/internal/gc: re-vendor math/big, manually adjust mparith3.go
The only unreviewed change is in mparith3.go.

Change-Id: Iec0885e7688981cbaed04c152dc9b1c7032677e6
Reviewed-on: https://go-review.googlesource.com/10665
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2015-06-03 22:28:06 +00:00
Robert Griesemer
c1fed8482d math/big: turn off debug mode
Change-Id: Ie38742cddc5a256e2f0fc0f720c0ed2f1b2e1bca
Reviewed-on: https://go-review.googlesource.com/10664
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-03 22:08:17 +00:00
Dave Cheney
d15597e1b2 math/big: trim trailing zeros before hex printing
m was being resliced as the result of looking for the first
non zero word of the mantissa, however m was not used later
in printing.

Spotted by Gordon Klaus, https://groups.google.com/forum/#!topic/golang-nuts/MdDLbvOjb4o

Change-Id: Ifbebb51ea5e0d86cb8e0422eb184b8634639a733
Reviewed-on: https://go-review.googlesource.com/10604
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-03 22:06:04 +00:00
Russ Cox
0f6da8923f cmd/internal/gc: add -buildid flag to write build ID into object file
The build ID is an opaque token supplied by the build system.
The compiler writes it out early in the Go export metadata
(the second line), in a way that does not bother existing readers.

The intent is that the go command can use this to store information
about the sources for the generated code, so that it can detect
stale packages even in cases (like removed files) where mtimes fail.

Change-Id: Ib5082515d6cde8a07a8d4b5c69d1e8e4190cb5e1
Reviewed-on: https://go-review.googlesource.com/9153
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-03 20:43:51 +00:00
Russ Cox
3974357ecd cmd/dist: one more file for CL 9152
This one didn't get written out.

Change-Id: Iee173861fb4dc7cafa64ba5f601f4664b6e8da4e
Reviewed-on: https://go-review.googlesource.com/10681
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-03 20:42:13 +00:00
Russ Cox
e346adf568 cmd/dist: do not rewrite files that already have the correct content
In particular, this avoids moving the mtime on runtime/zversion.go
forward unless the file is out of date. In turn, this makes cross compiles
that run dist multiple times coexist nicely.

(It's no longer necessary to run dist multiple times to set up cross compiles,
but people still might, and it's easy to fix regardless.)

Fixes #4749.

Change-Id: Id430525f168f106bc4b821ca74b2ca498a748f14
Reviewed-on: https://go-review.googlesource.com/9152
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-03 20:39:35 +00:00
Russ Cox
85069e9e9b cmd/dist: fix build tag parser
It was mishandling conjunctions containing negations.

Change-Id: Ife571b28416870ba2ceadbdac5ecb4670432bba1
Reviewed-on: https://go-review.googlesource.com/9151
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-03 20:35:04 +00:00
Russ Cox
c345f7ff95 cmd/go: make test.bash pass again
Fixes #8809.

Change-Id: Id443fd406e9c611d5dfabc71a98eb71d1cc0972c
Reviewed-on: https://go-review.googlesource.com/9150
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-03 20:33:30 +00:00
Russ Cox
8f0cc6c0d8 cmd/go: expand 'internal' rule to all repositories
See golang.org/s/go14internal.

Fixes #10479.

Change-Id: I8c657dadeb5f10af060f22dedc15c1af989d4519
Reviewed-on: https://go-review.googlesource.com/9156
Reviewed-by: Rob Pike <r@golang.org>
2015-06-03 20:27:25 +00:00
Russ Cox
3be7f28e82 cmd/compile: remove Node.Nname, now unused
$ sizeof -p cmd/compile/internal/gc Node
Node 160
$

Change-Id: Ib0bd4230c8547f36972b2a9d81ba3eca81496e39
Reviewed-on: https://go-review.googlesource.com/10537
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-03 20:11:25 +00:00
Aamir Khan
6d9df14fec text/template: refactor code to accomodate bi-state requirement for templates
This is follow-up to CL10607

- Refactor AddParseTree() to use t.associate()
- Refactor Parse() to use AddParseTree() to put entries into common structure
- Clone() should not put entry in t.tmpl for undefined template
- Clarify documentation for Templates()
- Clarify documentation for AddParseTree() to include the error case

Updates #10910
Uodates #10926

Includes test cases for most of the above changes

Change-Id: I25b2fce6f9651272866f881acf44e4dbca04a4a8
Reviewed-on: https://go-review.googlesource.com/10622
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-03 20:10:54 +00:00
Russ Cox
f1f0eda446 cmd/compile: remove use of Node.Nname in initplan
$ sizeof -p cmd/compile/internal/gc Node
Node 168
$

Change-Id: Ie7e2cee8cec101560bd5dd013b23969278f89b12
Reviewed-on: https://go-review.googlesource.com/10536
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-03 20:10:42 +00:00
Russ Cox
da094f19f1 cmd/compile: move OCASE/OXCASE Node.Nname into Node.Rlist (type switch variable)
$ sizeof -p cmd/compile/internal/gc Node
Node 168
$

Change-Id: I22bcea8099f308298c9db75c937f35e7fca906f1
Reviewed-on: https://go-review.googlesource.com/10535
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-03 20:10:31 +00:00
Russ Cox
bd4fff6358 cmd/compile: move ODCLFUNC Node.Nname into Node.Func.Nname
$ sizeof -p cmd/compile/internal/gc Node
Node 168
$

Change-Id: I7decd950fe068c0f294c6c9bff07ef809c394429
Reviewed-on: https://go-review.googlesource.com/10534
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-03 20:10:17 +00:00
Russ Cox
8f4d964641 cmd/compile, cmd/internal: replace %P with %v in a few final prints
$ sizeof -p cmd/compile/internal/gc Node
Node 168
$

Change-Id: I1e2f17bfee0e6ca7213706c4cef8d990f4461915
Reviewed-on: https://go-review.googlesource.com/10533
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-03 20:10:03 +00:00