p.link = gp._panic
gp._panic = (*_panic)(noescape(unsafe.Pointer(&p)))
- atomic.Xadd(&runningPanicDefers, 1)
+ runningPanicDefers.Add(1)
// By calculating getcallerpc/getcallersp here, we avoid scanning the
// gopanic frame (stack scanning is slow...)
mcall(recovery)
throw("bypassed recovery failed") // mcall should not return
}
- atomic.Xadd(&runningPanicDefers, -1)
+ runningPanicDefers.Add(-1)
// After a recover, remove any remaining non-started,
// open-coded defer entries, since the corresponding defers
}
// runningPanicDefers is non-zero while running deferred functions for panic.
-// runningPanicDefers is incremented and decremented atomically.
// This is used to try hard to get a panic stack trace out when exiting.
-var runningPanicDefers uint32
+var runningPanicDefers atomic.Uint32
// panicking is non-zero when crashing the program for an unrecovered panic.
// panicking is incremented and decremented atomically.
// startpanic_m set panicking, which will
// block main from exiting, so now OK to
// decrement runningPanicDefers.
- atomic.Xadd(&runningPanicDefers, -1)
+ runningPanicDefers.Add(-1)
printpanics(msgs)
}
// another goroutine at the same time as main returns,
// let the other goroutine finish printing the panic trace.
// Once it does, it will exit. See issues 3934 and 20018.
- if atomic.Load(&runningPanicDefers) != 0 {
+ if runningPanicDefers.Load() != 0 {
// Running deferred functions should not take long.
for c := 0; c < 1000; c++ {
- if atomic.Load(&runningPanicDefers) == 0 {
+ if runningPanicDefers.Load() == 0 {
break
}
Gosched()