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

Fix storage of stack trace of exception from reflection #106901

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

janvorli
Copy link
Member

There was one more case where we have saved the stack trace into the _remoteStackTraceString field in the exception when the exception was passing from reflection invoked code to the caller of that code. While there is no visible difference in the Exception.ToString, a SOS test was failing due to that. And it is not necessary to save the stack trace there.

I have thought about the cases when we really need the stack trace saved into the _remoteStackTraceString and I believe that actually the only case is when an existing exception is thrown again in managed code. So I have removed the option to save the stack trace from all the variants of the DispatchManagedException.

There was one more case where we have saved the stack trace into the _remoteStackTraceString
field in the exception when the exception was passing from reflection invoked code
to the caller of that code. While there is no visible difference in the Exception.ToString,
a SOS test was failing due to that. And it is not necessary to save the stack trace
there.

I have thought about the cases when we really need the stack trace saved into the
_remoteStackTraceString and I believe that actually the only case is when an existing
exception is thrown again in managed code. So I have removed the option to save the stack
trace from all the variants of the DispatchManagedException.
@janvorli janvorli added this to the 9.0.0 milestone Aug 23, 2024
@janvorli janvorli self-assigned this Aug 23, 2024
@janvorli
Copy link
Member Author

cc: @mikem8361

@janvorli janvorli requested a review from jkotas August 23, 2024 20:54
@janvorli
Copy link
Member Author

/azp run runtime-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

if (preserveStackTrace)
{
pThread->IncPreventAbort();
ExceptionPreserveStackTrace(throwable);
Copy link
Member

@jkotas jkotas Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering whether the one remaining use of ExceptionPreserveStackTrace in the VM is actually necessary. It is wrapped in very confusing logic that does not look right and we seem to be getting lucky that it never kicks in practice.

It is fine to clean it up in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I'll look into it separately.

@janvorli
Copy link
Member Author

/ba-g the changes are in coreclr, the legs that are failing (timing out) are NativeAOT builds only.

@janvorli janvorli merged commit ef0c712 into dotnet:main Aug 27, 2024
129 of 142 checks passed
@janvorli janvorli deleted the fix-sos-test-with-reflection branch August 27, 2024 11:55
@mikem8361
Copy link
Member

Are we going to backport this to 9.0?

@janvorli
Copy link
Member Author

@mikem8361 yes, I am planning to do that.

@janvorli
Copy link
Member Author

/backport to release/9.0

Copy link
Contributor

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10600017871

jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 17, 2024
There was one more case where we have saved the stack trace into the _remoteStackTraceString
field in the exception when the exception was passing from reflection invoked code
to the caller of that code. While there is no visible difference in the Exception.ToString,
a SOS test was failing due to that. And it is not necessary to save the stack trace
there.

I have thought about the cases when we really need the stack trace saved into the
_remoteStackTraceString and I believe that actually the only case is when an existing
exception is thrown again in managed code. So I have removed the option to save the stack
trace from all the variants of the DispatchManagedException.
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants