Repository navigation
Use __fastfail() for crash() on Windows - #166175
Jules-Bertholet wants to merge 2 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
ce5ad7e to
aec71b0
Compare
This comment has been minimized.
This comment has been minimized.
aec71b0 to
3f32b71
Compare
This comment has been minimized.
This comment has been minimized.
3f32b71 to
d8cd592
Compare
This comment has been minimized.
This comment has been minimized.
d8cd592 to
c88cc5a
Compare
|
cc @bjorn3 Any special-casing of Miri in the standard library requires review. cc @rust-lang/miri |
|
r? @clarfonthey rustbot has assigned @clarfonthey. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| /// | ||
| /// <https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail> | ||
| #[inline] | ||
| #[unstable(feature = "windows_fastfail", issue = "none")] |
There was a problem hiding this comment.
Is this meant to be an internal feature? Then it should be called something_internal to trigger the lint.
There was a problem hiding this comment.
We may want to consider putting it on a stabilization track, so that users can pass custom codes. (I don't have a strong opinion either way)
There was a problem hiding this comment.
We should keep it unstable for now anyway. I don't know if calling it __fastfail is the best name rather than without the two underscores, but I'm not going to nitpick here.
|
The backend also invokes the intrinsic directly in a couple of places. |
It's also used for CFI mismatches. I think ideally that would be |
|
CFI mismatches are UB. 🤷 If you think that's not the ideal choice there, maybe add a FIXME. |
Some are, but others are merely EB—is that not the plan? |
2c572a0 to
e22ec7b
Compare
|
This pull request was unapproved. This PR was contained in a rollup (#166671), which was unapproved. |
|
Right, your issue was that the I would just add a |
|
@rustbot ready |
1847f89 to
7f0c30d
Compare
There was a problem hiding this comment.
That.... works I guess but seems very hacky. It's definitely not how fallback bodies are meant to be used. They are called fallback bodies, after all -- this intrinsic is doing the exact opposite of "fallback" with them.
At the very least, every backend should have a comment explaining the strange logic there (where we avoid overwriting the intrinsic if it has a fallback body).
|
This approach only partially achieves the desired goal -- when the backend invokes My proposal of a lang item would have avoided all these issues. Why did you use this alternative instead? |
I don't know how to ensure the lang item is codegenned. (By the time we get to the backend, that decision has already been made.) |
|
Somewhere we have a function that defines all the roots for the mono item collector. It already puts a bunch of special things in there. This lang item can be added there. |
|
It's |
|
This makes me wonder how that works for the lang items that cause panics -- those also have calls inserted by codegen, and I don't see special treatment for them in the mono item collector... EDIT: oh... rust/compiler/rustc_monomorphize/src/collector.rs Lines 908 to 930 in 1abbb55 |
7f0c30d to
b004cab
Compare
|
Some changes occurred in compiler/rustc_attr_ir |
b004cab to
7fadb2d
Compare
This comment has been minimized.
This comment has been minimized.
|
|
51a60d5 to
b84dd1b
Compare
|
@rustbot ready |
|
(happy to also pass off to someone on compiler to do some better backend review) |
|
r? compiler |
|
Also to be clear on my requirements from a libs perspective: I don't think that |
| // The backend may insert calls to this lang item at any time, | ||
| // so collect it unconditionally. | ||
| if let Some(def_id) = tcx.lang_items().get(LangItem::CrashImpl) { |
There was a problem hiding this comment.
Repeating this for every instance seems odd?
There was a problem hiding this comment.
I don't know of a better place to put this.
| } | ||
|
|
||
| #[cfg(windows)] | ||
| #[lang = "crash_impl"] |
There was a problem hiding this comment.
Given that this is used to overwrite the abort_immediate intrinsic, the name should be consistent with that intrinsic. So either rename the intrinsic to crash or the lang item to something involving abort_immediate.
There was a problem hiding this comment.
I think we should rename the intrinsic to match the stabilized method, but I'd rather do that in a follow-up PR.
View all comments
__fastfailis the preferred way to quickly abort the process on this platform. Unlikeud2, it won't go through SEH.See previously #149780
@rustbot label O-windows