aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sigqueue.go
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2014-12-27 19:15:38 -0500
committerMinux Ma <minux@golang.org>2014-12-31 23:10:44 +0000
commit5da9c8cd0a0427d1771b3a9a6d8d931430ce50dd (patch)
tree1adbb445e5f0ecc73adac3bd9cc793729cc91b00 /src/runtime/sigqueue.go
parent6cb403319fd162f02499332e0aab32487c1b1ef8 (diff)
downloadgo-5da9c8cd0a0427d1771b3a9a6d8d931430ce50dd.tar.xz
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>
Diffstat (limited to 'src/runtime/sigqueue.go')
-rw-r--r--src/runtime/sigqueue.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/sigqueue.go b/src/runtime/sigqueue.go
index 4b97745a23..a760790396 100644
--- a/src/runtime/sigqueue.go
+++ b/src/runtime/sigqueue.go
@@ -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))
}