Skip to content

Commit 82a0799

Browse files
committed
runtime: use CompareAndSwap to avoid racy issue while two threads crash concurrently & fix typo
1 parent de25957 commit 82a0799

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/runtime/runtime-gdb_unix_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func TestGdbCoreCrashThreadBacktrace(t *testing.T) {
361361
err = cmd.Wait()
362362
t.Logf("child output:\n%s", output.String())
363363
if err == nil {
364-
t.Fatalf("Wait succeeded, want SIGSEGV")
364+
t.Fatalf("Wait succeeded, want SIGABRT")
365365
}
366366
ee, ok := err.(*exec.ExitError)
367367
if !ok {

src/runtime/signal_unix.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,11 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
753753

754754
if docrash {
755755
isCrashThread := false
756-
if crashing.Load() == 0 {
756+
if crashing.CompareAndSwap(0, 1) {
757757
isCrashThread = true
758+
} else {
759+
crashing.Add(1)
758760
}
759-
crashing.Add(1)
760761
if crashing.Load() < mcount()-int32(extraMLength.Load()) {
761762
// There are other m's that need to dump their stacks.
762763
// Relay SIGQUIT to the next m by sending it to the current process.

0 commit comments

Comments
 (0)