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

Directly implement native exception raise methods in miri #3319

Merged
merged 2 commits into from
May 19, 2024

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Feb 24, 2024

This implements the _Unwind_RaiseException function used on pretty much every unix system for starting unwinding. This allows removing the miri special case from libpanic_unwind for unix.

Windows still needs miri_start_unwind as SEH unwinding isn't supported by miri. Unlike DWARF unwinding, SEH preserves all stack frames until right after the do_catch function has executed. Because of this panic_unwind stack allocates the exception object. Miri can't currently model unwinding without destroying stack frames and as such will report a use-after-free of the exception object.

@RalfJung
Copy link
Member

I was confused by the context here, since it's unclear what issue you are fixing, and what "old custom ABI" is.

After reading the PR code and mulling over this for a bit, I think "old custom ABI" is the miri_start_panic way of doing panics? I'd never call this an ABI so I didn't think of this at all when reading the PR description.^^ And the entire PR description is about what the PR does not do, rather than what the PR actually does, right? Would be good to update it to make it less confusing. :)

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 24, 2024

I was confused by the context here, since it's unclear what issue you are fixing, and what "old custom ABI" is.

My bad. I was indeed referring to miri_start_panic.

Comment on lines 51 to 52
// M O Z \0 R U S T -- vendor, language
0x4d4f5a_00_52555354
Copy link
Member

Choose a reason for hiding this comment

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

Maybe set this to something else since we're testing the unwinder mechanism in general, not specifically Rust panics?

@RalfJung
Copy link
Member

For miri_start_panic we have some interesting tests: miri_bad_start_panic, unwind_panic_abort. We probably want to have similar tests for this as well. Other than that, LGTM.

@RalfJung
Copy link
Member

RalfJung commented Mar 2, 2024

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Mar 2, 2024
@RalfJung
Copy link
Member

@bjorn3 what is the status of this? This seems basically done, just needs more tests.

@bors
Copy link
Collaborator

bors commented May 4, 2024

☔ The latest upstream changes (presumably #3557) made this pull request unmergeable. Please resolve the merge conflicts.

bjorn3 and others added 2 commits May 19, 2024 19:06
Windows still needs the old custom ABI as SEH unwinding isn't supported
by miri. Unlike DWARF unwinding it preserves all stack frames until
right after the do_catch function has executed. Because of this
panic_unwind stack allocates the exception object. Miri can't currently
model unwinding without destroying stack frames and as such will report
a use-after-free of the exception object.
- share implementation with miri_starting_unwind
- make test use a custom unwinding class
- extend comments
- use NeedsUnwind more consistently
@RalfJung
Copy link
Member

I did a bit of refactoring to finish the PR. Thanks for the initial idea!
@bors r+

@bors
Copy link
Collaborator

bors commented May 19, 2024

📌 Commit c7debbd has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented May 19, 2024

⌛ Testing commit c7debbd with merge 9b5daa8...

@bors
Copy link
Collaborator

bors commented May 19, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 9b5daa8 to master...

@bors bors merged commit 9b5daa8 into rust-lang:master May 19, 2024
8 checks passed
@bjorn3 bjorn3 deleted the some_more_shims branch May 19, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: Waiting for the PR author to address review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants