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

Enhanced Stack Frames with Native AOT #3323

Open
jamescrosswell opened this issue Apr 24, 2024 · 4 comments
Open

Enhanced Stack Frames with Native AOT #3323

jamescrosswell opened this issue Apr 24, 2024 · 4 comments

Comments

@jamescrosswell
Copy link
Collaborator

jamescrosswell commented Apr 24, 2024

Continuing on from #3322 we need to implement Michal's other suggetions:

In the end, someone will need to do the work to enable the AOT/trim/single file safety analyzers and address all the warnings, but this is enough to have a golden path that makes sample/StackTrace project produce the same results under native AOT as under JIT.

Necessary fixes:

GetMethodBody under AOT throws. This will not return anything useful under Mono with ILStrip either. The code simply needs to deal with it.
Runtime reflection stack doesn't guarantee referential equality of MemberInfos (except for TypeInfo). This is also true on JIT-based runtimes, but there's even less caching on native AOT. Use operator ==.
The reflection to read TupleElementNamesAttribute is trim-unfriendly and cannot be analyzed. Replace with no-reflection.
Some fallout from the previous point because the nullable annotations on the thing returned by reflection were wrong.

Finally we should be able to simplify this:

var frames = (!AotHelper.IsNativeAot && _options.StackTraceMode == StackTraceMode.Enhanced)
? EnhancedStackTrace.GetFrames(stackTrace).Select(p => new RealStackFrame(p))
: stackTrace.GetFrames().Select(p => new RealStackFrame(p));

@jamescrosswell jamescrosswell changed the title Enhanced Stack Frames in Native AOT Enhanced Stack Frames with Native AOT Apr 24, 2024
@bitsandfoxes
Copy link
Contributor

bitsandfoxes commented May 10, 2024

Just for my understanding - and to help prioritizing this, is this just about cleaning up the check? Or would we actually get better stack frames?

@jamescrosswell
Copy link
Collaborator Author

Just for my understanding - and to help prioritizing this, is this just about cleaning up the check? Or would we actually get better stack frames?

If we can get Ben.Demystifier working with AOT, we should get better stack frames yes... that code above could be changed to:

 var frames = (_options.StackTraceMode == StackTraceMode.Enhanced) 
     ? EnhancedStackTrace.GetFrames(stackTrace).Select(p => new RealStackFrame(p)) 
     : stackTrace.GetFrames().Select(p => new RealStackFrame(p)); 

@bitsandfoxes
Copy link
Contributor

If we can get Ben.Demystifier working with AOT

I'm failing to keep track of how to get there. Is #3230 the only missing part?

@jamescrosswell
Copy link
Collaborator Author

I'm failing to keep track of how to get there. Is #3230 the only missing part?

Yes I think so. I added some detail to that issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants