]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: allocate mp.cgocallers earlier
authorIan Lance Taylor <iant@golang.org>
Fri, 1 Apr 2016 22:06:25 +0000 (15:06 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 1 Apr 2016 22:23:13 +0000 (22:23 +0000)
Fixes #15061.

Change-Id: I71f69f398d1c5f3a884bbd044786f1a5600d0fae
Reviewed-on: https://go-review.googlesource.com/21398
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/cgocall.go
src/runtime/proc.go

index 7cffa8361705a3cebc07e2b6a45fa2981d52d57a..d5248803a48f86b4893a5435e310085b5938da31 100644 (file)
@@ -113,11 +113,6 @@ func cgocall(fn, arg unsafe.Pointer) int32 {
        mp.ncgo++
        defer endcgo(mp)
 
-       // Allocate memory to hold a cgo traceback if the cgo call crashes.
-       if mp.cgoCallers == nil {
-               mp.cgoCallers = new(cgoCallers)
-       }
-
        // Reset traceback.
        mp.cgoCallers[0] = 0
 
index 27e61bd3e2b148a6caf90ed7c0dddf1dc6967295..1e1987ff9e01c397b4c99b477c1ed4fa0b2b15d7 100644 (file)
@@ -510,6 +510,11 @@ func mcommoninit(mp *m) {
        // so we need to publish it safely.
        atomicstorep(unsafe.Pointer(&allm), unsafe.Pointer(mp))
        unlock(&sched.lock)
+
+       // Allocate memory to hold a cgo traceback if the cgo call crashes.
+       if iscgo || GOOS == "solaris" || GOOS == "windows" {
+               mp.cgoCallers = new(cgoCallers)
+       }
 }
 
 // Mark gp ready to run.