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

14790 Commits

Author SHA1 Message Date
Robert Hencke
3b3e1a09a9 html: fix small typo
LGTM=dsymonds, adg, crawshaw, r, bradfitz, campoy, nigeltao, sameer, iant, robsc, djd, michael.j.fromberger, gmlewis, adonovan, rsc
R=golang-codereviews, dsymonds, adg, crawshaw, r, nigeltao, sameer, iant, robsc, djd, michael.j.fromberger, gmlewis, adonovan, rsc
CC=golang-codereviews
https://golang.org/cl/98880043
2014-05-01 16:29:34 -04:00
Brad Fitzpatrick
3100088743 go/build: add go1.3 release tag
Fixes #7918

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/91980043
2014-05-01 12:16:03 -04:00
Andrew Gerrand
5cb67d7ba4 cmd/dist: permit go* tag in main branch when it includes "beta"
This change allows us to give an hg tag such as "go1.3beta1" to
revisions in the main branch without breaking the build.

This is helpful for community members who want to build the beta
from source.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/90190044
2014-05-01 12:13:32 -04:00
Keith Randall
e9977dad45 runtime: correctly type interface data.
The backing memory for >1 word interfaces was being scanned
conservatively.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/94000043
2014-05-01 09:37:55 -04:00
Michael Fraenkel
61fac6845a cmd/go: test: clean up all temporary directories
go test may call builder.init() multiple times which will create a new work directory.  The cleanup needs to hoist the current work directory.
Fixes #7904.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95900044
2014-04-30 13:03:38 -04:00
Rui Ueyama
70f6c43024 time: MeST is a time zone name
Not only ChST but also MeST (America/Metlakatla) is a zone
name containing a lower case letter.

LGTM=robert.hencke, r
R=golang-codereviews, robert.hencke, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/99910043
2014-04-30 11:30:36 -04:00
Mikio Hara
ace8bc35ef net: enable builtin dns resolver tests on solaris
LGTM=aram
R=golang-codereviews, aram
CC=golang-codereviews
https://golang.org/cl/99890045
2014-04-30 23:26:07 +09:00
Shenghou Ma
6f3f2d0ab8 run.bash: skip -static cgo test if -static linking isn't possible.
Some system doesn't have libc.a available.

While we're at here, also export GOROOT in run.bash, so that
one doesn't need to set GOROOT to run run.bash.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/99870043
2014-04-29 14:43:10 -04:00
Robert Hencke
f999e14f02 all: spelling tweaks, A-G
LGTM=ruiu, bradfitz
R=golang-codereviews, bradfitz, ruiu
CC=golang-codereviews
https://golang.org/cl/91840044
2014-04-29 12:44:40 -04:00
Ian Lance Taylor
fee51f45ab cmd/cgo: for gccgo add #define to cgo_export.h for expected name
For gccgo we rename exported functions so that the compiler
will make them visible.  This CL adds a #define so that C
functions that #include "cgo_export.h" can use the expected
names of the function.

The test for this is the existing issue6833 test in
misc/cgo/test.  Without this CL it fails when using
-compiler=gccgo.

LGTM=minux.ma, rsc
R=golang-codereviews, gobot, rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/91830046
2014-04-29 08:53:38 -04:00
Shenghou Ma
382cc8cb39 make.bash: if CC is not set, and gcc doesn't exist, try clang/clang++.
This should make Go build without setting CC and CXX on newer FreeBSDs.

LGTM=iant
R=golang-codereviews, dave, gobot, iant
CC=golang-codereviews
https://golang.org/cl/89230045
2014-04-29 00:32:16 -04:00
Mikio Hara
7e41abbc6b net: make WriteTo, WriteToIP and WriteMsgIP fail when IPConn is already connected
This CL tries to fill the gap between Linux and other Unix-like systems
in the same way UDPConn and UnixConn already did.

Fixes #7887.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/97810043
2014-04-29 12:37:16 +09:00
Shenghou Ma
4cc708ae1d log/syslog: document if network=="" for Dial, it will connect to local syslog server.
Fixes #7828.

LGTM=robert.hencke, iant, bradfitz
R=golang-codereviews, robert.hencke, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/97780045
2014-04-28 14:29:45 -04:00
Keith Randall
29d1b211fd runtime: clean up scanning of Gs
Use a real type for Gs instead of scanning them conservatively.
Zero the schedlink pointer when it is dead.

Update #7820

LGTM=rsc
R=rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/89360043
2014-04-28 12:47:09 -04:00
Keith Randall
573cfe9561 runtime: heapdump - make sure spans are swept before dumping.
LGTM=rsc
R=golang-codereviews, adonovan, rsc
CC=golang-codereviews
https://golang.org/cl/90440043
2014-04-28 12:45:00 -04:00
Mikio Hara
6dac550270 syscall: don't display syscall prototype lines on godoc
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/90810045
2014-04-28 13:38:23 +09:00
Mikio Hara
d873e642cd syscall: add missing SendmsgN for NaCl
Update #7645

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/98790044
2014-04-28 11:34:52 +09:00
Robert Hencke
78fbe9020c net/tcp: fix check for openbsd in test
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/98740045
2014-04-27 17:39:13 -07:00
Mikio Hara
d844d6982e syscall: fix handling socket control messages on dragonfly
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/91860043
2014-04-27 22:28:41 +09:00
Peter Collingbourne
8cb916f71d cmd/cgo: fix C.CString for strings containing null terminators under gccgo
Previously we used strndup(3) to implement C.CString for gccgo. This
is wrong because strndup assumes the string to be null terminated,
and stops at the first null terminator. Instead, use malloc
and memmove to create a copy of the string, as we do in the
gc implementation.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/96790047
2014-04-26 22:16:38 -07:00
Brad Fitzpatrick
9f2e1efd72 net/http/httputil: tell people not to use ClientConn and ServerConn
A very smart developer at Gophercon just asked me to help debug
a problem and I was horrified to learn that he was using httputil's
ClientConn. I forgot ClientConn and ServerConn were even included
in Go 1! They should've been deleted.

Scare people away from using them. The net/http package does
not use them and they're unused, unmaintained and untouched in
4+ years.

LGTM=r
R=r, adg
CC=golang-codereviews
https://golang.org/cl/92790043
2014-04-26 22:14:39 -07:00
Robert Obryk
4c129c083b net: Remove an unmatched unlock of ForkLock
Remove an RUnlock of syscall.ForkLock with no matching RLock.
Holding ForkLock in netFD.dup is unnecessary: dupCloseOnExecOld
locks and unlocks the lock on its own and dupCloseOnExec doesn't
need the ForkLock to be held.

LGTM=iant
R=golang-codereviews, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/99800044
2014-04-26 19:59:00 -07:00
Rui Ueyama
9d7b9fb7d0 encoding/ascii85: handle non-data bytes correctly
Previously Read wouldn't return once its internal input buffer
is filled with non-data bytes.
Fixes #7875.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/90820043
2014-04-26 19:56:06 -07:00
Robert Hencke
d46134830f src: fix issues found by go vet std
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96850043
2014-04-26 19:54:48 -07:00
Brad Fitzpatrick
8409dea8ee os: cap reads and writes to 2GB on Darwin and FreeBSD
Fixes #7812

LGTM=josharian, iant
R=rsc, iant, adg, ruiu, minux.ma, josharian
CC=golang-codereviews
https://golang.org/cl/89900044
2014-04-26 10:34:33 -07:00
Jonathan Allie
7faf72bd0d encoding/gob: handle interface types in isZero() by returning true for nil interfaces.
Fixes #7741.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/96830044
2014-04-26 10:25:16 -06:00
Brad Fitzpatrick
d0402cb416 net/http/httputil: don't leak goroutines in DumpRequestOut
Fixes #7869

LGTM=dsymonds
R=golang-codereviews
CC=adg, dsymonds, golang-codereviews, rsc
https://golang.org/cl/91770048
2014-04-25 15:19:32 -07:00
Mikio Hara
e419ab6452 net: make WriteMsg{IP,UDP,Unix} return the correct number of bytes transferred
Fixes #7645

LGTM=iant, bradfitz
R=iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/90170046
2014-04-26 06:52:37 +09:00
Robert Griesemer
9144d8752a bufio: make all read functions UnreadByte-friendly
Fixes #7844.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/90620045
2014-04-25 09:46:07 -06:00
Brad Fitzpatrick
13ea1fd233 net/http, strings, bytes: fix http race, revert part of Reader behavior change
I fixed this data race regression in two ways: in net/http itself, and also
partially reverting the change from https://golang.org/cl/77580046 .
Previously a Read from a strings.Reader or bytes.Reader returning 0 bytes
would not be a memory write. After 77580046 it was. This reverts that back
in case others depended on that. Also adds tests.

Fixes #7856

LGTM=ruiu, iant
R=iant, ruiu
CC=golang-codereviews, gri
https://golang.org/cl/94740044
2014-04-25 06:44:51 -07:00
Rui Ueyama
f40e574d85 net: fix confusing typo in comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/93750043
2014-04-24 12:24:22 -07:00
Rob Pike
59d7aa32ca math/cmpx: change space to tab in the Pow docs for better formatting
Godoc makes it look better this way; before, it all ran together into nonsense.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/90400045
2014-04-22 21:12:15 -07:00
Brad Fitzpatrick
5600572249 os/exec: deflake a test on Linux
Work around buggy(?) Linux /proc filesystem.

Fixes #7808

LGTM=iant
R=golang-codereviews, iant
CC=adg, golang-codereviews
https://golang.org/cl/90400044
2014-04-22 17:13:38 -07:00
Rui Ueyama
7ff8e90eb7 strings: fix off-by-one error in test
Previously it would panic because of out-of-bound access
if s1 is longer than s2.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/90110043
2014-04-21 17:00:27 -07:00
Robert Griesemer
2653386ce8 math/big: fix Int.Exp
Fixes #7814.

LGTM=agl, adonovan
R=agl, adonovan
CC=golang-codereviews
https://golang.org/cl/90080043
2014-04-21 15:54:51 -07:00
Josh Bleecher Snyder
9cddb60d25 net: extend TestVariousDeadlines1Proc timeout
TestVariousDeadlines1Proc was flaky on my system,
failing on about 5% of runs.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/89830045
2014-04-21 13:07:51 -07:00
Mark Zavislak
800d8adf35 runtime: fix typo in error message
LGTM=robert.hencke, iant
R=golang-codereviews, robert.hencke, iant
CC=golang-codereviews
https://golang.org/cl/89760043
2014-04-21 08:55:23 -07:00
Rémy Oudompheng
1332eb5b62 runtime/race: add test for issue 7561.
LGTM=dvyukov
R=rsc, iant, khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/76520045
2014-04-21 17:21:09 +02:00
Alex Brainman
296eeaa78d cmd/nm: do not fail TestNM if symbol has less then 3 columns in nm output
Fixes #7829

LGTM=dave
R=golang-codereviews, aram, dave
CC=golang-codereviews
https://golang.org/cl/89830043
2014-04-21 21:12:18 +10:00
Alex Brainman
6a40d549f1 cmd/nm: disable TestNM on darwin, linux and solaris
Update #7829

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/89810043
2014-04-21 20:36:35 +10:00
Alex Brainman
80e7f97206 cmd/ld: correct addresses in windows pe symbol table
This should have been part of 36eb4a62fbb6,
but I later discovered that addresses are all wrong.
Appropriate test added now.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/89470043
2014-04-21 19:28:02 +10:00
Shenghou Ma
1bb4f37fce runtime, go/build: re-enable cgo on FreeBSD.
Fixes #7331.

LGTM=dave, iant
R=golang-codereviews, dave, gobot, iant
CC=golang-codereviews
https://golang.org/cl/89150043
2014-04-21 00:09:22 -04:00
Shenghou Ma
d31d19765b runtime, cmd/ld, cmd/5l, run.bash: enable external linking on FreeBSD/ARM.
Update #7331

LGTM=dave, iant
R=golang-codereviews, dave, gobot, iant
CC=golang-codereviews
https://golang.org/cl/89520043
2014-04-21 00:08:59 -04:00
Shenghou Ma
9ba153e3e0 lib9: restore argv0 initialization code.
`GOARCH=arm go tool 6c` used to give "<prog>: cannot use 6c with GOARCH=arm"

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/89330043
2014-04-21 00:08:39 -04:00
Shenghou Ma
0a8f5177f6 cmd/go: handle -ccflags in 'go test'
CL 89050043 only allows -ccflags for 'go test', this
CL really handles the flag like the other -??flags.
Many thanks to Dobrosław Żybort for pointing this out.
Fixes #7810 (again).

LGTM=iant, matrixik
R=golang-codereviews, iant, matrixik
CC=golang-codereviews
https://golang.org/cl/89230044
2014-04-21 00:02:21 -04:00
Jan Ziak
943dc2cb8d cmd/gc: avoid %L in error message
Fixes #7783

LGTM=minux.ma
R=rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/89290043
2014-04-20 11:02:01 +02:00
Alex Brainman
6e8c7f5bb2 cmd/nm: print symbol sizes for windows pe executables
Fixes #6973

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/88820043
2014-04-19 14:47:20 +10:00
Mike Andrews
7c7aaa4156 cmd/ld: don't delete output binary if not "ordinary" file (redux).
following on CL https://golang.org/cl/76810045 and
issue 7563, i now see there's another "remove(outfile)" a few
dozen lines down that also needs fixing.

LGTM=iant
R=golang-codereviews, iant
CC=0intro, golang-codereviews, r
https://golang.org/cl/89030043
2014-04-18 15:37:55 -07:00
Lucio De Re
cd4c1f18a1 pkg/reflect/value.go: Correction in comment, the argument is "typ", not "t".
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/89270043
2014-04-18 08:11:31 -07:00
Shenghou Ma
4b9ab7dd69 os: change return variable name for Getwd to avoid confusion
changed (pwd string) to (dir string), as some think pwd means passwd.
Fixes #7811.

LGTM=iant
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/89100043
2014-04-17 23:17:15 -04:00
Shenghou Ma
c7d864c4d0 cmd/go: support -ccflags in 'go test'
Fixes #7810.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/89050043
2014-04-17 23:16:11 -04:00
Brad Fitzpatrick
8f76641230 net/http/httputil: include Content-Length in DumpResponse output
Fixes #5357

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/87910050
2014-04-17 14:03:05 -07:00
Brad Fitzpatrick
c45392bae0 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
2014-04-17 13:28:40 -07:00
Russ Cox
576318c7bd 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
2014-04-17 16:25:38 -04:00
Ian Lance Taylor
6524310770 cmd/pack: handle very long lines in pkgdef
LGTM=rsc, bradfitz
R=golang-codereviews, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/88170049
2014-04-17 11:47:12 -07:00
Volker Dobler
ed88076c64 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
2014-04-16 23:01:02 -07:00
Ian Lance Taylor
827aab07b8 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
2014-04-16 20:28:53 -07:00
Shenghou Ma
32dffef098 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
2014-04-16 23:12:06 -04:00
Robert Daniel Kortschak
6277cc3df5 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
2014-04-16 22:43:44 -04:00
Shenghou Ma
6f25f1d4c9 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
2014-04-16 22:42:24 -04:00
Jan Ziak
1d2b71ce83 cmd/gc: fewer errors for wrong argument count
Fixes #7675

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/85040044
2014-04-16 22:42:09 -04:00
Anthony Martin
1e2a61aee1 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
2014-04-16 22:42:02 -04:00
Russ Cox
6f2d91a094 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
2014-04-16 22:30:10 -04:00
Alex Brainman
fce4f0484c 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
2014-04-16 22:25:40 -04:00
Alex Brainman
06dc4e78c4 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
2014-04-16 22:17:38 -04:00
Alex Brainman
387895f9ac 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
2014-04-16 22:10:59 -04:00
Russ Cox
5e8c922625 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
2014-04-16 22:08:00 -04:00
Brad Fitzpatrick
877e0a135f encoding/xml: document NewDecoder buffering
Fixes #7225

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, rsc
https://golang.org/cl/88710043
2014-04-16 17:16:08 -07:00
Rob Pike
1f40b841b3 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
2014-04-16 17:14:48 -07:00
Rui Ueyama
fb91559fbd all: fix typos
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/88670043
2014-04-16 16:57:25 -07:00
Ian Lance Taylor
58b86e5013 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
2014-04-16 14:36:44 -07:00
Russ Cox
cc08d9232c 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
2014-04-16 17:11:44 -04:00
Alan Donovan
0de521d111 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
2014-04-16 16:17:50 -04:00
Alan Donovan
d079144190 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
2014-04-16 14:51:33 -04:00
Brad Fitzpatrick
a6d3cc2904 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
2014-04-16 11:32:41 -07:00
Brad Fitzpatrick
6ddd995af5 net/http: fix data race in TestTransportResponseHeaderTimeout
Fixes #7264

LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/87970045
2014-04-16 11:32:16 -07:00
Russ Cox
0a8a719ded 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
2014-04-16 13:59:42 -04:00
Russ Cox
ade6bc68b0 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
2014-04-16 13:12:18 -04:00
Russ Cox
468cf82780 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
2014-04-16 11:53:14 -04:00
Russ Cox
fcf8a77525 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
2014-04-16 11:52:27 -04:00
Russ Cox
a5b1530557 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
2014-04-16 11:39:43 -04:00
Shenghou Ma
d0d425a987 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
2014-04-16 01:46:56 -04:00
Shenghou Ma
a4ff90df28 cmd/ld: correct comment.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/88360044
2014-04-16 01:41:47 -04:00
Shenghou Ma
560471fbab run.bash: fix build on netbsd builders.
LGTM=bradfitz
R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/88000044
2014-04-15 23:54:04 -04:00
Billie Harold Cleek
cabdb85333 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
2014-04-16 13:40:47 +10:00
Brad Fitzpatrick
853c99ddb8 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
2014-04-15 19:40:00 -07:00
Nigel Tao
c47f08657a 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
2014-04-16 12:18:57 +10:00
Russ Cox
dacc020c00 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
2014-04-15 21:17:18 -04:00
Russ Cox
e97b3ab1f9 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
2014-04-15 20:46:46 -04:00
Brad Fitzpatrick
fdade68379 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
2014-04-15 17:36:25 -07:00
Brad Fitzpatrick
a1ae3a0536 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
2014-04-15 17:14:03 -07:00
Russ Cox
44f96d4488 addr2line, objdump: write doc comments
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/88050046
2014-04-15 20:06:08 -04:00
Russ Cox
22505cd2a1 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
2014-04-15 20:05:56 -04:00
David du Colombier
b9f5dce4fc net/http: skip TestTransportClosesBodyOnError on Plan 9
LGTM=rsc
R=bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/87800044
2014-04-16 00:48:21 +02:00
Shenghou Ma
0a96d64c9c math/big: fix doc typos.
Fixes #7768.

LGTM=iant, gri
R=golang-codereviews, iant, gri
CC=golang-codereviews
https://golang.org/cl/87260043
2014-04-15 14:50:19 -07:00
Russ Cox
ed890e7414 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
2014-04-15 15:52:23 -04:00
Russ Cox
568e3526b1 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
2014-04-15 15:52:02 -04:00
Russ Cox
6f8b120869 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
2014-04-15 12:13:52 -07:00
Russ Cox
90093f0634 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
2014-04-15 13:45:39 -04:00
Rob Pike
aeb37527d3 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
2014-04-15 08:48:40 -07:00