Skip to content

Commit cb09ca7

Browse files
Enable logging managed stack trace for AV to event log (#76428)
.NET Framework was logging managed stack trace of access violations that happened in external native code in the event log. .NET core only logs the address and error code of the exception, which makes it difficult for developers to figure out which part of their managed code has called the failing native code. The reason why .NET core doesn't print the stack trace is that the access violation is now handled as fail fast instead of regular unhandled exception. And while we report managed stack traces in the EEPolicy::FatalError for fail fasts called from our runtime and managed code in both runtime and user code, we don't report it when we come to that method due to the access violation. This change enables printing the stack trace for that case too. Co-authored-by: Jan Vorlicek <[email protected]>
1 parent ab479d1 commit cb09ca7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/coreclr/vm/eepolicy.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,12 @@ void EEPolicy::LogFatalError(UINT exitCode, UINT_PTR address, LPCWSTR pszMessage
445445
failureType = EventReporter::ERT_ManagedFailFast;
446446
else if (exitCode == (UINT)COR_E_CODECONTRACTFAILED)
447447
failureType = EventReporter::ERT_CodeContractFailed;
448+
else if (exitCode == EXCEPTION_ACCESS_VIOLATION)
449+
failureType = EventReporter::ERT_UnhandledException;
448450
EventReporter reporter(failureType);
449451
StackSString s(argExceptionString);
450452

451-
if ((exitCode == (UINT)COR_E_FAILFAST) || (exitCode == (UINT)COR_E_CODECONTRACTFAILED) || (exitCode == (UINT)CLR_E_GC_OOM))
453+
if ((exitCode == (UINT)COR_E_FAILFAST) || (exitCode == (UINT)COR_E_CODECONTRACTFAILED) || (exitCode == (UINT)CLR_E_GC_OOM) || (exitCode == EXCEPTION_ACCESS_VIOLATION))
452454
{
453455
if (pszMessage)
454456
{

0 commit comments

Comments
 (0)