]> Cypherpunks repositories - gostls13.git/log
gostls13.git
9 years agoencoding/binary: update protobuf documentation link
Dmitry Savintsev [Mon, 29 Jun 2015 11:09:06 +0000 (13:09 +0200)]
encoding/binary: update protobuf documentation link

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

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

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

Add lots of tests.

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

Fixes #11422.
Fixes #10430.

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

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

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

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

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

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

Fixes #11418

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

Fixes #11417

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

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

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

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

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

Fixes #10747
Fixes #11396

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

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

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

Fixes #11126.

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

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

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

Fixes #11134.

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

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

Fixes #10406

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

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

Fixes windows build

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

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

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

Fixes #11136

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

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

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

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

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

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

We now have the following errors:

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

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

Fixes #11118
Fixes #11356

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

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

Manually tested with iostest.bash while builder is offline.

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

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

Fixes #10952

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

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

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

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

For #7764.

Change-Id: I8248efb851130620ef762a765ab8716af430572a
Reviewed-on: https://go-review.googlesource.com/9815
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: adjust TestFileLineInErrorMessages
Alex Brainman [Thu, 25 Jun 2015 04:12:48 +0000 (14:12 +1000)]
cmd/go: adjust TestFileLineInErrorMessages

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

Fixes #11355

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

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

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

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

Fixes #11338.

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

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

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

Update #11426

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

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

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

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

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

Fixes #11430.

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

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

Update #11426

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

These tests pass after cl/11417.

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

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

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

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

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

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

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

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

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

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

Fixes #10572

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

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

  func f() {}

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

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

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

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

Fixes #11309

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

Updates #8154

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

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

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

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

Fixes #11403.

Filed #11419 to merge them.

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

Includes a new net/http test too.

Fixes #11202

Change-Id: I61edc594f4de8eb6780b8dfa221269dd482e8f35
Reviewed-on: https://go-review.googlesource.com/11492
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http: don't overwrite Authorization headers when URL has username
Steve Streeting [Thu, 25 Jun 2015 15:52:51 +0000 (16:52 +0100)]
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>
9 years agonet/http: change default user agent string
Aamir Khan [Mon, 27 Apr 2015 13:31:12 +0000 (22:31 +0900)]
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>
9 years agonet/http: add comment to exported ErrNoCookie and ErrNoLocation values
Matt Layher [Sat, 13 Jun 2015 15:25:17 +0000 (11:25 -0400)]
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>
9 years agoreflect: test repeats with large scalar tails
Austin Clements [Wed, 24 Jun 2015 15:43:40 +0000 (11:43 -0400)]
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>
9 years agoreflect: test GC bits for slices
Austin Clements [Wed, 24 Jun 2015 15:25:28 +0000 (11:25 -0400)]
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>
9 years agonet/http: Fix test that occasionally fails
Todd Neal [Wed, 17 Jun 2015 14:31:08 +0000 (09:31 -0500)]
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>
9 years agodebug/elf: change R_ARM_REL32 to R_ARM_ABS32 in applyRelocationsARM
Ian Lance Taylor [Thu, 18 Jun 2015 01:28:50 +0000 (18:28 -0700)]
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>

9 years agocrypto/x509: don't panic when decrypting invalid PEM data.
Adam Langley [Sun, 14 Jun 2015 23:41:31 +0000 (16:41 -0700)]
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>
9 years agocrypto/ecdsa, crypto/x509: update SEC1 ECC link in comments
Dmitry Savintsev [Fri, 26 Jun 2015 10:09:45 +0000 (12:09 +0200)]
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>
9 years agocmd/compile: fix half multiply issue
Todd Neal [Tue, 23 Jun 2015 23:59:52 +0000 (18:59 -0500)]
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>
9 years agocmd/compile: add instrumentation of OKEY
Dmitry Vyukov [Wed, 24 Jun 2015 17:25:51 +0000 (19:25 +0200)]
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>
9 years agoarchive/tar: fix round-trip attributes
Vincent Batts [Wed, 4 Mar 2015 17:29:16 +0000 (12:29 -0500)]
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>
9 years agodoc: suggest security@golang.org for reporting security issues
Andrew Gerrand [Thu, 25 Jun 2015 22:46:30 +0000 (08:46 +1000)]
doc: suggest security@golang.org for reporting security issues

Fixes #11402

Change-Id: I195575a54e30ad6d6b1d0996fde34c0163bbd2c2
Reviewed-on: https://go-review.googlesource.com/11530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agodoc/go1.5.html: fix typo
Matt Layher [Fri, 26 Jun 2015 04:23:50 +0000 (00:23 -0400)]
doc/go1.5.html: fix typo

Change-Id: I193b416ac91b4fa9234d30a1c1c58b3f0a71f398
Reviewed-on: https://go-review.googlesource.com/11543
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years agoFix several out of date references to 4g/5g/6g/8g/9g.
Aaron Jacobs [Tue, 23 Jun 2015 23:50:12 +0000 (09:50 +1000)]
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>
9 years agospec: fix bare & in HTML
Rob Pike [Fri, 26 Jun 2015 01:11:45 +0000 (11:11 +1000)]
spec: fix bare & in HTML

No need to update the date; this is not a spec change.

Change-Id: I10a31234ed985c59e5d9b5328664a36661cef31e
Reviewed-on: https://go-review.googlesource.com/11531
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agomath: explain OEIS link
Andrew Gerrand [Thu, 25 Jun 2015 12:38:19 +0000 (22:38 +1000)]
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>
9 years agonet/http: tolerate old buggy user agents, per RFC 2616 section 4.1
Brad Fitzpatrick [Thu, 25 Jun 2015 09:31:37 +0000 (11:31 +0200)]
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>

9 years agomisc/cgo/testcshared: don't leave garbages after test
Mikio Hara [Thu, 25 Jun 2015 02:33:48 +0000 (11:33 +0900)]
misc/cgo/testcshared: don't leave garbages after test

Change-Id: I668b18b1e6901c59cf170e0c1cde9a3923c0cb13
Reviewed-on: https://go-review.googlesource.com/11472
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agodoc: first cut at prose for big changes in go1.5.html
Rob Pike [Thu, 25 Jun 2015 06:20:27 +0000 (16:20 +1000)]
doc: first cut at prose for big changes in go1.5.html

Change-Id: Ie2aba3d5069d88548414f7d76b9b6efb9acf0393
Reviewed-on: https://go-review.googlesource.com/11477
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime/race: fix test driver
Dmitry Vyukov [Wed, 24 Jun 2015 16:51:06 +0000 (18:51 +0200)]
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>
9 years agonet/http: bound the number of bytes read seeking EOF in Handler's Body.Close
Brad Fitzpatrick [Wed, 24 Jun 2015 09:53:24 +0000 (11:53 +0200)]
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>
9 years agodoc: add a missing space in func signature
Brad Fitzpatrick [Thu, 25 Jun 2015 03:33:51 +0000 (05:33 +0200)]
doc: add a missing space in func signature

Fixes #11383

Change-Id: I7ef0bb8b535ef513afdfcda19317ae4ff21f7166
Reviewed-on: https://go-review.googlesource.com/11490
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years agofmt: handle negative width/prec when supplied as an argument
Todd Neal [Wed, 24 Jun 2015 12:48:35 +0000 (07:48 -0500)]
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>

9 years agonet/http: sync Get and Head's documentation
Matthew Dempsky [Tue, 23 Jun 2015 18:36:57 +0000 (11:36 -0700)]
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>
9 years agodoc: move go1.5.txt to go1.5.html
Rob Pike [Thu, 25 Jun 2015 04:36:49 +0000 (14:36 +1000)]
doc: move go1.5.txt to go1.5.html

Just a copy, other than adding a header, preparatory to preparing the release notes.

Change-Id: Ia4dc27777b96b1e898d9873e7d38e6e795057698
Reviewed-on: https://go-review.googlesource.com/11474
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agonet/http: document that Hijack's net.Conn might have left-over timeouts set
Brad Fitzpatrick [Wed, 24 Jun 2015 10:11:58 +0000 (12:11 +0200)]
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>
9 years agocmd/compile/internal/gc: make sure nonzero-sized objects have nonzero alignment
Keith Randall [Wed, 24 Jun 2015 14:23:40 +0000 (07:23 -0700)]
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>
9 years agonet/http: don't always require certFile, keyFile in Server.ListenAndServerTLS
Brad Fitzpatrick [Wed, 24 Jun 2015 11:57:33 +0000 (13:57 +0200)]
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>
9 years agonet/http: document that FormValue returns the empty string
Brad Fitzpatrick [Wed, 24 Jun 2015 10:34:06 +0000 (12:34 +0200)]
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>
9 years agotext/template: make zero Template work again
Russ Cox [Wed, 24 Jun 2015 15:11:51 +0000 (11:11 -0400)]
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>
9 years agocmd/compile: handle copy in escape analysis
Russ Cox [Wed, 24 Jun 2015 21:31:57 +0000 (17:31 -0400)]
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>
9 years agoruntime: set m.procid always on Linux
Russ Cox [Mon, 22 Jun 2015 16:32:05 +0000 (12:32 -0400)]
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>
9 years agogo/format: fix //line corner case when formatting statements
Didier Spezia [Sat, 20 Jun 2015 11:25:59 +0000 (11:25 +0000)]
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>
9 years agoruntime/race: make test more robust
Dmitry Vyukov [Thu, 7 May 2015 09:33:45 +0000 (12:33 +0300)]
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>
9 years agonet/url: validate ports in URLs and bytes after IPv6 literals
Brad Fitzpatrick [Wed, 24 Jun 2015 14:50:49 +0000 (16:50 +0200)]
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>
9 years agonet: make LookupIP("1.2.3.4") behavior consistent
Russ Cox [Wed, 24 Jun 2015 12:39:44 +0000 (08:39 -0400)]
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>
9 years agotext/scanner: add runnable example for package
Carlos C [Thu, 18 Jun 2015 18:58:50 +0000 (20:58 +0200)]
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>
9 years agocmd/go: don't fetch from insecure repositories without -insecure
Andrew Gerrand [Tue, 5 May 2015 21:11:39 +0000 (07:11 +1000)]
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>
9 years agospec: clarify effect of rounding of constant expressions
Robert Griesemer [Tue, 23 Jun 2015 21:17:59 +0000 (14:17 -0700)]
spec: clarify effect of rounding of constant expressions

Not a language change.

Fixes #11350.

Change-Id: I9b905f17d1ef2722cab4bae38a037270165c7d95
Reviewed-on: https://go-review.googlesource.com/11369
Reviewed-by: Rob Pike <r@golang.org>
9 years agogo/types: in string(x) conversions, x must be of integer type
Robert Griesemer [Tue, 23 Jun 2015 21:01:45 +0000 (14:01 -0700)]
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>
9 years agogo/types: better error message for certain unary/binary expression errors
Robert Griesemer [Tue, 23 Jun 2015 20:59:18 +0000 (13:59 -0700)]
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>
9 years agoruntime: fix heap bitmap repeating with large scalar tails
Austin Clements [Tue, 23 Jun 2015 15:35:21 +0000 (11:35 -0400)]
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>
9 years agoruntime: document memory ordering for h_spans
Austin Clements [Tue, 23 Jun 2015 18:04:09 +0000 (14:04 -0400)]
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>
9 years agogo/types: add missing test for constant shifts
Robert Griesemer [Mon, 22 Jun 2015 23:01:17 +0000 (16:01 -0700)]
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>
9 years agocmd/asm: fix shifts again, this time for sure
Rob Pike [Mon, 22 Jun 2015 22:40:40 +0000 (08:40 +1000)]
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>
9 years agoimage/gif: set default loop count to 0 when app ext. is not present
Andrew Bonventre [Fri, 19 Jun 2015 17:29:58 +0000 (13:29 -0400)]
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>
9 years agotext/template: explain better the semantics of ParseFiles
Rob Pike [Tue, 23 Jun 2015 03:05:25 +0000 (13:05 +1000)]
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>
9 years agonet/http: Remove unused code
Todd Neal [Mon, 22 Jun 2015 13:31:38 +0000 (08:31 -0500)]
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>

9 years agocmd/doc: fix copy/paste error in test
Rob Pike [Sat, 20 Jun 2015 19:10:05 +0000 (05:10 +1000)]
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>
9 years agocmd/asm: fix handling of negative shifts.
Rob Pike [Mon, 22 Jun 2015 20:23:04 +0000 (06:23 +1000)]
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>
9 years agocmd/vet: refer info about -printfuncs to the -printf flag
Rob Pike [Mon, 22 Jun 2015 20:12:11 +0000 (06:12 +1000)]
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>
9 years agoruntime: remove race and increase precision in pointer validation.
Rick Hudson [Mon, 22 Jun 2015 18:05:00 +0000 (14:05 -0400)]
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>
9 years agonet/http: fix tests for recent URL.RawPath addition
Russ Cox [Mon, 22 Jun 2015 18:42:09 +0000 (14:42 -0400)]
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>
9 years agoruntime: one more Map{Bits,Spans} before arena_used update
Austin Clements [Mon, 22 Jun 2015 15:18:23 +0000 (11:18 -0400)]
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>
9 years agoruntime: document relaxed access to arena_used
Austin Clements [Fri, 19 Jun 2015 16:29:42 +0000 (12:29 -0400)]
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>
9 years agonet/url: add RawPath field, a hint at the desired encoding of Path
Russ Cox [Fri, 19 Jun 2015 21:04:56 +0000 (17:04 -0400)]
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>
9 years agocmd/go: fix test for issue 8181
Russ Cox [Fri, 19 Jun 2015 18:43:09 +0000 (14:43 -0400)]
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>
9 years agoencoding/csv: add examples for package
Carlos C [Thu, 18 Jun 2015 07:37:06 +0000 (09:37 +0200)]
encoding/csv: add examples for package

Change-Id: I3463826aa760aa5984dec4fc043b95fd2a5120ac
Reviewed-on: https://go-review.googlesource.com/11240
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/asm: remove needless check for negative right shift
Rob Pike [Mon, 22 Jun 2015 01:02:44 +0000 (18:02 -0700)]
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>
9 years agonet/textproto: skip zero-length keys
Jeff R. Allen [Thu, 18 Jun 2015 12:28:54 +0000 (14:28 +0200)]
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>
9 years agocmd/asm: remove pointless check for negative uint
Rob Pike [Sat, 20 Jun 2015 23:10:39 +0000 (09:10 +1000)]
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>
9 years agocmd/doc: add test for constructor, fix build
Rob Pike [Sat, 20 Jun 2015 10:28:46 +0000 (20:28 +1000)]
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>
9 years agosyscall: skip non-root user namespace test if kernel forbids
Ian Lance Taylor [Fri, 19 Jun 2015 20:48:06 +0000 (13:48 -0700)]
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>
9 years agocmd/doc: fix test on nacl
Rob Pike [Fri, 19 Jun 2015 22:12:10 +0000 (08:12 +1000)]
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>