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

[NativeAOT-LLVM] Fix EH with table-disjoint mutually protecting handlers #2652

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

SingleAccretion
Copy link

@SingleAccretion SingleAccretion commented Aug 11, 2024

As it turns out, EH table entries of mutually protecting handlers do not have to be immediately adjacent (despite what some comments in the Jit claim...). The dispatch code I wrote some time back made such an assumption, and this change fixes that.

Fixes #2641.

Comment on lines +384 to +386
// The main loop will need to map an outermost mutually protecting region to the innermost. While usually
// mutually protecting handlers form a contiguous 'run' in the table, this is not guaranteed, and disjoint
// regions, or regions nested inside the respective handlers can 'break up' the run.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the EH table from the test:

***************  Exception Handling table
index  eTry, eHnd
  0  ::   6        - Try at BB02..BB02 [000..00C), Handler at BB03..BB03 [00C..015)
  1  ::   4     6  - Try at BB05..BB05 [016..022), Handler at BB06..BB06 [022..02B)
  2  ::   3     4  - Try at BB08..BB08 [02C..038), Handler at BB09..BB09 [038..041)
  3  ::   8     4  - Try at BB08..BB10 [02C..043), Finally at BB11..BB11 [043..04F)
  4  ::   5     6  - Try at BB05..BB05 [016..022), Handler at BB07..BB12 [02B..051)
  5  ::   8     6  - Try at BB05..BB05 [016..022), Handler at BB13..BB13 [051..05A)
  6  ::   7        - Try at BB02..BB02 [000..00C), Handler at BB04..BB14 [015..05C)
  7  ::   8        - Try at BB02..BB02 [000..00C), Handler at BB15..BB15 [05C..065)
  8  ::            - Try at BB02..BB15 [000..065), Finally at BB16..BB16 [065..06C)

There are two sets of mutually protecting handlers: {H0, H6, H7} and {H1, H4, H5}.

@SingleAccretion SingleAccretion marked this pull request as ready for review August 11, 2024 18:33
@SingleAccretion
Copy link
Author

@dotnet/nativeaot-llvm

@maraf maraf added the area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly) label Aug 12, 2024
Copy link
Contributor

@yowl yowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@jkotas jkotas merged commit fec5053 into dotnet:feature/NativeAOT-LLVM Aug 12, 2024
11 checks passed
@SingleAccretion SingleAccretion deleted the EH-Bug branch August 12, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants