Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 17 additions & 28 deletions src/coreclr/vm/excep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4925,8 +4925,6 @@ DefaultCatchHandler(PEXCEPTION_POINTERS pExceptionPointers,
#endif

GCPROTECT_BEGIN(throwable);
//BOOL IsStackOverflow = (throwable->GetMethodTable() == g_pStackOverflowExceptionClass);
BOOL IsOutOfMemory = (throwable->GetMethodTable() == g_pOutOfMemoryExceptionClass);

const int buf_size = 128;
WCHAR buf[buf_size] = {0};
Expand All @@ -4936,31 +4934,14 @@ DefaultCatchHandler(PEXCEPTION_POINTERS pExceptionPointers,
{
EX_TRY
{
// If this isn't ThreadAbortException, we want to print a stack trace to indicate why this thread abruptly
// terminated. Exceptions kill threads rarely enough that an uncached name check is reasonable.
BOOL dump = TRUE;

if (/*IsStackOverflow ||*/
!pThread->DetermineIfGuardPagePresent() ||
IsOutOfMemory)
if (!pThread->DetermineIfGuardPagePresent())
{
// We have to be very careful. If we walk off the end of the stack, the process will just
// die. e.g. Exception.ToString both consume too much stack -- and can't
// be called here.
dump = FALSE;

if (IsOutOfMemory)
{
PrintToStdErrA("Out of memory.\n");
}
else
{
PrintToStdErrA("Stack overflow.\n");
}
PrintToStdErrA("Stack overflow.\n");
}

// Finally, should we print the message?
if (dump)
else
{
// this is stack heavy because of the CQuickWSTRBase, so we break it out
// and don't have to carry the weight through our other code paths.
Expand All @@ -4969,14 +4950,22 @@ DefaultCatchHandler(PEXCEPTION_POINTERS pExceptionPointers,
}
EX_CATCH
{
LOG((LF_EH, LL_INFO10, "Exception occurred while processing uncaught exception\n"));
if (throwable->GetMethodTable() == g_pOutOfMemoryExceptionClass)
{
// Try to print a short message at least.
PrintToStdErrA("Out of memory.\n");
}
else
{
LOG((LF_EH, LL_INFO10, "Exception occurred while processing uncaught exception\n"));

_ASSERTE(buf_size > 6);
wcscpy_s(buf, buf_size, W("\n "));
UtilLoadStringRC(IDS_EE_EXCEPTION_TOSTRING_FAILED, buf + 4, buf_size - 6);
wcscat_s(buf, buf_size, W("\n"));
_ASSERTE(buf_size > 6);
wcscpy_s(buf, buf_size, W("\n "));
UtilLoadStringRC(IDS_EE_EXCEPTION_TOSTRING_FAILED, buf + 4, buf_size - 6);
wcscat_s(buf, buf_size, W("\n"));

PrintToStdErrW(buf);
PrintToStdErrW(buf);
}
}
EX_END_CATCH
}
Expand Down
Loading