Skip to content

Commit 59fc42b

Browse files
runtime: allocate mp.cgocallers earlier
Fixes #15061. Change-Id: I71f69f398d1c5f3a884bbd044786f1a5600d0fae Reviewed-on: https://go-review.googlesource.com/21398 Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 5cab016 commit 59fc42b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/runtime/cgocall.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ func cgocall(fn, arg unsafe.Pointer) int32 {
113113
mp.ncgo++
114114
defer endcgo(mp)
115115

116-
// Allocate memory to hold a cgo traceback if the cgo call crashes.
117-
if mp.cgoCallers == nil {
118-
mp.cgoCallers = new(cgoCallers)
119-
}
120-
121116
// Reset traceback.
122117
mp.cgoCallers[0] = 0
123118

src/runtime/proc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,11 @@ func mcommoninit(mp *m) {
510510
// so we need to publish it safely.
511511
atomicstorep(unsafe.Pointer(&allm), unsafe.Pointer(mp))
512512
unlock(&sched.lock)
513+
514+
// Allocate memory to hold a cgo traceback if the cgo call crashes.
515+
if iscgo || GOOS == "solaris" || GOOS == "windows" {
516+
mp.cgoCallers = new(cgoCallers)
517+
}
513518
}
514519

515520
// Mark gp ready to run.

0 commit comments

Comments
 (0)