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
[runtime] Setup stack trace for use in exception filters too #8241
Conversation
I don't know how to have a test case for the |
Also, reading I'm not very familiar with the code, so I might be making sense only in my head :) |
|
@alexanderkyte @vargaz could you please review? |
mono/tests/exception20.cs
Outdated
// Single frame | ||
// Filter returns false | ||
try { | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you reuse the exception here? Also, you should mark Throw ()
with [MethodImpl(MethodImplOptions.NoInlining)]
, otherwise the framecount is 1 too very likely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. This was based on exception19.cs
where the exception was being reused too. I think maybe we can enhance this to test that the trace was indeed reset when the filter invoked. Currently, trace from both the original exception and the new trace here would have 1 frame, but if we change Throw
to instead have two frames then we will be checking if the filter got a new trace or not. How does that sound?
+ } catch (Exception ex) when (CheckTrace (ex, 2, true)) {
+ CheckTrace (ex, 2);
+ }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, good job! I'm not 100% sure about the dynamic_methods stuff. It looks like it makes sense, and also doesn't break any tests.
If we have `catch (Exception e) when (SomeMethod (e))` .. then the exception object received in `SomeMethod` has an empty trace. This is because in `handle_exception_first_pass` we populate the trace in `MonoException` object only at the "end": - filter returns TRUE - exception caught - unhandled exception But if we have a filter then the trace at that point needs to be accessible. And if the filter fails then as we unwind more frames, the earlier frames (`trace_ips`) need to be retained to get the correct full trace. `dynamic_methods` needs to be handled similarly and in `setup_stack_trace` we need to add to the existing `dynamic_methods` in the MonoException object. Fixes mono#7649 .
544209a
to
1f6c2d9
Compare
Updated the test with https://gist.github.com/radical/26d9b11e185353ea4f869ce3fbeaf61a |
The runtime crashed while running some System/System.Xml tests. Looking at the trace I don't think my patch caused it but I don't know what made it crash. https://gist.github.com/radical/0996979b5fdd2dce6f1b0a460a0d6e27 .. for |
@monojenkins build Linux ARMv7 |
@monojenkins build Linux ARMv5 |
@monojenkins build Linux AArch64 |
@monojenkins build Linux ARMv7 |
@monojenkins build Linux AArch64 |
@monojenkins rebase |
…no#8241) If we have `catch (Exception e) when (SomeMethod (e))` .. then the exception object received in `SomeMethod` has an empty trace. This is because in `handle_exception_first_pass` we populate the trace in `MonoException` object only at the "end": - filter returns TRUE - exception caught - unhandled exception But if we have a filter then the trace at that point needs to be accessible. And if the filter fails then as we unwind more frames, the earlier frames (`trace_ips`) need to be retained to get the correct full trace. `dynamic_methods` needs to be handled similarly and in `setup_stack_trace` we need to add to the existing `dynamic_methods` in the MonoException object. Fixes mono/mono#7649 . Commit migrated from mono/mono@963f944
If we have
catch (Exception e) when (SomeMethod (e))
.. then the exception object received in
SomeMethod
has an emptytrace. This is because in
handle_exception_first_pass
we populate thetrace in
MonoException
object only at the "end":But if we have a filter then the trace at that point needs to be
accessible. And if the filter fails then as we unwind more frames, the
earlier frames (
trace_ips
) need to be retained to get the correct fulltrace.
dynamic_methods
needs to be handled similarly and insetup_stack_trace
we need to add to the existingdynamic_methods
inthe MonoException object.
Fixes #7649 .