mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: ignore SIGPROF to foreign threads before cgocallback is fully initialized
Some libraries, for example, OpenBLAS, create work threads in a global constructor. If we're doing cpu profiling, it's possible that SIGPROF might come to some of the worker threads before we make our first cgo call. Cgocallback used to terminate the process when that happens, but it's better to miss a couple profiling signals than to abort in this case. Fixes #9456. Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b Reviewed-on: https://go-review.googlesource.com/2141 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
6cb403319f
commit
5da9c8cd0a
2 changed files with 64 additions and 0 deletions
|
|
@ -154,5 +154,14 @@ func signal_disable(s uint32) {
|
|||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
//go:nosplit
|
||||
func badsignal(sig uintptr) {
|
||||
// Some external libraries, for example, OpenBLAS, create worker threads in
|
||||
// a global constructor. If we're doing cpu profiling, and the SIGPROF signal
|
||||
// comes to one of the foreign threads before we make our first cgo call, the
|
||||
// call to cgocallback below will bring down the whole process.
|
||||
// It's better to miss a few SIGPROF signals than to abort in this case.
|
||||
// See http://golang.org/issue/9456.
|
||||
if sig == _SIGPROF && needextram != 0 {
|
||||
return
|
||||
}
|
||||
cgocallback(unsafe.Pointer(funcPC(sigsend)), noescape(unsafe.Pointer(&sig)), unsafe.Sizeof(sig))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue