Skip to content

Commit f231010

Browse files
committed
runtime: let the fault thread to crash the process
1 parent 3839447 commit f231010

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/runtime/signal_unix.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,20 +752,34 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
752752
}
753753

754754
if docrash {
755+
isCrashThread := false
756+
if crashing == 0 {
757+
isCrashThread = true
758+
}
755759
crashing++
756760
if crashing < mcount()-int32(extraMLength.Load()) {
757761
// There are other m's that need to dump their stacks.
758762
// Relay SIGQUIT to the next m by sending it to the current process.
759763
// All m's that have already received SIGQUIT have signal masks blocking
760764
// receipt of any signals, so the SIGQUIT will go to an m that hasn't seen it yet.
761-
// When the last m receives the SIGQUIT, it will fall through to the call to
762-
// crash below. Just in case the relaying gets botched, each m involved in
765+
// The first m will wait until all ms received the SIGQUIT, then crash/exit.
766+
// Just in case the relaying gets botched, each m involved in
763767
// the relay sleeps for 5 seconds and then does the crash/exit itself.
764-
// In expected operation, the last m has received the SIGQUIT and run
765-
// crash/exit and the process is gone, all long before any of the
766-
// 5-second sleeps have finished.
768+
// In expected operation, the first m will wait until the last m has received the SIGQUIT,
769+
// and then run crash/exit and the process is gone.
770+
// However, if it spends more than 5 seconds to send SIGQUIT to all ms,
771+
// any of ms may crash/exit the process after waiting for 5 seconds.
767772
print("\n-----\n\n")
768773
raiseproc(_SIGQUIT)
774+
}
775+
// fix #63277
776+
if isCrashThread {
777+
i := 0
778+
for (crashing < mcount()-int32(extraMLength.Load()) && i < 10) {
779+
i++
780+
usleep(500 * 1000)
781+
}
782+
} else {
769783
usleep(5 * 1000 * 1000)
770784
}
771785
printDebugLog()

0 commit comments

Comments
 (0)