Commit 59fc42b2 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 5cab0169
......@@ -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
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment