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

Add support for new exception trace storage format #4635

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

janvorli
Copy link
Member

To eliminate global spinlock in stack trace saving to exceptions, the format of the stack trace storage has changed. The _stackTrace array can now be either a byte[] with the actual stack trace as before or an object[] where the first element references the byte[] with the actual stack trace and the following elements contain references to System.Resolver or System.Reflection.LoaderAllocator instances that keep code of methods that can be collected alive.

This change modifies SOS to handle the object[] case properly, while staying compatible with the old way. Since the same code to get the stack trace was duplicated at two places, I have taken this opportunity to refactor it into a separate function.

To eliminate global spinlock in stack trace saving to exceptions, the
format of the stack trace storage has changed. The `_stackTrace` array
can now be either a byte[] with the actual stack trace as before or an
object[] where the first element references the byte[] with the actual
stack trace and the following elements contain references to
System.Resolver or System.Reflection.LoaderAllocator instances that keep
code of methods that can be collected alive.

This change modifies SOS to handle the object[] case properly, while
staying compatible with the old way. Since the same code to get the
stack trace was duplicated at two places, I have taken this opportunity
to refactor it into a separate function.
@janvorli janvorli added this to the 9.0.0 milestone Apr 23, 2024
@janvorli janvorli requested a review from mikem8361 April 23, 2024 15:25
@janvorli janvorli self-assigned this Apr 23, 2024
@janvorli janvorli requested a review from a team as a code owner April 23, 2024 15:25
@noahfalk
Copy link
Member

@janvorli - This looks like all previous versions of SOS that don't have this change won't work against new runtime versions so we probably want to bump the breaking change version number. Anyone who tries to use a version of SOS containing the old version number gets an error saying their SOS is out-of-date and they should update it.

I'll let Mike take a look at the rest of the code change but it looked good to me 👍

fyi @elinor-fung @lambdageek - this looks like an example where SOS is directly inspecting runtime internal data structures without using a DAC API. Whether the code stays in SOS or migrates to a new API that cDAC implements this parsing code would not work cross-bitness as-is.

@janvorli
Copy link
Member Author

@noahfalk thank you for pointing it out, I'll add bumping the version in the runtime change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants