Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarSignalHandler_windows.cpp
diff options
context:
space:
mode:
authorgrbr404 <166065505+grbr404@users.noreply.github.com>2025-05-09 17:57:28 +0200
committerGitHub <noreply@github.com>2025-05-09 17:57:28 +0200
commit682267e765f6d7c8314e31056e68c498819d524c (patch)
tree2e160bda754116278090542714d7978d9e588d97 /source/core/StarSignalHandler_windows.cpp
parent3fc211bcb8dcddd90d50b081553750573bddea7d (diff)
parent3a54621bd8a55b672ba986f02ab094bfb4ba6faf (diff)
Merge branch 'OpenStarbound:main' into main
Diffstat (limited to 'source/core/StarSignalHandler_windows.cpp')
-rw-r--r--source/core/StarSignalHandler_windows.cpp39
1 files changed, 8 insertions, 31 deletions
diff --git a/source/core/StarSignalHandler_windows.cpp b/source/core/StarSignalHandler_windows.cpp
index 2fbde88..a3b4478 100644
--- a/source/core/StarSignalHandler_windows.cpp
+++ b/source/core/StarSignalHandler_windows.cpp
@@ -1,38 +1,15 @@
+#include "StarMiniDump.hpp"
#include "StarSignalHandler.hpp"
#include "StarFormat.hpp"
#include "StarString.hpp"
#include "StarLogging.hpp"
#include <windows.h>
-#include "minidumpapiset.h"
namespace Star {
String g_sehMessage;
-static DWORD WINAPI writeMiniDump(void* ExceptionInfo) {
- auto hFile = CreateFileA("starbound.dmp", GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- if (hFile == INVALID_HANDLE_VALUE)
- return 0;
- MINIDUMP_EXCEPTION_INFORMATION dumpExceptionInfo{};
- dumpExceptionInfo.ThreadId = GetCurrentThreadId();
- dumpExceptionInfo.ExceptionPointers = (PEXCEPTION_POINTERS)ExceptionInfo;
- dumpExceptionInfo.ClientPointers = FALSE;
- MiniDumpWriteDump(
- GetCurrentProcess(),
- GetCurrentProcessId(),
- hFile,
- MiniDumpNormal,
- &dumpExceptionInfo,
- NULL,
- NULL);
- CloseHandle(hFile);
- if (dumpExceptionInfo.ExceptionPointers->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) {
- MessageBoxA(NULL, "Fatal stack overflow encountered\nA minidump has been generated", NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
- }
- return 0;
-};
-
struct SignalHandlerImpl {
bool handlingFatal;
bool handlingInterrupt;
@@ -122,10 +99,14 @@ struct SignalHandlerImpl {
}
static LONG CALLBACK vectoredExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) {
- HANDLE thread = NULL;
LONG result = EXCEPTION_CONTINUE_SEARCH;
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) {
- thread = CreateThread(NULL, 0, writeMiniDump, (void*)ExceptionInfo, 0, NULL);
+ if (HANDLE thread = CreateThread(NULL, 0, writeMiniDump, (void*)ExceptionInfo, 0, NULL)) {
+ WaitForSingleObject(thread, 10000);
+ CloseHandle(thread);
+ }
+ handleFatalError("Stack overflow detected", ExceptionInfo);
+ result = EXCEPTION_CONTINUE_EXECUTION;
}
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
handleFatalError("Access violation detected", ExceptionInfo);
@@ -144,7 +125,6 @@ struct SignalHandlerImpl {
|| (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_FLT_OVERFLOW)
|| (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_FLT_STACK_CHECK)
|| (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_FLT_UNDERFLOW)
-
) {
handleFatalError("Floating point exception", ExceptionInfo);
result = EXCEPTION_CONTINUE_EXECUTION;
@@ -169,10 +149,7 @@ struct SignalHandlerImpl {
handleFatalError("Error occurred", ExceptionInfo);
result = EXCEPTION_CONTINUE_EXECUTION;
}
- if (thread != NULL) {
- WaitForSingleObject(thread, 10000);
- CloseHandle(thread);
- }
+
return result;
}