]> Cypherpunks repositories - gostls13.git/log
gostls13.git
11 years agonet/http/httputil: include Content-Length in DumpResponse output
Brad Fitzpatrick [Thu, 17 Apr 2014 21:03:05 +0000 (14:03 -0700)]
net/http/httputil: include Content-Length in DumpResponse output

Fixes #5357

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/87910050

11 years agonet: fix probabilities in DNS SRV shuffleByWeight
Brad Fitzpatrick [Thu, 17 Apr 2014 20:28:40 +0000 (13:28 -0700)]
net: fix probabilities in DNS SRV shuffleByWeight

Patch from msolo. Just moving it to a CL.
The test fails before and passes with the fix.

Fixes #7098

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

11 years agocmd/pack: avoid ./ import in test (fix Windows build)
Russ Cox [Thu, 17 Apr 2014 20:25:38 +0000 (16:25 -0400)]
cmd/pack: avoid ./ import in test (fix Windows build)

It is possible to use ./ imports on Windows but it
requires some extra command-line work
('go build' does this automatically, but we can't use 'go build' here).

Instead, use an ordinary import and -I/-L, which are easier to use.

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

11 years agocmd/pack: handle very long lines in pkgdef
Ian Lance Taylor [Thu, 17 Apr 2014 18:47:12 +0000 (11:47 -0700)]
cmd/pack: handle very long lines in pkgdef

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

11 years agonet/http: allow commas and spaces in cookie values
Volker Dobler [Thu, 17 Apr 2014 06:01:02 +0000 (23:01 -0700)]
net/http: allow commas and spaces in cookie values

According to RFC 6265 a cookie value may contain neither
commas nor spaces but such values are very common in the
wild and browsers handle them very well so we'll allow
both commas and spaces.
Values starting or ending in a comma or a space are
sent in the quoted form to prevent missinterpetations.

RFC 6265 conforming values are handled as before and
semicolons, backslashes and double-quotes are still
disallowed.

Fixes #7243

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

11 years agodoc/effective_go: mention that b.Write is a shorthand for (&b).Write when b is addres...
Shenghou Ma [Thu, 17 Apr 2014 05:40:04 +0000 (01:40 -0400)]
doc/effective_go: mention that b.Write is a shorthand for (&b).Write when b is addressable.

The rewrite is due to Rob.

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

11 years agocmd/ld: don't pass -rdynamic to external linker if -static is used
Ian Lance Taylor [Thu, 17 Apr 2014 03:28:53 +0000 (20:28 -0700)]
cmd/ld: don't pass -rdynamic to external linker if -static is used

Fixes #7800.

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

11 years agocmd/gc: fix segfault in isgoconst.
Shenghou Ma [Thu, 17 Apr 2014 03:12:06 +0000 (23:12 -0400)]
cmd/gc: fix segfault in isgoconst.

Variables declared with 'var' have no sym->def.

Fixes #7794.

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

11 years agotest: demo for issue 7695
Russ Cox [Thu, 17 Apr 2014 03:06:37 +0000 (23:06 -0400)]
test: demo for issue 7695

Cgo writes C function declarations pretending every arg is a pointer.
If the C function is deferred, it does not inhibit stack copying on split.
The stack copying code believes the C declaration, possibly misinterpreting
integers as pointers.

Probably the right fix for Go 1.3 is to make deferred C functions inhibit
stack copying.

For Go 1.4 and beyond we probably need to make cgo generate Go code
for 6g here, not C code for 6c.

Update #7695

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

11 years agocompress/gzip: add Reset method to Reader
Robert Daniel Kortschak [Thu, 17 Apr 2014 02:43:44 +0000 (22:43 -0400)]
compress/gzip: add Reset method to Reader

Fixes #6364.

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

11 years agoencoding/json: document Encoder will terminate each JSON value with '\n'
Shenghou Ma [Thu, 17 Apr 2014 02:42:24 +0000 (22:42 -0400)]
encoding/json: document Encoder will terminate each JSON value with '\n'
Fixes #7767.

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

11 years agocmd/gc: fewer errors for wrong argument count
Jan Ziak [Thu, 17 Apr 2014 02:42:09 +0000 (22:42 -0400)]
cmd/gc: fewer errors for wrong argument count

Fixes #7675

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

11 years agocmd/ld: restore the call graph dump
Anthony Martin [Thu, 17 Apr 2014 02:42:02 +0000 (22:42 -0400)]
cmd/ld: restore the call graph dump

Before the switch to liblink, the linkers accepted the -c flag
to print the call graph. This change restores the functionality.

This came in handy when I was trying to audit the use of SSE
instructions inside the Plan 9 note handler.

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

11 years agocmd/go: reapply doc change from CL 60590044.
Russ Cox [Thu, 17 Apr 2014 02:30:10 +0000 (22:30 -0400)]
cmd/go: reapply doc change from CL 60590044.

https://golang.org/cl/60590044 edited
doc.go without editing the file it is generated from.
The edit was lost at the next mkdoc.sh.
Make the change in help.go and rerun mkdoc.sh.

Pointed out in the review of CL 68580043.

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

11 years agocmd/ld: populate pe symbol table with Go symbols
Alex Brainman [Thu, 17 Apr 2014 02:25:40 +0000 (22:25 -0400)]
cmd/ld: populate pe symbol table with Go symbols

Fixes #6936

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

11 years agocmd/nm: windows pe handling fixes
Alex Brainman [Thu, 17 Apr 2014 02:17:38 +0000 (22:17 -0400)]
cmd/nm: windows pe handling fixes

- output absolute addresses, not relative;
- accept negative section numbers.

Update #6936
Fixes #7738

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

11 years agodebug/pe: add optional header to File
Alex Brainman [Thu, 17 Apr 2014 02:10:59 +0000 (22:10 -0400)]
debug/pe: add optional header to File

This information is required by cmd/nm
to calculate absolute symbol addresses.

Update #6936
Update #7738

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

11 years agoliblink, cmd/ld: reenable nosplit checking and test
Russ Cox [Thu, 17 Apr 2014 02:08:00 +0000 (22:08 -0400)]
liblink, cmd/ld: reenable nosplit checking and test

The new code is adapted from the Go 1.2 nosplit code,
but it does not have the bug reported in issue 7623:

g% go run nosplit.go
g% go1.2 run nosplit.go
BUG
rejected incorrectly:
        main 0 call f; f 120

        linker output:
        # _/tmp/go-test-nosplit021064539
        main.main: nosplit stack overflow
                120 guaranteed after split check in main.main
                112 on entry to main.f
                -8 after main.f uses 120

g%

Fixes #6931.
Fixes #7623.

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

11 years agoencoding/xml: document NewDecoder buffering
Brad Fitzpatrick [Thu, 17 Apr 2014 00:16:08 +0000 (17:16 -0700)]
encoding/xml: document NewDecoder buffering

Fixes #7225

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

11 years agoflag: document that Bool also accepts "T" and "F"
Rob Pike [Thu, 17 Apr 2014 00:14:48 +0000 (17:14 -0700)]
flag: document that Bool also accepts "T" and "F"
Fixes #7752.

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

11 years agoall: fix typos
Rui Ueyama [Wed, 16 Apr 2014 23:57:25 +0000 (16:57 -0700)]
all: fix typos

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

11 years agoliblink, cmd/gc, cmd/{5,6,8}{a,c}: rename linkwriteobj to writeobj
Ian Lance Taylor [Wed, 16 Apr 2014 21:36:44 +0000 (14:36 -0700)]
liblink, cmd/gc, cmd/{5,6,8}{a,c}: rename linkwriteobj to writeobj

The name linkwriteobj is misleading because it implies that
the function has something to do with the linker, which it
does not.  The name is historical: the function performs an
operation that was previously performed by the linker, but no
longer is.

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

11 years agoliblink: add leaf bit to object file format
Russ Cox [Wed, 16 Apr 2014 21:11:44 +0000 (17:11 -0400)]
liblink: add leaf bit to object file format

Without the leaf bit, the linker cannot record
the correct frame size in the symbol table, and
then stack traces get mangled. (Only for ARM.)

Fixes #7338.
Fixes #7347.

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

11 years agogo/scanner: interpret //line directives sans filename sensibly, second try.
Alan Donovan [Wed, 16 Apr 2014 20:17:50 +0000 (16:17 -0400)]
go/scanner: interpret //line directives sans filename sensibly, second try.

A //line directive without a filename now denotes the empty
filename, not the current directory (the Go 1.2 behaviour) nor
the previous //line's filename (the behaviour since CL
86990044).

They should never appear (but they do, e.g. due to a bug in godoc).

Fixes #7765

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

11 years agodoc/go1.3.html: fix id anchor for FreeBSD
Emil Hessman [Wed, 16 Apr 2014 19:15:39 +0000 (12:15 -0700)]
doc/go1.3.html: fix id anchor for FreeBSD

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

11 years agogo/scanner: interpret //line directives sans filename sensibly
Alan Donovan [Wed, 16 Apr 2014 18:51:33 +0000 (14:51 -0400)]
go/scanner: interpret //line directives sans filename sensibly

A //line directive without a filename now denotes the same
filename as the previous line (as in C).
Previously it denoted the file's directory (!).

Fixes #7765

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

11 years agoencoding/base64: don't lose a byte of output when encountering trailing garbage
Brad Fitzpatrick [Wed, 16 Apr 2014 18:32:41 +0000 (11:32 -0700)]
encoding/base64: don't lose a byte of output when encountering trailing garbage

Fixes #7733

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

11 years agonet/http: fix data race in TestTransportResponseHeaderTimeout
Brad Fitzpatrick [Wed, 16 Apr 2014 18:32:16 +0000 (11:32 -0700)]
net/http: fix data race in TestTransportResponseHeaderTimeout

Fixes #7264

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

11 years agocmd/5g, cmd/6g, cmd/8g: preserve wide values in large functions
Russ Cox [Wed, 16 Apr 2014 17:59:42 +0000 (13:59 -0400)]
cmd/5g, cmd/6g, cmd/8g: preserve wide values in large functions

In large functions with many variables, the register optimizer
may give up and choose not to track certain variables at all.
In this case, the "nextinnode" information linking together
all the words from a given variable will be incomplete, and
the result may be that only some of a multiword value is
preserved across a call. That confuses the garbage collector,
so don't do that. Instead, mark those variables as having
their address taken, so that they will be preserved at all
calls. It's overkill, but correct.

Tested by hand using the 6g -S output to see that it does fix
the buggy generated code leading to the issue 7726 failure.

There is no automated test because I managed to break the
compiler while writing a test (see issue 7727). I will check
in a test along with the fix to issue 7727.

Fixes #7726.

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

11 years agodoc/go1.3.html: document the state of FreeBSD
Rob Pike [Wed, 16 Apr 2014 17:40:41 +0000 (10:40 -0700)]
doc/go1.3.html: document the state of FreeBSD
Update #7056

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

11 years agoruntime: crash when func main calls Goexit and all other goroutines exit
Russ Cox [Wed, 16 Apr 2014 17:12:18 +0000 (13:12 -0400)]
runtime: crash when func main calls Goexit and all other goroutines exit

This has typically crashed in the past, although usually with
an 'all goroutines are asleep - deadlock!' message that shows
no goroutines (because there aren't any).

Previous discussion at:
https://groups.google.com/d/msg/golang-nuts/uCT_7WxxopQ/BoSBlLFzUTkJ
https://groups.google.com/d/msg/golang-dev/KUojayEr20I/u4fp_Ej5PdUJ
http://golang.org/issue/7711

There is general agreement that runtime.Goexit terminates the
main goroutine, so that main cannot return, so the program does
not exit.

The interpretation that all other goroutines exiting causes an
exit(0) is relatively new and was not part of those discussions.
That is what this CL changes.

Thankfully, even though the exit(0) has been there for a while,
some other accounting bugs made it very difficult to trigger,
so it is reasonable to replace. In particular, see golang.org/issue/7711#c10
for an examination of the behavior across past releases.

Fixes #7711.

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

11 years agoliblink: fix incorrect hash collision in lookup
Russ Cox [Wed, 16 Apr 2014 15:53:14 +0000 (11:53 -0400)]
liblink: fix incorrect hash collision in lookup

linklookup uses hash(name, v) as the hash table index but then
only compares name to find a symbol to return.
If hash(name, v1) == hash(name, v2) for v1 != v2, the lookup
for v2 will return the symbol with v1.

The input routines assume that each symbol is found only once,
and then each symbol is added to a linked list, with the list header
in the symbol. Adding a symbol to such a list multiple times
short-circuits the list the second time it is added, causing symbols
to be dropped.

The liblink rewrite introduced an elegant, if inefficient, handling
of duplicated symbols by creating a dummy symbol to read the
duplicate into. The dummy symbols are named .dup with
sequential version numbers. With many .dup symbols, eventually
there will be a conflict, causing a duplicate list add, causing elided
symbols, causing a crash when calling one of the elided symbols.

The bug is old (2011) but could not have manifested until the
liblink rewrite introduced this heavily duplicated symbol .dup.
(See History section below.)

1. Correct the lookup function.

2. Since we want all the .dup symbols to be different, there's no
point in inserting them into the table. Call linknewsym directly,
avoiding the lookup function entirely.

3. Since nothing can refer to the .dup symbols, do not bother
adding them to the list of functions (textp) at all.

4. In lieu of a unit test, introduce additional consistency checks to
detect adding a symbol to a list multiple times. This would have
caught the short-circuit more directly, and it will detect a variety
of double-use bugs, including the one arising from the bad lookup.

Fixes #7749.

History

On April 9, 2011, I submitted CL 4383047, making ld 25% faster.
Much of the focus was on the hash table lookup function, and
one of the changes was to remove the s->version == v comparison [1].

I don't know if this was a simple editing error or if I reasoned that
same name but different v would yield a different hash slot and
so the name test alone sufficed. It is tempting to claim the former,
but it was probably the latter.

Because the hash is an iterated multiply+add, the version ends up
adding v*3ⁿ to the hash, where n is the length of the name.
A collision would need x*3ⁿ ≡ y*3ⁿ (mod 2²⁴ mod 100003),
or equivalently x*3ⁿ ≡ x*3ⁿ + (y-x)*3ⁿ (mod 2²⁴ mod 100003),
so collisions will actually be periodic: versions x and y collide
when d = y-x satisfies d*3ⁿ ≡ 0 (mod 2²⁴ mod 100003).
Since we allocate version numbers sequentially, this is actually
about the best case one could imagine: the collision rate is
much lower than if the hash were more random.
http://play.golang.org/p/TScD41c_hA computes the collision
period for various name lengths.

The most common symbol in the new linker is .dup, and for n=4
the period is maximized: the 100004th symbol is the first collision.
Unfortunately, there are programs with more duplicated symbols
than that.

In Go 1.2 and before, duplicate symbols were handled without
creating a dummy symbol, so this particular case for generating
many duplicate symbols could not happen. Go does not use
versioned symbols. Only C does; each input file gives a different
version to its static declarations. There just aren't enough C files
for this to come up in that context.

So the bug is old but the realization of the bug is new.

[1] https://golang.org/cl/4383047/diff/5001/src/cmd/ld/lib.c

LGTM=minux.ma, iant, dave
R=golang-codereviews, minux.ma, bradfitz, iant, dave
CC=golang-codereviews, r
https://golang.org/cl/87910047

11 years agoreflect: correct type descriptor for call of interface method
Russ Cox [Wed, 16 Apr 2014 15:52:27 +0000 (11:52 -0400)]
reflect: correct type descriptor for call of interface method

When preparing a call with an interface method, the argument
frame holds the receiver "iword", but funcLayout was being
asked to write a descriptor as if the receiver were a complete
interface value. This was originally caught by running a large
program with Debug=3 in runtime/mgc0.c, but the new panic
in funcLayout suffices to catch the mistake with the existing
tests.

Fixes #7748.

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

11 years agoruntime: adjust GC debug print to include source pointers
Russ Cox [Wed, 16 Apr 2014 15:39:43 +0000 (11:39 -0400)]
runtime: adjust GC debug print to include source pointers

Having the pointers means you can grub around in the
binary finding out more about them.

This helped with issue 7748.

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

11 years agocmd/ld: cast PE32 absolute addend to int32.
Shenghou Ma [Wed, 16 Apr 2014 05:46:56 +0000 (01:46 -0400)]
cmd/ld: cast PE32 absolute addend to int32.
Didn't manage to find a way to write test cases.

Fixes #7769.

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

11 years agocmd/ld: correct comment.
Shenghou Ma [Wed, 16 Apr 2014 05:41:47 +0000 (01:41 -0400)]
cmd/ld: correct comment.

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

11 years agodoc/debugging_with_gdb: use -w to strip debug info.
Shenghou Ma [Wed, 16 Apr 2014 05:19:26 +0000 (01:19 -0400)]
doc/debugging_with_gdb: use -w to strip debug info.
Don't advertise -s anymore.
Fixes #7793.

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

11 years agodoc: remove outdated Makefile
Shenghou Ma [Wed, 16 Apr 2014 04:00:25 +0000 (00:00 -0400)]
doc: remove outdated Makefile
Fixes #7773.

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

11 years agorun.bash: fix build on netbsd builders.
Shenghou Ma [Wed, 16 Apr 2014 03:54:04 +0000 (23:54 -0400)]
run.bash: fix build on netbsd builders.

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

11 years agodoc: edit documentation that uses "satisfies reads" and "satisfies writes"
Billie Harold Cleek [Wed, 16 Apr 2014 03:40:47 +0000 (13:40 +1000)]
doc: edit documentation that uses "satisfies reads" and "satisfies writes"

Make it clear that types that wrap another reader or writer delegate to the wrapped type.

Fixes #7667

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

11 years agoA+C: Billie Harold Cleek (individual CLA)
Andrew Gerrand [Wed, 16 Apr 2014 03:39:51 +0000 (13:39 +1000)]
A+C: Billie Harold Cleek (individual CLA)

Generated by addca.

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

11 years agocrypto/tls: don't block on Read of zero bytes
Brad Fitzpatrick [Wed, 16 Apr 2014 02:40:00 +0000 (19:40 -0700)]
crypto/tls: don't block on Read of zero bytes

Fixes #7775

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

11 years agoimage/png: fix crash when an alleged PNG has too much pixel data,
Nigel Tao [Wed, 16 Apr 2014 02:18:57 +0000 (12:18 +1000)]
image/png: fix crash when an alleged PNG has too much pixel data,
so that the zlib.Reader returns nil error.

Fixes #7762.

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

11 years agocmd/ld: record complete runtime-gdb.py path again
Russ Cox [Wed, 16 Apr 2014 01:17:18 +0000 (21:17 -0400)]
cmd/ld: record complete runtime-gdb.py path again

This code never got updated after the liblink shuffle.
Tested by hand that it works and respects GOROOT_FINAL.

The discussion in issue 6963 suggests that perhaps we should
just drop runtime-gdb.py entirely, but I am not convinced
that is true. It was in Go 1.2 and I don't see a reason not to
keep it in Go 1.3. The fact that binaries have not been emitting
the reference was just a missed detail in the liblink conversion,
not part of a grand plan.

Fixes #7506.
Fixes #6963.

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

11 years agobuild: remove tmp dir names from objects, support GOROOT_FINAL again
Russ Cox [Wed, 16 Apr 2014 00:46:46 +0000 (20:46 -0400)]
build: remove tmp dir names from objects, support GOROOT_FINAL again

If we compile a generated file stored in a temporary
directory - let's say /tmp/12345/work/x.c - then by default
6c stores the full path and then the pcln table in the
final binary includes the full path. This makes repeated builds
(using different temporary directories) produce different
binaries, even if the inputs are the same.

In the old 'go tool pack', the P flag specified a prefix to remove
from all stored paths (if present), and cmd/go invoked
'go tool pack grcP $WORK' to remove references to the
temporary work directory.

We've changed the build to avoid pack as much as possible,
under the theory that instead of making pack convert from
.6 to .a, the tools should just write the .a directly and save a
round of I/O.

Instead of going back to invoking pack always, define a common
flag -trimpath in the assemblers, C compilers, and Go compilers,
implemented in liblink, and arrange for cmd/go to use the flag.
Then the object files being written out have the shortened paths
from the start.

While we are here, reimplement pcln support for GOROOT_FINAL.
A build in /tmp/go uses GOROOT=/tmp/go, but if GOROOT_FINAL=/usr/local/go
is set, then a source file named /tmp/go/x.go is recorded instead as
/usr/local/go/x.go. We use this so that we can prepare distributions
to be installed in /usr/local/go without actually working in that
directory. The conversion to liblink deleted all the old file name
handling code, including the GOROOT_FINAL translation.
Bring the GOROOT_FINAL translation back.

Before this CL, using GOROOT_FINAL=/goroot make.bash:

        g% strings $(which go) | grep -c $TMPDIR
        6
        g% strings $(which go) | grep -c $GOROOT
        793
        g%

After this CL:

        g% strings $(which go) | grep -c $TMPDIR
        0
        g% strings $(which go) | grep -c $GOROOT
        0
        g%

(The references to $TMPDIR tend to be cgo-generated source files.)

Adding the -trimpath flag to the assemblers required converting
them to the new Go-semantics flag parser. The text in go1.3.html
is copied and adjusted from go1.1.html, which is when we applied
that conversion to the compilers and linkers.

Fixes #6989.

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

11 years agoos/exec: make TestPipeLookPathLeak more verbose when it fails
Brad Fitzpatrick [Wed, 16 Apr 2014 00:36:25 +0000 (17:36 -0700)]
os/exec: make TestPipeLookPathLeak more verbose when it fails

Trying to understand the linux-386-387 failures:
http://build.golang.org/log/78a91da173c11e986b4e623527c2d0b746f4e814

Also modernize the closeOnce code with a method value, while I
was looking.

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

11 years agoio: document that a Writer must not write to p
Brad Fitzpatrick [Wed, 16 Apr 2014 00:14:03 +0000 (17:14 -0700)]
io: document that a Writer must not write to p

Per golang-nuts question. Writing to p breaks
other writers (e.g. io.MultiWriter).

Make this explicit.

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

11 years agoaddr2line, objdump: write doc comments
Russ Cox [Wed, 16 Apr 2014 00:06:08 +0000 (20:06 -0400)]
addr2line, objdump: write doc comments

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

11 years agocmd/pack: print error along with usage
Russ Cox [Wed, 16 Apr 2014 00:05:56 +0000 (20:05 -0400)]
cmd/pack: print error along with usage

My cmd/go got in a weird state where it started invoking pack grcP.
Change pack to print a 1-line explanation of the usage problem
before the generic usage message.

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

11 years agodoc/install.html: FreeBSD 8 and higher only are supported
Rob Pike [Tue, 15 Apr 2014 23:40:48 +0000 (16:40 -0700)]
doc/install.html: FreeBSD 8 and higher only are supported
Fixes #7188

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

11 years agodoc/asm.html: remove mention of 6l -a
Rob Pike [Tue, 15 Apr 2014 23:27:48 +0000 (16:27 -0700)]
doc/asm.html: remove mention of 6l -a
Also make it clear this is not a complete description of all features.
Fixes #7790.

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

11 years agonet/http: skip TestTransportClosesBodyOnError on Plan 9
David du Colombier [Tue, 15 Apr 2014 22:48:21 +0000 (00:48 +0200)]
net/http: skip TestTransportClosesBodyOnError on Plan 9

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

11 years agomath/big: fix doc typos.
Shenghou Ma [Tue, 15 Apr 2014 21:50:19 +0000 (14:50 -0700)]
math/big: fix doc typos.
Fixes #7768.

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

11 years agocmd/ld: attempt at fixing openbsd build
Russ Cox [Tue, 15 Apr 2014 19:52:23 +0000 (15:52 -0400)]
cmd/ld: attempt at fixing openbsd build

OpenBSD is excluded from all the usual thread-local storage
code, not just emitting the tbss section in the external link .o
but emitting a PT_TLS section in an internally-linked executable.
I assume it just has no proper TLS support. Exclude it here too.

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

11 years agobuild: disable static cgo linking test on netbsd
Russ Cox [Tue, 15 Apr 2014 19:52:02 +0000 (15:52 -0400)]
build: disable static cgo linking test on netbsd

We get
/usr/lib/libc.a(stack_protector.o): In function `__stack_chk_fail_local':
stack_protector.c:(.text+0x158): multiple definition of `__stack_chk_fail_local'
/var/tmp/go-link-04838a/000001.o:/tmp/gobuilder/netbsd-386-minux-c7a9e9243878/go/src/pkg/runtime/cgo/gcc_386.S:41: first defined here

I am assuming this has never worked and possibly is not intended to work.
(Some systems are vehemently against static linking.)

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

11 years agocmd/ld: use TLS relocations on ELF systems in external linking mode
Russ Cox [Tue, 15 Apr 2014 19:13:52 +0000 (12:13 -0700)]
cmd/ld: use TLS relocations on ELF systems in external linking mode

Fixes #7719.

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

11 years agoliblink: introduce TLS register on 386 and amd64
Russ Cox [Tue, 15 Apr 2014 17:45:39 +0000 (13:45 -0400)]
liblink: introduce TLS register on 386 and amd64

When I did the original 386 ports on Linux and OS X, I chose to
define GS-relative expressions like 4(GS) as relative to the actual
thread-local storage base, which was usually GS but might not be
(it might be FS, or it might be a different constant offset from GS or FS).

The original scope was limited but since then the rewrites have
gotten out of control. Sometimes GS is rewritten, sometimes FS.
Some ports do other rewrites to enable shared libraries and
other linking. At no point in the code is it clear whether you are
looking at the real GS/FS or some synthesized thing that will be
rewritten. The code manipulating all these is duplicated in many
places.

The first step to fixing issue 7719 is to make the code intelligible
again.

This CL adds an explicit TLS pseudo-register to the 386 and amd64.
As a register, TLS refers to the thread-local storage base, and it
can only be loaded into another register:

        MOVQ TLS, AX

An offset from the thread-local storage base is written off(reg)(TLS*1).
Semantically it is off(reg), but the (TLS*1) annotation marks this as
indexing from the loaded TLS base. This emits a relocation so that
if the linker needs to adjust the offset, it can. For example:

        MOVQ TLS, AX
        MOVQ 8(AX)(TLS*1), CX // load m into CX

On systems that support direct access to the TLS memory, this
pair of instructions can be reduced to a direct TLS memory reference:

        MOVQ 8(TLS), CX // load m into CX

The 2-instruction and 1-instruction forms correspond roughly to
ELF TLS initial exec mode and ELF TLS local exec mode, respectively.

Liblink applies this rewrite on systems that support the 1-instruction form.
The decision is made using only the operating system (and probably
the -shared flag, eventually), not the link mode. If some link modes
on a particular operating system require the 2-instruction form,
then all builds for that operating system will use the 2-instruction
form, so that the link mode decision can be delayed to link time.

Obviously it is late to be making changes like this, but I despair
of correcting issue 7719 and issue 7164 without it. To make sure
I am not changing existing behavior, I built a "hello world" program
for every GOOS/GOARCH combination we have and then worked
to make sure that the rewrite generates exactly the same binaries,
byte for byte. There are a handful of TODOs in the code marking
kludges to get the byte-for-byte property, but at least now I can
explain exactly how each binary is handled.

The targets I tested this way are:

        darwin-386
        darwin-amd64
        dragonfly-386
        dragonfly-amd64
        freebsd-386
        freebsd-amd64
        freebsd-arm
        linux-386
        linux-amd64
        linux-arm
        nacl-386
        nacl-amd64p32
        netbsd-386
        netbsd-amd64
        openbsd-386
        openbsd-amd64
        plan9-386
        plan9-amd64
        solaris-amd64
        windows-386
        windows-amd64

There were four exceptions to the byte-for-byte goal:

windows-386 and windows-amd64 have a time stamp
at bytes 137 and 138 of the header.

darwin-386 and plan9-386 have five or six modified
bytes in the middle of the Go symbol table, caused by
editing comments in runtime/sys_{darwin,plan9}_386.s.

Fixes #7164.

LGTM=iant
R=iant, aram, minux.ma, dave
CC=golang-codereviews
https://golang.org/cl/87920043

11 years agotext/template: say more often that templates are safe for parallel execution
Rob Pike [Tue, 15 Apr 2014 15:48:40 +0000 (08:48 -0700)]
text/template: say more often that templates are safe for parallel execution
It was said already but apparently not enough times.

Fixes #6985.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/86300043

11 years agoruntime: fix program termination when main goroutine calls Goexit
Dmitriy Vyukov [Tue, 15 Apr 2014 15:48:17 +0000 (19:48 +0400)]
runtime: fix program termination when main goroutine calls Goexit
Do not consider idle finalizer/bgsweep/timer goroutines as doing something useful.
We can't simply set isbackground for the whole lifetime of the goroutines,
because when finalizer goroutine calls user function, we do want to consider it
as doing something useful.
This is borken due to timers for quite some time.
With background sweep is become even more broken.
Fixes #7784.

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

11 years agocmd/dist: use GOHOSTARCH/GOHOSTOS instead of GOOS/GOARCH for host libraries and binaries
Jan Ziak [Tue, 15 Apr 2014 06:46:21 +0000 (08:46 +0200)]
cmd/dist: use GOHOSTARCH/GOHOSTOS instead of GOOS/GOARCH for host libraries and binaries

Fixes #6559

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

11 years agoos/exec: quiet distracting log output during test
Brad Fitzpatrick [Tue, 15 Apr 2014 00:20:30 +0000 (17:20 -0700)]
os/exec: quiet distracting log output during test

TLS handshake failures didn't use to log, but do in Go 1.3.
Shut it up so the actual failure can be seen in e.g.
http://build.golang.org/log/ede7e12362a941d93bf1fe21db9208a3e298029e

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

11 years agoundo CL 87300043 / 1dc800571456
Andrew Gerrand [Tue, 15 Apr 2014 00:20:04 +0000 (10:20 +1000)]
undo CL 87300043 / 1dc800571456

This breaks "go get -d repo/path/...".

««« original CL description
cmd/go: do not miss an error if import path contains "cmd/something"

Fixes #7638

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

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

11 years agonet/http: clarify Response.Body Close responsibility
Brad Fitzpatrick [Mon, 14 Apr 2014 23:50:03 +0000 (16:50 -0700)]
net/http: clarify Response.Body Close responsibility

Per TODO email in my inbox.

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

11 years agodoc: simplify a go1.3 change description
Brad Fitzpatrick [Mon, 14 Apr 2014 23:28:52 +0000 (16:28 -0700)]
doc: simplify a go1.3 change description

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

11 years agocrypto/x509: fix Windows build.
Adam Langley [Mon, 14 Apr 2014 20:23:58 +0000 (13:23 -0700)]
crypto/x509: fix Windows build.

Windows is building a chain to the AddTrust root which is different
from the native Go code and causing a build failure.

This change alters the test so that both should build to the AddTrust
root.

R=bradfitz

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

11 years agodoc/help.html: fix typo in word order
Andrew Szeto [Mon, 14 Apr 2014 20:03:03 +0000 (13:03 -0700)]
doc/help.html: fix typo in word order

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

11 years agocmd/go: do not miss an error if import path contains "cmd/something"
Jan Ziak [Mon, 14 Apr 2014 20:01:27 +0000 (22:01 +0200)]
cmd/go: do not miss an error if import path contains "cmd/something"

Fixes #7638

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

11 years agoA+C: Andrew Szeto (individual CLA)
Brad Fitzpatrick [Mon, 14 Apr 2014 20:00:41 +0000 (13:00 -0700)]
A+C: Andrew Szeto (individual CLA)

Generated by addca.

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

11 years agoliblink: remove arch-specific constants from file format
Russ Cox [Mon, 14 Apr 2014 19:54:20 +0000 (15:54 -0400)]
liblink: remove arch-specific constants from file format

The relocation and automatic variable types were using
arch-specific numbers. Introduce portable enumerations
instead.

To the best of my knowledge, these are the only arch-specific
bits left in the new object file format.

Remove now, before Go 1.3, because file formats are forever.

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

11 years agocrypto/x509: support SHA-512 by default.
Adam Langley [Mon, 14 Apr 2014 19:12:06 +0000 (12:12 -0700)]
crypto/x509: support SHA-512 by default.

Comodo are now using a SHA-384 signed intermediate. The crypto/x509
package seeks to import hash functions needed for typical operation
without needing to import every hash function possible. Since a SHA-384
certificate is being used by Comodo, crypto/sha512 now appears to fall
into the scope of "typical operation".

R=bradfitz

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

11 years agonet/http: make race detector happy for recently-added test
Brad Fitzpatrick [Mon, 14 Apr 2014 19:08:32 +0000 (12:08 -0700)]
net/http: make race detector happy for recently-added test

Update #7264

Races:
http://build.golang.org/log/a2e401fdcd4903a61a3375bff5da702a20ddafad
http://build.golang.org/log/ec4c69e92076a747ac6d5df7eb7b382b31ab3d43

I think this is the first time I've actually seen a manifestation
of Issue 7264, and one that I can reproduce.

I don't know why it triggers on this test and not any others
just like it, or why I can't reproduce Issue 7264
independently, even when Dmitry gives me minimal repros.

Work around it for now with some synchronization to make the
race detector happy.

The proper fix will probably be in net/http/httptest itself, not
in all hundred some tests.

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

11 years agoA+C: Guillaume J. Charmes (individual CLA)
Ian Lance Taylor [Mon, 14 Apr 2014 18:26:22 +0000 (11:26 -0700)]
A+C: Guillaume J. Charmes (individual CLA)

Generated by addca.

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

11 years agoliblink, cmd/link: add version number to object file
Russ Cox [Mon, 14 Apr 2014 17:20:51 +0000 (13:20 -0400)]
liblink, cmd/link: add version number to object file

There are changes we know we want to make, but not before Go 1.3
Add a version number so that we can make them more easily later.

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

11 years agodoc: add go1.3 note about the http Transport closing Request.Body
Brad Fitzpatrick [Mon, 14 Apr 2014 17:19:10 +0000 (10:19 -0700)]
doc: add go1.3 note about the http Transport closing Request.Body

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

11 years agosync: less agressive local caching in Pool
Dmitriy Vyukov [Mon, 14 Apr 2014 17:13:32 +0000 (21:13 +0400)]
sync: less agressive local caching in Pool
Currently Pool can cache up to 15 elements per P, and these elements are not accesible to other Ps.
If a Pool caches large objects, say 2MB, and GOMAXPROCS is set to a large value, say 32,
then the Pool can waste up to 960MB.
The new caching policy caches at most 1 per-P element, the rest is shared between Ps.

Get/Put performance is unchanged. Nested Get/Put performance is 57% worse.
However, overall scalability of nested Get/Put is significantly improved,
so the new policy starts winning under contention.

benchmark                     old ns/op     new ns/op     delta
BenchmarkPool                 27.4          26.7          -2.55%
BenchmarkPool-4               6.63          6.59          -0.60%
BenchmarkPool-16              1.98          1.87          -5.56%
BenchmarkPool-64              1.93          1.86          -3.63%
BenchmarkPoolOverlflow        3970          6235          +57.05%
BenchmarkPoolOverlflow-4      10935         1668          -84.75%
BenchmarkPoolOverlflow-16     13419         520           -96.12%
BenchmarkPoolOverlflow-64     10295         380           -96.31%

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

11 years agolibbio: add casts to eliminate -Wconversion warning
Ian Lance Taylor [Mon, 14 Apr 2014 16:36:47 +0000 (09:36 -0700)]
libbio: add casts to eliminate -Wconversion warning

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

11 years agocmd/dist: mark cmd/link and debug/goobj as unreleased
Russ Cox [Mon, 14 Apr 2014 16:33:51 +0000 (12:33 -0400)]
cmd/dist: mark cmd/link and debug/goobj as unreleased

These are not ready and will not be in Go 1.3.

Fixes #6932.

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

11 years agocmd/prof, libmach: delete
Russ Cox [Mon, 14 Apr 2014 15:09:25 +0000 (11:09 -0400)]
cmd/prof, libmach: delete

We have never released cmd/prof and don't plan to.
Now that nm, addr2line, and objdump have been rewritten in Go,
cmd/prof is the only thing keeping us from deleting libmach.

Delete cmd/prof, and then since nothing is using libmach, delete libmach.

13,000 lines of C deleted.

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews, iant, r
https://golang.org/cl/87020044

11 years agonet/http: close Body in client code always, even on errors, and document
Brad Fitzpatrick [Mon, 14 Apr 2014 15:06:13 +0000 (08:06 -0700)]
net/http: close Body in client code always, even on errors, and document

Fixes #6981

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

11 years agocmd/objdump: rewrite in Go
Russ Cox [Mon, 14 Apr 2014 14:58:49 +0000 (10:58 -0400)]
cmd/objdump: rewrite in Go

Update cmd/dist not to build the C version.
Update cmd/go to install the Go version to the tool directory.

Update #7452

This is the basic logic needed for objdump, and it works well enough
to support the pprof list and weblist commands. A real disassembler
needs to be added in order to support the pprof disasm command
and the per-line assembly displays in weblist. That's still to come.

Probably objdump will move to go.tools when the disassembler
is added, but it can stay here for now.

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews, iant, r
https://golang.org/cl/87580043

11 years agoundo CL 66510044 / 6c0339d94123
Russ Cox [Mon, 14 Apr 2014 13:48:11 +0000 (09:48 -0400)]
undo CL 66510044 / 6c0339d94123

Broke other things - see issue 7522.

Fixes #7522.
Reopens issue 7363.

««« original CL description
cmd/gc: make embedded, unexported fields read-only.

Fixes #7363.

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

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

11 years agoruntime: increase timeout in TestStackGrowth
Russ Cox [Mon, 14 Apr 2014 00:19:10 +0000 (20:19 -0400)]
runtime: increase timeout in TestStackGrowth

It looks like maybe on slower builders 4 seconds is not enough.
Trying to get rid of the flaky failures.

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

11 years agodoc/go1.3.html: windows NewCallbackCDecl
Rob Pike [Sat, 12 Apr 2014 04:56:17 +0000 (14:56 +1000)]
doc/go1.3.html: windows NewCallbackCDecl

LGTM=alex.brainman
R=alex.brainman
CC=golang-codereviews
https://golang.org/cl/87250043

11 years agoC: add Yan Zou (Google CLA).
Adam Langley [Fri, 11 Apr 2014 17:11:21 +0000 (10:11 -0700)]
C: add Yan Zou (Google CLA).

R=adg

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

11 years agonet/http: quiet useless warning during shutdown
Brad Fitzpatrick [Fri, 11 Apr 2014 16:40:36 +0000 (09:40 -0700)]
net/http: quiet useless warning during shutdown

What was happening on Issue 7010 was handler intentionally took 30
milliseconds and the proxy's client timeout was 35 milliseconds. Then it
slammed the proxy with a bunch of requests.

Sometimes the server would be too slow to respond in its 5 millisecond
window and the client code would cancel the request, force-closing the
persistConn.  If this came at the right time, the server's reply was
already in flight, and one of the goroutines would report:

Unsolicited response received on idle HTTP channel starting with "H"; err=<nil>

... rightfully scaring the user.

But the error was already handled and returned to the user, and this
connection knows it's been shut down. So look at the closed flag after
acquiring the same mutex guarding another field we were checking, and
don't complain if it's a known shutdown.

Also move closed down below the mutex which guards it.

Fixes #7010

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

11 years agocmd/gc: increase specificity of errors in function call context
Jan Ziak [Fri, 11 Apr 2014 13:57:30 +0000 (15:57 +0200)]
cmd/gc: increase specificity of errors in function call context

Fixes #7129

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

11 years agocmd/gc: fix typo in ordermapassign
Jan Ziak [Fri, 11 Apr 2014 13:28:37 +0000 (15:28 +0200)]
cmd/gc: fix typo in ordermapassign

Fixes #7742

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

11 years agonet/http/httptest: add test for issue 7264
Dmitriy Vyukov [Fri, 11 Apr 2014 09:01:10 +0000 (13:01 +0400)]
net/http/httptest: add test for issue 7264
The test fails now with -race, so it's disabled.
The intention is that the fix for issue 7264
will also modify this test the same way and enable it.
Reporduce with 'go test -race -issue7264 -cpu=4'.
Update #7264

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

11 years agoos/signal: use unique program name during TestCtrlBreak
Alex Brainman [Fri, 11 Apr 2014 06:43:36 +0000 (16:43 +1000)]
os/signal: use unique program name during TestCtrlBreak

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

11 years agonet/http: Return ErrNotMultipart from ParseMultipartForm if content-type isn't multip...
Matthew Cottingham [Fri, 11 Apr 2014 05:50:04 +0000 (22:50 -0700)]
net/http: Return ErrNotMultipart from ParseMultipartForm if content-type isn't multipart/form-data.

Add test for multipart form requests with an invalid content-type to ensure
ErrNotMultipart is returned.

Change ParseMultipartForm to return ErrNotMultipart when it is returned by multipartReader.

Modify test for empty multipart request handling to use POST so that the body is checked.

Fixes #6334.

This is the first changeset working on multipart request handling. Further changesets
could add more tests and clean up the TODO.

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

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