runtime: allocate mp.cgocallers earlier

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>
This commit is contained in:
Ian Lance Taylor 2016-04-01 15:06:25 -07:00
parent 5cab01698a
commit 59fc42b230
2 changed files with 5 additions and 5 deletions

View 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

View 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.