-
Notifications
You must be signed in to change notification settings - Fork 324
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
Eliminate handler frames from Caught_Panic.stack_trace
#12024
Conversation
Without any fix the test introduced by c33d647 fails on the CI:
because it contains forbidden frames Results:
Good! Time to speed it up. |
Local benchmarking indicates everything is OK, but running final verification on the CI as well.
Just like it always was. |
/** | ||
* Whoever catches a {@code PanicException} should associate its location with it, so proper stack | ||
* traces can be computed later. Because the stacktrace information is relative to the caught | ||
* location | ||
* | ||
* @param node the node who caught the panic | ||
*/ | ||
public final void assignCaughtLocation(CatchPanicNode node) { | ||
this.caughtBy = node; | ||
} |
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.
What happens if the panic is rethrown and caught again elsewhere? Should this keep the first catch location or be reassigned?
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 very good question. It points out that this all is just a heuristic with the goal (as stated in the description):
... fix the most common scenario when a
caught_exception.stack_trace
is requested in the exception handler
I will add a new
- test with re-throw.
- done here
Should this ... be reassigned?
Both CatchPanicNode
and Node queryNode
have to be on the stack for any transformation to happen. Thus yes, it has to be reassigned.
I will also add a test that
- catches the panic
- queries the
stack_trace
in the handler - stores the panic into a
Vector
- and then queries later
- both stacks have to be identical
Done in 9a056e3
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java
Outdated
Show resolved
Hide resolved
} else { | ||
// materializes stack trace of non-Enso | ||
// exceptions in case it is needed by the handler | ||
TruffleStackTrace.fillIn(originalException); |
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.
This path is now tested by a5d001b that throws JavaScript exception and checks its stacktrace.
out . should_contain "f4" | ||
out . should_contain "f5" | ||
|
||
top_lines.take (..While l-> l.starts_with "2nd:") . length . should_equal 11 |
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.
The stack trace in this case is:
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.lines<arg-1> (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:72:38-63)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check.f5 (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:44:17-17)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check.f4 (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:45:17-23)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check.f3<arg-1> (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:48:17-23)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check.rethrow_handler (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:39:13-36)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check.f3 (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:47-48)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check.f2 (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:49:17-23)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check.f1 (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:50:17-23)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.stack_trace_check (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:52:9-26)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.lines<arg-1> (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:72:17-77)
2nd: at Stack_Traces_Spec.add_specs.Stack_Traces_Spec.add_specs.lines (Base_Tests/src/Runtime/Stack_Traces_Spec.enso:71-72)
which I believe is exactly what we want.
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 I think.
11f3266
to
64e4af5
Compare
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java
Show resolved
Hide resolved
Co-authored-by: Radosław Waśko <[email protected]>
67667bc
to
5a8f973
Compare
Pull Request Description
Fixes #8153 by
Important Notes
The expected refinement of the fix is going to:
CatchPanicNode
inPanicException
when it is caught@ExportMessage Object getExceptionStackTrace()
to control the stack trace ofPanicException
getExceptionStackTrace
of thePanicException
skip frames between...CatchPanicNode
anchorThis will fix the most common scenario when a
caught_exception.stack_trace
is requested in the exception handler.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,