-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Report allocation errors as panics, second attempt #112331
base: master
Are you sure you want to change the base?
Conversation
r? @jackh726 (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
77ba90f
to
d4f1f6a
Compare
☔ The latest upstream changes (presumably #112671) made this pull request unmergeable. Please resolve the merge conflicts. |
Should this be assigned to someone on libs team? I guess it's mostly compiler work? |
Yes, most of the compiler changes are just removing r? libs |
d4f1f6a
to
bacf25d
Compare
@Amanieu could you say if some updates on it planned? Why not merging into master? |
It's waiting on review. |
☔ The latest upstream changes (presumably #113014) made this pull request unmergeable. Please resolve the merge conflicts. |
bacf25d
to
5196f92
Compare
r? libs-api |
☔ The latest upstream changes (presumably #113162) made this pull request unmergeable. Please resolve the merge conflicts. |
#[lang = "eh_personality"] | ||
fn eh_personality() -> ! { | ||
loop {} | ||
} | ||
|
||
#[start] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is still necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that was a mistake.
238d017
to
35d75e3
Compare
☔ The latest upstream changes (presumably #113391) made this pull request unmergeable. Please resolve the merge conflicts. |
35d75e3
to
3a6ff98
Compare
This comment has been minimized.
This comment has been minimized.
3a6ff98
to
8a24112
Compare
☔ The latest upstream changes (presumably #116578) made this pull request unmergeable. Please resolve the merge conflicts. |
The issue at swc-project/swc#8362 and following discussion on Zulip uncovered some subtle concerns around allocation-fail-handlers -- and this here is the first time user-defined code gets run on allocation failure. (Specifically, that user-defined code is the panic hook.) The problem in that issue is that the library assumes there is no reentrancy, but it does cause an allocation, and so if that allocation fails and then the panic handler calls back into the library, we have an unsoundness due to aliasing references (or due to any of the other problems that reentrancy can cause). We have to globally decide that either libraries must generally assume that calling the allocator will run arbitrary safe code (and add safeguards against reentrancy where needed), or the code that runs on allocation failure needs to be "careful" to not touch state that might be invalid since the library governing that state is in the middle of something. |
This has conflicts to be resolved before getting reviewed |
directly call handle_alloc_error Also test more codepaths. There's like 5 different things that can happen on allocation failure! Between `-Zoom`, `#[alloc_error_handler]`, and `set_alloc_error_hook`, we have 3 layers of behavior overrides. It's all a bit messy. rust-lang/rust#112331 seems intended to clean this up, but has not yet reached consensus.
directly call handle_alloc_error Also test more codepaths. There's like 5 different things that can happen on allocation failure! Between `-Zoom`, `#[alloc_error_handler]`, and `set_alloc_error_hook`, we have 3 layers of behavior overrides. It's all a bit messy. rust-lang#112331 seems intended to clean this up, but has not yet reached consensus.
Most of the unstable features are not required for building. For panics, the only remaining detail is having an implementation of the panic handler (`panic_handler`) itself. - `eh_personality`: Not required with `panic=abort` - `_Unwind_Resume`: Symbol not present with `panic=abort` - `alloc_error_handler`: OOM triggers a panic; feature will be removed [1] [1]: rust-lang/rust#112331 Signed-off-by: Tim Crawford <tcrawford@system76.com>
Attempt to re-land #109507 now that #110771 is fixed.
OOM is now reported as a panic but with a custom payload type (
AllocErrorPanicPayload
) which holds the layout that was passed tohandle_alloc_error
.This should be reviewed one commit at a time:
AllocErrorPanicPayload
and changes allocation errors to always be reported as panics.#[alloc_error_handler]
and thealloc_error_hook
API.ACP: rust-lang/libs-team#192
Closes #51540
Closes #51245