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

Scoped disposal within an exception handler generates incorrect IL #1101

Closed
degory opened this issue Mar 4, 2024 · 0 comments · Fixed by #1102
Closed

Scoped disposal within an exception handler generates incorrect IL #1101

degory opened this issue Mar 4, 2024 · 0 comments · Fixed by #1102

Comments

@degory
Copy link
Owner

degory commented Mar 4, 2024

Attempting to declare scoped disposed variables with let use inside a try or catch block results in invalid IL that fails at runtime.

The root cause is that a ret IL instruction is emitted inside the outer exception handler, which is not not supported in CIL.

The rest of the post-finally return handling boilerplate is correctly emitted, but the ret needs to be replaced with a leave targeting the label immediately after the finally where the return handling code is.

degory added a commit that referenced this issue Mar 4, 2024
Bugs fixed:
- Returning from finally doesn't work reliably (closes #1100)
- Scoped disposal within an exception handler generates incorrect IL (closes #1101)
degory added a commit that referenced this issue Mar 4, 2024
Bugs fixed:
- Returning from finally doesn't work reliably (closes #1100)
- Scoped disposal within an exception handler generates incorrect IL (closes #1101)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant