llvm-project
c36234b2 - [Support] Don't take a lock in CrashRecoverySignalHandler (#219529)

Commit
55 days ago
[Support] Don't take a lock in CrashRecoverySignalHandler (#219529) Disable() locks a mutex with static storage duration, which is not safe from a signal handler. When the signal arrives during exit(), after static destructors have run, the mutex is already destroyed, causing pthread_mutex_lock returns EINVAL and in turn causing libc++ to throw. To make matters worse, without exceptions, the throw becomes a std::terminate, which happens before uninstallExceptionOrSignalHandlers. Because the signal handler is installed without SA_RESETHAND, every call to abort() re-enters the handler and throws again. Inline the two statements Disable() performs. Racing with another thread here doesn't matter, as the previous comment noted.
Author
Parents
Loading