-
Notifications
You must be signed in to change notification settings - Fork 322
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
Panics can be caught from TCO loops #9705
Conversation
p . should_equal "fn_with_tco" | ||
|
||
# The same test as the one before, but it does not use the `<|` function. | ||
group_builder.specify "should be caught in a TCO loop with a wrapper fn" <| |
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.
As suggested by @JaroslavTulach, I have added this test. And as expected, this test succeeds, but the former ("should be caught in a TCO loop") fails. It seems that your suspicion, @JaroslavTulach, was right - this is probably caused by the fact that the <|
function is inlineable and therefore there is no frame for it.
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.
@JaroslavTulach EDIT: The test added in cce3c03 suggests otherwise. In that commit, I have introduced a test that doesn't use the <|
method, but uses a method defined in a top scope, and it fails as well.
The only place where a
The two failing tests fail, because the It is all about looking at the stack trace at the moment when |
Evaluating the following
|
@@ -59,7 +59,7 @@ Object doExecute( | |||
@Cached BranchProfile otherExceptionBranchProfile, | |||
@CachedLibrary(limit = "3") InteropLibrary interop) { | |||
try { | |||
return thunkExecutorNode.executeThunk(frame, action, state, BaseNode.TailStatus.TAIL_DIRECT); | |||
return thunkExecutorNode.executeThunk(frame, action, state, BaseNode.TailStatus.NOT_TAIL); |
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.
Panic.catch
cannot be in tail call position. I believe it has to be NOT_TAIL
. All the tests in Error_Spec
are fixed. Let's see what other collateral damage this change may have created. Btw. I have a feeling @hubertp was fighting with some similar issue a year back or so...
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 a good observation! At the end, it seems that we will not have to dig in the IR phases. I have just added some comments and made sure that even the handler
callback is not in a tail call position, just to be sure - in commit 8539997.
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.
On contrary to the action
invocation, handler can probably be in tail position. There is nothing in the CatchPanicNode
that needs to run after handler...
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.
Good note. Add a comment about that in d86c7b5 . handler
is invoked with TAIL_DIRECT
.
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.
@@ -59,7 +59,7 @@ Object doExecute( | |||
@Cached BranchProfile otherExceptionBranchProfile, | |||
@CachedLibrary(limit = "3") InteropLibrary interop) { | |||
try { | |||
return thunkExecutorNode.executeThunk(frame, action, state, BaseNode.TailStatus.TAIL_DIRECT); | |||
return thunkExecutorNode.executeThunk(frame, action, state, BaseNode.TailStatus.NOT_TAIL); |
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.
Fixes #9251
Pull Request Description
In certain cases, when the
action
ofPanic.catch
is tail-call-optimized (via@Tail_Call
) annotation, the panic is not caught. Fixed by ensuring that theaction
ofPanic.catch
is executed asNOT_TAIL
rather thanTAIL_DIRECT
.Important Notes
The
handler
parameter ofPanic.catch
is executed asNOT_TAIL
as well, just to be sure.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.