Fun fact: two threads can crash at the same time.

This commit is contained in:
Bartosz Taudul 2018-08-21 01:45:33 +02:00
parent 47943d6a86
commit 22346feea3

View File

@ -429,6 +429,7 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
#ifdef __linux__
static long s_profilerTid = 0;
static char s_crashText[1024];
static std::atomic<bool> s_alreadyCrashed( false );
static void ThreadFreezer( int signal )
{
@ -463,6 +464,9 @@ static inline void HexPrint( char*& ptr, uint64_t val )
static void CrashHandler( int signal, siginfo_t* info, void* ucontext )
{
bool expected = false;
if( !s_alreadyCrashed.compare_exchange_strong( expected, true ) ) ThreadFreezer( signal );
auto msgPtr = s_crashText;
switch( signal )
{