1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Improve robustness of CrashCatcher registration

This commit is contained in:
Hunter Bridges 2022-02-15 22:11:56 -08:00
parent ff5dee3583
commit 795c70af2f
3 changed files with 73 additions and 3 deletions

View file

@ -917,6 +917,8 @@ static void InitCPUFreq()
}
}
static void(*sOldSIGABRTHandler)(int signal) = nullptr;
BFP_EXPORT void BFP_CALLTYPE BfpSystem_Init(int version, BfpSystemInitFlags flags)
{
InitCPUFreq();
@ -947,7 +949,9 @@ BFP_EXPORT void BFP_CALLTYPE BfpSystem_Init(int version, BfpSystemInitFlags flag
// default, but explicitly setting it seems like a good idea.
_set_abort_behavior(_CALL_REPORTFAULT, _CALL_REPORTFAULT);
// Then we install our abort handler.
signal(SIGABRT, &AbortHandler);
sOldSIGABRTHandler = signal(SIGABRT, &AbortHandler);
if (sOldSIGABRTHandler == SIG_ERR)
sOldSIGABRTHandler = nullptr;
CrashCatcher::Get()->Init();
if ((flags & BfpSystemInitFlag_SilentCrash) != 0)
@ -988,6 +992,13 @@ BFP_EXPORT void BFP_CALLTYPE BfpSystem_Shutdown()
delete gManagerTail;
gManagerTail = next;
}
if (CrashCatcher::Shutdown())
{
_set_purecall_handler(nullptr);
_set_invalid_parameter_handler(nullptr);
signal(SIGABRT, sOldSIGABRTHandler);
}
}
BFP_EXPORT uint32 BFP_CALLTYPE BfpSystem_TickCount()