STRESS_LOG0(LF_CORDB, LL_INFO10, "D::RFFE: About to call RaiseFailFastException\n");
#ifdef HOST_WINDOWS
- CreateCrashDumpIfEnabled();
+ CreateCrashDumpIfEnabled(fSOException);
#endif
RaiseFailFastException(pExceptionInfo == NULL ? NULL : pExceptionInfo->ExceptionRecord,
pExceptionInfo == NULL ? NULL : pExceptionInfo->ContextRecord,
}
}
-static bool
+static DWORD
LaunchCreateDump(LPCWSTR lpCommandLine)
{
- bool fSuccess = false;
+ DWORD fSuccess = false;
EX_TRY
{
}
void
-CreateCrashDumpIfEnabled()
+CreateCrashDumpIfEnabled(bool stackoverflow)
{
// If enabled, launch the create minidump utility and wait until it completes. Only launch createdump once for this process.
LPCWSTR createDumpCommandLine = InterlockedExchangeT<LPCWSTR>(&g_createDumpCommandLine, nullptr);
if (createDumpCommandLine != nullptr)
{
- LaunchCreateDump(createDumpCommandLine);
+ if (stackoverflow)
+ {
+ HandleHolder createDumpThreadHandle = Thread::CreateUtilityThread(Thread::StackSize_Small, (LPTHREAD_START_ROUTINE)LaunchCreateDump, (void*)createDumpCommandLine, W(".NET Stack overflow create dump"));
+ if (createDumpThreadHandle != INVALID_HANDLE_VALUE)
+ {
+ // Wait for the dump to be generated
+ DWORD res = WaitForSingleObject(createDumpThreadHandle, INFINITE);
+ _ASSERTE(res == WAIT_OBJECT_0);
+ }
+ }
+ else
+ {
+ LaunchCreateDump(createDumpCommandLine);
+ }
}
}
void CrashDumpAndTerminateProcess(UINT exitCode)
{
#ifdef HOST_WINDOWS
- CreateCrashDumpIfEnabled();
+ CreateCrashDumpIfEnabled(exitCode == COR_E_STACKOVERFLOW);
#endif
TerminateProcess(GetCurrentProcess(), exitCode);
}
#ifdef HOST_WINDOWS
void InitializeCrashDump();
bool GenerateCrashDump(LPCWSTR dumpName, int dumpType, bool diag);
-void CreateCrashDumpIfEnabled();
+void CreateCrashDumpIfEnabled(bool stackoverflow = false);
#endif
// Generates crash dumps if enabled for both Windows and Linux