diff options
| author | Shauren <shauren.trinity@gmail.com> | 2018-03-10 15:15:41 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2018-03-10 15:15:41 +0100 |
| commit | abdf6479ddbf42c8b53cb943c54203211ceb0691 (patch) | |
| tree | cae92dcba32d74d1f8b52153cdf3dbf35c856094 | |
| parent | 12beb3dd1b5166481ed68f945b4294ff4aca9000 (diff) | |
Core/CrashHandler: Fixed generating crash logs from CRT debug assertions
| -rw-r--r-- | src/common/Debugging/WheatyExceptionReport.cpp | 9 | ||||
| -rw-r--r-- | src/common/Debugging/WheatyExceptionReport.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 266389bd4a7..6e98bf23c5f 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -61,6 +61,7 @@ inline LPTSTR ErrorMessage(DWORD dw) TCHAR WheatyExceptionReport::m_szLogFileName[MAX_PATH]; TCHAR WheatyExceptionReport::m_szDumpFileName[MAX_PATH]; LPTOP_LEVEL_EXCEPTION_FILTER WheatyExceptionReport::m_previousFilter; +_invalid_parameter_handler WheatyExceptionReport::m_previousCrtHandler; HANDLE WheatyExceptionReport::m_hReportFile; HANDLE WheatyExceptionReport::m_hDumpFile; HANDLE WheatyExceptionReport::m_hProcess; @@ -81,6 +82,7 @@ WheatyExceptionReport::WheatyExceptionReport() // Constructor { // Install the unhandled exception filter function m_previousFilter = SetUnhandledExceptionFilter(WheatyUnhandledExceptionFilter); + m_previousCrtHandler = _set_invalid_parameter_handler(WheatyCrtHandler); m_hProcess = GetCurrentProcess(); stackOverflowException = false; alreadyCrashed = false; @@ -101,6 +103,8 @@ WheatyExceptionReport::~WheatyExceptionReport() { if (m_previousFilter) SetUnhandledExceptionFilter(m_previousFilter); + if (m_previousCrtHandler) + _set_invalid_parameter_handler(m_previousCrtHandler); ClearSymbols(); } @@ -189,6 +193,11 @@ PEXCEPTION_POINTERS pExceptionInfo) return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/; } +void __cdecl WheatyExceptionReport::WheatyCrtHandler(wchar_t const* /*expression*/, wchar_t const* /*function*/, wchar_t const* /*file*/, unsigned int /*line*/, uintptr_t /*pReserved*/) +{ + RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, nullptr); +} + BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxcount) { if (!sProcessorName) diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h index 0f5ceb3c263..7d7ae3feb4e 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/WheatyExceptionReport.h @@ -154,6 +154,8 @@ class WheatyExceptionReport static LONG WINAPI WheatyUnhandledExceptionFilter( PEXCEPTION_POINTERS pExceptionInfo); + static void __cdecl WheatyCrtHandler(wchar_t const* expression, wchar_t const* function, wchar_t const* file, unsigned int line, uintptr_t pReserved); + static void printTracesForAllThreads(bool); private: // where report info is extracted and generated @@ -191,6 +193,7 @@ class WheatyExceptionReport static TCHAR m_szLogFileName[MAX_PATH]; static TCHAR m_szDumpFileName[MAX_PATH]; static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter; + static _invalid_parameter_handler m_previousCrtHandler; static HANDLE m_hReportFile; static HANDLE m_hDumpFile; static HANDLE m_hProcess; |
