]> Cypherpunks repositories - gostls13.git/log
gostls13.git
9 years agonet/url: restrict :port checking to [ipv6]:port form
Russ Cox [Thu, 6 Aug 2015 01:22:10 +0000 (21:22 -0400)]
net/url: restrict :port checking to [ipv6]:port form

Go 1.4 and earlier accepted mysql://x@y(z:123)/foo
and I don't see any compelling reason to break that.

The CL during Go 1.5 that broke this syntax was
trying to fix #11208 and was probably too aggressive.
I added a test case for #11208 to make sure that stays
fixed.

Relaxing the check did not re-break #11208 nor did
it cause any existing test to fail. I added a test for the
mysql://x@y(z:123)/foo syntax being preserved.

Fixes #12023.

Change-Id: I659d39f18c85111697732ad24b757169d69284fc
Reviewed-on: https://go-review.googlesource.com/13253
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
9 years agoA+C: add Andy Maloney
Andrew Gerrand [Wed, 5 Aug 2015 22:59:05 +0000 (08:59 +1000)]
A+C: add Andy Maloney

Fixes #10639

Change-Id: I0aa3bcbf656e23e6a110041439f6052057074b88
Reviewed-on: https://go-review.googlesource.com/13270
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: fix handling of vendored imports in foo_test.go files
Russ Cox [Wed, 5 Aug 2015 16:09:05 +0000 (12:09 -0400)]
cmd/go: fix handling of vendored imports in foo_test.go files

Fixes #11977.
Fixes #11988.

Change-Id: I9f80006946d3752ee6d644ee51f2decfeaca1ff6
Reviewed-on: https://go-review.googlesource.com/13230
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agospec: clarify semantics of built-in functions 'complex', 'real', and 'imag'
Robert Griesemer [Wed, 29 Jul 2015 22:42:04 +0000 (15:42 -0700)]
spec: clarify semantics of built-in functions 'complex', 'real', and 'imag'

For #11669, #11540, #11945, #11946, #11947.

Change-Id: Ifb0053c498cee9f3473c396f9338d82bd856c110
Reviewed-on: https://go-review.googlesource.com/12860
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agocrypto/tls: fix ConnectionState().VerifiedChains for resumed connection
Russ Cox [Wed, 5 Aug 2015 13:53:56 +0000 (09:53 -0400)]
crypto/tls: fix ConnectionState().VerifiedChains for resumed connection

Strengthening VerifyHostname exposed the fact that for resumed
connections, ConnectionState().VerifiedChains was not being saved
and restored during the ClientSessionCache operations.
Do that.

This change just saves the verified chains in the client's session
cache. It does not re-verify the certificates when resuming a
connection.

There are arguments both ways about this: we want fast, light-weight
resumption connections (thus suggesting that we shouldn't verify) but
it could also be a little surprising that, if the verification config
is changed, that would be ignored if the same session cache is used.

On the server side we do re-verify client-auth certificates, but the
situation is a little different there. The client session cache is an
object in memory that's reset each time the process restarts. But the
server's session cache is a conceptual object, held by the clients, so
can persist across server restarts. Thus the chance of a change in
verification config being surprisingly ignored is much higher in the
server case.

Fixes #12024.

Change-Id: I3081029623322ce3d9f4f3819659fdd9a381db16
Reviewed-on: https://go-review.googlesource.com/13164
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
9 years agobuild: clean current tree in clean.bash
Russ Cox [Wed, 5 Aug 2015 17:39:07 +0000 (13:39 -0400)]
build: clean current tree in clean.bash

Otherwise clean.bash cleans $GOROOT, which might be something else entirely.

Fixes #12003.

Change-Id: I2ad5369017dde6db25f0c0514bc27c33d0a8bf54
Reviewed-on: https://go-review.googlesource.com/13251
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agonet/http: close server conn after broken trailers
Jed Denlea [Tue, 4 Aug 2015 01:00:44 +0000 (18:00 -0700)]
net/http: close server conn after broken trailers

Prior to this change, broken trailers would be handled by body.Read, and
an error would be returned to its caller (likely a Handler), but that
error would go completely unnoticed by the rest of the server flow
allowing a broken connection to be reused.  This is a possible request
smuggling vector.

Fixes #12027.

Change-Id: I077eb0b8dff35c5d5534ee5f6386127c9954bd58
Reviewed-on: https://go-review.googlesource.com/13148
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocrypto/tls: update testing certificates.
Adam Langley [Wed, 5 Aug 2015 17:55:41 +0000 (10:55 -0700)]
crypto/tls: update testing certificates.

This change alters the certificate used in many tests so that it's no
longer self-signed. This allows some tests to exercise the standard
certificate verification paths in the future.

Change-Id: I9c3fcd6847eed8269ff3b86d9b6966406bf0642d
Reviewed-on: https://go-review.googlesource.com/13244
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
9 years agogo/build: fix internal/testenv dependency
Russ Cox [Wed, 5 Aug 2015 17:13:33 +0000 (13:13 -0400)]
go/build: fix internal/testenv dependency

Change-Id: Id1e30d70d6891ef12110f8e7832b94eeac9e2fa9
Reviewed-on: https://go-review.googlesource.com/13250
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: don't recheck heap trigger for periodic GC
Austin Clements [Wed, 5 Aug 2015 15:07:47 +0000 (11:07 -0400)]
runtime: don't recheck heap trigger for periodic GC

88e945f introduced a non-speculative double check of the heap trigger
before actually starting a concurrent GC. This was necessary to fix a
race for heap-triggered GC, but broke sysmon-triggered periodic GC,
since the heap check will of course fail for periodically triggered
GC.

Fix this by telling startGC whether or not this GC was triggered by
heap size or a timer and only doing the heap size double check for GCs
triggered by heap size.

Fixes #12026.

Change-Id: I7c3f6ec364545c36d619f2b4b3bf3b758e3bcbd6
Reviewed-on: https://go-review.googlesource.com/13168
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agospec: better organization of arithmetic operator section
Robert Griesemer [Tue, 4 Aug 2015 22:04:39 +0000 (15:04 -0700)]
spec: better organization of arithmetic operator section

First step towards cleaning up the operator section - no language
changes. Specifically:

- Grouped arithmetic operations by types (integer, floating-point,
  string), with corresponding h4 headings.

- Changed Operator precedence title from h3 to h4.

- Moved Integer Overflow section after integer operations and changed
  its title from h3 to h4.

This puts things that belong together closer. No heading id's were
lost (in case of references from outside the spec).

Change-Id: I6b349ba8d86a6ae29b596beb297cc45c81e69399
Reviewed-on: https://go-review.googlesource.com/13143
Reviewed-by: Rob Pike <r@golang.org>
9 years agospec: fix inconsistency of visibility rules for method names
Robert Griesemer [Tue, 4 Aug 2015 18:52:01 +0000 (11:52 -0700)]
spec: fix inconsistency of visibility rules for method names

Inconsistency identified by Anmol Sethi (anmol@aubble.com).

Fixes #10341.

Change-Id: I1a1f5b22aad29b56280f81026feaa37a61b3e0a9
Reviewed-on: https://go-review.googlesource.com/13132
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agospec: clarify that short variable declarations can redeclare parameters
Robert Griesemer [Tue, 4 Aug 2015 18:29:28 +0000 (11:29 -0700)]
spec: clarify that short variable declarations can redeclare parameters

Fixes #9837.

Change-Id: Ia513c7e5db221eee8e3ab0affa6d3688d2099fd9
Reviewed-on: https://go-review.googlesource.com/13130
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agospec: clarify sentence about non-constant shifts
Robert Griesemer [Tue, 4 Aug 2015 17:38:50 +0000 (10:38 -0700)]
spec: clarify sentence about non-constant shifts

Fixes #10514.

Change-Id: Iae95a304d3ebb1ed82567aa234e05dc434db984f
Reviewed-on: https://go-review.googlesource.com/13098
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc/go1.5: fix hyperlink for runtime/trace
Russ Cox [Wed, 5 Aug 2015 14:20:02 +0000 (10:20 -0400)]
doc/go1.5: fix hyperlink for runtime/trace

Missed in CL 13074.

Change-Id: Ic0600341abbc423cd8d7b2201bf50e3b0bf398a7
Reviewed-on: https://go-review.googlesource.com/13167
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agogo/build: enable cgo on freebsd/arm
Russ Cox [Wed, 5 Aug 2015 13:12:18 +0000 (09:12 -0400)]
go/build: enable cgo on freebsd/arm

Now that it works we need to turn it back on.

Fixes #10119.

Change-Id: I9c62d3026f7bb62c49a601ad73f33bf655372915
Reviewed-on: https://go-review.googlesource.com/13162
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/go: skip external tests on freebsd-arm builder
Russ Cox [Wed, 5 Aug 2015 14:19:12 +0000 (10:19 -0400)]
cmd/go: skip external tests on freebsd-arm builder

It is just far too slow.
I have a CL for Go 1.6 that makes many of these into internal tests.
That will improve the coverage.

It does not matter much, because basically none of the go command
tests are architecture dependent, so the other builders will catch
any problems.

Fixes freebsd-arm builder.

Change-Id: I8b2f6ac2cc1e7657019f7731c6662dc43e20bfb5
Reviewed-on: https://go-review.googlesource.com/13166
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agointernal/testenv: add Builder, to report builder name
Russ Cox [Wed, 5 Aug 2015 14:11:59 +0000 (10:11 -0400)]
internal/testenv: add Builder, to report builder name

This works after golang.org/cl/13120 is running on the
coordinator (maybe it already is).

Change-Id: I4053d8e2f32fafd47b927203a6f66d5858e23376
Reviewed-on: https://go-review.googlesource.com/13165
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agodoc: mention new DWARF line table decoder in go1.5.html
Austin Clements [Tue, 4 Aug 2015 19:57:07 +0000 (15:57 -0400)]
doc: mention new DWARF line table decoder in go1.5.html

Change-Id: I4e8c20284255e0e17b6fb72475d2d37f49994788
Reviewed-on: https://go-review.googlesource.com/13113
Reviewed-by: Rob Pike <r@golang.org>
9 years agodoc/go1.5.html: update references to runtime/trace package
Dmitry Vyukov [Tue, 4 Aug 2015 07:11:06 +0000 (09:11 +0200)]
doc/go1.5.html: update references to runtime/trace package

Tracing functionality was moved from runtime/pprof to runtime/trace.

Change-Id: I694e0f209d043c7ffecb113f1825175bf963dde3
Reviewed-on: https://go-review.googlesource.com/13074
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime: align stack pointer during initcgo call on arm
Russ Cox [Wed, 5 Aug 2015 03:44:06 +0000 (23:44 -0400)]
runtime: align stack pointer during initcgo call on arm

This is what is causing freebsd/arm to crash mysteriously when using cgo.
The bug was introduced in golang.org/cl/4030, which moved this code out
of rt0_go and into its own function. The ARM ABI says that calls must
be made with the stack pointer at an 8-byte boundary, but only FreeBSD
seems to crash when this is violated.

Fixes #10119.

Change-Id: Ibdbe76b2c7b80943ab66b8abbb38b47acb70b1e5
Reviewed-on: https://go-review.googlesource.com/13161
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
9 years agodoc: adjust installation instructions dynamically for a given download
Andrew Gerrand [Wed, 5 Aug 2015 01:58:44 +0000 (11:58 +1000)]
doc: adjust installation instructions dynamically for a given download

This change allows the download page to redirect the user to
/doc/install?download=filename so the user can see installation
instructions specific to the file they are downloading.

This change also expands the "Test your Go installation" section
to instruct the user to create a workspace, hopefully leading
to less confusion down the line.

It also changes the front page download link to go directly
to the downloads page, which will in turn take them to the
installation instructions (the original destination).

This is related to this change to the tools repo:
https://golang.org/cl/13180

Change-Id: I658327bdb93ad228fb1846e389b281b15da91b1d
Reviewed-on: https://go-review.googlesource.com/13151
Reviewed-by: Chris Broadfoot <cbro@golang.org>
9 years agodoc: bump minimum requirement to OS X 10.7
Andrew Gerrand [Tue, 4 Aug 2015 23:40:33 +0000 (09:40 +1000)]
doc: bump minimum requirement to OS X 10.7

Fixes #11995

Change-Id: I9e2901d77ebde705f59822e7d4a8163cbacffcd7
Reviewed-on: https://go-review.googlesource.com/13150
Reviewed-by: Rob Pike <r@golang.org>
9 years agoreflect: fix doc string
Robert Griesemer [Tue, 4 Aug 2015 20:44:01 +0000 (13:44 -0700)]
reflect: fix doc string

Fixes #12017.

Change-Id: I3dfcf9d0b62cae02eca1973383f0aad286a6ef4d
Reviewed-on: https://go-review.googlesource.com/13136
Reviewed-by: Keith Randall <khr@golang.org>
9 years agoruntime: fix typos in comments
Austin Clements [Mon, 3 Aug 2015 22:09:13 +0000 (18:09 -0400)]
runtime: fix typos in comments

Change-Id: I66f7937b22bb6e05c3f2f0f2a057151020ad9699
Reviewed-on: https://go-review.googlesource.com/13049
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: fix assist utilization computation
Austin Clements [Mon, 3 Aug 2015 22:06:05 +0000 (18:06 -0400)]
runtime: fix assist utilization computation

When commit 510fd13 enabled assists during the scan phase, it failed
to also update the code in the GC controller that computed the assist
CPU utilization and adjusted the trigger based on it. Fix that code so
it uses the start of the scan phase as the wall-clock time when
assists were enabled rather than the start of the mark phase.

Change-Id: I05013734b4448c3e2c730dc7b0b5ee28c86ed8cf
Reviewed-on: https://go-review.googlesource.com/13048
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: revise assist ratio aggressively
Austin Clements [Mon, 3 Aug 2015 21:48:47 +0000 (17:48 -0400)]
runtime: revise assist ratio aggressively

At the start of a GC cycle, the garbage collector computes the assist
ratio based on the total scannable heap size. This was intended to be
conservative; after all, this assumes the entire heap may be reachable
and hence needs to be scanned. But it only assumes that the *current*
entire heap may be reachable. It fails to account for heap allocated
during the GC cycle. If the trigger ratio is very low (near zero), and
most of the heap is reachable when GC starts (which is likely if the
trigger ratio is near zero), then it's possible for the mutator to
create new, reachable heap fast enough that the assists won't keep up
based on the assist ratio computed at the beginning of the cycle. As a
result, the heap can grow beyond the heap goal (by hundreds of megs in
stress tests like in issue #11911).

We already have some vestigial logic for dealing with situations like
this; it just doesn't run often enough. Currently, every 10 ms during
the GC cycle, the GC revises the assist ratio. This was put in before
we switched to a conservative assist ratio (when we really were using
estimates of scannable heap), and it turns out to be exactly what we
need now. However, every 10 ms is far too infrequent for a rapidly
allocating mutator.

This commit reuses this logic, but replaces the 10 ms timer with
revising the assist ratio every time the heap is locked, which
coincides precisely with when the statistics used to compute the
assist ratio are updated.

Fixes #11911.

Change-Id: I377b231ab064946228378fa10422a46d1b50f4c5
Reviewed-on: https://go-review.googlesource.com/13047
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: when gcpacertrace > 0, print information about assist ratio
Austin Clements [Mon, 3 Aug 2015 21:45:44 +0000 (17:45 -0400)]
runtime: when gcpacertrace > 0, print information about assist ratio

This was useful in debugging the mutator assist behavior for #11911,
and it fits with the other gcpacertrace output.

Change-Id: I1e25590bb4098223a160de796578bd11086309c7
Reviewed-on: https://go-review.googlesource.com/13046
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: make sweep proportional to spans bytes allocated
Austin Clements [Mon, 3 Aug 2015 13:46:50 +0000 (09:46 -0400)]
runtime: make sweep proportional to spans bytes allocated

Proportional concurrent sweep is currently based on a ratio of spans
to be swept per bytes of object allocation. However, proportional
sweeping is performed during span allocation, not object allocation,
in order to minimize contention and overhead. Since objects are
allocated from spans after those spans are allocated, the system tends
to operate in debt, which means when the next GC cycle starts, there
is often sweep debt remaining, so GC has to finish the sweep, which
delays the start of the cycle and delays enabling mutator assists.

For example, it's quite likely that many Ps will simultaneously refill
their span caches immediately after a GC cycle (because GC flushes the
span caches), but at this point, there has been very little object
allocation since the end of GC, so very little sweeping is done. The
Ps then allocate objects from these cached spans, which drives up the
bytes of object allocation, but since these allocations are coming
from cached spans, nothing considers whether more sweeping has to
happen. If the sweep ratio is high enough (which can happen if the
next GC trigger is very close to the retained heap size), this can
easily represent a sweep debt of thousands of pages.

Fix this by making proportional sweep proportional to the number of
bytes of spans allocated, rather than the number of bytes of objects
allocated. Prior to allocating a span, both the small object path and
the large object path ensure credit for allocating that span, so the
system operates in the black, rather than in the red.

Combined with the previous commit, this should eliminate all sweeping
from GC start up. On the stress test in issue #11911, this reduces the
time spent sweeping during GC (and delaying start up) by several
orders of magnitude:

                mean    99%ile     max
    pre fix      1 ms    11 ms   144 ms
    post fix   270 ns   735 ns   916 ns

Updates #11911.

Change-Id: I89223712883954c9d6ec2a7a51ecb97172097df3
Reviewed-on: https://go-review.googlesource.com/13044
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: always give concurrent sweep some heap distance
Austin Clements [Mon, 3 Aug 2015 13:25:23 +0000 (09:25 -0400)]
runtime: always give concurrent sweep some heap distance

Currently it's possible for the next_gc heap size trigger computed for
the next GC cycle to be less than the current allocated heap size.
This means the next cycle will start immediately, which means there's
no time to perform the concurrent sweep between GC cycles. This places
responsibility for finishing the sweep on GC itself, which delays GC
start-up and hence delays mutator assist.

Fix this by ensuring that next_gc is always at least a little higher
than the allocated heap size, so we won't trigger the next cycle
instantly.

Updates #11911.

Change-Id: I74f0b887bf187518d5fedffc7989817cbcf30592
Reviewed-on: https://go-review.googlesource.com/13043
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: assist the GC during GC startup and shutdown
Austin Clements [Fri, 31 Jul 2015 18:29:02 +0000 (14:29 -0400)]
runtime: assist the GC during GC startup and shutdown

Currently there are two sensitive periods during which a mutator can
allocate past the heap goal but mutator assists can't be enabled: 1)
at the beginning of GC between when the heap first passes the heap
trigger and sweep termination and 2) at the end of GC between mark
termination and when the background GC goroutine parks. During these
periods there's no back-pressure or safety net, so a rapidly
allocating mutator can allocate past the heap goal. This is
exacerbated if there are many goroutines because the GC coordinator is
scheduled as any other goroutine, so if it gets preempted during one
of these periods, it may stay preempted for a long period (10s or 100s
of milliseconds).

Normally the mutator does scan work to create back-pressure against
allocation, but there is no scan work during these periods. Hence, as
a fall back, if a mutator would assist but can't yet, simply yield the
CPU. This delays the mutator somewhat, but more importantly gives more
CPU time to the GC coordinator for it to complete the transition.

This is obviously a workaround. Issue #11970 suggests a far better but
far more invasive way to fix this.

Updates #11911. (This very nearly fixes the issue, but about once
every 15 minutes I get a GC cycle where the assists are enabled but
don't do enough work.)

Change-Id: I9768b79e3778abd3e06d306596c3bd77f65bf3f1
Reviewed-on: https://go-review.googlesource.com/13026
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agoruntime: recheck GC trigger before actually starting GC
Austin Clements [Fri, 31 Jul 2015 17:52:17 +0000 (13:52 -0400)]
runtime: recheck GC trigger before actually starting GC

Currently allocation checks the GC trigger speculatively during
allocation and then triggers the GC without rechecking. As a result,
it's possible for G 1 and G 2 to detect the trigger simultaneously,
both enter startGC, G 1 actually starts GC while G 2 gets preempted
until after the whole GC cycle, then G 2 immediately starts another GC
cycle even though the heap is now well under the trigger.

Fix this by re-checking the GC trigger non-speculatively just before
actually kicking off a new GC cycle.

This contributes to #11911 because when this happens, we definitely
don't finish the background sweep before starting the next GC cycle,
which can significantly delay the start of concurrent scan.

Change-Id: I560ab79ba5684ba435084410a9765d28f5745976
Reviewed-on: https://go-review.googlesource.com/13025
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agodoc: link to design doc for GOMAXPROCS change in go1.5.html
Ian Lance Taylor [Mon, 3 Aug 2015 19:35:59 +0000 (12:35 -0700)]
doc: link to design doc for GOMAXPROCS change in go1.5.html

Change-Id: Ifac10621fece766f3a0e8551e98d1f8d7072852f
Reviewed-on: https://go-review.googlesource.com/13068
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agocmd/go: fix documentation for exported functions
Ian Lance Taylor [Mon, 3 Aug 2015 19:49:00 +0000 (12:49 -0700)]
cmd/go: fix documentation for exported functions

I accidentally submitted https://golang.org/cl/13080 too early.

Update #11955.

Change-Id: I1a5a6860bb46bc4bc6fd278f8a867d2dd9e411e1
Reviewed-on: https://go-review.googlesource.com/13096
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agoarchive/tar: don't treat multiple file system links as a tar hardlink
Vincent Batts [Mon, 3 Aug 2015 16:26:38 +0000 (12:26 -0400)]
archive/tar: don't treat multiple file system links as a tar hardlink

Do not assume that if stat shows multiple links that we should mark the
file as a hardlink in the tar format.  If the hardlink link was not
referenced, this caused a link to "/".  On an overlay file system, all
files have multiple links.

The caller must keep the inode references and set TypeLink, Size = 0,
and LinkName themselves.

Change-Id: I873b8a235bc8f8fbb271db74ee54232da36ca013
Reviewed-on: https://go-review.googlesource.com/13045
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/go: document that functions are exported by cgo
Ian Lance Taylor [Mon, 3 Aug 2015 19:49:00 +0000 (12:49 -0700)]
cmd/go: document that functions are exported by cgo

The buildmode docs mention exported functions, but don't say anything
about how to export them.  Mention the cgo tool to make this somewhat
clearer.

Fixes #11955.

Change-Id: Ie5420445daa87f5aceec6ad743465d5d32d0a786
Reviewed-on: https://go-review.googlesource.com/13080
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agogo/types: remove the renaming import of go/constant
Rob Pike [Mon, 3 Aug 2015 03:57:25 +0000 (13:57 +1000)]
go/types: remove the renaming import of go/constant

For niceness, when go/exact was moved from x/tools, it
was renamed go/constant.

For simplicity, when go/types was moved from x/tools, its
imports of (now) go/constant were done with a rename:

    import exact "go/constant"

This kept the code just as it was before and avoided the issue
of what to call the internal constant called, um, constant.

But not all was hidden, as the text of some fields of structs and
the like leaked the old name, so things like "exact.Value" appeared
in type definitions and function signatures in the documentation.
This is unacceptable.

Fix the documentation issue by fixing the code. Rename the constant
constant constant_, and remove the renaming import.

This should go into 1.5. It's mostly a mechanical change, is
internal to the package, and fixes the documentation. It contains
no semantic changes except to fix a benchmark that was broken
in the original transition.

Fixes #11949.

Change-Id: Ieb94b6558535b504180b1378f19e8f5a96f92d3c
Reviewed-on: https://go-review.googlesource.com/13051
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc: link to the release cycle from contribute.html
Caleb Spare [Tue, 4 Aug 2015 00:48:43 +0000 (17:48 -0700)]
doc: link to the release cycle from contribute.html

Change-Id: Ia5d41b66006682084fcbfac3da020946ea3dd116
Reviewed-on: https://go-review.googlesource.com/13093
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/go: re-run mkalldocs.sh after testflag change
Caleb Spare [Tue, 4 Aug 2015 00:20:31 +0000 (17:20 -0700)]
cmd/go: re-run mkalldocs.sh after testflag change

Change-Id: Ia21501df23a91c065d9f2acc6f043019a1419b22
Reviewed-on: https://go-review.googlesource.com/13092
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agodoc: Mention contributor agreement immediately after Gerrit
Andy Maloney [Mon, 3 Aug 2015 14:15:52 +0000 (10:15 -0400)]
doc: Mention contributor agreement immediately after Gerrit

I walked through the steps for a contribution but ended up
with an error when doing "git mail" because I didn't have a
signed agreement.

Added a section to check for or create one through Gerrit right
after the user has created the account and logged in.

Moved some info from copyright section to the new section.

Change-Id: I79bbd3e18fc3a742fa59a242085da14be9e19ba0
Reviewed-on: https://go-review.googlesource.com/13062
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/go: documented default value of the -timeout testflag
Caleb Spare [Mon, 3 Aug 2015 23:32:28 +0000 (16:32 -0700)]
cmd/go: documented default value of the -timeout testflag

Change-Id: I4dc75065038a9cfd06f61c0deca1c86c70713d3a
Reviewed-on: https://go-review.googlesource.com/13091
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/go: clean up installHeader action
Russ Cox [Fri, 31 Jul 2015 19:07:44 +0000 (15:07 -0400)]
cmd/go: clean up installHeader action

This was confusing when I was trying to fix go build -o.
Perhaps due to that fix, this can now be simplified from
three functions to one.

Change-Id: I878a6d243b14132a631e7c62a3bb6d101bc243ea
Reviewed-on: https://go-review.googlesource.com/13027
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/go: document and fix 'go build -o' semantics
Russ Cox [Fri, 31 Jul 2015 17:07:41 +0000 (13:07 -0400)]
cmd/go: document and fix 'go build -o' semantics

Quoting the new docs:

«
If the arguments to build are a list of .go files, build treats
them as a list of source files specifying a single package.

When compiling a single main package, build writes
the resulting executable to an output file named after
the first source file ('go build ed.go rx.go' writes 'ed' or 'ed.exe')
or the source code directory ('go build unix/sam' writes 'sam' or 'sam.exe').
The '.exe' suffix is added when writing a Windows executable.

When compiling multiple packages or a single non-main package,
build compiles the packages but discards the resulting object,
serving only as a check that the packages can be built.

The -o flag, only allowed when compiling a single package,
forces build to write the resulting executable or object
to the named output file, instead of the default behavior described
in the last two paragraphs.
»

There is a change in behavior here, namely that 'go build -o x.a x.go'
where x.go is not a command (not package main) did not write any
output files (back to at least Go 1.2) but now writes x.a.
This seems more reasonable than trying to explain that -o is
sometimes silently ignored.

Otherwise the behavior is unchanged.

The lines being deleted in goFilesPackage look like they are
setting up 'go build x.o' to write 'x.a', but they were overridden
by the p.target = "" in runBuild. Again back to at least Go 1.2,
'go build x.go' for a non-main package has never produced
output. It seems better to keep it that way than to change it,
both for historical consistency and for consistency with
'go build strings' and 'go build std'.

All of this behavior is now tested.

Fixes #10865.

Change-Id: Iccdf21f366fbc8b5ae600a1e50dfe7fc3bff8b1c
Reviewed-on: https://go-review.googlesource.com/13024
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dave Day <djd@golang.org>
9 years agonet/http: deflake TestZeroLengthPostAndResponse
Brad Fitzpatrick [Mon, 3 Aug 2015 09:51:21 +0000 (11:51 +0200)]
net/http: deflake TestZeroLengthPostAndResponse

It was failing with multiple goroutines a few out of every thousand
runs (with errRequestCanceled) because it was using the same
*http.Request for all 5 RoundTrips, but the RoundTrips' goroutines
(notably the readLoop method) were all still running, sharing that
same pointer. Because the response has no body (which is what
TestZeroLengthPostAndResponse tests), the readLoop was marking the
connection as reusable early (before the caller read until the body's
EOF), but the Transport code was clearing the Request's cancelation
func *AFTER* the caller had already received it from RoundTrip. This
let the test continue looping and do the next request with the same
pointer, fetch a connection, and then between getConn and roundTrip
have an invariant violated: the Request's cancelation func was nil,
tripping this check:

        if !pc.t.replaceReqCanceler(req.Request, pc.cancelRequest) {
                pc.t.putIdleConn(pc)
                return nil, errRequestCanceled
        }

The solution is to clear the request cancelation func in the readLoop
goroutine in the no-body case before it's returned to the caller.

This now passes reliably:

$ go test -race -run=TestZeroLengthPostAndResponse -count=3000

I think we've only seen this recently because we now randomize scheduling
of goroutines in race mode (https://golang.org/cl/11795). This race
has existed for a long time but the window was hard to hit.

Change-Id: Idb91c582919f85aef5b9e5ef23706f1ba9126e9a
Reviewed-on: https://go-review.googlesource.com/13070
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agonet/http: fix server/transport data race when sharing the request body
Brad Fitzpatrick [Mon, 3 Aug 2015 08:04:42 +0000 (10:04 +0200)]
net/http: fix server/transport data race when sharing the request body

Introduced in https://go-review.googlesource.com/12865 (git rev c2db5f4c).

This fix doesn't add any new lock acquistions: it just moves the
existing one taken by the unreadDataSize method and moves it out
wider.

It became flaky at rev c2db5f4c, but now reliably passes again:
$ go test -v -race -run=TestTransportAndServerSharedBodyRace -count=100 net/http

Fixes #11985

Change-Id: I6956d62839fd7c37e2f7441b1d425793f4a0db30
Reviewed-on: https://go-review.googlesource.com/12909
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: skip TestCgoCallbackGC on dragonfly
Mikio Hara [Mon, 3 Aug 2015 03:43:25 +0000 (12:43 +0900)]
runtime: skip TestCgoCallbackGC on dragonfly

Updates #11990.

Change-Id: I6c58923a1b5a3805acfb6e333e3c9e87f4edf4ba
Reviewed-on: https://go-review.googlesource.com/13050
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agodoc: document new linker -X syntax in go1.5.html
Rob Pike [Mon, 3 Aug 2015 01:05:05 +0000 (11:05 +1000)]
doc: document new linker -X syntax in go1.5.html

Fixes #11973.

Change-Id: Icffa3213246663982b7cc795982e0923e272f405
Reviewed-on: https://go-review.googlesource.com/12919
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agodoc: link to proposal process from contribution guidelines
Andrew Gerrand [Fri, 31 Jul 2015 01:43:57 +0000 (11:43 +1000)]
doc: link to proposal process from contribution guidelines

Change-Id: I992cb1afeef498353d529238e508fa438d6c069c
Reviewed-on: https://go-review.googlesource.com/12912
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agodoc: update install from source instructions for go1.5
ALTree [Sun, 2 Aug 2015 15:59:31 +0000 (17:59 +0200)]
doc: update install from source instructions for go1.5

Fixes #11983

Change-Id: I5ee930314a43356f5be31d758d90d7ddcafc7b37
Reviewed-on: https://go-review.googlesource.com/12908
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agonet/http: close server conn after request body error
Jed Denlea [Thu, 30 Jul 2015 01:10:32 +0000 (18:10 -0700)]
net/http: close server conn after request body error

HTTP servers attempt to entirely consume a request body before sending a
response.  However, when doing so, it previously would ignore any errors
encountered.

Unfortunately, the errors triggered at this stage are indicative of at
least a couple problems: read timeouts and chunked encoding errors.
This means properly crafted and/or timed requests could lead to a
"smuggled" request.

The fix is to inspect the errors created by the response body Reader,
and treat anything other than io.EOF or ErrBodyReadAfterClose as
fatal to the connection.

Fixes #11930

Change-Id: I0bf18006d7d8f6537529823fc450f2e2bdb7c18e
Reviewed-on: https://go-review.googlesource.com/12865
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/http: fix SetKeepAlivesEnabled receiver name
Carl Jackson [Sat, 1 Aug 2015 06:25:48 +0000 (23:25 -0700)]
net/http: fix SetKeepAlivesEnabled receiver name

This makes the receiver name consistent with the rest of the methods on
type Server.

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

9 years agospec: fixed various example code snippets
Robert Griesemer [Fri, 31 Jul 2015 18:15:11 +0000 (11:15 -0700)]
spec: fixed various example code snippets

Per suggestions by Peter Olsen (https://github.com/pto).

Fixes #11964.

Change-Id: Iae261ac14f75abf848f5601f59d7fe6e95b6805a
Reviewed-on: https://go-review.googlesource.com/13006
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/objdump: don't run TestDisasmExtld if cgo is not enabled
Ian Lance Taylor [Fri, 31 Jul 2015 17:49:01 +0000 (10:49 -0700)]
cmd/objdump: don't run TestDisasmExtld if cgo is not enabled

The test uses external linking mode, which is probably not available
if cgo does not work.

Fixes #11969.

Change-Id: Id1c2828cd2540391e16b422bf51674ba6ff084b0
Reviewed-on: https://go-review.googlesource.com/13005
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoos: add explicit tests for fchown(2) and lchown(2) on unix platforms
Dave Cheney [Wed, 29 Jul 2015 10:06:45 +0000 (20:06 +1000)]
os: add explicit tests for fchown(2) and lchown(2) on unix platforms

Fixes #11919

Issue #11918 suggested that os.File.Chown and os.Lchown were under tested.

Change-Id: Ib41f7cb2d2fe0066d2ccb4d1bdabe1795efe80fc
Reviewed-on: https://go-review.googlesource.com/12834
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd/go: fix go get x/... matching internal directories
Russ Cox [Fri, 31 Jul 2015 16:10:22 +0000 (12:10 -0400)]
cmd/go: fix go get x/... matching internal directories

Fixes #11960.

Change-Id: I9361a9f17f4eaf8e4f54b4ba380fd50a4b9cf003
Reviewed-on: https://go-review.googlesource.com/13023
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/go: fix disallow of p/vendor/x during vendor experiment
Russ Cox [Fri, 31 Jul 2015 15:54:42 +0000 (11:54 -0400)]
cmd/go: fix disallow of p/vendor/x during vendor experiment

The percolation of errors upward in the load process could
drop errors, meaning that a build tree could, depending on the
processing order, import the same directory as both "p/vendor/x"
and as "x". That's not supposed to be allowed. But then, worse,
the build would generate two jobs for building that directory,
which would use the same work space and overwrite each other's files,
leading to very strange failures.

Two fixes:

1. Fix the propagation of errors upward (prefer errors over success).
2. Check explicitly for duplicated packages before starting a build.

New test for #1.
Since #2 can't happen, tested #2 by hand after reverting fix for #1.

Fixes #11913.

Change-Id: I6d2fc65f93b8fb5f3b263ace8d5f68d803a2ae5c
Reviewed-on: https://go-review.googlesource.com/13022
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/compile, runtime: fix placement of map bucket overflow pointer on nacl
Russ Cox [Fri, 31 Jul 2015 02:05:51 +0000 (22:05 -0400)]
cmd/compile, runtime: fix placement of map bucket overflow pointer on nacl

On most systems, a pointer is the worst case alignment, so adding
a pointer field at the end of a struct guarantees there will be no
padding added after that field (to satisfy overall struct alignment
due to some more-aligned field also present).

In the runtime, the map implementation needs a quick way to
get to the overflow pointer, which is last in the bucket struct,
so it uses size - sizeof(pointer) as the offset.

NaCl/amd64p32 is the exception, as always.
The worst case alignment is 64 bits but pointers are 32 bits.
There's a long history that is not worth going into, but when
we moved the overflow pointer to the end of the struct,
we didn't get the padding computation right.
The compiler computed the regular struct size and then
on amd64p32 added another 32-bit field.
And the runtime assumed it could step back two 32-bit fields
(one 64-bit register size) to get to the overflow pointer.
But in fact if the struct needed 64-bit alignment, the computation
of the regular struct size would have added a 32-bit pad already,
and then the code unconditionally added a second 32-bit pad.
This placed the overflow pointer three words from the end, not two.
The last two were padding, and since the runtime was consistent
about using the second-to-last word as the overflow pointer,
no harm done in the sense of overwriting useful memory.
But writing the overflow pointer to a non-pointer word of memory
means that the GC can't see the overflow blocks, so it will
collect them prematurely. Then bad things happen.

Correct all this in a few steps:

1. Add an explicit check at the end of the bucket layout in the
compiler that the overflow field is last in the struct, never
followed by padding.

2. When padding is needed on nacl (not always, just when needed),
insert it before the overflow pointer, to preserve the "last in the struct"
property.

3. Let the compiler have the final word on the width of the struct,
by inserting an explicit padding field instead of overwriting the
results of the width computation it does.

4. For the same reason (tell the truth to the compiler), set the type
of the overflow field when we're trying to pretend its not a pointer
(in this case the runtime maintains a list of the overflow blocks
elsewhere).

5. Make the runtime use "last in the struct" as its location algorithm.

This fixes TestTraceStress on nacl/amd64p32.
The 'bad map state' and 'invalid free list' failures no longer occur.

Fixes #11838.

Change-Id: If918887f8f252d988db0a35159944d2b36512f92
Reviewed-on: https://go-review.googlesource.com/12971
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agotest/bench/shootout: fix build
Mikio Hara [Fri, 31 Jul 2015 05:57:16 +0000 (14:57 +0900)]
test/bench/shootout: fix build

Change-Id: Ic8ff6c28ec899cf5e01553b83110eb6262870995
Reviewed-on: https://go-review.googlesource.com/12918
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/mail: fixed quoted-local
MathiasB [Fri, 31 Jul 2015 10:25:06 +0000 (12:25 +0200)]
net/mail: fixed quoted-local

Fixes some minor issues regarding quoted-string when parsing
the local-part.

Those strings should return an error:
- quoted-string without any content: `""@test.com`
- quoted-string containing tab: "\"\t\"@test.com"

Fixes #11293

Change-Id: Ied93eb6831915c9b1f8e727cea14168af21f8d3b
Reviewed-on: https://go-review.googlesource.com/12905
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/internal/obj/arm: fix large stack offsets on nacl/arm
Russ Cox [Fri, 31 Jul 2015 02:35:56 +0000 (22:35 -0400)]
cmd/internal/obj/arm: fix large stack offsets on nacl/arm

The code already fixed large non-stack offsets
but explicitly excluded stack references.
Perhaps you could get away with that before,
but current versions of nacl reject such stack
references. Rewrite them the same as the others.

For #11956 but probably not the last problem.

Change-Id: I0db4e3a1ed4f88ccddf0d30228982960091d9fb7
Reviewed-on: https://go-review.googlesource.com/13010
Reviewed-by: Dave Cheney <dave@cheney.net>
9 years agoruntime: fix systemstack tracebacks on nacl/arm
Russ Cox [Fri, 31 Jul 2015 02:52:45 +0000 (22:52 -0400)]
runtime: fix systemstack tracebacks on nacl/arm

For #11956.

Change-Id: Ic9b57cafa197953cc7f435941e44d42b60b3ddf0
Reviewed-on: https://go-review.googlesource.com/13011
Reviewed-by: Dave Cheney <dave@cheney.net>
9 years agotest/bench/shootout: clean up binaries after run
Andrew Gerrand [Fri, 31 Jul 2015 02:03:48 +0000 (12:03 +1000)]
test/bench/shootout: clean up binaries after run

Update #11943

Change-Id: I3e6592876bf16d2f9129995b723ecf69c069653d
Reviewed-on: https://go-review.googlesource.com/12913
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: avoid reference to stale stack after GC shrinkstack
Russ Cox [Thu, 30 Jul 2015 23:39:16 +0000 (19:39 -0400)]
runtime: avoid reference to stale stack after GC shrinkstack

Dangling pointer error. Unlikely to trigger in practice, but still.
Found by running GODEBUG=efence=1 GOGC=1 trace.test.

Change-Id: Ice474dedcf62dd33ab77526287a023ba3b166db9
Reviewed-on: https://go-review.googlesource.com/12991
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/link: increase ELFRESERVE to a full page
Russ Cox [Thu, 30 Jul 2015 20:30:54 +0000 (16:30 -0400)]
cmd/link: increase ELFRESERVE to a full page

Etcd and kubernetes have hit this.
See  https://bugzilla.redhat.com/show_bug.cgi?id=1248071

Change-Id: I6231013efa0a19ee74f7ebacd1024adb368af83a
Reviewed-on: https://go-review.googlesource.com/12951
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/go: permit installing into a subdirectory of $GOPATH/bin
Ian Lance Taylor [Thu, 30 Jul 2015 22:20:12 +0000 (15:20 -0700)]
cmd/go: permit installing into a subdirectory of $GOPATH/bin

In https://golang.org/cl/12080 we forbade installing cross-compiled
binaries into a subdirectory of $GOBIN, in order to fix
https://golang.org/issue/9769.  However, that fix was too aggressive,
in that it also forbade installing into a subdirectory of $GOPATH/bin.

This patch permits installing cross-compiled binaries into a
subdirectory $GOPATH/bin while continuing to forbid installing into a
subdirectory of $GOBIN.

Fixes #11778.

Change-Id: Ibc9919554e8c275beff54ec8bf919cfaa03b11ba
Reviewed-on: https://go-review.googlesource.com/12938
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc: solaris info added to go1.5.html
Rob Pike [Thu, 30 Jul 2015 23:03:58 +0000 (09:03 +1000)]
doc: solaris info added to go1.5.html

Fixes #11952.

Change-Id: I548f9d75c6223bf79bdf654ef733f1568e3d5804
Reviewed-on: https://go-review.googlesource.com/12990
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agospec: document existing expression switch restrictions
Robert Griesemer [Mon, 27 Jul 2015 20:30:16 +0000 (13:30 -0700)]
spec: document existing expression switch restrictions

The spec didn't specify several aspects of expression switches:

- The switch expression is evaluated exactly once.

- Switch expressions evaluating to an untyped value are converted
  to the respective default type before use.

- An (untyped) nil value is not permitted as expression switch
  value. (We could permit it relatively easily, but gc doesn't,
  and disallowing it is in symmetry with the rules for var decls
  without explicit type and untyped initializer expressions.)

- The comparison x == t between each case expression x and
  switch expression value t must be valid.

- (Some) duplicate constant case expressions are not permitted.

This change also clarifies the following issues:

 4524: mult. equal int const switch case values should be illegal
                                         -> spec issue fixed
 6398: switch w/ no value uses bool rather than untyped bool
                                         -> spec issue fixed
11578: allows duplicate switch cases     -> go/types bug
11667: int overflow in switch expression -> go/types bug
11668: use of untyped nil in switch      -> not a gc bug

Fixes #4524.
Fixes #6398.
Fixes #11668.

Change-Id: Iae4ab3e714575a5d11c92c9b8fbf027aa706b370
Reviewed-on: https://go-review.googlesource.com/12711
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agodoc: in go1.5.html fix claim about linking for ppc64(le)?
Rob Pike [Thu, 30 Jul 2015 05:53:10 +0000 (15:53 +1000)]
doc: in go1.5.html fix claim about linking for ppc64(le)?

Change-Id: If61c2063a8b63f0e3e498a5e86803b5ddba9fa3c
Reviewed-on: https://go-review.googlesource.com/12886
Reviewed-by: Austin Clements <austin@google.com>
9 years agoA+C: automated update
Brad Fitzpatrick [Thu, 30 Jul 2015 13:25:29 +0000 (15:25 +0200)]
A+C: automated update

Change-Id: Ie4431e74f095b85b4b5c07d087c3d29acf46d138
Reviewed-on: https://go-review.googlesource.com/12902
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoapi: update go1.5.txt
Brad Fitzpatrick [Thu, 30 Jul 2015 09:27:51 +0000 (11:27 +0200)]
api: update go1.5.txt

Fixes #11935

Change-Id: Ife00c246345f7d3f96aa95349a35e76671ca7160
Reviewed-on: https://go-review.googlesource.com/12769
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime/trace: report negative frequency as a time-ordering problem
Russ Cox [Thu, 30 Jul 2015 17:39:30 +0000 (13:39 -0400)]
runtime/trace: report negative frequency as a time-ordering problem

This should fix the solaris/amd64 builder.

Change-Id: Idd6460cc9e842f7b874c9757379986aa723c974c
Reviewed-on: https://go-review.googlesource.com/12922
Reviewed-by: Austin Clements <austin@google.com>
9 years agosyscall: use fchownat(2) in place of lchown(2) for linux/arm64
Dave Cheney [Wed, 29 Jul 2015 09:36:55 +0000 (19:36 +1000)]
syscall: use fchownat(2) in place of lchown(2) for linux/arm64

Fixes #11918

Replace calls to lchown(2) with fchownat(2) for linux/arm64 as the former is not suppored.

This change has also landed on the x/sys repo as CL 12837.

Change-Id: I58d4b144e051e36dd650ec9b7f3a02610ea943e5
Reviewed-on: https://go-review.googlesource.com/12833
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc: add go1.5 note about change to zero-sized fields in cgo
Ian Lance Taylor [Thu, 30 Jul 2015 16:01:22 +0000 (09:01 -0700)]
doc: add go1.5 note about change to zero-sized fields in cgo

This documents the change made in https://golang.org/cl/12864 for
https://golang.org/issue/11925.

Update #11925.

Change-Id: Id09f2a489ea947a725ed12c9cf793e5daef07a06
Reviewed-on: https://go-review.googlesource.com/12866
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agoruntime, sync/atomic: add memory barriers in arm cas routines
Russ Cox [Thu, 30 Jul 2015 19:55:49 +0000 (15:55 -0400)]
runtime, sync/atomic: add memory barriers in arm cas routines

This only triggers on ARMv7+.
If there are important SMP ARMv6 machines we can reconsider.

Makes TestLFStress tests pass and sync/atomic tests not time out
on Apple iPad Mini 3.

Fixes #7977.
Fixes #10189.

Change-Id: Ie424dea3765176a377d39746be9aa8265d11bec4
Reviewed-on: https://go-review.googlesource.com/12950
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agogo/types: update comment to refer to package go/constant
Robert Griesemer [Thu, 30 Jul 2015 19:59:49 +0000 (12:59 -0700)]
go/types: update comment to refer to package go/constant

For #11949.

Change-Id: I4329604a24efc7f40cf5bf52fb3c9e30916b3cc2
Reviewed-on: https://go-review.googlesource.com/12931
Reviewed-by: Alan Donovan <adonovan@google.com>
9 years agoencoding/json: revert "fix decoding of JSON null values"
Russ Cox [Thu, 30 Jul 2015 14:05:04 +0000 (14:05 +0000)]
encoding/json: revert "fix decoding of JSON null values"

Fixes #11912.
Fixes #11937.

This reverts commit 1a99ba55df902a2657d1ccfc52a60024c22dba98.

Change-Id: I32b76053fdabc59f28ca5bedf1b15c0baa8afae1
Reviewed-on: https://go-review.googlesource.com/12893
Reviewed-by: Didier Spezia <didier.06@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agoruntime/cgo: fix darwin/amd64 signal handling setup
Russ Cox [Thu, 30 Jul 2015 18:53:44 +0000 (14:53 -0400)]
runtime/cgo: fix darwin/amd64 signal handling setup

Was not allocating space for the frame above sigpanic,
nor was it pushing the LR into the right place.
Because traceback past sigpanic only needs the
LR for faulting leaves, this was not noticed too much.
But it did break the sync/atomic nil deref tests.

Change-Id: Icba53fffa193423aab744c37f21ee893ce2ee3ac
Reviewed-on: https://go-review.googlesource.com/12926
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/compile: add case for ODOTTYPE to escwalk
David Chase [Thu, 30 Jul 2015 16:31:18 +0000 (12:31 -0400)]
cmd/compile: add case for ODOTTYPE to escwalk

ODOTTYPE should be treated a whole lot like ODOT,
but it was missing completely from the switch in
escwalk and thus escape status did not propagate
to fields.

Since interfaces are required to trigger this bug,
the test was added to escape_iface.go.

Fixes #11931.

Change-Id: Id0383981cc4b1a160f6ad447192a112eed084538
Reviewed-on: https://go-review.googlesource.com/12921
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agosync/atomic: reenable TestNilDeref everywhere
Russ Cox [Thu, 30 Jul 2015 16:37:05 +0000 (12:37 -0400)]
sync/atomic: reenable TestNilDeref everywhere

There is absolutely no information about how this was failing.
If we reenable the test then at least we can get a build log from
darwin/arm.

There are not even freebsd/arm or netbsd/arm builders,
so not too worried about those. (That is another problem.)

Change-Id: I0e739a4dd2897adbe110aa400d720d8fa02ae65f
Reviewed-on: https://go-review.googlesource.com/12920
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: change arm software div/mod call sequence not to modify stack
Russ Cox [Thu, 30 Jul 2015 14:45:01 +0000 (10:45 -0400)]
runtime: change arm software div/mod call sequence not to modify stack

Instead of pushing the denominator argument on the stack,
the denominator is now passed in m.

This fixes a variety of bugs related to trying to take stack traces
backwards from the middle of the software div/mod routines.
Some of those bugs have been kludged around in the past,
but others have not. Instead of trying to patch up after breaking
the stack, this CL stops breaking the stack.

This is an update of https://golang.org/cl/19810043,
which was rolled back in https://golang.org/cl/20350043.

The problem in the original CL was that there were divisions
at bad times, when m was not available. These were divisions
by constant denominators, either in C code or in assembly.
The Go compiler knows how to generate division by multiplication
for constant denominators, but the C compiler did not.
There is no longer any C code, so that's taken care of.
There was one problematic DIV in runtime.usleep (assembly)
but https://golang.org/cl/12898 took care of that one.
So now this approach is safe.

Reject DIV/MOD in NOSPLIT functions to keep them from
coming back.

Fixes #6681.
Fixes #6699.
Fixes #10486.

Change-Id: I09a13c76ad08ba75b3bd5d46a3eb78e66a84ab38
Reviewed-on: https://go-review.googlesource.com/12899
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/cgo: discard trailing zero-sized fields in a non-empty C struct
Ian Lance Taylor [Thu, 30 Jul 2015 05:04:09 +0000 (22:04 -0700)]
cmd/cgo: discard trailing zero-sized fields in a non-empty C struct

In order to fix issue #9401 the compiler was changed to add a padding
byte to any non-empty Go struct that ends in a zero-sized field.  That
causes the Go version of such a C struct to have a different size than
the C struct, which can considerable confusion.  Change cgo so that it
discards any such zero-sized fields, so that the Go and C structs are
the same size.

This is a change from previous releases, in that it used to be
possible to refer to a zero-sized trailing field (by taking its
address), and with this change it no longer is.  That is unfortunate,
but something has to change.  It seems better to visibly break
programs that do this rather than to silently break programs that rely
on the struct sizes being the same.

Update #9401.
Fixes #11925.

Change-Id: I3fba3f02f11265b3c41d68616f79dedb05b81225
Reviewed-on: https://go-review.googlesource.com/12864
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: replace divide with multiply in runtime.usleep on arm
Russ Cox [Thu, 30 Jul 2015 14:54:53 +0000 (10:54 -0400)]
runtime: replace divide with multiply in runtime.usleep on arm

We want to adjust the DIV calling convention to use m,
and usleep can be called without an m, so switch to a
multiplication by the reciprocal (and test).

Step toward a fix for #6699 and #10486.

Change-Id: Iccf76a18432d835e48ec64a2fa34a0e4d6d4b955
Reviewed-on: https://go-review.googlesource.com/12898
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/internal/obj/arm: fix line numbers after constant pool
Russ Cox [Thu, 30 Jul 2015 14:28:44 +0000 (10:28 -0400)]
cmd/internal/obj/arm: fix line numbers after constant pool

If a function is large enough to need to flush the constant pool
mid-function, the line number assignment code was forcing the
line numbers not just for the constant pool but for all the instructions
that follow it. This made the line number information completely
wrong for all but the beginning of large functions on arm.

Same problem in code copied into arm64.

This broke runtime/trace's TestTraceSymbolize.

Fixes arm build.

Change-Id: I84d9fb2c798c4085f69b68dc766ab4800c7a6ca4
Reviewed-on: https://go-review.googlesource.com/12894
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

9 years agocrypto/x509: mark root_darwin_armx.go as cgo-only
Russ Cox [Thu, 30 Jul 2015 15:08:15 +0000 (11:08 -0400)]
crypto/x509: mark root_darwin_armx.go as cgo-only

This allows running a cross-compile like
GOOS=darwin GOARCH=arm go build std
to check that everything builds.

Otherwise there is a redefinition error because both
root_nocgo_darwin.go and root_darwin_armx.go
supply initSystemRoots.

Change-Id: Ic95976b2b698d28c629bfc93d8dac0048b023578
Reviewed-on: https://go-review.googlesource.com/12897
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agonet: allow longer timeout in dialClosedPort test on windows
Russ Cox [Thu, 30 Jul 2015 14:39:07 +0000 (10:39 -0400)]
net: allow longer timeout in dialClosedPort test on windows

The test expects the dial to take 1.0 seconds
on Windows and allows it to go to 1.095 seconds.
That's far too optimistic.
Recent failures are reporting roughly 1.2 seconds.
Let it have 1.5.

Change-Id: Id69811ccb65bf4b4c159301a2b4767deb6ee8d28
Reviewed-on: https://go-review.googlesource.com/12895
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agomath/rand: warn against using package for security-sensitive work
Andrey Petrov [Thu, 30 Jul 2015 09:47:01 +0000 (11:47 +0200)]
math/rand: warn against using package for security-sensitive work

Urge users of math/rand to consider using crypto/rand when doing
security-sensitive work.

Related to issue #11871. While we haven't reached consensus on how
to make the package inherently safer, everyone agrees that the docs
for math/rand can be improved.

Change-Id: I576a312e51b2a3445691da6b277c7b4717173197
Reviewed-on: https://go-review.googlesource.com/12900
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime/trace: test requires 'go tool addr2line'
David Crawshaw [Wed, 29 Jul 2015 23:56:10 +0000 (19:56 -0400)]
runtime/trace: test requires 'go tool addr2line'

For the android/arm builder.

Change-Id: Iad4881689223cd6479870da9541524a8cc458cce
Reviewed-on: https://go-review.googlesource.com/12859
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>

9 years agocmd/compile: fix uninitialized memory during type switch assertE2I2
Russ Cox [Thu, 30 Jul 2015 04:46:42 +0000 (00:46 -0400)]
cmd/compile: fix uninitialized memory during type switch assertE2I2

Fixes arm64 builder crash.

The bug is possible on all architectures; you just have to get lucky
and hit a preemption or a stack growth on entry to assertE2I2.
The test stacks the deck.

Change-Id: I8419da909b06249b1ad15830cbb64e386b6aa5f6
Reviewed-on: https://go-review.googlesource.com/12890
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime: enable TestEmptySlice
Russ Cox [Wed, 29 Jul 2015 23:05:07 +0000 (19:05 -0400)]
runtime: enable TestEmptySlice

It says to disable until #7564 is fixed. It was fixed in April 2014.

Change-Id: I9bebfe96802bafdd2d1a0a47591df346d91b000c
Reviewed-on: https://go-review.googlesource.com/12858
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: set invalidptr=1 by default, as documented go1.5beta3
Russ Cox [Wed, 29 Jul 2015 23:04:35 +0000 (19:04 -0400)]
runtime: set invalidptr=1 by default, as documented

Also make invalidptr control the recently added GC pointer check,
as documented.

Change-Id: Iccfdf49480219d12be8b33b8f03d8312d8ceabed
Reviewed-on: https://go-review.googlesource.com/12857
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agodoc: remove non-answer from FAQ
Andrew Gerrand [Wed, 29 Jul 2015 22:27:56 +0000 (08:27 +1000)]
doc: remove non-answer from FAQ

Change-Id: Ie43986d016e5a9fb17ca1393263932bbb56e81ff
Reviewed-on: https://go-review.googlesource.com/12836
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime/trace: remove existing Skips
Russ Cox [Tue, 28 Jul 2015 17:37:13 +0000 (13:37 -0400)]
runtime/trace: remove existing Skips

The skips added in CL 12579, based on incorrect time stamps,
should be sufficient to identify and exclude all the time-related
flakiness on these systems.

If there is other flakiness, we want to find out.

For #10512.

Change-Id: I5b588ac1585b2e9d1d18143520d2d51686b563e3
Reviewed-on: https://go-review.googlesource.com/12746
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime/trace: record event sequence numbers explicitly
Russ Cox [Thu, 23 Jul 2015 18:01:03 +0000 (14:01 -0400)]
runtime/trace: record event sequence numbers explicitly

Nearly all the flaky failures we've seen in trace tests have been
due to the use of time stamps to determine relative event ordering.
This is tricky for many reasons, including:
 - different cores might not have exactly synchronized clocks
 - VMs are worse than real hardware
 - non-x86 chips have different timer resolution than x86 chips
 - on fast systems two events can end up with the same time stamp

Stop trying to make time reliable. It's clearly not going to be for Go 1.5.
Instead, record an explicit event sequence number for ordering.
Using our own counter solves all of the above problems.

The trace still contains time stamps, of course. The sequence number
is just used for ordering.

Should alleviate #10554 somewhat. Then tickDiv can be chosen to
be a useful time unit instead of having to be exact for ordering.

Separating ordering and time stamps lets the trace parser diagnose
systems where the time stamp order and actual order do not match
for one reason or another. This CL adds that check to the end of
trace.Parse, after all other sequence order-based checking.
If that error is found, we skip the test instead of failing it.
Putting the check in trace.Parse means that cmd/trace will pick
up the same check, refusing to display a trace where the time stamps
do not match actual ordering.

Using net/http's BenchmarkClientServerParallel4 on various CPU counts,
not tracing vs tracing:

name                      old time/op    new time/op    delta
ClientServerParallel4       50.4µs ± 4%    80.2µs ± 4%  +59.06%        (p=0.000 n=10+10)
ClientServerParallel4-2     33.1µs ± 7%    57.8µs ± 5%  +74.53%        (p=0.000 n=10+10)
ClientServerParallel4-4     18.5µs ± 4%    32.6µs ± 3%  +75.77%        (p=0.000 n=10+10)
ClientServerParallel4-6     12.9µs ± 5%    24.4µs ± 2%  +89.33%        (p=0.000 n=10+10)
ClientServerParallel4-8     11.4µs ± 6%    21.0µs ± 3%  +83.40%        (p=0.000 n=10+10)
ClientServerParallel4-12    14.4µs ± 4%    23.8µs ± 4%  +65.67%        (p=0.000 n=10+10)

Fixes #10512.

Change-Id: I173eecf8191e86feefd728a5aad25bf1bc094b12
Reviewed-on: https://go-review.googlesource.com/12579
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime: ignore arguments in cgocallback_gofunc frame
Russ Cox [Wed, 29 Jul 2015 20:16:13 +0000 (16:16 -0400)]
runtime: ignore arguments in cgocallback_gofunc frame

Otherwise the GC may see uninitialized memory there,
which might be old pointers that are retained, or it might
trigger the invalid pointer check.

Fixes #11907.

Change-Id: I67e306384a68468eef45da1a8eb5c9df216a77c0
Reviewed-on: https://go-review.googlesource.com/12852
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime: fix darwin/amd64 assembly frame sizes
Russ Cox [Wed, 29 Jul 2015 22:25:30 +0000 (18:25 -0400)]
runtime: fix darwin/amd64 assembly frame sizes

Change-Id: I2f0ecdc02ce275feadf07e402b54f988513e9b49
Reviewed-on: https://go-review.googlesource.com/12855
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/internal/obj/arm64: fix build
Russ Cox [Wed, 29 Jul 2015 21:42:58 +0000 (17:42 -0400)]
cmd/internal/obj/arm64: fix build

Change-Id: I3088e17aff72096e3ec2ced49c70564627c982a6
Reviewed-on: https://go-review.googlesource.com/12854
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: reenable bad pointer check in GC
Russ Cox [Wed, 29 Jul 2015 19:18:56 +0000 (15:18 -0400)]
runtime: reenable bad pointer check in GC

The last time we tried this, linux/arm64 broke.
The series of CLs leading to this one fixes that problem.
Let's try again.

Fixes #9880.

Change-Id: I67bc1d959175ec972d4dcbe4aa6f153790f74251
Reviewed-on: https://go-review.googlesource.com/12849
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/internal/obj/arm64: reject misaligned stack frames, except empty frames
Russ Cox [Wed, 29 Jul 2015 19:15:03 +0000 (15:15 -0400)]
cmd/internal/obj/arm64: reject misaligned stack frames, except empty frames

The layout code has to date insisted on stack frames that are 16-aligned
including the saved LR, and it ensured this by growing the frame itself.
This breaks code that refers to values near the top of the frame by positive
offset from SP, and in general it's too magical: if you see TEXT xxx, $N,
you expect that the frame size is actually N, not sometimes N and sometimes N+8.

This led to a serious bug in the compiler where ambiguously live values
were not being zeroed correctly, which in turn triggered an assertion
in the GC about finding only valid pointers. The compiler has been
fixed to always emit aligned frames, and the hand-written assembly
has also been fixed.

Now that everything is aligned, make unaligned an error instead of
something to "fix" silently.

For #9880.

Change-Id: I05f01a9df174d64b37fa19b36a6b6c5f18d5ba2d
Reviewed-on: https://go-review.googlesource.com/12848
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/link: fix nosplit stack overflow checks
Russ Cox [Wed, 29 Jul 2015 19:07:35 +0000 (15:07 -0400)]
cmd/link: fix nosplit stack overflow checks

The nosplit stack overflow checks were confused about morestack.
The comment about not having correct SP information at the call
to morestack was true, but that was a real bug, not something to
work around. I fixed that problem in CL 12144. With that fixed,
no need to special-case morestack in the way done here.

This cleanup and simplification of the code was the first step
to fixing a bug that happened when I started working on the
arm64 frame size adjustments, but the cleanup was sufficient
to make the bug go away.

For #9880.

Change-Id: I16b69a5c16b6b8cb4090295d3029c42d606e3b9b
Reviewed-on: https://go-review.googlesource.com/12846
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime, reflect: use correctly aligned stack frame sizes on arm64
Russ Cox [Wed, 29 Jul 2015 19:04:30 +0000 (15:04 -0400)]
runtime, reflect: use correctly aligned stack frame sizes on arm64

arm64 requires either no stack frame or a frame with a size that is 8 mod 16
(adding the saved LR will make it 16-aligned).

The cmd/internal/obj/arm64 has been silently aligning frames, but it led to
a terrible bug when the compiler and obj disagreed on the frame size,
and it's just generally confusing, so we're going to make misaligned frames
an error instead of something that is silently changed.

This CL prepares by updating assembly files.
Note that the changes in this CL are already being done silently by
cmd/internal/obj/arm64, so there is no semantic effect here,
just a clarity effect.

For #9880.

Change-Id: Ibd6928dc5fdcd896c2bacd0291bf26b364591e28
Reviewed-on: https://go-review.googlesource.com/12845
Reviewed-by: Austin Clements <austin@google.com>