fix(exception_handler): crash on unload (#1280)

Restore the value the ErrorMode and the UnhandledExceptionFilter values.
This commit is contained in:
Andreas Maerten
2023-04-23 22:00:37 +02:00
committed by GitHub
parent 5299fe52ef
commit 96174c7ab2
2 changed files with 21 additions and 20 deletions
+4 -4
View File
@@ -16,14 +16,14 @@ namespace big
exception_handler::exception_handler()
{
SetErrorMode(0);
SetUnhandledExceptionFilter(&vectored_exception_handler);
m_old_error_mode = SetErrorMode(0);
m_exception_handler = SetUnhandledExceptionFilter(&vectored_exception_handler);
}
exception_handler::~exception_handler()
{
// passing nullptr will make it go back to normal exception handling
SetUnhandledExceptionFilter(nullptr);
SetErrorMode(m_old_error_mode);
SetUnhandledExceptionFilter(reinterpret_cast<decltype(&vectored_exception_handler)>(m_exception_handler));
}
inline static stack_trace trace;
+17 -16
View File
@@ -1,17 +1,18 @@
#pragma once
#include "common.hpp"
namespace big
{
class exception_handler final
{
public:
exception_handler();
virtual ~exception_handler();
private:
void* m_exception_handler;
};
extern LONG vectored_exception_handler(EXCEPTION_POINTERS* exception_info);
#pragma once
#include "common.hpp"
namespace big
{
class exception_handler final
{
public:
exception_handler();
virtual ~exception_handler();
private:
void* m_exception_handler;
std::uint32_t m_old_error_mode;
};
extern LONG vectored_exception_handler(EXCEPTION_POINTERS* exception_info);
}