diff options
| author | bors <bors@rust-lang.org> | 2022-02-06 03:12:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-06 03:12:45 +0000 |
| commit | 719b04ca99be0c78e09a8ec5e2eda082a5d8ccae (patch) | |
| tree | f598bbc1686da10e317387aeed4d7cb86749d017 /library/alloc/src/alloc.rs | |
| parent | 88fb06a1f331926bccb448acdb52966fd1ec8a92 (diff) | |
| parent | 2082842340062eda5fa7215e831cdcd62379b0b3 (diff) | |
Auto merge of #92535 - Amanieu:oom_hook_unwind, r=m-ou-se
Allow unwinding from OOM hooks This is split off from #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 #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.
Diffstat (limited to 'library/alloc/src/alloc.rs')
| -rw-r--r-- | library/alloc/src/alloc.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index d075658f51a..9d4f9af91a5 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -348,7 +348,6 @@ extern "Rust" { // This is the magic symbol to call the global alloc error handler. rustc generates // it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the // default implementations below (`__rdl_oom`) otherwise. - #[rustc_allocator_nounwind] fn __rust_alloc_error_handler(size: usize, align: usize) -> !; } @@ -367,7 +366,6 @@ extern "Rust" { #[stable(feature = "global_alloc", since = "1.28.0")] #[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")] #[cfg(all(not(no_global_oom_handling), not(test)))] -#[rustc_allocator_nounwind] #[cold] pub const fn handle_alloc_error(layout: Layout) -> ! { const fn ct_error(_: Layout) -> ! { @@ -398,13 +396,13 @@ pub mod __alloc_error_handler { // if there is no `#[alloc_error_handler]` #[rustc_std_internal_symbol] - pub unsafe extern "C" fn __rdl_oom(size: usize, _align: usize) -> ! { + pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! { panic!("memory allocation of {} bytes failed", size) } // if there is an `#[alloc_error_handler]` #[rustc_std_internal_symbol] - pub unsafe extern "C" fn __rg_oom(size: usize, align: usize) -> ! { + pub unsafe extern "C-unwind" fn __rg_oom(size: usize, align: usize) -> ! { let layout = unsafe { Layout::from_size_align_unchecked(size, align) }; extern "Rust" { #[lang = "oom"] |
