]> Cypherpunks repositories - gostls13.git/log
gostls13.git
11 years agonet/http: don't reject 0-lengthed bodies with Expect 100-continue
Brad Fitzpatrick [Fri, 11 Apr 2014 05:25:31 +0000 (22:25 -0700)]
net/http: don't reject 0-lengthed bodies with Expect 100-continue

I was implementing rules from RFC 2616. The rules are apparently useless,
ambiguous, and too strict for common software on the Internet. (e.g. curl)

Add more tests, including a test of a chunked request.

Fixes #7625

LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=adg, golang-codereviews, rsc
https://golang.org/cl/84480045

11 years agoflag: remove extra space in error message
Rui Ueyama [Fri, 11 Apr 2014 05:15:55 +0000 (22:15 -0700)]
flag: remove extra space in error message

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/86420046

11 years agobufio: fix potential endless loop in ReadByte
Robert Griesemer [Fri, 11 Apr 2014 04:46:00 +0000 (21:46 -0700)]
bufio: fix potential endless loop in ReadByte

Also: Simplify ReadSlice implementation and
ensure that it doesn't call fill() with a full
buffer (this caused a failure in net/textproto
TestLargeReadMIMEHeader because fill() wasn't able
to read more data).

Fixes #7745.

LGTM=bradfitz
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/86590043

11 years agobytes, strings: more consistent error messages
Robert Griesemer [Fri, 11 Apr 2014 04:45:41 +0000 (21:45 -0700)]
bytes, strings: more consistent error messages

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/86060044

11 years agofmt: fix typo in help doc
Rui Ueyama [Fri, 11 Apr 2014 04:14:51 +0000 (21:14 -0700)]
fmt: fix typo in help doc

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/86600045

11 years agoexpvar: fix map key output
Rui Ueyama [Fri, 11 Apr 2014 04:14:04 +0000 (21:14 -0700)]
expvar: fix map key output

To create a valid JSON string, "%s" is not enough.
Fixes #7761.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/86730043

11 years agoruntime: make stack growth test shorter
Russ Cox [Fri, 11 Apr 2014 04:08:07 +0000 (00:08 -0400)]
runtime: make stack growth test shorter

It runs too long in -short mode.

Disable the one in init, because it doesn't respect -short.

Make the part that claims to test execution in a finalizer
actually execute the test in the finalizer.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=aram.h, golang-codereviews, iant, khr
https://golang.org/cl/86550045

11 years agonet/http: fix up Response.Write edge cases
Brad Fitzpatrick [Fri, 11 Apr 2014 00:12:31 +0000 (17:12 -0700)]
net/http: fix up Response.Write edge cases

The Go HTTP server doesn't use Response.Write, but others do,
so make it correct. Add a bunch more tests.

This bug is almost a year old. :/

Fixes #5381

LGTM=adg
R=golang-codereviews, adg
CC=dsymonds, golang-codereviews, rsc
https://golang.org/cl/85740046

11 years agonet/http: document, test, define, clean up Request.Trailer
Brad Fitzpatrick [Fri, 11 Apr 2014 00:01:21 +0000 (17:01 -0700)]
net/http: document, test, define, clean up Request.Trailer

Go's had pretty decent HTTP Trailer support for a long time, but
the docs have been largely non-existent. Fix that.

In the process, re-learn the Trailer code, clean some stuff
up, add some error checks, remove some TODOs, fix a minor bug
or two, and add tests.

LGTM=adg
R=golang-codereviews, adg
CC=dsymonds, golang-codereviews, rsc
https://golang.org/cl/86660043

11 years agodoc/go1.3.html: fix spelling mistakes
Rob Pike [Thu, 10 Apr 2014 22:52:16 +0000 (08:52 +1000)]
doc/go1.3.html: fix spelling mistakes
Keep those builders busy.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/85710046

11 years agobytes, strings: add Reader.ReadAt race tests
Brad Fitzpatrick [Thu, 10 Apr 2014 22:46:07 +0000 (15:46 -0700)]
bytes, strings: add Reader.ReadAt race tests

Tests for the race detector to catch anybody
trying to mutate Reader in ReadAt.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/86700043

11 years agodoc: finish net/http notes in go1.3.html
Brad Fitzpatrick [Thu, 10 Apr 2014 22:09:59 +0000 (15:09 -0700)]
doc: finish net/http notes in go1.3.html

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/86580043

11 years agonet/http: fix requests failing on short gzip body
Alexey Borzenkov [Thu, 10 Apr 2014 21:12:36 +0000 (14:12 -0700)]
net/http: fix requests failing on short gzip body

Fixes #7750.

LGTM=bradfitz
R=golang-codereviews, ibilicc, bradfitz
CC=golang-codereviews
https://golang.org/cl/84850043

11 years agoruntime: make times in GODEBUG=gctrace=1 output clearer
Russ Cox [Thu, 10 Apr 2014 18:34:48 +0000 (14:34 -0400)]
runtime: make times in GODEBUG=gctrace=1 output clearer

TBR=0intro
CC=golang-codereviews
https://golang.org/cl/86620043

11 years agocmd/6g: nacl: zero odd multiple of widthptr correctly
Keith Randall [Thu, 10 Apr 2014 14:59:46 +0000 (07:59 -0700)]
cmd/6g: nacl: zero odd multiple of widthptr correctly

LGTM=iant
R=remyoudompheng, iant
CC=golang-codereviews
https://golang.org/cl/86270043

11 years agosync: fix spurious wakeup from WaitGroup.Wait
Rui Ueyama [Thu, 10 Apr 2014 14:44:44 +0000 (18:44 +0400)]
sync: fix spurious wakeup from WaitGroup.Wait

There is a race condition that causes spurious wakeup from Wait
in the following case:

 G1: decrement wg.counter, observe the counter is now 0
     (should unblock goroutines queued *at this moment*)
 G2: increment wg.counter
 G2: call Wait() to add itself to the wait queue
 G1: acquire wg.m, unblock all waiting goroutines

In the last step G2 is spuriously woken up by G1.
Fixes #7734.

LGTM=rsc, dvyukov
R=dvyukov, 0xjnml, rsc
CC=golang-codereviews
https://golang.org/cl/85580043

11 years agonet/http: don't reuse Transport connection unless Request.Write finished
Brad Fitzpatrick [Thu, 10 Apr 2014 04:50:24 +0000 (21:50 -0700)]
net/http: don't reuse Transport connection unless Request.Write finished

In a typical HTTP request, the client writes the request, and
then the server replies. Go's HTTP client code (Transport) has
two goroutines per connection: one writing, and one reading. A
third goroutine (the one initiating the HTTP request)
coordinates with those two.

Because most HTTP requests are done when the server replies,
the Go code has always handled connection reuse purely in the
readLoop goroutine.

But if a client is writing a large request and the server
replies before it's consumed the entire request (e.g. it
replied with a 403 Forbidden and had no use for the body), it
was possible for Go to re-select that connection for a
subsequent request before we were done writing the first. That
wasn't actually a data race; the second HTTP request would
just get enqueued to write its request on the writeLoop. But
because the previous writeLoop didn't finish writing (and
might not ever), that connection is in a weird state. We
really just don't want to get into a state where we're
re-using a connection when the server spoke out of turn.

This CL changes the readLoop goroutine to verify that the
writeLoop finished before returning the connection.

In the process, it also fixes a potential goroutine leak where
a connection could close but the recycling logic could be
blocked forever waiting for the client to read to EOF or
error. Now it also selects on the persistConn's close channel,
and the closer of that is no longer the readLoop (which was
dead locking in some cases before). It's now closed at the
same place the underlying net.Conn is closed. This likely fixes
or helps Issue 7620.

Also addressed some small cosmetic things in the process.

Update #7620
Fixes #7569

LGTM=adg
R=golang-codereviews, adg
CC=dsymonds, golang-codereviews, rsc
https://golang.org/cl/86290043

11 years agoruntime: no longer skip stack growth test in short mode
David du Colombier [Thu, 10 Apr 2014 04:37:30 +0000 (06:37 +0200)]
runtime: no longer skip stack growth test in short mode

We originally decided to skip this test in short mode
to prevent the parallel runtime test to timeout on the
Plan 9 builder. This should no longer be required since
the issue was fixed in CL 86210043.

LGTM=dave, bradfitz
R=dvyukov, dave, bradfitz
CC=golang-codereviews, rsc
https://golang.org/cl/84790044

11 years agoruntime: fix semasleep on Plan 9
David du Colombier [Thu, 10 Apr 2014 04:36:20 +0000 (06:36 +0200)]
runtime: fix semasleep on Plan 9

If you pass ns = 100,000 to this function, timediv will
return ms = 0. tsemacquire in /sys/src/9/port/sysproc.c
will return immediately when ms == 0 and the semaphore
cannot be acquired immediately - it doesn't sleep - so
notetsleep will spin, chewing cpu and repeatedly reading
the time, until the 100us have passed.

Thanks to the time reads it won't take too many iterations,
but whatever we are waiting for does not get a chance to
run. Eventually the notetsleep spin loop returns and we
end up in the stoptheworld spin loop - actually a sleep
loop but we're not doing a good job of sleeping.

After 100ms or so of this, the kernel says enough and
schedules a different thread. That thread manages to do
whatever we're waiting for, and the spinning in the other
thread stops. If tsemacquire had actually slept, this
would have happened much quicker.

Many thanks to Russ Cox for help debugging.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/86210043

11 years agodoc/go1.3.html: minor changes: crypto, net
Rob Pike [Thu, 10 Apr 2014 04:17:48 +0000 (14:17 +1000)]
doc/go1.3.html: minor changes: crypto, net
All that's left is net/http and the stuff I need help describing: FreeBSD and Windows.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/86320043

11 years agocmd/go: always build package during "go test" command
Alex Brainman [Thu, 10 Apr 2014 04:02:24 +0000 (14:02 +1000)]
cmd/go: always build package during "go test" command

even when there are no *_test.go files present.
rsc suggested this change

Fixes #7108

LGTM=r, adg
R=golang-codereviews, r, adg
CC=golang-codereviews
https://golang.org/cl/84300043

11 years agosyscall: fix Getfsstat() for BSD
Preetam Jinka [Thu, 10 Apr 2014 03:58:03 +0000 (13:58 +1000)]
syscall: fix Getfsstat() for BSD

The buffer length should be the size in bytes
instead of the number of structs.

Fixes #6588.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh, adg
CC=golang-codereviews
https://golang.org/cl/84830043

11 years agoA+C: Preetam Jinka (individual CLA)
Andrew Gerrand [Thu, 10 Apr 2014 03:33:32 +0000 (13:33 +1000)]
A+C: Preetam Jinka (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/85550044

11 years agoundo CL 86220044 / 41388e58be65
Robert Griesemer [Thu, 10 Apr 2014 01:23:53 +0000 (18:23 -0700)]
undo CL 86220044 / 41388e58be65

bufio: undo incorrect bug fix

««« original CL description
bufio: fix potential endless loop in ReadByte

Fixes #7745.

LGTM=bradfitz, r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/86220044
»»»

LGTM=adg
R=r, adg
CC=golang-codereviews
https://golang.org/cl/85550045

11 years agobufio: fix potential endless loop in ReadByte
Robert Griesemer [Thu, 10 Apr 2014 00:53:09 +0000 (17:53 -0700)]
bufio: fix potential endless loop in ReadByte

Fixes #7745.

LGTM=bradfitz, r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/86220044

11 years agobufio: fix UnreadByte
Robert Griesemer [Wed, 9 Apr 2014 21:19:13 +0000 (14:19 -0700)]
bufio: fix UnreadByte

Also:
- fix error messages in tests
- make tests more symmetric

Fixes #7607.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/86180043

11 years agosync.Pool: better documentation
Rob Pike [Wed, 9 Apr 2014 19:45:18 +0000 (05:45 +1000)]
sync.Pool: better documentation
Explain what its purpose is and give examples of good and bad use.
Fixes #7167.

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/85880044

11 years agocmd/6g: relax constraint on variables that need zeroing.
Rémy Oudompheng [Wed, 9 Apr 2014 19:23:36 +0000 (21:23 +0200)]
cmd/6g: relax constraint on variables that need zeroing.

On amd64p32 pointers are 32-bit-aligned and cannot be assumed to
have an offset multiple of widthreg. Instead check that they are
withptr-aligned.

Also change the threshold for region merging to 2*widthreg
instead of 2*widthptr because performance on amd64 and amd64p32
is expected to be the same.

Fixes #7712.

LGTM=khr
R=rsc, dave, khr, brad, bradfitz
CC=golang-codereviews
https://golang.org/cl/84690044

11 years agomisc/emacs: ignore backquote in comment or string
Rui Ueyama [Wed, 9 Apr 2014 16:28:27 +0000 (12:28 -0400)]
misc/emacs: ignore backquote in comment or string

go-mode on Emacs 23 wrongly recognizes a backquote in a comment or
a string as a start of a raw string literal. Below is an example
that go-mode does not work well. This patch is to fix that issue.

  // `
  var x = 1
  // `

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef, adonovan
CC=golang-codereviews
https://golang.org/cl/84900043

11 years agoruntime: use 3x fewer nanotime calls in garbage collection
Russ Cox [Wed, 9 Apr 2014 14:38:12 +0000 (10:38 -0400)]
runtime: use 3x fewer nanotime calls in garbage collection

Cuts the number of calls from 6 to 2 in the non-debug case.

LGTM=iant
R=golang-codereviews, iant
CC=0intro, aram, golang-codereviews, khr
https://golang.org/cl/86040043

11 years agodoc: tweak Solaris wording
Russ Cox [Wed, 9 Apr 2014 14:08:35 +0000 (10:08 -0400)]
doc: tweak Solaris wording

Suggested in comments on CL 85740043.

LGTM=aram
R=golang-codereviews, aram
CC=dave, golang-codereviews, r
https://golang.org/cl/85990044

11 years agoruntime: fix flaky linux/386 build
Russ Cox [Wed, 9 Apr 2014 14:02:55 +0000 (10:02 -0400)]
runtime: fix flaky linux/386 build

TBR=iant
CC=golang-codereviews
https://golang.org/cl/86030043

11 years agocmd/gc: drop { } around single-line if-statement body
Jan Ziak [Wed, 9 Apr 2014 13:39:28 +0000 (15:39 +0200)]
cmd/gc: drop { } around single-line if-statement body

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/85890043

11 years agocmd/gc: avoid confusing error message "ovf in mpaddxx"
Jan Ziak [Wed, 9 Apr 2014 06:36:27 +0000 (08:36 +0200)]
cmd/gc: avoid confusing error message "ovf in mpaddxx"

Fixes #6889

LGTM=rsc
R=gri, rsc
CC=golang-codereviews
https://golang.org/cl/85080044

11 years agocmd/gc: ignore blank (_) labels in label declarations
Jan Ziak [Wed, 9 Apr 2014 06:34:17 +0000 (08:34 +0200)]
cmd/gc: ignore blank (_) labels in label declarations

Fixes #7538

LGTM=rsc
R=gri, rsc
CC=golang-codereviews
https://golang.org/cl/85040045

11 years agohtml/template: fix two unrelated bugs
Rob Pike [Wed, 9 Apr 2014 05:57:50 +0000 (15:57 +1000)]
html/template: fix two unrelated bugs
1) The code to catch an exception marked the template as escaped
when it was not yet, which caused subsequent executions of the
template to not escape properly.
2) ensurePipelineContains needs to handled Field as well as
Identifier nodes.

Fixes #7379.

LGTM=mikesamuel
R=mikesamuel
CC=golang-codereviews
https://golang.org/cl/85240043

11 years agodoc/go1.3.html: go command, major library changes
Rob Pike [Wed, 9 Apr 2014 05:20:00 +0000 (15:20 +1000)]
doc/go1.3.html: go command, major library changes

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/85840043

11 years agoruntime: fix GOTRACEBACK on Plan 9
David du Colombier [Wed, 9 Apr 2014 04:41:14 +0000 (06:41 +0200)]
runtime: fix GOTRACEBACK on Plan 9

Getenv() should not call malloc when called from
gotraceback(). Instead, we return a static buffer
in this case, with enough room to hold the longest
value.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/85680043

11 years agodoc/go1.3.html: gc precision, nacl, solaris
Rob Pike [Wed, 9 Apr 2014 02:47:35 +0000 (12:47 +1000)]
doc/go1.3.html: gc precision, nacl, solaris

LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/85740043

11 years agodoc: add a couple net/http go1.3 items
Brad Fitzpatrick [Wed, 9 Apr 2014 02:46:33 +0000 (19:46 -0700)]
doc: add a couple net/http go1.3 items

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/85760043

11 years agoruntime: cache gotraceback setting
Russ Cox [Wed, 9 Apr 2014 02:35:41 +0000 (22:35 -0400)]
runtime: cache gotraceback setting

On Plan 9 gotraceback calls getenv calls malloc, and we gotraceback
on every call to gentraceback, which happens during garbage collection.
Honestly I don't even know how this works on Plan 9.
I suspect it does not, and that we are getting by because
no one has tried to run with $GOTRACEBACK set at all.

This will speed up all the other systems by epsilon, since they
won't call getenv and atoi repeatedly.

LGTM=bradfitz
R=golang-codereviews, bradfitz, 0intro
CC=golang-codereviews
https://golang.org/cl/85430046

11 years agocmd/go: allow use of Context in 'go list -f'
Rick Arnold [Wed, 9 Apr 2014 02:35:29 +0000 (22:35 -0400)]
cmd/go: allow use of Context in 'go list -f'

Add a $Context variable to the template so that the build.Context values
such as BuildTags can be accessed.

Fixes #6666.

LGTM=adg, rsc
R=golang-codereviews, gobot, adg, rsc
CC=golang-codereviews
https://golang.org/cl/72770043

11 years agoreflect: fix variadic arg for funcs created by MakeFunc.
Carl Chatfield [Wed, 9 Apr 2014 02:35:23 +0000 (22:35 -0400)]
reflect: fix variadic arg for funcs created by MakeFunc.

Short circuit for calling values funcs by MakeFunc was placed
before variadic arg rearrangement code in reflect.call.
Fixes #7534.

LGTM=khr
R=golang-codereviews, bradfitz, khr, rsc
CC=golang-codereviews
https://golang.org/cl/75370043

11 years agoA+C: Carl Chatfield (individual CLA)
Russ Cox [Wed, 9 Apr 2014 02:35:15 +0000 (22:35 -0400)]
A+C: Carl Chatfield (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/85820043

11 years agodoc/go1.3.html: gccgo status
Rob Pike [Tue, 8 Apr 2014 23:45:39 +0000 (09:45 +1000)]
doc/go1.3.html: gccgo status

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/85720043

11 years agocrypto/(ec)dsa: use Fermat's inversion.
Adam Langley [Tue, 8 Apr 2014 23:32:48 +0000 (16:32 -0700)]
crypto/(ec)dsa: use Fermat's inversion.

Now that we have a constant-time P-256 implementation, it's worth
paying more attention elsewhere.

The inversion of k in (EC)DSA was using Euclid's algorithm which isn't
constant-time. This change switches to Fermat's algorithm, which is
much better. However, it's important to note that math/big itself isn't
constant time and is using a 4-bit window for exponentiation with
variable memory access patterns.

(Since math/big depends quite deeply on its values being in minimal (as
opposed to fixed-length) represetation, perhaps crypto/elliptic should
grow a constant-time implementation of exponentiation in the scalar
field.)

R=bradfitz
Fixes #7652.

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/82740043

11 years agodoc/go1.3.html: linker, go command, miscellany
Rob Pike [Tue, 8 Apr 2014 22:19:35 +0000 (08:19 +1000)]
doc/go1.3.html: linker, go command, miscellany

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/85660043

11 years agodoc/go1.3.html: Performance, plus some library details
Rob Pike [Tue, 8 Apr 2014 21:12:20 +0000 (07:12 +1000)]
doc/go1.3.html: Performance, plus some library details

LGTM=dvyukov, iant, rsc
R=golang-codereviews, dvyukov, iant, rsc
CC=golang-codereviews
https://golang.org/cl/85250043

11 years agogo/doc: fix URL matched in ToHTML
Robert Griesemer [Tue, 8 Apr 2014 20:51:44 +0000 (13:51 -0700)]
go/doc: fix URL matched in ToHTML

Permit paired parentheses in URLs such as:

http://en.wikipedia.org/wiki/Camellia_(cipher)

Fixes #5043.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/85610043

11 years agoencoding/xml: unmarshal into interfaces
Josh Bleecher Snyder [Tue, 8 Apr 2014 18:55:12 +0000 (14:55 -0400)]
encoding/xml: unmarshal into interfaces

Fixes #6836.

LGTM=rsc
R=golang-codereviews, rsc, r, mike
CC=golang-codereviews
https://golang.org/cl/33140043

11 years agoencoding/xml: Makes XML Marshaler take into account XMLName field from anonymous...
Alexander Zhavnerchik [Tue, 8 Apr 2014 15:12:51 +0000 (11:12 -0400)]
encoding/xml: Makes XML Marshaler take into account XMLName field from anonymous field

Fixes #7614.

LGTM=rsc
R=golang-codereviews, r, rsc, dan.kortschak, applezinc
CC=golang-codereviews
https://golang.org/cl/79210044

11 years agoA+C: Alexander Zhavnerchik (individual CLA)
Russ Cox [Tue, 8 Apr 2014 15:12:46 +0000 (11:12 -0400)]
A+C: Alexander Zhavnerchik (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/85490043

11 years agoreflect, runtime: fix crash in GC due to reflect.call + precise GC
Russ Cox [Tue, 8 Apr 2014 15:11:35 +0000 (11:11 -0400)]
reflect, runtime: fix crash in GC due to reflect.call + precise GC

Given
        type Outer struct {
                *Inner
                ...
        }
the compiler generates the implementation of (*Outer).M dispatching to
the embedded Inner. The implementation is logically:
        func (p *Outer) M() {
                (p.Inner).M()
        }
but since the only change here is the replacement of one pointer
receiver with another, the actual generated code overwrites the
original receiver with the p.Inner pointer and then jumps to the M
method expecting the *Inner receiver.

During reflect.Value.Call, we create an argument frame and the
associated data structures to describe it to the garbage collector,
populate the frame, call reflect.call to run a function call using
that frame, and then copy the results back out of the frame. The
reflect.call function does a memmove of the frame structure onto the
stack (to set up the inputs), runs the call, and the memmoves the
stack back to the frame structure (to preserve the outputs).

Originally reflect.call did not distinguish inputs from outputs: both
memmoves were for the full stack frame. However, in the case where the
called function was one of these wrappers, the rewritten receiver is
almost certainly a different type than the original receiver. This is
not a problem on the stack, where we use the program counter to
determine the type information and understand that during (*Outer).M
the receiver is an *Outer while during (*Inner).M the receiver in the
same memory word is now an *Inner. But in the statically typed
argument frame created by reflect, the receiver is always an *Outer.
Copying the modified receiver pointer off the stack into the frame
will store an *Inner there, and then if a garbage collection happens
to scan that argument frame before it is discarded, it will scan the
*Inner memory as if it were an *Outer. If the two have different
memory layouts, the collection will intepret the memory incorrectly.

Fix by only copying back the results.

Fixes #7725.

LGTM=khr
R=khr
CC=dave, golang-codereviews
https://golang.org/cl/85180043

11 years agoruntime/race: more precise handling of channel synchronization
Dmitriy Vyukov [Tue, 8 Apr 2014 06:18:20 +0000 (10:18 +0400)]
runtime/race: more precise handling of channel synchronization
It turns out there is a relatively common pattern that relies on
inverted channel semaphore:

gate := make(chan bool, N)
for ... {
        // limit concurrency
        gate <- true
        go func() {
                foo(...)
                <-gate
        }()
}
// join all goroutines
for i := 0; i < N; i++ {
        gate <- true
}

So handle synchronization on inverted semaphores with cap>1.
Fixes #7718.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/84880046

11 years agoliblink: remove code that is never executed
Ian Lance Taylor [Tue, 8 Apr 2014 05:12:26 +0000 (22:12 -0700)]
liblink: remove code that is never executed

This code tests linkmode == LinkExternal but is only invoked
by the compiler/assembler, not the linker.

Update #7164

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/85080043

11 years agodoc/go1.3.html: drop support for windows 2000
Rob Pike [Tue, 8 Apr 2014 04:07:17 +0000 (14:07 +1000)]
doc/go1.3.html: drop support for windows 2000

LGTM=bradfitz, alex.brainman
R=golang-codereviews, bradfitz, alex.brainman
CC=golang-codereviews
https://golang.org/cl/85190043

11 years agoruntime: make sure associated defers are copyable before trying to copy a stack.
Keith Randall [Tue, 8 Apr 2014 00:40:00 +0000 (17:40 -0700)]
runtime: make sure associated defers are copyable before trying to copy a stack.

Defers generated from cgo lie to us about their argument layout.
Mark those defers as not copyable.

CL 83820043 contains an additional test for this code and should be
checked in (and enabled) after this change is in.

Fixes bug 7695.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/84740043

11 years agoruntime: fix heapdump bugs.
Keith Randall [Tue, 8 Apr 2014 00:35:44 +0000 (17:35 -0700)]
runtime: fix heapdump bugs.

Iterate the right number of times in arrays and channels.
Handle channels with zero-sized objects in them.
Output longer type names if we have them.
Compute argument offset correctly.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/82980043

11 years agonet: move error messages related to OpError into net.go
Mikio Hara [Mon, 7 Apr 2014 21:14:49 +0000 (06:14 +0900)]
net: move error messages related to OpError into net.go

Also makes ErrWriteToConnected more appropriate; it's used
not only UDPConn operations but UnixConn operations.

Update #4856

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84800044

11 years agonet: remove "net:" prefix from error messages
Mikio Hara [Mon, 7 Apr 2014 21:14:19 +0000 (06:14 +0900)]
net: remove "net:" prefix from error messages

The prefix was not uniformly applied and is probably better
left off for using with OpError.

Update #4856

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84660046

11 years agocmd/go: Check error from SWIG link step.
Albert Strasheim [Mon, 7 Apr 2014 19:59:55 +0000 (12:59 -0700)]
cmd/go: Check error from SWIG link step.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/85070043

11 years agonet/textproto: simplify common header interning
Brad Fitzpatrick [Mon, 7 Apr 2014 17:39:24 +0000 (10:39 -0700)]
net/textproto: simplify common header interning

Takes advantage of CL 83740044, to optimize map[string] lookup
from []byte key.

Deletes code.

No conditional check for gccgo, since Ian plans to add this
to gccgo before GCC 4.10 (Go 1.3).

benchmark                   old ns/op     new ns/op     delta
BenchmarkReadMIMEHeader     6066          5086          -16.16%

benchmark                   old allocs     new allocs     delta
BenchmarkReadMIMEHeader     12             12             +0.00%

benchmark                   old bytes     new bytes     delta
BenchmarkReadMIMEHeader     1317          1317          +0.00%

Update #3512

LGTM=rsc
R=rsc, dave
CC=golang-codereviews, iant
https://golang.org/cl/84230043

11 years agolibbio, libmach: warnings from the Plan 9 tool chain
Lucio De Re [Mon, 7 Apr 2014 15:40:13 +0000 (08:40 -0700)]
libbio, libmach: warnings from the Plan 9 tool chain

Superficial inconsistencies that trigger warnings in
Plan 9.  Small enough to be considered trivial and
seemingly benign outside of the Plan 9 environment.

LGTM=iant
R=golang-codereviews, 0intro, iant
CC=golang-codereviews
https://golang.org/cl/73460043

11 years agonet: fix data race in benchmark
Dmitriy Vyukov [Mon, 7 Apr 2014 07:00:07 +0000 (11:00 +0400)]
net: fix data race in benchmark
If an error happens on a connection, server goroutine can call b.Logf
after benchmark finishes.
So join both client and server goroutines.
Update #7718

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/84750047

11 years agoA+C: StalkR (individual CLA)
Brad Fitzpatrick [Mon, 7 Apr 2014 03:23:45 +0000 (20:23 -0700)]
A+C: StalkR (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/84710045

11 years agobuild: remove depdenency on GNU make
Andrew Gerrand [Mon, 7 Apr 2014 01:34:35 +0000 (11:34 +1000)]
build: remove depdenency on GNU make

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/84920043

11 years agocmd/8g: fix liveness for 387 build (including plan9)
Russ Cox [Sun, 6 Apr 2014 14:30:02 +0000 (10:30 -0400)]
cmd/8g: fix liveness for 387 build (including plan9)

TBR=khr
CC=golang-codereviews
https://golang.org/cl/84570045

11 years agosyscall: use unsafe.Pointer instead of uintptr on windows when possible
Alex Brainman [Sun, 6 Apr 2014 02:18:01 +0000 (12:18 +1000)]
syscall: use unsafe.Pointer instead of uintptr on windows when possible

Fixes #7171

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84330043

11 years agocmd/gc: compute size of keys & values before making map bucket
Keith Randall [Fri, 4 Apr 2014 19:58:19 +0000 (12:58 -0700)]
cmd/gc: compute size of keys & values before making map bucket

Fixes #7547

LGTM=iant
R=iant, khr
CC=golang-codereviews
https://golang.org/cl/84470046

11 years agoruntime: fix plan9 warning.
Keith Randall [Fri, 4 Apr 2014 15:15:27 +0000 (08:15 -0700)]
runtime: fix plan9 warning.

I have no idea what this code is for, but it pretty
clearly needs to be uint64, not uint32.

LGTM=aram
R=0intro, aram
CC=golang-codereviews
https://golang.org/cl/84410043

11 years agocmd/gc: check duplicate keys in maps with interface{} key type
Jan Ziak [Fri, 4 Apr 2014 14:46:23 +0000 (16:46 +0200)]
cmd/gc: check duplicate keys in maps with interface{} key type

Fixes #7214

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews, minux.ma
https://golang.org/cl/82080044

11 years agocmd/6g, cmd/8g: disable Duff's device on NaCl.
Rémy Oudompheng [Fri, 4 Apr 2014 06:42:35 +0000 (08:42 +0200)]
cmd/6g, cmd/8g: disable Duff's device on NaCl.

Native Client forbids jumps/calls to arbitrary locations and
enforces a particular alignement, which makes the Duff's device
ineffective.

LGTM=khr
R=rsc, dave, khr
CC=golang-codereviews
https://golang.org/cl/84400043

11 years agonet: fix format string in TestAcceptIgnoreSomeErrors
Alex Brainman [Fri, 4 Apr 2014 06:36:01 +0000 (17:36 +1100)]
net: fix format string in TestAcceptIgnoreSomeErrors

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/84340043

11 years agoos/exec: always try appropriate command extensions during Cmd.Start on windows
Alex Brainman [Fri, 4 Apr 2014 05:26:15 +0000 (16:26 +1100)]
os/exec: always try appropriate command extensions during Cmd.Start on windows

Update #7362
Fixes #7377
Fixes #7570

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/83020043

11 years agonet: drop unnecessary indirection from PacketConn tests
Mikio Hara [Fri, 4 Apr 2014 02:45:53 +0000 (11:45 +0900)]
net: drop unnecessary indirection from PacketConn tests

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/83880043

11 years agocmd/gc: fix build
Mikio Hara [Fri, 4 Apr 2014 00:55:19 +0000 (09:55 +0900)]
cmd/gc: fix build

LGTM=minux.ma
R=rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/84260043

11 years agocmd/gc, runtime: make GODEBUG=gcdead=1 mode work with liveness
Russ Cox [Fri, 4 Apr 2014 00:33:25 +0000 (20:33 -0400)]
cmd/gc, runtime: make GODEBUG=gcdead=1 mode work with liveness

Trying to make GODEBUG=gcdead=1 work with liveness
and in particular ambiguously live variables.

1. In the liveness computation, mark all ambiguously live
variables as live for the entire function, except the entry.
They are zeroed directly after entry, and we need them not
to be poisoned thereafter.

2. In the liveness computation, compute liveness (and deadness)
for all parameters, not just pointer-containing parameters.
Otherwise gcdead poisons untracked scalar parameters and results.

3. Fix liveness debugging print for -live=2 to use correct bitmaps.
(Was not updated for compaction during compaction CL.)

4. Correct varkill during map literal initialization.
Was killing the map itself instead of the inserted value temp.

5. Disable aggressive varkill cleanup for call arguments if
the call appears in a defer or go statement.

6. In the garbage collector, avoid bug scanning empty
strings. An empty string is two zeros. The multiword
code only looked at the first zero and then interpreted
the next two bits in the bitmap as an ordinary word bitmap.
For a string the bits are 11 00, so if a live string was zero
length with a 0 base pointer, the poisoning code treated
the length as an ordinary word with code 00, meaning it
needed poisoning, turning the string into a poison-length
string with base pointer 0. By the same logic I believe that
a live nil slice (bits 11 01 00) will have its cap poisoned.
Always scan full multiword struct.

7. In the runtime, treat both poison words (PoisonGC and
PoisonStack) as invalid pointers that warrant crashes.

Manual testing as follows:

- Create a script called gcdead on your PATH containing:

        #!/bin/bash
        GODEBUG=gcdead=1 GOGC=10 GOTRACEBACK=2 exec "$@"
- Now you can build a test and then run 'gcdead ./foo.test'.
- More importantly, you can run 'go test -short -exec gcdead std'
   to run all the tests.

Fixes #7676.

While here, enable the precise scanning of slices, since that was
disabled due to bugs like these. That now works, both with and
without gcdead.

Fixes #7549.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/83410044

11 years agonet: don't export netFD closeRead and closeWrite methods
Mikio Hara [Fri, 4 Apr 2014 00:07:44 +0000 (09:07 +0900)]
net: don't export netFD closeRead and closeWrite methods

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/83910043

11 years agocmd/dist: reflect local changes to tree in goversion
Mike Andrews [Thu, 3 Apr 2014 23:31:41 +0000 (16:31 -0700)]
cmd/dist: reflect local changes to tree in goversion

runtime.Version() requires a trailing "+" when
tree had local modifications at time of build.

Fixes #7701

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84040045

11 years agoruntime: test malformed address fault and fix on OS X
Russ Cox [Thu, 3 Apr 2014 23:07:33 +0000 (19:07 -0400)]
runtime: test malformed address fault and fix on OS X

The garbage collector poison pointers
(0x6969696969696969 and 0x6868686868686868)
are malformed addresses on amd64.
That is, they are not 48-bit addresses sign extended
to 64 bits. This causes a different kind of hardware fault
than the usual 'unmapped page' when accessing such
an address, and OS X 10.9.2 sends the resulting SIGSEGV
incorrectly, making it look like it was user-generated
rather than kernel-generated and does not include the
faulting address. This means that in GODEBUG=gcdead=1
mode, if there is a bug and something tries to dereference
a poisoned pointer, the runtime delivers the SIGSEGV to
os/signal and returns to the faulting code, which faults
again, causing the process to hang instead of crashing.

Fix by rewriting "user-generated" SIGSEGV on OS X to
look like a kernel-generated SIGSEGV with fault address
0xb01dfacedebac1e.

I chose that address because (1) when printed in hex
during a crash, it is obviously spelling out English text,
(2) there are no current Google hits for that pointer,
which will make its origin easy to find once this CL
is indexed, and (3) it is not an altogether inaccurate
description of the situation.

Add a test. Maybe other systems will break too.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, iant, ken
https://golang.org/cl/83270049

11 years agoruntime: handle fault during runtime more like unexpected fault address
Russ Cox [Thu, 3 Apr 2014 23:05:59 +0000 (19:05 -0400)]
runtime: handle fault during runtime more like unexpected fault address

Delaying the runtime.throw until here will print more information.
In particular it will print the signal and code values, which means
it will show the fault address.

The canpanic checks were added recently, in CL 75320043.
They were just not added in exactly the right place.

LGTM=iant
R=dvyukov, iant
CC=golang-codereviews
https://golang.org/cl/83980043

11 years agocmd/gc, runtime: optimize map[string] lookup from []byte key
Russ Cox [Thu, 3 Apr 2014 23:05:17 +0000 (19:05 -0400)]
cmd/gc, runtime: optimize map[string] lookup from []byte key

Brad has been asking for this for a while.
I have resisted because I wanted to find a more general way to
do this, one that would keep the performance of code introducing
variables the same as the performance of code that did not.
(See golang.org/issue/3512#c20).

I have not found the more general way, and recent changes to
remove ambiguously live temporaries have blown away the
property I was trying to preserve, so that's no longer a reason
not to make the change.

Fixes #3512.

LGTM=iant
R=iant
CC=bradfitz, golang-codereviews, khr, r
https://golang.org/cl/83740044

11 years agoruntime: use mincore correctly in addrspace_free
Russ Cox [Thu, 3 Apr 2014 23:04:47 +0000 (19:04 -0400)]
runtime: use mincore correctly in addrspace_free

Fixes #7476.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/84000043

11 years agocmd/gc: reject builtin function calls in len(fixed array) constants
Russ Cox [Thu, 3 Apr 2014 23:04:33 +0000 (19:04 -0400)]
cmd/gc: reject builtin function calls in len(fixed array) constants

Fixes #7385.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84010044

11 years agocmd/cc: emit gc bitmaps in read-only memory
Russ Cox [Thu, 3 Apr 2014 23:04:15 +0000 (19:04 -0400)]
cmd/cc: emit gc bitmaps in read-only memory

Cuts hello world by 70kB, because we don't write
those names into the symbol table.

Update #6853

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/80370045

11 years agogo/doc: fix ToText
Robert Griesemer [Thu, 3 Apr 2014 22:52:04 +0000 (15:52 -0700)]
go/doc: fix ToText

Fixes #6769.

LGTM=bradfitz
R=bgarcia, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/84220044

11 years agofmt: fix go syntax formatting of []byte(nil)
Shenghou Ma [Thu, 3 Apr 2014 20:11:03 +0000 (16:11 -0400)]
fmt: fix go syntax formatting of []byte(nil)
Fixes #7639.

LGTM=rsc
R=r, adg, rsc
CC=golang-codereviews
https://golang.org/cl/81240043

11 years agonet: accept a few more errors in Accept4 wrapper
Russ Cox [Thu, 3 Apr 2014 20:10:45 +0000 (16:10 -0400)]
net: accept a few more errors in Accept4 wrapper

Fixes #7271.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/84170043

11 years agonet/url: add test of "Windows" file URL
Russ Cox [Thu, 3 Apr 2014 20:10:33 +0000 (16:10 -0400)]
net/url: add test of "Windows" file URL

This is just testing the status quo, so that any future attempt
to change it will make the test break and redirect the person
making the change to look at issue 6027.

Fixes #6027.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/83930046

11 years agoarchive/tar: add support for GNU sparse files.
David Thomas [Thu, 3 Apr 2014 20:01:04 +0000 (20:01 +0000)]
archive/tar: add support for GNU sparse files.

Supports all the current GNU tar sparse formats, including the
old GNU format and the GNU PAX format versions 0.0, 0.1, and 1.0.
Fixes #3864.

LGTM=rsc
R=golang-codereviews, dave, gobot, dsymonds, rsc
CC=golang-codereviews
https://golang.org/cl/64740043

11 years agoA+C: David Thomas (individual CLA)
Russ Cox [Thu, 3 Apr 2014 20:00:05 +0000 (16:00 -0400)]
A+C: David Thomas (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/81400045

11 years agoruntime: fix fault during arm software floating point
Russ Cox [Thu, 3 Apr 2014 19:39:48 +0000 (15:39 -0400)]
runtime: fix fault during arm software floating point

The software floating point runs with m->locks++
to avoid being preempted; recognize this case in panic
and undo it so that m->locks is maintained correctly
when panicking.

Fixes #7553.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/84030043

11 years agonet/http: clarify Request fields' client-vs-server semantics
Brad Fitzpatrick [Thu, 3 Apr 2014 04:05:41 +0000 (21:05 -0700)]
net/http: clarify Request fields' client-vs-server semantics

Fixes #7682

LGTM=adg
R=golang-codereviews, adg
CC=dsymonds, golang-codereviews, iant
https://golang.org/cl/83800043

11 years agoruntime: print up to 10 words of arguments
Russ Cox [Thu, 3 Apr 2014 03:00:40 +0000 (23:00 -0400)]
runtime: print up to 10 words of arguments

The old limit of 5 was chosen because we didn't actually know how
many bytes of arguments there were; 5 was a halfway point between
printing some useful information and looking ridiculous.

Now we know how many bytes of arguments there are, and we stop
the printing when we reach that point, so the "looking ridiculous" case
doesn't happen anymore: we only print actual argument words.
The cutoff now serves only to truncate very long (but real) argument lists.

In multiple debugging sessions recently (completely unrelated bugs)
I have been frustrated by not seeing more of the long argument lists:
5 words is only 2.5 interface values or strings, and not even 2 slices.
Double the max amount we'll show.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews, iant, r
https://golang.org/cl/83850043

11 years agocmd/ld: get rid of map.bucket's data field from dwarf info.
Keith Randall [Thu, 3 Apr 2014 02:46:47 +0000 (19:46 -0700)]
cmd/ld: get rid of map.bucket's data field from dwarf info.

The data field is the generic array that acts as a standin
for the keys and values arrays for the generic runtime code.
We want to substitute the keys and values arrays for the data
array, not just add keys and values in addition to it.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/81160044

11 years agoruntime: check that new slice cap doesn't overflow
Dave Cheney [Thu, 3 Apr 2014 02:44:44 +0000 (13:44 +1100)]
runtime: check that new slice cap doesn't overflow

Fixes #7550.

LGTM=iant
R=golang-codereviews, iant, josharian
CC=golang-codereviews
https://golang.org/cl/83520043

11 years agocmd/gc: fix build
Dave Cheney [Thu, 3 Apr 2014 00:34:31 +0000 (11:34 +1100)]
cmd/gc: fix build

Darwin 10.6 (gcc 4.2) and some older versions of gcc default to C90 mode, not C99 mode. Silence the warning.

LGTM=aram, iant
R=golang-codereviews, aram, iant
CC=golang-codereviews
https://golang.org/cl/83090050

11 years agonet: don't export netFD readFrom, writeTo, readMsg, writeMsg methods
Ian Lance Taylor [Thu, 3 Apr 2014 00:06:51 +0000 (17:06 -0700)]
net: don't export netFD readFrom, writeTo, readMsg, writeMsg methods

There is no way to call them from outside the net package.
They are used to implement UCPConn.ReadMsgUDP and similar.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/83730044

11 years agocmd/pack: fix format string error in log message
Dave Cheney [Wed, 2 Apr 2014 22:58:10 +0000 (09:58 +1100)]
cmd/pack: fix format string error in log message

Fixes #7693.

pack.go:347: possible formatting directive in Fatal call

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/83310045

11 years agocrypto/tls: deflake TestConnReadNonzeroAndEOF
Brad Fitzpatrick [Wed, 2 Apr 2014 21:31:57 +0000 (14:31 -0700)]
crypto/tls: deflake TestConnReadNonzeroAndEOF

Fixes #7683

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/83080048