Skip to content

Commit

Permalink
runtime: use CompareAndSwap to avoid racy issue while two threads cra…
Browse files Browse the repository at this point in the history
…sh concurrently
  • Loading branch information
zzkcode committed Nov 21, 2023
1 parent de25957 commit 08249f1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runtime/signal_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,11 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {

if docrash {
isCrashThread := false
if crashing.Load() == 0 {
if crashing.CompareAndSwap(0, 1) {
isCrashThread = true
} else {
crashing.Add(1)
}
crashing.Add(1)
if crashing.Load() < mcount()-int32(extraMLength.Load()) {
// There are other m's that need to dump their stacks.
// Relay SIGQUIT to the next m by sending it to the current process.
Expand Down

0 comments on commit 08249f1

Please sign in to comment.