Allow unwinding from OOM hooks#92535
Conversation
|
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
|
From your description I assumed that this program would abort in the current version of rust, and would succeed after the change in this PR: #![feature(alloc_error_hook)]
fn main() {
std::alloc::set_alloc_error_hook(|_| {
panic!("oh no");
});
assert!(std::panic::catch_unwind(|| {
vec![0u8; 12345678901234567890];
}).is_err());
println!("i'm ok :)");
}But it already succeeds on the current version of rust: Am I misunderstanding the purpose of this PR? |
|
I think panicking inside the alloc error hook is currently UB. |
|
Yes, it's currently UB due to |
|
If you try using a type with |
|
Ah, interesting. I didn't manage to make it fail on x86_64-unknown-linux-gnu, aarch64-apple-darwin, nor x86_64-pc-windows-gnu, but it does indeed fail on aarch64-unknown-linux-musl and x86_64-unknown-linux-musl. With this patch applied, it succeeds on all of them. @bors r+ |
|
📌 Commit f4545cc has been approved by |
If I add a |
Allow unwinding from OOM hooks This is split off from rust-lang#88098 and contains just the bare minimum to allow specifying a custom OOM hook with `set_alloc_error_hook` which unwinds instead of aborting. See rust-lang#88098 for an actual command-line flag which switches the default OOM behavior to unwind instead of aborting. Previous perf results show a negligible impact on performance.
Allow unwinding from OOM hooks This is split off from rust-lang#88098 and contains just the bare minimum to allow specifying a custom OOM hook with `set_alloc_error_hook` which unwinds instead of aborting. See rust-lang#88098 for an actual command-line flag which switches the default OOM behavior to unwind instead of aborting. Previous perf results show a negligible impact on performance.
Allow unwinding from OOM hooks This is split off from rust-lang#88098 and contains just the bare minimum to allow specifying a custom OOM hook with `set_alloc_error_hook` which unwinds instead of aborting. See rust-lang#88098 for an actual command-line flag which switches the default OOM behavior to unwind instead of aborting. Previous perf results show a negligible impact on performance.
Allow unwinding from OOM hooks This is split off from rust-lang#88098 and contains just the bare minimum to allow specifying a custom OOM hook with `set_alloc_error_hook` which unwinds instead of aborting. See rust-lang#88098 for an actual command-line flag which switches the default OOM behavior to unwind instead of aborting. Previous perf results show a negligible impact on performance.
|
Oh, sorry, I didn't see that. @bors r- |
|
Not really on Windows much these days, maybe someone from the Windows notification group can help? @rustbot ping windows |
|
Error: Only Rust team members can ping teams. Please let |
|
Just a backtrace at the point where it is hanging would be a good start to figuring out what the problem is. |
No, rls fails to build on master too. See #91543. |
|
I'm able to reproduce locally. At a minimum it required llvm assertions, though it may also require parallel-compiler. The reason it is hanging is because it pops open a helpful dialog box. In this particular instance, it was hung building tracing-subscriber. Here is a stack trace: I'm pretty much out of my depth when it comes to digging into LLVM, though. |
|
@ehuss Could you please rerun the asserting |
|
Here are the temp files: |
|
I confirmed the only non-default setting needed to trigger it is |
|
Best reduction I have for now is https://gist.github.com/nikic/2ff417bd7df48d660f5af0ea47ee3c89 with Edit: https://gist.github.com/nikic/65871cd4c29ded2d1b21cebbdab3f052 asserts under |
|
I filed llvm/llvm-project#53206. |
|
Fixed upstream by llvm/llvm-project@4810051. |
f4545cc to
2082842
Compare
|
📌 Commit 2082842 has been approved by |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (719b04c): comparison url. Summary: This benchmark run shows 34 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |

This is split off from #88098 and contains just the bare minimum to allow specifying a custom OOM hook with
set_alloc_error_hookwhich unwinds instead of aborting.See #88098 for an actual command-line flag which switches the default OOM behavior to unwind instead of aborting.
Previous perf results show a negligible impact on performance.