mirror of
https://github.com/golang/go.git
synced 2025-05-27 18:31:35 +00:00
runtime: make GOTRACEBACK=crash crash promptly in cgo binaries
GOTRACEBACK=crash works by bouncing a SIGQUIT around the process sched.mcount times. However, sched.mcount includes the extra Ms allocated by oneNewExtraM for cgo callbacks. Hence, if there are any extra Ms that don't have real OS threads, we'll try to send SIGQUIT more times than there are threads to catch it. Since nothing will catch these extra signals, we'll fall back to blocking for five seconds before aborting the process. Avoid this five second delay by subtracting out the number of extra Ms when sending SIGQUITs. Of course, in a cgo binary, it's still possible for the SIGQUIT to go to a cgo thread and cause some other failure mode. This does not fix that. Change-Id: I4fbf3c52dd721812796c4c1dcb2ab4cb7026d965 Reviewed-on: https://go-review.googlesource.com/38182 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
c03e75e539
commit
f2e87158f0
@ -1399,6 +1399,7 @@ func needm(x byte) {
|
||||
// running at all (that is, there's no garbage collection
|
||||
// running right now).
|
||||
mp.needextram = mp.schedlink == 0
|
||||
extraMCount--
|
||||
unlockextra(mp.schedlink.ptr())
|
||||
|
||||
// Save and block signals before installing g.
|
||||
@ -1484,6 +1485,7 @@ func oneNewExtraM() {
|
||||
// Add m to the extra list.
|
||||
mnext := lockextra(true)
|
||||
mp.schedlink.set(mnext)
|
||||
extraMCount++
|
||||
unlockextra(mp)
|
||||
}
|
||||
|
||||
@ -1525,6 +1527,7 @@ func dropm() {
|
||||
unminit()
|
||||
|
||||
mnext := lockextra(true)
|
||||
extraMCount++
|
||||
mp.schedlink.set(mnext)
|
||||
|
||||
setg(nil)
|
||||
@ -1541,6 +1544,7 @@ func getm() uintptr {
|
||||
}
|
||||
|
||||
var extram uintptr
|
||||
var extraMCount uint32 // Protected by lockextra
|
||||
var extraMWaiters uint32
|
||||
|
||||
// lockextra locks the extra list and returns the list head.
|
||||
|
@ -111,7 +111,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
||||
|
||||
if docrash {
|
||||
crashing++
|
||||
if crashing < sched.mcount {
|
||||
if crashing < sched.mcount-int32(extraMCount) {
|
||||
// There are other m's that need to dump their stacks.
|
||||
// Relay SIGQUIT to the next m by sending it to the current process.
|
||||
// All m's that have already received SIGQUIT have signal masks blocking
|
||||
|
Loading…
x
Reference in New Issue
Block a user