Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TESTING ONLY] Add another set of debugging prints for stack overflow issue #112284

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
27 changes: 25 additions & 2 deletions src/coreclr/vm/eepolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ inline void LogCallstackForLogWorker(Thread* pThread, PEXCEPTION_POINTERS pExcep
pThread->StackWalkFrames(&CallStackLogger::LogCallstackForLogCallback, &logger, QUICKUNWIND | FUNCTIONSONLY | ALLOW_ASYNC_STACK_WALK);

logger.PrintStackTrace(WordAt.GetUnicode());

#ifdef _DEBUG
PrintToStdErrA("@Exiting stack trace printing thread.\n");
#endif
}

//---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -668,22 +670,35 @@ void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pE
HandleHolder stackDumpThreadHandle = Thread::CreateUtilityThread(Thread::StackSize_Small, LogStackOverflowStackTraceThread, GetThreadNULLOk(), W(".NET Stack overflow trace logger"));
if (stackDumpThreadHandle != INVALID_HANDLE_VALUE)
{
#ifdef _DEBUG
PrintToStdErrA("@Waiting for the stack trace printing helper thread.\n");
#endif
// Wait for the stack trace logging completion
DWORD res = WaitForSingleObject(stackDumpThreadHandle, INFINITE);
_ASSERTE(res == WAIT_OBJECT_0);
#ifdef _DEBUG
PrintToStdErrA("@Stack trace printing helper thread exited.\n");
#endif
}

g_stackOverflowCallStackLogged = 2;
}
else
{
#ifdef _DEBUG
PrintToStdErrA("@Waiting for thread that's logging stack overflow.\n");
#endif
// Wait for the thread that is logging the stack trace to complete
while (g_stackOverflowCallStackLogged != 2)
{
Sleep(50);
}
}

#ifdef _DEBUG
PrintToStdErrA("@Proceeding with exit.\n");
#endif

if(ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context, FailFast))
{
// Fire an ETW FailFast event
Expand All @@ -701,6 +716,9 @@ void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pE
if (pThread)
{
GCX_COOP();
#ifdef _DEBUG
PrintToStdErrA("@Setting throwable.\n");
#endif
// If we had a SO before preallocated exception objects are initialized, we will AV here. This can happen
// during the initialization of SystemDomain during EEStartup. Thus, setup the SO throwable only if its not
// NULL.
Expand Down Expand Up @@ -734,10 +752,15 @@ void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pE
}
#endif // !TARGET_UNIX

#ifdef _DEBUG
PrintToStdErrA("@Calling WatsonLastChance.\n");
#endif
WatsonLastChance(pThread, pExceptionInfo,
(fTreatAsNativeUnhandledException == FALSE)? TypeOfReportedError::UnhandledException: TypeOfReportedError::NativeThreadUnhandledException);
}

#ifdef _DEBUG
PrintToStdErrA("@Terminating the process.\n");
#endif
CrashDumpAndTerminateProcess(COR_E_STACKOVERFLOW);
UNREACHABLE();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void TestStackOverflow(string testName, string testArgs, out List<string>
{
lines.Add(line.Data);
}
else
else if (!line.Data.StartsWith("@"))
{
endOfStackTrace = true;
}
Expand Down
Loading