From 2371794d47d6c5524b971ff2d531d7bd8d243fcd Mon Sep 17 00:00:00 2001 From: J Reece Wilson Date: Tue, 5 Mar 2024 11:06:29 +0000 Subject: [PATCH] [+] Linux Exception Handlers and AuExit::ETriggerLevel::eSigQuitNow [*] Linux stability fixes [+] AuProcAddresses.UNIX.[cpp/hpp] --- Include/Aurora/Exit/ETriggerLevel.hpp | 7 +- Include/Aurora/RuntimeConfig.hpp | 4 +- Include/AuroraAlloc.cpp | 24 +- Source/AuProcAddresses.Linux.cpp | 18 + Source/AuProcAddresses.Linux.hpp | 3 + Source/AuProcAddresses.UNIX.cpp | 29 ++ Source/AuProcAddresses.UNIX.hpp | 14 + Source/AuProcAddresses.hpp | 8 +- Source/Debug/Debug.cpp | 38 +- Source/Debug/ErrorStack.cpp | 4 +- Source/Debug/ExceptionWatcher.Unix.cpp | 422 +++++++++++++++++- Source/Debug/ExceptionWatcher.Unix.hpp | 6 +- Source/Debug/Panic.cpp | 4 +- Source/Debug/Stack.Unix.cpp | 5 + Source/Debug/Stack.Unix.hpp | 2 + Source/Exit/AuExit.Unix.cpp | 13 +- Source/Exit/AuExit.cpp | 39 +- .../Adapters/AuIOAdapterAsyncDelegators.cpp | 2 +- Source/IO/Net/AuNetResolver.Unix.cpp | 6 +- Source/IO/Net/AuNetStream.Linux.cpp | 62 +-- Source/IO/Net/AuNetStream.Linux.hpp | 2 +- Source/Processes/AuOpen.Unix.cpp | 8 +- Source/Processes/AuProcess.Unix.cpp | 7 +- 23 files changed, 640 insertions(+), 87 deletions(-) create mode 100755 Source/AuProcAddresses.UNIX.cpp create mode 100755 Source/AuProcAddresses.UNIX.hpp diff --git a/Include/Aurora/Exit/ETriggerLevel.hpp b/Include/Aurora/Exit/ETriggerLevel.hpp index da05c645..2b3d7ac1 100644 --- a/Include/Aurora/Exit/ETriggerLevel.hpp +++ b/Include/Aurora/Exit/ETriggerLevel.hpp @@ -14,11 +14,14 @@ namespace Aurora::Exit // Runtime deinitialize eSafeTermination, - // A fatal exception was caught by the watchdog. The process is on its way out + // A fatal exception was caught by the watchdog. The process is on its way out and there's nothing you can do about it. eFatalException, - // Control+C was sent, termination must follow + // Control+C was sent, termination should follow. Filter with CancelExit. eSigTerminate, + + // Do not attempt to block this signal. Terminal UX or system power events are asserting it's time to go. + eSigQuitNow, // Something went wrong in the process. These could be frequent depending on the process eProblematicEvent diff --git a/Include/Aurora/RuntimeConfig.hpp b/Include/Aurora/RuntimeConfig.hpp index 20e1cbaf..04f62da8 100644 --- a/Include/Aurora/RuntimeConfig.hpp +++ b/Include/Aurora/RuntimeConfig.hpp @@ -246,8 +246,8 @@ namespace Aurora { bool bFIODisableBatching { false }; bool bIOLinuxHasProcIpcPerms { false }; - AuUInt8 uSignalTerminate { 27 }; - AuUInt8 uSignalGAIOWorkerThreadDone { 28 }; + AuUInt8 uSignalTerminate { 64 - 3 }; + AuUInt8 uSignalGAIOWorkerThreadDone { 64 - 4 }; }; struct ProcessConfig diff --git a/Include/AuroraAlloc.cpp b/Include/AuroraAlloc.cpp index ad82f2af..96f7dbd6 100644 --- a/Include/AuroraAlloc.cpp +++ b/Include/AuroraAlloc.cpp @@ -117,4 +117,26 @@ ANNOYING_TAGONLY(void *operator new[], PROTOTYPE_LATTER(std::size_t s, std::alig #if defined(_AUHAS_AURORARUNTIME) #include #endif -*/ \ No newline at end of file +*/ + +#if defined(AURORA_PLATFORM_LINUX) + namespace std + { + struct type_info; + } + + extern void AU_NORETURN __au_cxa_throw(void *pException, std::type_info*, void (*fDtor)(void *pThis)); + + extern "C" inline void AU_NORETURN __cxa_throw(void *pException, std::type_info *typeInfo, void (*fDtor)(void *pThis)) + { + __au_cxa_throw(pException, typeInfo, fDtor); + } + + extern "C" AuUInt32 _au_Unwind_RaiseException(struct _Unwind_Exception *pUnwind); + + extern "C" AuUInt32 _Unwind_RaiseException(struct _Unwind_Exception *pUnwind) + { + return _au_Unwind_RaiseException(pUnwind); + } + +#endif \ No newline at end of file diff --git a/Source/AuProcAddresses.Linux.cpp b/Source/AuProcAddresses.Linux.cpp index 94827556..2da84817 100644 --- a/Source/AuProcAddresses.Linux.cpp +++ b/Source/AuProcAddresses.Linux.cpp @@ -9,6 +9,7 @@ #include #include #include