Fix issue with return / goto from catch inside catch that exits the outer catch #120821
+126
−83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When there is a try/catch inside a catch handler and there is a return
in the inner catch or goto going out of the outer catch handler, we were
resuming after the inner catch at the end of the method / goto target,
so we were not returning from the call to the outer catch.
We need to inject a catch leave island that the inner catch returns as
its resume after catch location and that island can then return from the
outer catch.
This mechanism needs to be part of the finally call islands chain so that
returns from catches / calls to finallys happen correctly and in the
right order.
This change extends the finally call islands chain to implement that.
This change also fixes a problem with ordering of emission of the code
for these islands and the basic blocks linking in the
GenerateCode
method.
It also fixes a bug in
GetNativeRangeForClause
that was in some edgecases getting incorrectly shorter range.
To make reviewing a bit easier, I've split this PR into two commits. The
first adds the actual functionality and the second just renames things
to match the fact that the islands are no longer finally call islands
only.