Skip to content

Call into fastfail on abort in libpanic_abort on Windows x86(_64) #75364

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

Merged
merged 3 commits into from
Aug 25, 2020

Conversation

rylev
Copy link
Member

@rylev rylev commented Aug 10, 2020

This partially resolves #73215 though this is only for x86 targets. This code is directly lifted from libstd. __fastfail is the preferred way to abort a process on Windows as it will hook into debugger toolchains.

Other platforms expose a _rust_abort symbol which wraps std::sys::abort_internal. This would also work on Windows, but is a slightly largely change as we'd need to make sure that the symbol is properly exposed to the linker. I'm inlining the call to the __fastfail, but the indirection through rust_abort might be a cleaner approach.

A different instruction must be used on ARM architectures. I'd like to verify this works first before tackling ARM.

@rust-highfive
Copy link
Contributor

r? @shepmaster

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2020
@rylev rylev force-pushed the libpanic-abort-failfast branch from 1c03f00 to 57572cf Compare August 10, 2020 12:40
@mati865
Copy link
Contributor

mati865 commented Aug 10, 2020

Is there a reason to duplicate the code instead of calling already existing function?

@rylev
Copy link
Member Author

rylev commented Aug 10, 2020

The function is not available as it's defined in standard and panic_abort is !#[no_std]. The trick pulled by some targets is to expose a __rust_panic symbol which is linked to when linking panic_abort and the standard library. We can also use that trick here I believe. I'm just not familiar enough with the mechanics of how std gets built to ensure that it works properly.

@alexcrichton
Copy link
Member

The already existing function only exists in libstd I believe which panic_abort can't depend on. I'm not sure what's up with __rust_abort but that looks like it's for niche use cases, and the amount of duplication here is just one line, so I think duplication is fine here.

@shepmaster
Copy link
Member

@alexcrichton would you feel comfortable taking this review? I definitely don't understand it enough.

@alexcrichton
Copy link
Member

Sure!

@bors: r+

@bors
Copy link
Collaborator

bors commented Aug 25, 2020

📌 Commit b9b8b5c has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 25, 2020
@bors
Copy link
Collaborator

bors commented Aug 25, 2020

⌛ Testing commit b9b8b5c with merge 3d6a3ed...

@bors
Copy link
Collaborator

bors commented Aug 25, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: alexcrichton
Pushing 3d6a3ed to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 25, 2020
@bors bors merged commit 3d6a3ed into rust-lang:master Aug 25, 2020
@rylev rylev deleted the libpanic-abort-failfast branch August 25, 2020 09:37
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use __fastfail in libpanic_abort on Windows
7 participants