-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: SIGPROF arriving on a foreign thread before any cgo call is made will crash the process #9456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sorry, I was not able to construct a reproducer that does not depend on being in tests. However, this code reproduces the failure if it is used to replace the covariancematrix_test.go file in github.com/gonum/stat. Run using (github.com/gonum/blas/cblas is installed using OpenBLAS). |
Thanks. I've verified that the essence of the problem is the same as the OpenBLAS has a global constructor (https://github.com/xianyi/OpenBLAS/blob/develop/driver/others/memory.c#L1291) The worker threads are periodically waken up to check if there is work for |
…ore 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> (cherry picked from commit 5da9c8c) Reviewed-on: https://go-review.googlesource.com/2789 Reviewed-by: Andrew Gerrand <adg@golang.org>
I'm seeing this periodically in Go 1.4.1. It's especially confusing because it happens seemingly randomly, and the most recent code doesn't import any cgo code, although I do have "export CGO_LDFLAGS="-L/Users/brendan/software/OpenBLAS -lopenblas" in my .bash_profile. I'd like to be more helpful, but I don't know how to make a consistent reproducer. I think I've only seen it when using "go run" if that has any relevance. |
Use ldd to see if the binary gets linked with libopenblas.
But I don't understand how it could happen with the fix in 1.4.1.
|
…ore 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 golang#9456. Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b Reviewed-on: https://go-review.googlesource.com/2141 Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 5da9c8c) Reviewed-on: https://go-review.googlesource.com/2789 Reviewed-by: Andrew Gerrand <adg@golang.org>
…ore 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 golang#9456. Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b Reviewed-on: https://go-review.googlesource.com/2141 Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 5da9c8c) Reviewed-on: https://go-review.googlesource.com/2789 Reviewed-by: Andrew Gerrand <adg@golang.org>
…ore 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 golang#9456. Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b Reviewed-on: https://go-review.googlesource.com/2141 Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 5da9c8c) Reviewed-on: https://go-review.googlesource.com/2789 Reviewed-by: Andrew Gerrand <adg@golang.org>
…ore 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 golang#9456. Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b Reviewed-on: https://go-review.googlesource.com/2141 Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 5da9c8c) Reviewed-on: https://go-review.googlesource.com/2789 Reviewed-by: Andrew Gerrand <adg@golang.org>
…ore 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 golang#9456. Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b Reviewed-on: https://go-review.googlesource.com/2141 Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 5da9c8c) Reviewed-on: https://go-review.googlesource.com/2789 Reviewed-by: Andrew Gerrand <adg@golang.org>
runtime.badsignal
will try to deliver the signal received by foreign threads to sigqueue using the cgo callback mechanism, however, cgocallback will not work if the process has not made any cgo call yet.A simple reproduction program:
This example is contrived, but imagine the thread is created by an external library linked in, and the user is profiling Go code. See https://groups.google.com/forum/#!topic/golang-nuts/SMhWSUsfPag for a real-world example (the symptom is the same, and disabling the cgocallback line in function runtime.badsignal fixes it, but I'm still not sure about how the program could create the extra thread during benchmarking without any cgocall. The problem could also be in other part of runtime.)
Tentatively labeled 1.4.1, as there is no meaningful workaround for 1.4.
The text was updated successfully, but these errors were encountered: