summaryrefslogtreecommitdiff
path: root/src/runtime/stubs.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-08 14:05:23 -0400
committerRuss Cox <rsc@golang.org>2014-09-08 14:05:23 -0400
commit9ad3fba8367769ee742f07e83aa714c9ae6b8d8a (patch)
tree927a0d6982e643c90edd5ddefaf706b4d20bd984 /src/runtime/stubs.go
parent87cb94fa270003e8d950d001e1c85e34a5457a8a (diff)
downloadgo-9ad3fba8367769ee742f07e83aa714c9ae6b8d8a.tar.gz
liblink, runtime: diagnose and fix C code running on Go stack
This CL contains compiler+runtime changes that detect C code running on Go (not g0, not gsignal) stacks, and it contains corrections for what it detected. The detection works by changing the C prologue to use a different stack guard word in the G than Go prologue does. On the g0 and gsignal stacks, that stack guard word is set to the usual stack guard value. But on ordinary Go stacks, that stack guard word is set to ^0, which will make any stack split check fail. The C prologue then calls morestackc instead of morestack, and morestackc aborts the program with a message about running C code on a Go stack. This check catches all C code running on the Go stack except NOSPLIT code. The NOSPLIT code is allowed, so the check is complete. Since it is a dynamic check, the code must execute to be caught. But unlike the static checks we've been using in cmd/ld, the dynamic check works with function pointers and other indirect calls. For example it caught sigpanic being pushed onto Go stacks in the signal handlers. Fixes issue 8667. LGTM=khr, iant R=golang-codereviews, khr, iant CC=golang-codereviews, r https://codereview.appspot.com/133700043
Diffstat (limited to 'src/runtime/stubs.go')
-rw-r--r--src/runtime/stubs.go1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index bf6c33a41..f8ea1092e 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -223,7 +223,6 @@ func lessstack()
func morestack()
func mstart()
func rt0_go()
-func sigpanic()
// return0 is a stub used to return 0 from deferproc.
// It is called at the very end of deferproc to signal