1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:18:32 -06:00
Commit Graph

20337 Commits

Author SHA1 Message Date
Russ Cox
902f8d9ca0 net/http/httptest: fix deadlock in TestIssue7264
I am seeing deadlocks waiting on <-inHandler.
It seems to me that there is no guarantee that the
handler actually runs, if the client does

        write header
        close connection

fast enough. The server might see the EOF on the
connection before it manages to invoke the handler.

This change fixes the deadlock, but it may make
the test not actually test anything. Not sure.

LGTM=bradfitz
R=bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/140970043
2014-09-07 20:13:35 -04:00
Russ Cox
b4bfa6c964 runtime: save g to TLS more aggressively
This is one of those "how did this ever work?" bugs.
The current build failures are happening because
a fault comes up while executing on m->curg on a
system-created thread using an m obtained from needm,
but TLS is set to m->g0, not m->curg. On fault,
sigtramp starts executing, assumes r10 (g) might be
incorrect, reloads it from TLS, and gets m->g0, not
m->curg. Then sighandler dutifully pushes a call to
sigpanic onto the stack and returns to it.
We're now executing on the m->curg stack but with
g=m->g0. Sigpanic does a stack split check, sees that
the SP is not in range (50% chance depending on relative
ordering of m->g0's and m->curg's stacks), and then
calls morestack. Morestack sees that g=m->g0 and
crashes the program.

The fix is to replace every change of g in asm_arm.s
with a call to a function that both updates g and
saves the updated g to TLS.

Why did it start happening? That's unclear.
Unfortunately there were other bugs in the initial
checkin that mask exactly which of a sequence of
CLs started the behavior where sigpanic would end
up tripping the stack split.

Fixes arm build.
Fixes #8675.

LGTM=iant
R=golang-codereviews, iant
CC=dave, golang-codereviews, khr, minux, r
https://golang.org/cl/135570043
2014-09-07 19:47:40 -04:00
Russ Cox
2c14dbe458 crypto/tls: print unexpected error in test
Maybe will help us understand Solaris build failure.

TBR=aram
CC=golang-codereviews
https://golang.org/cl/139290043
2014-09-07 09:07:19 -04:00
Russ Cox
fb818eab7f liblink: fix arm wrapper prologue
Fixes arm build.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/132700043
2014-09-07 08:59:20 -04:00
Russ Cox
2034dae94f build: fix windows make.bat
The Unix make.bash builds cmd/dist from *.c.
make.bat apparently does not.

TBR=r
CC=golang-codereviews
https://golang.org/cl/137280043
2014-09-07 07:31:53 -04:00
Russ Cox
c0951701cf cmd/dist: remove goc2c
After the three pending CLs listed below, there will be no more .goc files.

134580043	runtime: move stubs.goc code into runtime.c
133670043	runtime: fix windows syscalls for copying stacks
141180043	runtime: eliminate Go -> C -> block paths for Solaris

LGTM=bradfitz
R=golang-codereviews, bradfitz, dave
CC=golang-codereviews, iant, r
https://golang.org/cl/132680043
2014-09-07 07:23:49 -04:00
Russ Cox
8a7597fd7a runtime: fix nacl/amd64p32 build
Update #8675
Fixes nacl/amd64p32 build.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/141140045
2014-09-07 07:23:18 -04:00
Russ Cox
59dd20f4d3 runtime: fix windows syscalls for copying stacks
Syscall and everything it calls must be nosplit:
we cannot split a stack once Syscall has been invoked,
because we don't know which of its arguments are
pointers.

LGTM=khr, r, alex.brainman
R=dvyukov, iant, khr, r, bradfitz, alex.brainman
CC=golang-codereviews
https://golang.org/cl/133670043
2014-09-06 21:19:24 -04:00
Russ Cox
c01c2c8895 runtime: eliminate Go -> C -> block paths for Solaris
LGTM=aram, r
R=golang-codereviews, aram, r
CC=golang-codereviews, iant, khr
https://golang.org/cl/141180043
2014-09-06 21:16:35 -04:00
Russ Cox
b6951bcc0b runtime: increase stack split limit again
Increase NOSPLIT reservation from 192 to 384 bytes.
The problem is that the non-Unix systems (Solaris and Windows)
just can't make system calls in a small amount of space,
and then worse they do things that are complex enough
to warrant calling runtime.throw on failure.
We don't have time to rewrite the code to use less stack.

I'm not happy about this, but it's still a small amount.

The good news is that we're doing this to get to only
using copying stacks for stack growth. Once that is true,
we can drop the default stack size from 8k to 4k, which
should more than make up for the bytes we're losing here.

LGTM=r
R=iant, r, bradfitz, aram.h
CC=golang-codereviews
https://golang.org/cl/140350043
2014-09-06 21:16:13 -04:00
Russ Cox
7230db9ef8 misc/makerelease: make goimports-safe
LGTM=bradfitz
R=adg, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/140310045
2014-09-06 21:10:06 -04:00
Russ Cox
9c721aedd5 cmd/yacc: move cmd/yacc/expr to cmd/yacc/testdata/expr
This will keep the go command from trying to build it
when the cmd/ tree is no longer a special case.

Also update doc.go to refer to the correct location.
(It was incorrect even before this CL.)

LGTM=r
R=iant, r
CC=golang-codereviews
https://golang.org/cl/134560043
2014-09-06 15:27:52 -04:00
Russ Cox
e8fc362049 runtime/cgo: use just #include "textflag.h"
This will withstand the src/pkg/ to src/ move.

LGTM=r
R=iant, r
CC=golang-codereviews
https://golang.org/cl/134530044
2014-09-06 15:27:39 -04:00
Russ Cox
a09e61395e runtime: move stubs.goc code into runtime.c
Now that the calling conventions are the same,
there's no danger to using plain C for these.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/134580043
2014-09-06 15:27:26 -04:00
Russ Cox
e8d65b92d7 liblink: fix arm build errors
This was supposed to be in CL 135490044
but got lost in a transfer from machine to machine.

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/135560043
2014-09-06 14:53:44 -04:00
Aram Hăvărneanu
b4c28d9180 runtime, syscall: rewrite syscall_solaris.goc in Go
LGTM=dave, rsc
R=khr, dvyukov, dave, gobot, rsc
CC=golang-codereviews, rsc
https://golang.org/cl/133220044
2014-09-06 19:35:46 +02:00
Russ Cox
8473695797 runtime: fix panic/wrapper/recover math
The gp->panicwrap adjustment is just fatally flawed.
Now that there is a Panic.argp field, update that instead.
That can be done on entry only, so that unwinding doesn't
need to worry about undoing anything. The wrappers
emit a few more instructions in the prologue but everything
else in the system gets much simpler.

It also fixes (without trying) a broken test I never checked in.

Fixes #7491.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews, iant, r
https://golang.org/cl/135490044
2014-09-06 13:19:08 -04:00
Keith Randall
8620e2b04e runtime: badreflectcall runs on the G stack - convert to Go.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/136260043
2014-09-06 10:12:47 -07:00
Keith Randall
dbed4e9b4f runtime: get rid of other Go->C calls in test exports.
testSchedLocal* tests need to malloc now because their
stack frames are too big to fit on the G0 stack.

LGTM=iant
R=golang-codereviews, iant, khr
CC=golang-codereviews
https://golang.org/cl/133660043
2014-09-06 10:07:23 -07:00
Keith Randall
0e19a3d6d0 runtime: move gostringw and gogobytes test stubs to Go.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/141150043
2014-09-05 15:01:09 -07:00
Keith Randall
005806cab1 runtime: run getgcmask on the M stack.
LGTM=rsc
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/132660043
2014-09-05 14:59:31 -07:00
Russ Cox
277ef8fa07 runtime: disable StackCopyAlways
I forgot to clear this before submitting.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/132640044
2014-09-05 17:00:32 -04:00
Russ Cox
f8f630f5ec runtime: use reflect.call during panic instead of newstackcall
newstackcall creates a new stack segment, and we want to
be able to throw away all that code.

LGTM=khr
R=khr, iant
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139270043
2014-09-05 16:51:45 -04:00
Russ Cox
fcbe51c9e3 misc/cgo/test: make issue5548 test pickier
If there is doubt about passing arguments correctly
(as there is in this test), there should be doubt about
getting the results back intact too. Using 0 and 1
(especially 0 for success) makes it easy to get a PASS
accidentally when the return value is not actually
being propagated. Use less common values.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/141110043
2014-09-05 14:59:09 -04:00
Russ Cox
4b3906fec3 runtime: handle nil ptr load/store in arm software floating point
We cannot let a real panic start there, because there is C code
on the stack, and worse, there is an assembly frame with a
saved copy of the registers and we have no idea which ones
are pointers.

Instead, detect the nil ptr load/store and return out of the C
and assembly into a stub that will start the call to sigpanic.

Fixes GOARM=5 build.

LGTM=iant
R=golang-codereviews, iant
CC=dave, golang-codereviews, minux, r
https://golang.org/cl/138130043
2014-09-05 14:58:54 -04:00
Russ Cox
f93e21ac24 runtime: clean up sigqueue.go
Minor changes to make logic clearer.
Observed while working on the conversion.

LGTM=iant, dvyukov
R=dvyukov, iant
CC=golang-codereviews
https://golang.org/cl/140250043
2014-09-05 14:38:29 -04:00
Alex Brainman
0f9b6affb7 net: temporarily skip TestAcceptIgnoreSomeErrors
Update #8662

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/138120043
2014-09-05 08:48:21 -07:00
Keith Randall
8217b4a203 runtime: convert panic/recover to Go
created panic1.go just so diffs were available.
After this CL is in, I'd like to move panic.go -> defer.go
and panic1.go -> panic.go.

LGTM=rsc
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/133530045
2014-09-05 10:04:16 -04:00
Russ Cox
e0f08b938a runtime: use cas loop to coordinate with sigprof
sigprof and setcpuprofilerate coordinate the enabling/disabling
of the handler using a Mutex. This has always been a bit dodgy:
setcpuprofilerate must be careful to turn off signals before acquiring
the lock to avoid a deadlock.

Now the lock implementations use onM, and onM isn't okay on the
signal stack. We know how to make it okay, but it's more work than
is probably worth doing.

Since this is super-dodgy anyway, replace the lock with a simple
cas loop. It is only contended if setcpuprofilerate is being called,
and that doesn't happen frequently enough to care about the
raw speed or about using futexes/semaphores.

TBR to fix freebsd/amd64 and dragonfly/amd64 builds.
Happy to make changes in a follow-up CL.

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/141080044
2014-09-04 23:14:21 -04:00
Russ Cox
83824639c3 syscall: in linux/arm Syscall, zero R3, R4, R5
The general kernel system call interface
takes 6 arguments: R0, R1, R2, R3, R4, R5.

Syscall is for calls that only need 3.
The amd64 and 386 versions zero the extra arg registers,
but the arm version does not.

func utimensat calls Syscall with 3 arguments.
The kernel expects a 4th argument.
That turns out to be whatever is in R3 at the time of the call.
CL 137160043 changed various pieces of code and apparently
changed the value left in R3 at the time of utimensat's Syscall.
This causes the kernel to return EINVAL.

Change linux/arm Syscall to zero R3, R4, R5, so that calls will
behave deterministically, even if they pass too few arguments.

Arguably, utimensat could be fixed too, but the predictable
zeroing is certainly worth doing, and once done utimensat's
use of Syscall is fine.

Fixes arm build.

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/141080043
2014-09-04 23:12:10 -04:00
Russ Cox
cb040d59b9 runtime: use new #include "textflag.h"
I did this just to clean things up, but it will be important
when we drop the pkg directory later.

LGTM=bradfitz
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/132600043
2014-09-04 23:05:18 -04:00
Russ Cox
d16a2ad09b runtime: do not stop traceback at onM
Behavior before this CL:

1. If onM is called on a g0 stack, it just calls the given function.

2. If onM is called on a gsignal stack, it calls badonm.

3. If onM is called on a curg stack, it switches to the g0 stack
and then calls the function.

In cases 1 and 2, if the program then crashes (and badonm always does),
we want to see what called onM, but the traceback stops at onM.
In case 3, the traceback must stop at onM, because the g0
stack we are renting really does stop at onM.

The current code stops the traceback at onM to handle 3,
at the cost of making 1 and 2 crash with incomplete traces.

Change traceback to scan past onM but in case 3 make it look
like on the rented g0 stack, onM was called from mstart.
The traceback already knows that mstart is a top-of-stack function.

Alternate fix at CL 132610043 but I think this one is cleaner.
This CL makes 3 the exception, while that CL makes 1 and 2 the exception.

Submitting TBR to try to get better stack traces out of the
freebsd/amd64 builder, but happy to make changes in a
followup CL.

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/133620043
2014-09-04 22:48:08 -04:00
Russ Cox
cf3fd0a55f cmd/dist: another attempt at textflag.h
The old change worked fine in my client, but my client
must not have been in a completely clean state.

TBR=r
CC=golang-codereviews
https://golang.org/cl/138100043
2014-09-04 21:56:11 -04:00
Russ Cox
73a6d36d87 cmd/dist: make textflag.h available in runtime, avoid android/linux conflicts
1) cmd/dist was copying textflag.h to the build include directory,
but only after compiling package runtime. So other packages could
use it, just not runtime. Copy earlier, so that runtime can use it too.

2) We decided for android that anything marked linux is also included
in the build. The generated linux-specific files in cmd/dist must therefore
have explicit +build !android tags, or else you can't have simultaneous
linux/arm and android/arm builds in a single client. The tag was already
there for at least one file, but it was missing from many others.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/134500043
2014-09-04 21:22:18 -04:00
Russ Cox
99a08262af runtime: mark sysAlloc nosplit
sysAlloc is the only mem function called from Go.

LGTM=iant, khr
R=golang-codereviews, khr, 0intro, iant
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139210043
2014-09-04 21:12:48 -04:00
Russ Cox
db58ab96fa runtime: more C to Go conversion adjustments
Mostly NOSPLIT additions.
Had to rewrite atomic_arm.c in Go because it calls lock,
and lock is too complex.

With this CL, I find no Go -> C calls that can split the stack
on any system except Solaris and Windows.

Solaris and Windows need more work and will be done separately.

LGTM=iant, dave
R=golang-codereviews, bradfitz, iant, dave
CC=dvyukov, golang-codereviews, khr, r
https://golang.org/cl/137160043
2014-09-04 21:12:31 -04:00
Brad Fitzpatrick
1a14b5bad8 cmd/api: don't depend on os/user or USER to check api
The -nocgo builder failed because it has cgo disabled
as well as no USER environment variable:
http://build.golang.org/log/2250abb82f5022b72a12997b8ff89fcdeff094c9

# Checking API compatibility.
Error getting current user: user: Current not implemented on linux/amd64
exit status 1

Don't require the environment variable here.

LGTM=minux
R=dave, adg, minux
CC=golang-codereviews
https://golang.org/cl/140290043
2014-09-04 17:13:22 -07:00
Robert Griesemer
a29437101c go/parser: fix "zero day" parse error
(a b string, ok bool) is not a valid signature

Fixes #8656.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/137140043
2014-09-04 15:18:32 -07:00
Russ Cox
f545b05aae runtime: make more functions safe for Go
Convert no-op race functions.
Everything else is tiny and gets NOSPLITs.

After this, all that is left on darwin is sysAlloc, panic, and gothrow (all pending).
There may be system-specific calls in other builds.

LGTM=iant
R=golang-codereviews, iant
CC=dvyukov, golang-codereviews, khr, r
https://golang.org/cl/140240044
2014-09-04 15:53:45 -04:00
Dmitriy Vyukov
c08d8834dd runtime: convert cgocall to Go
LGTM=khr, rsc
R=golang-codereviews, khr, rsc
CC=golang-codereviews
https://golang.org/cl/131670043
2014-09-04 14:40:40 -04:00
Russ Cox
503bcd464e runtime: use C for readgstatus, goroutine status values
When this code was written, there was no way for Go to
reuse the C function and enum values. Now there is.

LGTM=bradfitz
R=rlh, bradfitz
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/139150045
2014-09-04 14:19:50 -04:00
Russ Cox
81ed684a71 runtime: reconvert sigqueue.goc from C to Go
The original conversion in CL 132090043 cut up
the function in an attempt to avoid converting most
of the code to Go. This contorts the control flow.

While debugging the onM signal stack bug,
I reconverted sigqueue.goc in its entirety.
This restores the original control flow, which is
much easier to understand.

The current conversion is correct, it's just complex
and will be hard to maintain. The new one is as
readable as the original code.

I uploaded sigqueue.goc as the initial copy of
sigqueue.go in the CL, so if you view the diffs
of sigqueue.go comparing against patch set 2 [sic]
it will show the actual starting point.

For example:
https://golang.org/cl/136160043/diff2/20001:60001/src/pkg/runtime/sigqueue.go

LGTM=dvyukov, iant
R=golang-codereviews, dvyukov, iant
CC=golang-codereviews, khr, r
https://golang.org/cl/136160043
2014-09-04 13:51:12 -04:00
Robert Griesemer
43345a118b go/parser: initialize file set even in only some tests are run
Without this fix, some tests crashed (e.g. go test -run Invalid).

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/133580043
2014-09-04 10:43:03 -07:00
David Crawshaw
fa9f3058e0 androidtest.bash: drop noisy adb sync output
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/138070043
2014-09-04 13:39:51 -04:00
Dmitriy Vyukov
97fdfdb52c runtime: fix solaris netpoll
TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/141030043
2014-09-04 11:34:01 +04:00
Dmitriy Vyukov
29225211e1 runtime: fix netbsd build
TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/140220043
2014-09-04 11:31:39 +04:00
Mikio Hara
d3a2021f71 runtime: fix typos
LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/141000043
2014-09-04 16:23:37 +09:00
David du Colombier
b1d0152997 runtime: fix Plan 9 build
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/138050043
2014-09-04 08:36:18 +02:00
Dmitriy Vyukov
1b47af2199 runtime: fix arm build
TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/140990043
2014-09-04 10:16:57 +04:00
Dmitriy Vyukov
91a670d179 runtime: convert netpoll to Go
The common code is converted, epoll and kqueue are converted.
Windows and solaris are still C.

LGTM=rsc
R=golang-codereviews, rsc, dave
CC=golang-codereviews, iant, khr, rsc
https://golang.org/cl/132910043
2014-09-04 10:04:04 +04:00