Skip to content
Discussion options

You must be logged in to vote

The _stackTrace field is populated once the exception is thrown.

try
{
Exception e = new Exception();
// e._stackTrace is null here
throw e;
}
catch (Exception e)
{
// e._stackTrace is non-null here
}

if (gc.pKeepAliveArray != NULL)
{
_ASSERTE(keepAliveItemsCount > 0);
gc.pKeepAliveArray->SetAt(0, gc.stackTrace.m_pStackTraceArray.Get());
((EXCEPTIONREF)ObjectFromHandle(hThrowable))->SetStackTrace(dac_cast<OBJECTREF>(gc.pKeepAliveArray));
}
else
{
_ASSERTE(keepAliveItemsCount == 0);
((EXCEPTIONREF)ObjectFromHandle(hThrowable))->SetStackTrace(dac_cast<OBJECTREF>(gc.stackTrace

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@meriffa
Comment options

Answer selected by meriffa
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area-ExceptionHandling-coreclr untriaged New issue has not been triaged by the area owner
2 participants
Converted from issue

This discussion was converted from issue #121504 on November 10, 2025 18:32.