summaryrefslogtreecommitdiff
path: root/src/runtime/cgocall.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-03 12:22:19 -0400
committerRuss Cox <rsc@golang.org>2014-10-03 12:22:19 -0400
commitc5aca6fedbdd83d9153f6a00dc656aaabb0774c5 (patch)
tree26952b971b307783cde4b126c0a133f62ac3c893 /src/runtime/cgocall.go
parent4eb6792aa572c7e6d3448d4cf22223b61b65724f (diff)
parent338c7ea5df93e25ac4dc143970603a1e88b26124 (diff)
downloadgo-c5aca6fedbdd83d9153f6a00dc656aaabb0774c5.tar.gz
[dev.garbage] merge default into dev.garbage
Diffstat (limited to 'src/runtime/cgocall.go')
-rw-r--r--src/runtime/cgocall.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go
index a21474b01..7fd91469e 100644
--- a/src/runtime/cgocall.go
+++ b/src/runtime/cgocall.go
@@ -177,14 +177,22 @@ func cfree(p unsafe.Pointer) {
// Call from C back to Go.
//go:nosplit
func cgocallbackg() {
- if gp := getg(); gp != gp.m.curg {
+ gp := getg()
+ if gp != gp.m.curg {
println("runtime: bad g in cgocallback")
exit(2)
}
+ // entersyscall saves the caller's SP to allow the GC to trace the Go
+ // stack. However, since we're returning to an earlier stack frame and
+ // need to pair with the entersyscall() call made by cgocall, we must
+ // save syscall* and let reentersyscall restore them.
+ savedsp := unsafe.Pointer(gp.syscallsp)
+ savedpc := gp.syscallpc
exitsyscall() // coming out of cgo call
cgocallbackg1()
- entersyscall() // going back to cgo call
+ // going back to cgo call
+ reentersyscall(savedpc, savedsp)
}
func cgocallbackg1() {