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

14634 Commits

Author SHA1 Message Date
Mikio Hara
4f1aecf2c4 net: deflake TestTCPConcurrentAccept
Some platform that implements inp_localgroup-like shared internet
protocol control block group looks a bit sensitive about transport
layer protocol's address:port reuse. Sometimes it rejects a TCP SYN
packet using TCP RST, and sometimes silence.

For now, until test case refactoring, we admit few Dial failures on
TestTCPConcurrentAccept as a workaround.

Update #7400
Update #7541

LGTM=jsing
R=jsing
CC=golang-codereviews
https://golang.org/cl/75920043
2014-03-25 02:56:37 +09:00
Mikio Hara
d1e3ad8bc1 net: avoid multiple calling of syscall connect on Unix variants
The previous fix CL 69340044 still leaves a possibility of it.
This CL prevents the kernel, especially DragonFly BSD, from
performing unpredictable asynchronous connection establishment
on stream-based transport layer protocol sockets.

Update #7541
Update #7474

LGTM=jsing
R=jsing
CC=golang-codereviews
https://golang.org/cl/75930043
2014-03-25 02:56:10 +09:00
Mikio Hara
4ffa021965 runtime: slience warning on 32-bit platforms
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/80250043
2014-03-26 10:21:22 +09:00
Alex Brainman
a837347dd9 runtime: use VEH for windows/amd64 exception handling
Fixes windows/amd64 build.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/79470046
2014-03-26 11:13:50 +11:00
Brad Fitzpatrick
aa2d4dee60 net/http: disable recently-introduced flaky test on Windows
Disable it until it's debugged so it doesn't hide other real
problems on Windows. The test was known to be unreliable
anyway (which is why it only needed 1 of 20 runs to pass), but
apparently it never passes on Windows. Figure out why later.

Update #7634

LGTM=alex.brainman
R=adg, alex.brainman
CC=golang-codereviews
https://golang.org/cl/80110043
2014-03-25 15:19:58 -07:00
Keith Randall
fff63c2448 runtime: WriteHeapDump dumps the heap to a file.
See http://golang.org/s/go13heapdump for the file format.

LGTM=rsc
R=rsc, bradfitz, dvyukov, khr
CC=golang-codereviews
https://golang.org/cl/37540043
2014-03-25 15:09:49 -07:00
Ian Lance Taylor
bee3848f4e runtime: fix windows build (buggy commit in 19543:d68b79ccbfed)
TBR=rsc
CC=golang-codereviews
https://golang.org/cl/80090043
2014-03-25 14:17:00 -07:00
Keith Randall
1b45cc45e3 runtime: redo stack map entries to avoid false retention
Change two-bit stack map entries to encode:
0 = dead
1 = scalar
2 = pointer
3 = multiword

If multiword, the two-bit entry for the following word encodes:
0 = string
1 = slice
2 = iface
3 = eface

That way, during stack scanning we can check if a string
is zero length or a slice has zero capacity.  We can avoid
following the contained pointer in those cases.  It is safe
to do so because it can never be dereferenced, and it is
desirable to do so because it may cause false retention
of the following block in memory.

Slice feature turned off until issue 7564 is fixed.

Update #7549

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/76380043
2014-03-25 14:11:34 -07:00
Ian Lance Taylor
4ebfa83199 runtime: accurately record whether heap memory is reserved
The existing code did not have a clear notion of whether
memory has been actually reserved.  It checked based on
whether in 32-bit mode or 64-bit mode and (on GNU/Linux) the
requested address, but it confused the requested address and
the returned address.

LGTM=rsc
R=rsc, dvyukov
CC=golang-codereviews, michael.hudson
https://golang.org/cl/79610043
2014-03-25 13:22:19 -07:00
Brad Fitzpatrick
cc2c5fc3d2 net/http: don't re-use Transport connections if we've seen an EOF
This the second part of making persistent HTTPS connections to
certain servers (notably Amazon) robust.

See the story in part 1: https://golang.org/cl/76400046/

This is the http Transport change that notes whether our
net.Conn.Read has ever seen an EOF. If it has, then we use
that as an additional signal to not re-use that connection (in
addition to the HTTP response headers)

Fixes #3514

LGTM=rsc
R=agl, rsc
CC=golang-codereviews
https://golang.org/cl/79240044
2014-03-25 10:59:09 -07:00
Brad Fitzpatrick
f61f18d694 crypto/tls: make Conn.Read return (n, io.EOF) when EOF is next in buffer
Update #3514

An io.Reader is permitted to return either (n, nil)
or (n, io.EOF) on EOF or other error.

The tls package previously always returned (n, nil) for a read
of size n if n bytes were available, not surfacing errors at
the same time.

Amazon's HTTPS frontends like to hang up on clients without
sending the appropriate HTTP headers. (In their defense,
they're allowed to hang up any time, but generally a server
hangs up after a bit of inactivity, not immediately.) In any
case, the Go HTTP client tries to re-use connections by
looking at whether the response headers say to keep the
connection open, and because the connection looks okay, under
heavy load it's possible we'll reuse it immediately, writing
the next request, just as the Transport's always-reading
goroutine returns from tls.Conn.Read and sees (0, io.EOF).

But because Amazon does send an AlertCloseNotify record before
it hangs up on us, and the tls package does its own internal
buffering (up to 1024 bytes) of pending data, we have the
AlertCloseNotify in an unread buffer when our Conn.Read (to
the HTTP Transport code) reads its final bit of data in the
HTTP response body.

This change makes that final Read return (n, io.EOF) when
an AlertCloseNotify record is buffered right after, if we'd
otherwise return (n, nil).

A dependent change in the HTTP code then notes whether a
client connection has seen an io.EOF and uses that as an
additional signal to not reuse a HTTPS connection. With both
changes, the majority of Amazon request failures go
away. Without either one, 10-20 goroutines hitting the S3 API
leads to such an error rate that empirically up to 5 retries
are needed to complete an API call.

LGTM=agl, rsc
R=agl, rsc
CC=golang-codereviews
https://golang.org/cl/76400046
2014-03-25 10:58:35 -07:00
Ian Lance Taylor
8de04c78b7 runtime: change nproc local variable to uint32
The nproc and ndone fields are uint32.  This makes the type
consistent.

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/79340044
2014-03-25 05:18:08 -07:00
Nigel Tao
50ca1a52ca database/sql: add "defer rows.Close()" to the example code.
Strictly speaking, it's not necessary in example_test.go, as the
Rows.Close docs say that "If Next returns false, the Rows are closed
automatically". However, if the for loop breaks or returns early, it's
not obvious that you'll leak unless you explicitly call Rows.Close.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, rsc
https://golang.org/cl/79330043
2014-03-25 13:32:18 +11:00
Russ Cox
3750904a7e runtime: use VEH, not SEH, for windows/386 exception handling
Structured Exception Handling (SEH) was the first way to handle
exceptions (memory faults, divides by zero) on Windows.
The S might as well stand for "stack-based": the implementation
interprets stack addresses in a few different ways, and it gets
subtly confused by Go's management of stacks. It's also something
that requires active maintenance during cgo switches, and we've
had bugs in that maintenance in the past.

We have recently come to believe that SEH cannot work with
Go's stack usage. See http://golang.org/issue/7325 for details.

Vectored Exception Handling (VEH) is more like a Unix signal
handler: you set it once for the whole process and forget about it.

This CL drops all the SEH code and replaces it with VEH code.
Many special cases and 7 #ifdefs disappear.

VEH was introduced in Windows XP, so Go on windows/386 will
now require Windows XP or later. The previous requirement was
Windows 2000 or later. Windows 2000 immediately preceded
Windows XP, so Windows 2000 is the only affected version.
Microsoft stopped supporting Windows 2000 in 2010.
See http://golang.org/s/win2000-golang-nuts for details.

Fixes #7325.

LGTM=alex.brainman, r
R=golang-codereviews, alex.brainman, stephen.gutekanst, dave
CC=golang-codereviews, iant, r
https://golang.org/cl/74790043
2014-03-24 21:22:16 -04:00
Russ Cox
3b27343c14 time: add comment explaining rejection of years outside [0000,9999]
This has come up twice now. Redirect future questions
to the explanation in the issue tracker.

LGTM=iant, r
R=r, iant
CC=golang-codereviews
https://golang.org/cl/79550043
2014-03-24 20:34:17 -04:00
Rob Pike
a9014ba415 math/cmplx: define Pow(0, x) for problematic values of x.
Currently it's always zero, but that is inconsistent with math.Pow
and also plain wrong.
This is a proposal for how it should be defined.
Fixes #7583.

LGTM=rsc
R=golang-codereviews, iant, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/76940044
2014-03-25 11:25:20 +11:00
Rob Pike
929ee59fce regexp/syntax: document the upper limit of n in x{n}
Fixes #7252.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/77990044
2014-03-25 11:19:25 +11:00
Rob Pike
c790b029e6 regexp: document that it is linear in the input size.
Fixes #7488.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/78050043
2014-03-25 11:17:30 +11:00
Jan Ziak
833dae6d26 cmd/gc: fix spurious 'const initializer is not a constant' error
Fixes #6403

LGTM=rsc
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/72840044
2014-03-24 20:36:42 +01:00
Rui Ueyama
4ffc799295 bufio: fix bug that ReadFrom stops before EOF or error
ReadFrom should not return until it receives a non-nil error
or too many contiguous (0, nil)s from a given reader.
Currently it immediately returns if it receives one (0, nil).
Fixes #7611.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/76400048
2014-03-24 11:48:34 -07:00
Jan Ziak
a43673cf8a cmd/gc: round floats with a large negative exponent towards zero
Fixes #6902

LGTM=iant
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/78730049
2014-03-24 10:10:29 -07:00
Rui Ueyama
de1ea5de86 strings: minor cleanup
bi is a slice and not an array, so bi[:] does not make much sense.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/79280043
2014-03-23 18:58:35 -07:00
Rui Ueyama
446d90d727 unicode/utf8: minor code simplification
It's a little bit waste to check if r is not a surrogate
code point because RuneError is not a surrogate code point.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/79230043
2014-03-23 15:44:29 -07:00
Rui Ueyama
160649ff9a unicode/utf16: remove unnecessary type conversions
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/79080044
2014-03-23 15:07:26 -07:00
Rui Ueyama
fa445849d1 bufio: fix typo in test
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/79120043
2014-03-22 17:40:17 -07:00
Rui Ueyama
ed97788af9 regexp: remove unused variables
"min" and "max" in "case '{'" clause are fresh variables.
The variables defined in the outer scope never get value
other than 0.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/78750044
2014-03-22 11:05:40 -07:00
Rui Ueyama
b89a9fff5e text/scanner: handle non-io.EOF errors
Currently Scan ignores an error returned from source if the number
of bytes source has read is 0.

Fixes #7594.

LGTM=gri
R=golang-codereviews, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/78120043
2014-03-21 17:05:57 -07:00
David du Colombier
dc008af94d cmd/ld: fix warnings on Plan 9
warning: src/cmd/ld/macho.c:595 sign-extended character constant
warning: src/cmd/ld/macho.c:595 sign-extended character constant
warning: src/cmd/ld/symtab.c:63 sign-extended character constant
warning: src/cmd/ld/symtab.c:63 sign-extended character constant

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76580046
2014-03-21 19:26:47 +01:00
David du Colombier
f182a6eec8 runtime: skip stack growth test in short mode
LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/78410043
2014-03-21 18:13:23 +01:00
Adam Langley
050b60a369 encoding/asn1: use GeneralizedTime for times outside the range of UTCTime.
Fixes issue #6976.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/72080044
2014-03-21 11:14:38 -04:00
Rémy Oudompheng
0285d2b96b cmd/6g, cmd/8g: skip CONVNOP nodes in bgen.
Revision 3ae4607a43ff introduced CONVNOP layers
to fix type checking issues arising from comparisons.
The added complexity made 8g run out of registers
when compiling an equality function in go.net/ipv6.

A similar issue occurred in test/sizeof.go on
amd64p32 with 6g.

Fixes #7405.

LGTM=khr
R=rsc, dave, iant, khr
CC=golang-codereviews
https://golang.org/cl/78100044
2014-03-20 22:22:37 +01:00
Rémy Oudompheng
ea7d801130 reflect: correct alignment of call arguments on amd64p32.
Changes adapted from original CL 15680044.

LGTM=iant
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/76150044
2014-03-20 22:22:07 +01:00
Rémy Oudompheng
ceb346685d cmd/6g: make comment more consistent.
LGTM=dave, iant
R=iant, khr, rsc, dave
CC=golang-codereviews
https://golang.org/cl/77960044
2014-03-20 22:21:10 +01:00
Brad Fitzpatrick
ca2cb5190b crypto/tls: clarify concurrent use of Config
LGTM=r, agl
R=agl, r
CC=golang-codereviews
https://golang.org/cl/77530044
2014-03-20 08:32:06 -07:00
Rui Ueyama
a2770af447 base64: fix bug that decoder fails to detect corruption
Encoding.Decode() failed to detect trailing garbages if input contains "==" followed by garbage smaller than 3 bytes (for example, it failed to detect "x" in "AA==x"). This patch fixes the bug and adds a few tests.

LGTM=nigeltao
R=golang-codereviews, bradfitz, nigeltao
CC=golang-codereviews
https://golang.org/cl/75340044
2014-03-20 16:00:34 +11:00
Rui Ueyama
90a66fa6af base32: remove unnecessary "if" condition
This is a patch to apply the same change as CL 76610045.

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/77460044
2014-03-20 15:54:17 +11:00
Ian Lance Taylor
6ea340fd61 cmd/6g: remove unused stosptr variable
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/78030043
2014-03-19 17:18:25 -07:00
Keith Randall
14664050b9 cmd/6g: do small zeroings with straightline code.
Removes most uses of the REP prefix, which has a high startup cost.

LGTM=iant
R=golang-codereviews, iant, khr
CC=golang-codereviews
https://golang.org/cl/77920043
2014-03-19 15:41:34 -07:00
Rob Pike
b00d967706 fmt: make %F a synonym for %f
Rationale:
        It already is for scanning.
        It is accepted for complexes already, but doesn't work.
        It's analogous to %G and %E.
        C accepts it too, and we try to be roughly compatible.
Fixes #7518.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77580044
2014-03-20 08:51:06 +11:00
Rui Ueyama
cc4bdf0226 strings, bytes: ReadAt should not mutate receiver
CL 77580046 caused a data race issue with tests that assumes ReadAt
does not mutate receiver. This patch partially revert CL 77580046
to fix it.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77900043
2014-03-19 12:13:47 -07:00
Rui Ueyama
79b3daa977 unicode: minor cleanup
These test cases are redundant because TestSimpleFold tests
all possible rotations of test data, so no need to add
rotated strings.

Also updated the comment as it's guaranteed that SimpleFold
returns values in increasing order.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77730043
2014-03-19 10:14:04 -07:00
Rui Ueyama
a509026ff0 strings, bytes: fix Reader.UnreadRune
UnreadRune should return an error if previous operation is not
ReadRune.

Fixes #7579.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77580046
2014-03-19 09:00:58 -07:00
Dmitriy Vyukov
8a908efd74 runtime: add stack growth tests
Also move generated code into a separate file,
because it's difficult to work with the file otherwise.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/76080044
2014-03-19 17:22:56 +04:00
Dmitriy Vyukov
1895014257 runtime: fix stack split detection around fork
If runtime_BeforeFork splits stack, it will unsplit it
with spoiled g->stackguard. It leads to check failure in oldstack:

fatal error: stackfree: bad fixed size

runtime stack:
runtime.throw(0xadf3cd)
runtime.stackfree(0xc208040480, 0xfffffffffffff9dd, 0x1b00fa8)
runtime.oldstack()
runtime.lessstack()

goroutine 311 [stack unsplit]:
syscall.forkAndExecInChild(0xc20802eea0, 0xc208192c00, 0x5, 0x5, 0xc208072a80, ...)
syscall.forkExec(0xc20802ed80, 0x54, 0xc2081ccb40, 0x4, 0x4, ...)

Fixes #7567.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, khr, rsc
https://golang.org/cl/77340045
2014-03-19 17:04:51 +04:00
Jan Ziak
cb50277510 cmd/gc: check exponent overflow and underflow in mparith
A too large float constant is an error.
A too small float constant is rounded to zero.

Fixes #7419
Update #6902

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76730046
2014-03-19 05:48:00 +01:00
Rui Ueyama
1a21dbc572 bytes: fix panic in Map
utf8.RuneLen returns -1 for an invalid rune. In that case we
need to extend the internal buffer at least by 3 for \uFFFD.

Fixes #7577.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/77420044
2014-03-18 20:52:58 -07:00
Rob Pike
f34251a91c strconv: CanBackquote should reject \x7F
It's a control character.
Fixes #7565.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77300043
2014-03-19 10:16:48 +11:00
Jan Ziak
f081e2b9f4 cmd/go: let build -x output describe CGO_LDFLAGS env variable
Fixes #7249

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/75820046
2014-03-18 21:47:21 +01:00
Brad Fitzpatrick
666f5b4a89 expvar: don't recursively acquire Map.RLock
Fixes #7575

LGTM=iant
R=dvyukov, iant
CC=golang-codereviews
https://golang.org/cl/77540044
2014-03-18 11:38:39 -07:00
Mikio Hara
d7039b71a9 net/http: make use of testing.Errorf instead of testing.Fatalf in non-test function goroutines
See testing.FailNow for further information.
Also avoid nil pointer derefernce in TestTransportMaxPerHostIdleConns.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/76470043
2014-03-18 21:12:00 +09:00
Rui Ueyama
41818f8fcc base64: refactor encoder.Write
"nn" can never be zero for any input "p", so no check is needed.
This change should improve readability a bit.

LGTM=nigeltao
R=golang-codereviews, bradfitz, nigeltao
CC=golang-codereviews
https://golang.org/cl/76610045
2014-03-18 16:26:23 +11:00
Rob Pike
108a4dcd75 cmd/go: make the default coverage mode -atomic if -race is set
Fixes #7013.

LGTM=adg
R=golang-codereviews, gobot, adg
CC=golang-codereviews
https://golang.org/cl/76370043
2014-03-18 14:38:40 +11:00
Rob Pike
0de0de0907 fmt: document GoStringer and explain application of formats to compound objects
%q quotes each element of a string slice; this was never explained in the docs.
Fixes #7015.

LGTM=josharian
R=golang-codereviews, josharian
CC=golang-codereviews
https://golang.org/cl/77140044
2014-03-18 11:25:04 +11:00
Luka Zakrajšek
2701dadbac net/http: Request Body error should not be ignored.
Fixes #7521.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/76320043
2014-03-17 15:52:52 -07:00
Catalin Patulea
a387f91553 net/http/fcgi: fix handling of request ID reuse
Request ID reuse is allowed by the FastCGI spec [1]. In particular nginx uses
the same request ID, 1, for all requests on a given connection. Because
serveRequest does not remove the request from conn.requests, this causes it to
treat the second request as a duplicate and drops the connection immediately
after beginRequest. This manifests with nginx option 'fastcgi_keep_conn on' as
the following message in nginx error log:

2014/03/17 01:39:13 [error] 730#0: *109 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: example.org, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "example.org"

Because handleRecord and serveRequest run in different goroutines, access to
conn.requests must now be synchronized.

[1] http://www.fastcgi.com/drupal/node/6?q=node/22#S3.3

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/76800043
2014-03-17 15:47:16 -07:00
Rui Ueyama
01d49dc2dd encoding/hex: add error check for write error.
I believe the original author of this code just forgot to check for error here.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/76760043
2014-03-17 12:07:30 -07:00
Ian Lance Taylor
e3609ca672 cmd/gc: fix comment about how GOEXPERIMENT works
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/76270043
2014-03-15 11:18:11 -07:00
Mikio Hara
f0433e422b net: make use of testing.Errorf instead of testing.Fatalf in non-test function goroutines
See testing.FailNow for further information.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/75900043
2014-03-15 13:43:02 +09:00
Rémy Oudompheng
6436df0d81 runtime: fix 386 assembly for syscall.naclWrite
It was using the wrong offset and returned random values
making "runoutput" compiler tests crash.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76250043
2014-03-14 22:49:46 +01:00
Rémy Oudompheng
88f84b3e41 liblink, runtime: make nacl/386 binaries valid.
They were rejected by NaCl due to AES instructions and
accesses to %gs:0x8, caused by wrong tlsoffset value.

LGTM=iant
R=rsc, dave, iant
CC=golang-codereviews
https://golang.org/cl/76050044
2014-03-14 21:33:55 +01:00
Dmitriy Vyukov
fed5428c4a runtime: fix another race in bgsweep
It's possible that bgsweep constantly does not catch up for some reason,
in this case runfinq was not woken at all.

R=rsc
CC=golang-codereviews
https://golang.org/cl/75940043
2014-03-14 23:32:12 +04:00
Dmitriy Vyukov
8d321625fd runtime: fix spans corruption
The problem was that spans end up in wrong lists after split
(e.g. in h->busy instead of h->central->empty).
Also the span can be non-swept before split,
I don't know what it can cause, but it's safer to operate on swept spans.
Fixes #7544.

R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/76160043
2014-03-14 23:25:48 +04:00
Rémy Oudompheng
f210fd1fa9 cmd/6g, runtime: alignment fixes for amd64p32.
LGTM=rsc
R=rsc, dave, iant, khr
CC=golang-codereviews
https://golang.org/cl/75820044
2014-03-14 19:37:39 +01:00
Dmitriy Vyukov
d8e6881166 runtime: report "out of memory" in efence mode
Currently processes crash with obscure message.
Say that it's "out of memory".

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/75820045
2014-03-14 21:22:03 +04:00
Dmitriy Vyukov
0da73b9f07 runtime: fix a race in bgsweep
See the comment for description.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75670044
2014-03-14 21:21:44 +04:00
Dmitriy Vyukov
b8d40172ce runtime: do not shrink stacks GOCOPYSTACK=0
LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/76070043
2014-03-14 21:11:04 +04:00
Jan Ziak
22aa54965e cmd/go: fix invalid go pack command line in the output of go build -x
Fixes #7262

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76110043
2014-03-14 16:44:54 +01:00
Jan Ziak
1483747f3c cmd/gc: fix spurious 'not enough arguments to return' error
Fixes #6405

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/72920046
2014-03-14 16:42:42 +01:00
Shenghou Ma
cbe777b2c7 cmd/gc: replace '·' as '.' in ELF/Mach-O symbol tables
Old versions of DTrace (as those shipped in OS X and FreeBSD)
don't support unicode characters in symbol names.  Replace '·'
to '.' to make DTrace happy.

Fixes #7493

LGTM=aram, rsc
R=aram, rsc, gobot, iant
CC=golang-codereviews
https://golang.org/cl/72280043
2014-03-14 10:07:51 -04:00
Aram Hăvărneanu
199e703083 runtime: fix use after close race in Solaris network poller
The Solaris network poller uses event ports, which are
level-triggered. As such, it has to re-arm itself after each
wakeup. The arming mechanism (which runs in its own thread) raced
with the closing of a file descriptor happening in a different
thread. When a network file descriptor is about to be closed,
the network poller is awaken to give it a chance to remove its
association with the file descriptor. Because the poller always
re-armed itself, it raced with code that closed the descriptor.

This change makes the network poller check before re-arming if
the file descriptor is about to be closed, in which case it will
ignore the re-arming request. It uses the per-PollDesc lock in
order to serialize access to the PollDesc.

This change also adds extensive documentation describing the
Solaris implementation of the network poller.

Fixes #7410.

LGTM=dvyukov, iant
R=golang-codereviews, bradfitz, iant, dvyukov, aram.h, gobot
CC=golang-codereviews
https://golang.org/cl/69190044
2014-03-14 17:53:05 +04:00
Keith Randall
4c6d2d6aa8 debug/macho: handle missing __debug_str section
debug/elf does the same thing, use []byte{} for
any missing sections.

Fixes #7510

LGTM=rsc
R=golang-codereviews, iant
CC=golang-codereviews, rsc
https://golang.org/cl/75230043
2014-03-13 14:04:29 -07:00
Anthony Martin
41aa887be5 runtime: fix signal handling on Plan 9
LGTM=rsc
R=rsc, 0intro, aram, jeremyjackins, iant
CC=golang-codereviews, lucio.dere, minux.ma, paurea, r
https://golang.org/cl/9796043
2014-03-13 09:00:12 -07:00
Dmitriy Vyukov
c115cda22c runtime: improve efence
Mark free memory blocks as unused.
On amd64 it allows the process to eat all 128 GB of heap
without killing the machine.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/74070043
2014-03-13 19:04:00 +04:00
Dmitriy Vyukov
e678ab4e37 runtime: detect stack split after fork
This check would allowed to easily prevent issue 7511.
Update #7511

LGTM=rsc
R=rsc, aram
CC=golang-codereviews
https://golang.org/cl/75260043
2014-03-13 17:41:08 +04:00
Dmitriy Vyukov
1569628725 runtime: harden conditions when runtime panics on crash
This is especially important for SetPanicOnCrash,
but also useful for e.g. nil deref in mallocgc.
Panics on such crashes can't lead to anything useful,
only to deadlocks, hangs and obscure crashes.
This is a copy of broken but already LGTMed
https://golang.org/cl/68540043/

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75320043
2014-03-13 13:25:59 +04:00
Dmitriy Vyukov
5daffee17f runtime: fix stack size check
When we copy stack, we check only new size of the top segment.
This is incorrect, because we can have other segments below it.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/73980045
2014-03-13 13:16:02 +04:00
Aram Hăvărneanu
28792f5d83 runtime: avoid runtime·cgocall in functions called by forkAndExecInChild
Calling runtime·cgocall could trigger a GC in the child while
gclock was held by the parent.

Fixes #7511

LGTM=bradfitz, dvyukov, dave
R=golang-codereviews, bradfitz, dvyukov, dave
CC=golang-codereviews, rsc
https://golang.org/cl/75210044
2014-03-13 18:26:01 +11:00
Rémy Oudompheng
fcc10bc0f1 cmd/gc: fix spurious type errors in walkselect.
The lowering to runtime calls introduces hidden pointers to the
arguments of select clauses. When implicit conversions were
involved it could end up with incompatible pointers. Since the
pointed-to types have the same representation, we can introduce a
forced conversion.

Fixes #6847.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/72380043
2014-03-13 08:14:05 +01:00
Rémy Oudompheng
741244e433 cmd/6g: fix stack zeroing preamble on amd64p32.
It was using a REP STOSQ but putting in CX the number of 32-bit
words to clear.

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/75240043
2014-03-13 08:12:38 +01:00
Mikio Hara
6a6224c88d net: fix TCP keepalive on dragonfly
Fixes #7528.

LGTM=jsing
R=jsing
CC=golang-codereviews
https://golang.org/cl/75140045
2014-03-13 14:45:50 +09:00
Michael Hudson-Doyle
12474d01c4 cmd/go: use correct libraries during gccgo link
Under some circumstances, gccgoToolchain's ld can pass the path of
build outputs that have been deleted to the link command.

Fixes #7303.

LGTM=rsc
R=golang-codereviews, dave, michael.hudson, rsc
CC=golang-codereviews
https://golang.org/cl/61970044
2014-03-12 23:05:54 -04:00
Anthony Martin
64e041652a runtime: call symtabinit earlier
Otherwise, we won't get a stack trace in some of the early init.

Here's one example:

        http://build.golang.org/log/a96d10f6aee1fa3e3ae51f41da46d414a7ab02de

After walking the stack by hand in acid, I was able to determine
that the stackalloc inside mpreinit was causing the throw.

LGTM=rsc
R=rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/72450044
2014-03-12 19:42:58 -07:00
Anthony Martin
b53d2f5ba7 cmd/gc: make the fpu handle all exceptions on Plan 9
The compilers expect to not be interrupted by floating
point exceptions. On Plan 9, every process starts with
interrupts enabled for invalid operation, stack overflow,
and divide by zero exceptions.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/72750043
2014-03-12 19:41:36 -07:00
Anthony Martin
189397df58 os: relax the way we kill processes on Plan 9
Previously, we wrote "kill" to the process control file
to kill a program. This is problematic because it doesn't
let the program gracefully exit.

This matters especially if the process we're killing is a
Go program. On Unix, sending SIGKILL to a Go program will
automatically kill all runtime threads. On Plan 9, there
are no threads so when the program wants to exit it has to
somehow signal all of the runtime processes. It can't do
this if we mercilessly kill it by writing to it's control
file.

Instead, we now send it a note to invoke it's note handler
and let it perform any cleanup before exiting.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/74440044
2014-03-12 18:12:56 -07:00
Anthony Martin
8303a13bb8 runtime: use unoptimized memmove and memclr on Plan 9
On Plan 9, the kernel disallows the use of floating point
instructions while handling a note. Previously, we worked
around this by using a simple loop in place of memmove.

When I added that work-around, I verified that all paths
from the note handler didn't end up calling memmove. Now
that memclr is using SSE instructions, the same process
will have to be done again.

Instead of doing that, however, this CL just punts and
uses unoptimized functions everywhere on Plan 9.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/73830044
2014-03-12 18:12:25 -07:00
Anthony Martin
b67979320a cmd/ld: give acid a fighting chance at unwinding the stack
Acid can't produce a stack trace without .frame symbols.

Of course, it can only unwind through linear stacks but
this is still better than nothing. (I wrote an acid func
to do the full unwind a long time ago but lost it and
haven't worked up the courage to write it again).

Note that these will only be present in the native symbol
table for Plan 9 binaries.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72450045
2014-03-12 18:10:31 -07:00
Dave Cheney
f2037e1533 runtime: fix missing nacl/386 symbol
syscall.naclWrite was missing from sys_nacl_386.s

This gets ./make.bash passing, but doesn't pass validation. I'm not sure if this is the fault of this change, or validation was broken anyway.

LGTM=rsc
R=minux.ma, rsc
CC=golang-codereviews
https://golang.org/cl/74510043
2014-03-13 07:58:42 +11:00
Rob Pike
78992439f4 fmt: improve documentation for width and precision
Fixes #7048.

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/74280044
2014-03-12 22:00:48 +11:00
Dmitriy Vyukov
1f4d2e79b0 runtime: efence support for growable stacks
1. Fix the bug that shrinkstack returns memory to heap.
   This causes growslice to misbehave (it manually initialized
   blocks, and in efence mode shrinkstack's free leads to
   partially-initialized blocks coming out of growslice.
   Which in turn causes GC to crash while treating the garbage
   as Eface/Iface.
2. Enable efence for stack segments.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/74080043
2014-03-12 10:21:34 +04:00
Dmitriy Vyukov
00e6fc1e9e runtime: temporary weaken a check in test
Currently the test fails as:
$ go test -v -cpu 1,1,1,1 runtime -test.run=TestStack
stack_test.go:1584: Stack inuse: want 4194304, got 18446744073709547520

Update #7468

LGTM=rsc
R=golang-codereviews, bradfitz
CC=golang-codereviews, khr, rsc
https://golang.org/cl/74010043
2014-03-12 10:20:58 +04:00
Jan Ziak
b87c7729ba cmd/go: respect system CGO_CFLAGS and CGO_CXXFLAGS
Fixes #6882

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/72080043
2014-03-12 07:16:22 +01:00
Brad Fitzpatrick
d53251d4ab net/http/cgi: serve 500, not 200, on invalid responses from child processes
Per RFC 3875 section 6 rules.

Fixes #7198

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/68960049
2014-03-11 22:55:15 -07:00
Russ Cox
54c901cd08 runtime: fix empty string handling in garbage collector
The garbage collector uses type information to guide the
traversal of the heap. If it sees a field that should be a string,
it marks the object pointed at by the string data pointer as
visited but does not bother to look at the data, because
strings contain bytes, not pointers.

If you save s[len(s):] somewhere, though, the string data pointer
actually points just beyond the string data; if the string data
were exactly the size of an allocated block, the string data
pointer would actually point at the next block. It is incorrect
to mark that next block as visited and not bother to look at
the data, because the next block may be some other type
entirely.

The fix is to ignore strings with zero length during collection:
they are empty and can never become non-empty: the base
pointer will never be used again. The handling of slices already
does this (but using cap instead of len).

This was not a bug in Go 1.2, because until January all string
allocations included a trailing NUL byte not included in the
length, so s[len(s):] still pointed inside the string allocation
(at the NUL).

This bug was causing the crashes in test/run.go. Specifically,
the parsing of a regexp in package regexp/syntax allocated a
[]syntax.Inst with rounded size 1152 bytes. In fact it
allocated many such slices, because during the processing of
test/index2.go it creates thousands of regexps that are all
approximately the same complexity. That takes a long time, and
test/run works on other tests in other goroutines. One such
other test is chan/perm.go, which uses an 1152-byte source
file. test/run reads that file into a []byte and then calls
strings.Split(string(src), "\n"). The string(src) creates an
1152-byte string - and there's a very good chance of it
landing next to one of the many many regexp slices already
allocated - and then because the file ends in a \n,
strings.Split records the tail empty string as the final
element in the slice. A garbage collection happens at this
point, the collection finds that string before encountering
the []syntax.Inst data it now inadvertently points to, and the
[]syntax.Inst data is not scanned for the pointers that it
contains. Each syntax.Inst contains a []rune, those are
missed, and the backing rune arrays are freed for reuse. When
the regexp is later executed, the runes being searched for are
no longer runes at all, and there is no match, even on text
that should match.

On 64-bit machines the pointer in the []rune inside the
syntax.Inst is larger (along with a few other pointers),
pushing the []syntax.Inst backing array into a larger size
class, avoiding the collision with chan/perm.go's
inadvertently sized file.

I expect this was more prevalent on OS X than on Linux or
Windows because those managed to run faster or slower and
didn't overlap index2.go with chan/perm.go as often. On the
ARM systems, we only run one errorcheck test at a time, so
index2 and chan/perm would never overlap.

It is possible that this bug is the root cause of other crashes
as well. For now we only know it is the cause of the test/run crash.

Many thanks to Dmitriy for help debugging.

Fixes #7344.
Fixes #7455.

LGTM=r, dvyukov, dave, iant
R=golang-codereviews, dave, r, dvyukov, delpontej, iant
CC=golang-codereviews, khr
https://golang.org/cl/74250043
2014-03-11 23:58:39 -04:00
Russ Cox
ab844022ee cmd/gc: fix crash in -live mode
debuglive >= 1 is not the condition under which we
start recording messages (we avoid printing for
init functions even if debuglive is set).

LGTM=bradfitz, iant
R=golang-codereviews, bradfitz
CC=golang-codereviews, iant, khr
https://golang.org/cl/74390043
2014-03-11 23:58:11 -04:00
Dhiru Kholia
5b5c8f0576 dwarf: add extensions for multi-file compression (.dwz)
LGTM=iant
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews, math-nuts
https://golang.org/cl/72820044
2014-03-11 18:49:50 -07:00
Mikio Hara
ae9b661fa8 runtime: make use of THREAD_SHARE userspace mutex on freebsd
For now Note, futexsleep and futexwakeup are designed for threads,
not for processes. The explicit use of UMTX_OP_WAIT_UINT_PRIVATE and
UMTX_OP_WAKE_PRIVATE can avoid unnecessary traversals of VM objects,
to hit undiscovered bugs related to VM system on SMP/SMT/NUMA
environment.

Update #7496

LGTM=iant
R=golang-codereviews, gobot, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/72760043
2014-03-12 10:33:09 +09:00
Mikio Hara
ef6c21d0e9 syscall, net: clean up socket stub for solaris
Solaris doesn't have struct ip_mreqn, instead it uses struct ip_mreq
and struct group_req with struct sockaddr_storage.

Also fixes incorrect SockaddrDatalink.

Update #7399

LGTM=aram, iant
R=golang-codereviews, aram, gobot, iant
CC=golang-codereviews
https://golang.org/cl/73920043
2014-03-12 10:32:46 +09:00
Dave Cheney
42da29f474 runtime: disable Native Client fake time support
This CL is a reformulation of CL 73110043 containing only the minimum required to get the nacl builds compiling.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/74220043
2014-03-12 08:55:30 +11:00
Kay Zhu
07dc50b8f1 path/filepath: fixed misaligned comment.
The comment for 'Clean' function is prepended with spaces instead of
a single tab, resulting in visually misaligned comment in the generated
documentation.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/73840043
2014-03-11 14:34:07 -07:00
Dave Cheney
053127b12f runtime: fix nacl/amd64p32 signal handling
The change to signal_amd64.c from CL 15790043 was not merged correctly.

This CL reapplies the change, renaming the file to signal_amd64x.c and adds the appropriate build tags.

LGTM=iant, bradfitz
R=rsc, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/72790043
2014-03-12 07:21:55 +11:00
Josh Bleecher Snyder
4e5f31a760 liblink: fix bad code generated for MOVFD/MOVDF when reg > 7
The byte that r is or'd into is already 0x7, so the failure to zero r only
impacts the generated machine code if the register is > 7.

Fixes #7044.

LGTM=dave, minux.ma, rsc
R=dave, minux.ma, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/73730043
2014-03-11 14:04:44 -04:00
Shenghou Ma
da291de5a2 crypto/rsa: fix docs for PrecomputedValues.Qinv
Fixes #7507.

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/74090043
2014-03-11 13:06:01 -04:00
Dmitriy Vyukov
3877f1d9c8 runtime: remove atomic CAS loop from marknogc
Spans are now private to threads, and the loop
is removed from all other functions.
Remove it from marknogc for consistency.

LGTM=khr, rsc
R=golang-codereviews, bradfitz, khr
CC=golang-codereviews, khr, rsc
https://golang.org/cl/72520043
2014-03-11 17:35:49 +04:00
Dmitriy Vyukov
38f6c3f59d runtime: wipe out bitSpecial from GC code
LGTM=khr, rsc
R=golang-codereviews, bradfitz, khr
CC=golang-codereviews, khr, rsc
https://golang.org/cl/72480044
2014-03-11 17:33:03 +04:00
Alex Brainman
c07ca77432 syscall: replace mksyscall_windows.pl with mksyscall_windows.go
Not many windows users have perl installed. They can just use
standard go tools instead. Also mkerrors_windows.sh script
removed - we don't add any new "unix" errors to windows
syscall package anymore.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/41060044
2014-03-11 16:36:14 +11:00
Dave Cheney
6431be3fe4 runtime: more Native Client fixes
Thanks to Ian for spotting these.

runtime.h: define uintreg correctly.
stack.c: address warning caused by the type of uintreg being 32 bits on amd64p32.

Commentary (mainly for my own use)

nacl/amd64p32 defines a machine with 64bit registers, but address space is limited to a 4gb window (the window is placed randomly inside the full 48 bit virtual address space of a process). To cope with this 6c defines _64BIT and _64BITREG.

_64BITREG is always defined by 6c, so both GOARCH=amd64 and GOARCH=amd64p32 use 64bit wide registers.

However _64BIT itself is only defined when 6c is compiling for amd64 targets. The definition is elided for amd64p32 environments causing int, uint and other arch specific types to revert to their 32bit definitions.

LGTM=iant
R=iant, rsc, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/72860046
2014-03-11 14:43:10 +11:00
Alan Donovan
cf57cf17e7 net/http: eliminate defined-but-not-used var.
gc does not report this as an error, but go/types does.
(I suspect that constructing a closure counts as a reference
to &all in gc's implementation).

This is not a tool bug, since the spec doesn't require
implementations to implement this check, but it does
illustrate that dialect variations are always a nuisance.

LGTM=rsc, bradfitz
R=bradfitz
CC=golang-codereviews, gri, rsc
https://golang.org/cl/73850043
2014-03-10 22:22:51 -04:00
Keith Randall
1306279cd1 runtime: remove unused declarations.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/73720044
2014-03-10 16:02:46 -07:00
Dave Cheney
9ab4d1d6b3 runtime: small Native Client fixes
mem_nacl.c: add SysFault
env_posix.c: add nacl to build tag, from CL 15790043

LGTM=remyoudompheng, iant
R=rsc, remyoudompheng, iant
CC=golang-codereviews
https://golang.org/cl/72780043
2014-03-11 06:57:46 +11:00
Adam Langley
4ca6e588e4 time: handle int64 overflow in ParseDuration.
Previously, passing a long duration to ParseDuration could result in
random, even negative, values.

LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/72120043
2014-03-10 12:33:45 -04:00
Rémy Oudompheng
4bc632cead runtime: fix cgocallback stack size on amd64p32.
LGTM=dave
R=rsc, dave, iant
CC=golang-codereviews
https://golang.org/cl/73160043
2014-03-10 07:57:58 +01:00
Mikio Hara
4888781f24 runtime: fix flakiness on futexsleep test
Fixes #7496.

LGTM=jsing
R=golang-codereviews, jsing
CC=golang-codereviews
https://golang.org/cl/72840043
2014-03-10 12:20:16 +09:00
Dave Cheney
4c75cab678 syscall: add missing SO_ERROR constant for nacl/*
CL 69340044 requires that syscall.SO_ERROR be defined on all unix like platforms. Add SO_ERROR to the list of dummy constants in sycall/net_nacl.go.

LGTM=bradfitz
R=iant, rsc, mikioh.mikioh, bradfitz
CC=golang-codereviews
https://golang.org/cl/73100043
2014-03-09 13:18:12 +11:00
Brad Fitzpatrick
7718c62692 net/rpc/jsonrpc: set exactly one of result or error to non-null in response
Fixes #7442

LGTM=gri
R=golang-codereviews, gri
CC=golang-codereviews
https://golang.org/cl/72570044
2014-03-07 16:59:11 -08:00
Brad Fitzpatrick
a35b9e4960 os: document that Process.Wait only works on child processes
Fixes #7072

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/71900045
2014-03-07 14:44:31 -08:00
Mikio Hara
a594f7ddd7 runtime: fix futexsleep test on freebsd/386
Fixes #7194.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/72310043
2014-03-08 07:34:40 +09:00
Rémy Oudompheng
e09ac3cf2a cmd/gc: correct GOARCH in object files for amd64p32.
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72260045
2014-03-07 23:18:07 +01:00
Rémy Oudompheng
849ee73f67 runtime: add missing nacl build tag for lock_sema.c
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72240045
2014-03-07 23:17:44 +01:00
Russ Cox
e721778f3e sync: give finalizers more time in TestPoolGC
If we report a leak, make sure we've waited long enough to be sure.
The new sleep regimen waits 1.05 seconds before failing; the old
one waited 0.005 seconds.

(The single linux/amd64 failure in this test feels more like a
timing problem than a leak. I don't want to spend time on it unless
we're sure.)

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/72630043
2014-03-07 16:08:12 -05:00
Dave Cheney
3d869c6e0c crypto/md5, crypto/sha1: exclude amd64p32 from generic implementations.
We provide amd64p32 implementations for md5 and sha1 so we need to exclude amd64p32 from the generic implementations in those packages.

Fixes build once CL 72360044 lands.

LGTM=agl, remyoudompheng
R=rsc, bradfitz, agl, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/72460043
2014-03-08 07:54:41 +11:00
David Covert
76236ef136 regexp: add one-pass optimization from RE2
This produces about a 2.3x speedup for patterns
that can be handled this way.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/13345046
2014-03-07 15:30:02 -05:00
Shenghou Ma
84570aa9a1 runtime: round stack size to power of 2.
Fixes build on windows/386 and plan9/386.
Fixes #7487.

LGTM=mattn.jp, dvyukov, rsc
R=golang-codereviews, mattn.jp, dvyukov, 0intro, rsc
CC=golang-codereviews
https://golang.org/cl/72360043
2014-03-07 15:11:16 -05:00
Rémy Oudompheng
3d5e219e02 cmd/gc: enforce register-width alignment for stack sizes.
This fixes the following amd64p32 issue:
    pkg/time/format.go:724: internal compiler error: twobitwalktype1: invalid initial alignment, Time

caused by the pointer zone ending on a 32-bit-aligned boundary.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72270046
2014-03-07 20:28:18 +01:00
Russ Cox
b2fa6f41a4 runtime: comment out breakpoint in windows/386 sighandler
This code being buggy is the only explanation I can come up
with for issue 7325. It's probably not, but the only alternative
is a Windows kernel bug. Comment this out to see what breaks
or gets fixed.

Update #7325

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/72590044
2014-03-07 14:22:17 -05:00
Russ Cox
02903f8395 runtime: fix windows/386 build
From the trace it appears that stackalloc is being
called with 0x1800 which is 6k = 4k + (StackSystem=2k).
Make StackSystem 4k too, to make stackalloc happy.
It's already 4k on windows/amd64.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/72600043
2014-03-07 14:19:05 -05:00
Rémy Oudompheng
9460cf7825 liblink: fix morestack handling on amd64p32.
It was using MOVL to pass a 64-bit argument
(concatenated framesize and argsize) to morestack11.

LGTM=dave, rsc
R=dave, rsc, iant
CC=golang-codereviews
https://golang.org/cl/72360044
2014-03-07 19:44:35 +01:00
Dmitriy Vyukov
1a89e6388c runtime: refactor and fix stack management code
There are at least 3 bugs:
1. g->stacksize accounting is broken during copystack/shrinkstack
2. stktop->free is not properly maintained during copystack/shrinkstack
3. stktop->free logic is broken:
        we can have stktop->free==FixedStack,
        and we will free it into stack cache,
        but it actually comes from heap as the result of non-copying segment shrink
This shows as at least spurious races on race builders (maybe something else as well I don't know).

The idea behind the refactoring is to consolidate stacksize and
segment origin logic in stackalloc/stackfree.

Fixes #7490.

LGTM=rsc, khr
R=golang-codereviews, rsc, khr
CC=golang-codereviews
https://golang.org/cl/72440043
2014-03-07 20:52:29 +04:00
Dmitriy Vyukov
f946a7ca09 runtime: fix memory corruption and leak in recursive panic handling
Recursive panics leave dangling Panic structs in g->panic stack.
At best it leads to a Defer leak and incorrect output on a subsequent panic.
At worst it arbitrary corrupts heap.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72480043
2014-03-07 20:50:30 +04:00
Russ Cox
b08156cd87 runtime: fix memory leak in runfinq
One reason the sync.Pool finalizer test can fail is that
this function's ef1 contains uninitialized data that just
happens to point at some of the old pool. I've seen this cause
retention of a single pool cache line (32 elements) on arm.

Really we need liveness information for C functions, but
for now we can be more careful about data in long-lived
C functions that block.

LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews, iant, khr
https://golang.org/cl/72490043
2014-03-07 11:27:01 -05:00
Dave Cheney
e509bbc943 cmd/6a: add support for nacl/amd64p32
Replaces CL 70000043.

Switch to the amd64p32 linker model if we are building under nacl/amd64p32.

No need to introduce linkarchinit() as 6a contains its own main() function.

LGTM=rsc
R=rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/72020043
2014-03-07 16:02:25 +11:00
Dave Cheney
e31a1ce109 cmd/gc, cmd/5g, cmd/6g, cmd/8g: introduce linkarchinit and add amd64p32 support
Replaces CL 70000043.

Introduce linkarchinit() from cmd/ld.

For cmd/6g, switch to the amd64p32 linker model if we are building under nacl/amd64p32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/71330045
2014-03-07 15:33:44 +11:00
Rob Pike
22c668a810 encoding/gob: document that Decode returns EOF at EOF
Just commentary describing existing behavior, no code changes.

Fixes #7033.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71860043
2014-03-07 13:24:14 +11:00
Rob Pike
c0d4576593 strconv: document value returned by ParseInt when there is an error
Documenting existing behavior; new commentary only.
Fixes #7105.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68840044
2014-03-07 13:23:50 +11:00
Keith Randall
f4359afa7f runtime: shrink bigger stacks without any copying.
Instead, split the underlying storage in half and
free just half of it.

Shrinking without copying lets us reclaim storage used
by a previously profligate Go routine that has now blocked
inside some C code.

To shrink in place, we need all stacks to be a power of 2 in size.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/69580044
2014-03-06 16:03:43 -08:00
Russ Cox
9abcd53eda cmd/go: add test case for cgo coverage
This is a test case for CL 34680044.

Fixes #6333.

LGTM=bradfitz
R=golang-codereviews, bradfitz, minux.ma
CC=golang-codereviews
https://golang.org/cl/71230049
2014-03-06 18:36:32 -05:00
Russ Cox
da1bea0ef0 runtime: fix malloc page alignment + efence
Two memory allocator bug fixes.

- efence is not maintaining the proper heap metadata
  to make eventual memory reuse safe, so use SysFault.

- now that our heap PageSize is 8k but most hardware
  uses 4k pages, SysAlloc and SysReserve results must be
  explicitly aligned. Do that in a few more call sites and
  document this fact in malloc.h.

Fixes #7448.

LGTM=iant
R=golang-codereviews, josharian, iant
CC=dvyukov, golang-codereviews
https://golang.org/cl/71750048
2014-03-06 18:34:29 -05:00
Dave Cheney
1d2b7171d5 cmd/5c: fix arm build
cmd/5c/txt.c was missing from CL 72010043.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/72220043
2014-03-07 10:13:00 +11:00
Dave Cheney
d4896fb876 cmd/cc, cmd/5c, cmd/6c, cmd/8c: introduce linkarchinit and add amd64p32 support
Replaces CL 70000043.

Introduce linkarchinit() from cmd/ld.

For cmd/6c, switch to the amd64p32 linker model if we are building under nacl/amd64p32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72010043
2014-03-07 09:55:59 +11:00
Dmitriy Vyukov
2fb87ddb59 runtime: print goroutine header on fault
I've just needed the G status on fault to debug runtime bug.
For some reason we print everything except header here.
Make it more informative and consistent.

R=rsc
CC=golang-codereviews
https://golang.org/cl/67870056
2014-03-07 00:01:24 +04:00
David du Colombier
fb5e1e1fa1 runtime: fix warnings on Plan 9
warning: pkg/runtime/mgc0.c:2352 format mismatch p UVLONG, arg 2
warning: pkg/runtime/mgc0.c:2352 format mismatch p UVLONG, arg 3

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71950044
2014-03-06 20:56:22 +01:00
Dmitriy Vyukov
a1695d2ea3 runtime: use custom thunks for race calls instead of cgo
Implement custom assembly thunks for hot race calls (memory accesses and function entry/exit).
The thunks extract caller pc, verify that the address is in heap or global and switch to g0 stack.

Before:
ok  	regexp	3.692s
ok  	compress/bzip2	9.461s
ok  	encoding/json	6.380s
After:
ok  	regexp	2.229s (-40%)
ok  	compress/bzip2	4.703s (-50%)
ok  	encoding/json	3.629s (-43%)

For comparison, normal non-race build:
ok  	regexp	0.348s
ok  	compress/bzip2	0.304s
ok  	encoding/json	0.661s
Race build:
ok  	regexp	2.229s (+540%)
ok  	compress/bzip2	4.703s (+1447%)
ok  	encoding/json	3.629s (+449%)

Also removes some race-related special cases from cgocall and scheduler.
In long-term it will allow to remove cyclic runtime/race dependency on cmd/cgo.

Fixes #4249.
Fixes #7460.
Update #6508
Update #6688

R=iant, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/55100044
2014-03-06 23:48:30 +04:00
Brad Fitzpatrick
5db255fa3c net/http/cgi: kill child CGI process on copy error
Fixes #7196

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, iant
https://golang.org/cl/69970052
2014-03-06 11:24:28 -08:00
Dmitriy Vyukov
8ca3372d7b runtime: fix bad g status after copystack
LGTM=khr
R=khr
CC=golang-codereviews, rsc
https://golang.org/cl/69870054
2014-03-06 21:33:19 +04:00
Dmitriy Vyukov
aea99eda0f runtime: fix runaway memory usage
It was caused by mstats.heap_alloc skew.
Fixes #7430.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/69870055
2014-03-06 21:33:00 +04:00
Dmitriy Vyukov
fd7ff20495 net/http: make TestUseProxy repeatable
Currently it fails on second and subsequent runs (when using -cpu=1,2,4) as:
--- FAIL: TestUseProxy-4 (0.00 seconds)
proxy_test.go:109: useProxy(barbaz.net) = true, want false
proxy_test.go:109: useProxy(foobar.com) = true, want false
proxy_test.go:109: useProxy(www.foobar.com) = true, want false

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/71940044
2014-03-06 18:44:14 +04:00
Dmitriy Vyukov
130458470a run.bash: explain why we set GOMAXPROCS for runtime test
Fixes #7459.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/71060044
2014-03-06 13:16:14 +04:00
Shenghou Ma
56e261ef2f cmd/dist: enable GOARM>5 on NetBSD/ARM.
Tested GOARM=6 on Raspberry Pi, and I found only a few tests that
use sub-normal numbers fails. I have a patch to NetBSD kernel pending
that fixes this issue (NetBSD kernel doesn't allow us to disable the
Flush-to-Zero feature).

LGTM=jsing
R=golang-codereviews, jsing
CC=golang-codereviews
https://golang.org/cl/70730043
2014-03-06 00:57:23 -05:00
Shenghou Ma
30d60936d9 syscall: update NetBSD/ARM port to EABI.
LGTM=jsing
R=golang-codereviews, jsing
CC=golang-codereviews
https://golang.org/cl/70720043
2014-03-06 00:55:57 -05:00
Brad Fitzpatrick
31731b27cd net/rpc/jsonrpc: add temporarily-disabled failing test
To be enabled by https://golang.org/cl/71230045/

Update #7442

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/69860056
2014-03-05 16:01:37 -08:00
Brad Fitzpatrick
3b961ba3d2 net/http: deflake a test
I missed this one in codereview.appspot.com/70010050
Same thing, but different test.

Fixes windows-amd64-race and likely other Windows
machines failing like:
http://build.golang.org/log/0382bf0048bf5835a51a8a902df5c6fc73cd7ff5

LGTM=adg
R=rsc, adg
CC=golang-codereviews
https://golang.org/cl/71770043
2014-03-05 14:56:50 -08:00
Brad Fitzpatrick
6433bff205 net/http: minor fixes and optimization for Response.TLS
Also add it to doc/go1.3.txt.

Update #7289

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/71740043
2014-03-05 12:40:13 -08:00
Paul A Querna
4816986ff5 net/http: Add TLS Connection State to Responses.
Fixes #7289.

LGTM=bradfitz
R=golang-codereviews, r, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/52660047
2014-03-05 12:25:55 -08:00
Shenghou Ma
fd4b001a0f syscall: add mmap constants for NetBSD/ARM.
Fixes the syscall test.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71470043
2014-03-05 15:18:36 -05:00
Shenghou Ma
c887193382 cmd/dist: support building pkg/runtime/*.
Essentialy for running tests without a working cmd/go.
While we're at it, also fix a typo.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/70640043
2014-03-05 14:57:17 -05:00
Kelsey Hightower
13e359bdca encoding/gob: improve interface assignment error message
During the glob decoding process interface values are set to concrete
values after a test for assignability. If the assignability test fails
a slightly vague error message is produced. While technically accurate
the error message does not clearly describe the problem.

Rewrite the error message to include the usage of the word assignable,
which makes it clear the concrete value type is not assignable to the
interface value type.

Fixes #6467.

LGTM=r
R=golang-codereviews, rsc, r
CC=golang-codereviews
https://golang.org/cl/71590043
2014-03-06 06:52:18 +11:00
Shawn Smith
58980821c7 encoding/xml: add test for EncodeToken
LGTM=rsc
R=golang-codereviews, josharian, dave, iant, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/47870043
2014-03-05 14:49:33 -05:00
Shenghou Ma
37e195cf72 cmd/ld: don't include padding length in size of the note section
Recently NetBSD starts to enforce this, and refuses to execute
the program if n is larger than the sum of entry sizes.

Before:
$ readelf -n ../bin/go.old
Notes at offset 0x00000bd0 with length 0x00000019:
  Owner         Data size       Description
  NetBSD                0x00000004      NT_VERSION (version)
readelf: Warning: corrupt note found at offset 18 into core notes
readelf: Warning:  type: 0, namesize: 00000000, descsize: 00000000
$ readelf -n ../bin/go
Notes at offset 0x00000bd0 with length 0x00000018:
Owner         Data size       Description
NetBSD                0x00000004      NT_VERSION (version)

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/70710043
2014-03-05 14:40:55 -05:00
Alberto García Hierro
22705d0995 cmd/go: add support for coverage in CgoFiles
Add CgoFiles to the covered files when building
with cover support.

LGTM=rsc
R=golang-codereviews, gobot, r, rsc
CC=golang-codereviews
https://golang.org/cl/34680044
2014-03-05 14:28:11 -05:00
Russ Cox
3f1374fcf8 cmd/dist: use vfprintf on Windows, same as on Unix
Apparently, the Windows routines sometimes fail to generate output.
Copy the Unix stdio-based implementations instead.

Suggested by Pietro Gagliardi in CL 65280043 but that CL
seems to have been abandoned.

Fixes #7242.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71550044
2014-03-05 14:16:30 -05:00
Chris Manghane
671cc6efba cmd/gc: allow append and complex builtins to accept 2-result call expression as first argument.
Fixes #5793.

LGTM=rsc
R=rsc, adonovan, dave
CC=golang-codereviews
https://golang.org/cl/13367051
2014-03-05 14:16:21 -05:00
Jan Ziak
202e6153f5 cmd/dist: respect system CFLAGS/LDFLAGS
Update #6882.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/69860055
2014-03-05 14:10:22 -05:00
Russ Cox
1249d3a518 runtime: handle Go calls C calls Go panic correctly on windows/386
32-bit Windows uses "structured exception handling" (SEH) to
handle hardware faults: that there is a per-thread linked list
of fault handlers maintained in user space instead of
something like Unix's signal handlers. The structures in the
linked list are required to live on the OS stack, and the
usual discipline is that the function that pushes a record
(allocated from the current stack frame) onto the list pops
that record before returning. Not to pop the entry before
returning creates a dangling pointer error: the list head
points to a stack frame that no longer exists.

Go pushes an SEH record in the top frame of every OS thread,
and that record suffices for all Go execution on that thread,
at least until cgo gets involved.

If we call into C using cgo, that called C code may push its
own SEH records, but by the convention it must pop them before
returning back to the Go code. We assume it does, and that's
fine.

If the C code calls back into Go, we want the Go SEH handler
to become active again, not whatever C has set up. So
runtime.callbackasm1, which handles a call from C back into
Go, pushes a new SEH record before calling the Go code and
pops it when the Go code returns. That's also fine.

It can happen that when Go calls C calls Go like this, the
inner Go code panics. We allow a defer in the outer Go to
recover the panic, effectively wiping not only the inner Go
frames but also the C calls. This sequence was not popping the
SEH stack up to what it was before the cgo calls, so it was
creating the dangling pointer warned about above. When
eventually the m stack was used enough to overwrite the
dangling SEH records, the SEH chain was lost, and any future
panic would not end up in Go's handler.

The bug in TestCallbackPanic and friends was thus creating a
situation where TestSetPanicOnFault - which causes a hardware
fault - would not find the Go fault handler and instead crash
the binary.

Add checks to TestCallbackPanicLocked to diagnose the mistake
in that test instead of leaving a bad state for another test
case to stumble over.

Fix bug by restoring SEH chain during deferred "endcgo"
cleanup.

This bug is likely present in Go 1.2.1, but since it depends
on Go calling C calling Go, with the inner Go panicking and
the outer Go recovering the panic, it seems not important
enough to bother fixing before Go 1.3. Certainly no one has
complained.

Fixes #7470.

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=golang-codereviews, iant, khr
https://golang.org/cl/71440043
2014-03-05 11:10:40 -05:00
Joel Sing
4e7049bb84 syscall: regenerate z-files for dragonfly
Regenerate z-files for DragonFly BSD 3.6.

F_DUP_FD_CLOEXEC is now supported, so remove the zero value constant
from types_dragonfly.go so that we use the generated value from the
z-files.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/70080047
2014-03-06 00:09:09 +11:00
Joel Sing
b586f56e76 syscall: fix mksysnum_dragonfly.pl
The format of the DragonFly BSD syscalls.master file has changed
slightly - update mksysnum_dragonfly.pl to match.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/71460044
2014-03-06 00:08:34 +11:00
Joel Sing
18019dffd2 net: disable "udp" to IPv6 unicast address loopback test on dragonfly
Disable the "udp" to IPv6 unicast address on the loopback interface
test under DragonFly BSD. This currently returns a local address of
0.0.0.1, rather than an IPv6 address with zone identifier.

Update #7473

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/71500044
2014-03-06 00:08:03 +11:00
Joel Sing
734d4637c5 net: fix non-blocking connect handling on dragonfly
Performing multiple connect system calls on a non-blocking socket
under DragonFly BSD does not necessarily result in errors from earlier
connect calls being returned, particularly if we are connecting to
localhost. Instead, once netpoll tells us that the socket is ready,
get the SO_ERROR socket option to see if the connection succeeded
or failed.

Fixes #7474

LGTM=mikioh.mikioh
R=mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/69340044
2014-03-06 00:07:16 +11:00
Patrick Mézard
9a7cd11bc8 os: try openFile before openDir in windows os.OpenFile
Logging calls when running "go install -a std" turns:

  547  openDir succeeded
  3593 openDir failed and fell back to openFile
  3592 openFile succeeded
  1    both failed

into:

  3592 openFile succeeded
  548  openFile failed and fell back
  547  openDir succeeded
  1    both failed

Here the change trades 3593 failed openDir for 548 failed openFile.

Fix issue 7426.

LGTM=alex.brainman
R=golang-codereviews, alex.brainman, bradfitz
CC=golang-codereviews
https://golang.org/cl/70480044
2014-03-05 12:19:56 +11:00
Robert Griesemer
1624c73c9d go/parser: better error position for non-invoked gp/defer functions
Added test cases and expanded test harness to handle token end
positions.

Also: Make sure token end positions are never outside the valid
      position range, as was possible in case of parse errors.

Fixes #7458.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/70190046
2014-03-04 14:10:30 -08:00
Mike Andrews
a18bfb8c67 net/smtp: set ServerName in StartTLS, as now required by crypto/tls
the crypto/tls revision d3d43f270632 (CL 67010043, requiring ServerName or InsecureSkipVerify) breaks net/smtp,
since it seems impossible to do SMTP via TLS anymore. i've tried to fix this by simply using a tls.Config with
ServerName, instead of a nil *tls.Config. without this fix, doing SMTP with TLS results in error "tls: either
ServerName or InsecureSkipVerify must be specified in the tls.Config".

testing: the new method TestTlsClient(...) sets up a skeletal smtp server with tls capability, and test client
injects a "fake" certificate allowing tls to work on localhost; thus, the modification to SendMail(...) enabling
this.

Fixes #7437.

LGTM=bradfitz
R=golang-codereviews, josharian, bradfitz
CC=golang-codereviews
https://golang.org/cl/70380043
2014-03-04 13:43:26 -08:00
Brad Fitzpatrick
3b015616f7 net/http: improve Client.Timeout docs, quiet test
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/70930043
2014-03-04 13:41:05 -08:00
Russ Cox
77720904a8 liblink: fix arm build
The arm puts the text flags in a different place
than the other architectures. This needs to be
cleaned up.

TBR=minux
CC=golang-codereviews
https://golang.org/cl/71260043
2014-03-04 14:59:08 -05:00
Matt Aimonetti
b38320bffb net/http: make Request.ParseForm parse form-urlencoded for method PATCH too
Fixes #7454

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/70990044
2014-03-04 11:58:21 -08:00
Brad Fitzpatrick
a5166a9512 net/http: fix test failure on some Windows machines
The network connection dies differently from the server's
perspective on (some) Windows when the client goes away. Match
on the common prefix (common to Unix and Windows) instead of
the network error part.

Fixes #7456

LGTM=josharian
R=golang-codereviews, josharian
CC=alex.brainman, golang-codereviews, iant
https://golang.org/cl/70010050
2014-03-04 11:55:35 -08:00
Russ Cox
f884e15aab runtime: fix arm build (B not JMP)
TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/71060046
2014-03-04 14:03:39 -05:00
Russ Cox
c2dd33a46f cmd/ld: clear unused ctxt before morestack
For non-closure functions, the context register is uninitialized
on entry and will not be used, but morestack saves it and then the
garbage collector treats it as live. This can be a source of memory
leaks if the context register points at otherwise dead memory.
Avoid this by introducing a parallel set of morestack functions
that clear the context register, and use those for the non-closure functions.

I hope this will help with some of the finalizer flakiness, but it probably won't.

Fixes #7244.

LGTM=dvyukov
R=khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/71030044
2014-03-04 13:53:08 -05:00
Brad Fitzpatrick
542415c9df net/http: deflake another alloc test
I have one machine where this 25 test run is flaky
and fails ("21 >= 21"), but 50 works everywhere.

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/67870053
2014-03-04 09:59:07 -08:00
Brad Fitzpatrick
c7157bf449 crypto/cipher: fix AEAD.Open documentation nit
It mentioned true and false for error values. Instead, just
don't mention the error semantics, as they match normal Go
conventions (if error is non-nil, the other value is
meaningless). We generally only document error values when
they're interesting (where non-nil, non-nil is valid, or the
error value can be certain known values or types).

Fixes #7464

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/68440044
2014-03-04 09:58:54 -08:00
Kelsey Hightower
96c373f9e1 path/filepath: ensure Glob does not ignore broken symlinks
Fixes #6463.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/69870050
2014-03-04 09:00:45 -08:00
Brad Fitzpatrick
5f1e0fa538 net/http: disable an alloc test under the race detector
LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/70200052
2014-03-04 08:56:52 -08:00
Russ Cox
241f63debd runtime: fix finalizer flakiness
The flakiness appears to be just in tests, not in the actual code.
Specifically, the many tests call runtime.GC once and expect that
the finalizers will be running in the background when GC returns.
Now that the sweep phase is concurrent with execution, however,
the finalizers will not be run until sweep finishes, which might
be quite a bit later. To force sweep to finish, implement runtime.GC
by calling the actual collection twice. The second will complete the
sweep from the first.

This was reliably broken after a few runs before the CL and now
passes tens of runs:

while GOMAXPROCS=2 ./runtime.test -test.run=Finalizer -test.short \
        -test.timeout=300s -test.cpu=$(perl -e 'print ("1,2,4," x 100) . "1"')
do true; done

Fixes #7328.

LGTM=dvyukov
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/71080043
2014-03-04 09:46:40 -05:00
Dmitriy Vyukov
d1c6c6004b cmd/go: fix data race on buildLdflags
Fixes #7438.

LGTM=rsc
R=golang-codereviews
CC=bradfitz, golang-codereviews, iant, rsc
https://golang.org/cl/70420044
2014-03-04 11:42:02 +04:00
Rémy Oudompheng
52e6d7c622 cmd/gc: use a register to checknil constants.
Fixes #7346.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/69050044
2014-03-04 08:18:17 +01:00
Russ Cox
0a3bd045f5 runtime: fix traceback on Windows
The exception handler runs on the ordinary g stack,
and the stack copier is now trying to do a traceback
across it. That's never been needed before, so it was
unimplemented. Implement it, in all its ugliness.

Fixes windows/amd64 build.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/71030043
2014-03-03 23:33:27 -05:00
Brad Fitzpatrick
709b12ffe6 net/http: fix location of StateHijacked and StateActive
1) Move StateHijacked callback earlier, to make it
panic-proof.  A Hijack followed by a panic didn't previously
result in ConnState getting fired for StateHijacked.  Move it
earlier, to the time of hijack.

2) Don't fire StateActive unless any bytes were read off the
wire while waiting for a request. This means we don't
transition from New or Idle to Active if the client
disconnects or times out. This was documented before, but not
implemented properly.

This CL is required for an pending fix for Issue 7264

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/69860049
2014-03-03 18:58:28 -08:00
Russ Cox
1a936ebcfa math/rand: speed up Float32, Float64
Actually, speed up Int31n and Int63n by avoiding retry loop.

benchmark           old ns/op    new ns/op    delta
BenchmarkFloat32           32           26  -19.45%
BenchmarkFloat64           46           23  -49.47%

Fixes #7267.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/69980047
2014-03-03 20:43:23 -05:00
Russ Cox
56b983c112 cmd/gc: fix internal crash
TBR=ken2
CC=golang-codereviews
https://golang.org/cl/70200053
2014-03-03 19:55:40 -05:00
Mikio Hara
1d086e39b0 net: enable fast socket creation with close-on-exec flag on freebsd
Also makes variable names explicit.

Fixes #7186.

LGTM=iant
R=golang-codereviews, gobot, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/69100043
2014-03-04 09:28:09 +09:00
Mikio Hara
a918c2c6d8 syscall: add Accept4 for freebsd
Update #7186
Update #7428

LGTM=r, bradfitz
R=golang-codereviews, rsc, minux.ma, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/68880043
2014-03-04 09:27:48 +09:00
Mikio Hara
be8aa4b073 os: handle file creation with close-on-exec flag correctly on darwin, freebsd
Fixes #7187.
Update #7193

LGTM=bradfitz
R=golang-codereviews, dave, rsc, minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/64510043
2014-03-04 09:27:29 +09:00
Mikio Hara
25668b9b34 syscall: add support for FreeBSD 10
This CL tweaks syscall.InterfaceMessage to support FreeBSD 10 and
prior to 10.

See http://svnweb.freebsd.org/base?view=revision&revision=254804.

Fixes #7193.

LGTM=iant
R=golang-codereviews, rsc, minux.ma, gobot, iant
CC=golang-codereviews
https://golang.org/cl/56980043
2014-03-04 09:26:56 +09:00
Mikio Hara
737efeb5b8 syscall: regenerate z-files on FreeBSD 10
Unfortunately FreeBSD 10 has changed its syscall arguments for
some reasons but as per request at golang-dev this CL does not
generate some structures, syscall numbers and constants as
compatible to FreeBSD 10 as follows:

Structure: Stat_t, IfData, IfMsghdr are based on 8-STABLE
Syscall number: Capsicum API is based on 9-STABLE
Constant: IFT_CARP, SIOCAIFADDR, SIOCSIFPHYADDR are based on 9-STABLE

Update #7193

FreeBSD 10 breaking changes:

r205792: Rename st_*timespec fields to st_*tim for POSIX 2008
compliance.
http://svnweb.freebsd.org/base?view=revision&revision=205792

r254804: Restructure the mbuf pkthdr to make it fit for upcoming
capabilities and features.
http://svnweb.freebsd.org/base?view=revision&revision=254804

r255219: Change the cap_rights_t type from uint64_t to a structure
that we can extend in the future in a backward compatible (API and
ABI) way.
http://svnweb.freebsd.org/base?view=revision&revision=255219

LGTM=iant
R=golang-codereviews, rsc, minux.ma, gobot, iant
CC=golang-codereviews
https://golang.org/cl/56770044
2014-03-04 09:26:01 +09:00
Dave Cheney
13ab78fdd9 runtime: update CBARGS macro for nacl/amd64p32
CBARGS is unused on amd64p32 so make this explicit.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/70940043
2014-03-04 10:36:04 +11:00
Brad Fitzpatrick
76cc0a2712 net/http: in Client, consume small redirect bodies before making next request
In Go 1.2, closing a request body without reading to EOF
causes the underlying TCP connection to not be reused. This
client code following redirects was never updated when that
happened.

This was part of a previous CL but moved to its own CL at
Josh's request.  Now with test too.

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/70800043
2014-03-03 11:25:57 -08:00
Graham King
ebe1eb6537 cmd/ld: DWARF opcode base to 10
DWARF 2 has 9 standard opcodes, so dwarfdump expects us to use an
opcode base of at least 10. Previously we used 5.

Discussion:
https://groups.google.com/forum/#!topic/golang-dev/d-BqpPgalzc

LGTM=josharian, rsc
R=golang-codereviews, gobot, rsc, josharian, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/69320043
2014-03-03 11:11:04 -08:00
Adam Langley
3656c2db96 crypto/tls: split connErr to avoid read/write races.
Currently a write error will cause future reads to return that same error.
However, there may have been extra information from a peer pending on
the read direction that is now unavailable.

This change splits the single connErr into errors for the read, write and
handshake. (Splitting off the handshake error is needed because both read
and write paths check the handshake error.)

Fixes #7414.

LGTM=bradfitz, r
R=golang-codereviews, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/69090044
2014-03-03 09:01:44 -05:00
David du Colombier
f608806092 cmd/ld: fix warning on Plan 9
warning: src/cmd/ld/pcln.c:184 more arguments than format INT

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/69870047
2014-03-03 08:14:27 +01:00
Brad Fitzpatrick
2ad72ecf34 net/http: add Client.Timeout for end-to-end timeouts
Fixes #3362

LGTM=josharian
R=golang-codereviews, josharian
CC=adg, dsymonds, golang-codereviews, n13m3y3r
https://golang.org/cl/70120045
2014-03-02 20:39:20 -08:00
Mikio Hara
f706d707b7 net: remove the dreg of solaris merge
Also enables netgo test on solaris.

LGTM=aram, jsing
R=golang-codereviews, dave, aram, jsing
CC=golang-codereviews
https://golang.org/cl/70300043
2014-03-03 07:09:28 +09:00
Mikio Hara
d9fc789df2 runtime: make SIGSYS notifiable on FreeBSD
Update #7186

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/70490043
2014-03-03 07:08:44 +09:00
Richard Crowley
7124ee59d1 net/http: ensure ConnState for StateNew fires before Server.Serve returns
The addition of Server.ConnState provides all the necessary
hooks to stop a Server gracefully, but StateNew previously
could fire concurrently with Serve exiting (as it does when
its net.Listener is closed). This previously meant one
couldn't use a WaitGroup incremented in the StateNew hook
along with calling Wait after Serve. Now you can.

Update #4674

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/70410044
2014-03-01 20:32:42 -08:00