summaryrefslogtreecommitdiff
path: root/src/runtime/stubs.go
diff options
context:
space:
mode:
authorHector Martin Cantero <hector@marcansoft.com>2014-09-24 13:20:25 -0400
committerHector Martin Cantero <hector@marcansoft.com>2014-09-24 13:20:25 -0400
commitfc939958db89c3cb14b87d3944a09c541951644b (patch)
treed42b571a540833bd9b0e84c223adf411f97b5935 /src/runtime/stubs.go
parentef69714063fe22d25ff726cd16864743407fac32 (diff)
downloadgo-fc939958db89c3cb14b87d3944a09c541951644b.tar.gz
runtime: keep g->syscallsp consistent after cgo->Go callbacks
Normally, the caller to runtime.entersyscall() must not return before calling runtime.exitsyscall(), lest g->syscallsp become a dangling pointer. runtime.cgocallbackg() violates this constraint. To work around this, save g->syscallsp and g->syscallpc around cgo->Go callbacks, then restore them after calling runtime.entersyscall(), which restores the syscall stack frame pointer saved by cgocall. This allows the GC to correctly trace a goroutine that is currently returning from a Go->cgo->Go chain. This also adds a check to proc.c that panics if g->syscallsp is clearly invalid. It is not 100% foolproof, as it will not catch a case where the stack was popped then pushed back beyond g->syscallsp, but it does catch the present cgo issue and makes existing tests fail without the bugfix. Fixes issue 7978. LGTM=dvyukov, rsc R=golang-codereviews, dvyukov, minux, bradfitz, iant, gobot, rsc CC=golang-codereviews, rsc https://codereview.appspot.com/131910043 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/stubs.go')
-rw-r--r--src/runtime/stubs.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index 2e6aadca7..1381c7efd 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -164,6 +164,7 @@ func noescape(p unsafe.Pointer) unsafe.Pointer {
}
func entersyscall()
+func reentersyscall(pc uintptr, sp unsafe.Pointer)
func entersyscallblock()
func exitsyscall()