Rollup merge of #30801 - Amanieu:oom_print, r=alexcrichton
This adds the ability to override the default OOM behavior by setting a handler function. This is used by libstd to print a message when running out of memory instead of crashing with an obscure "illegal hardware instruction" error (at least on Linux). Fixes #14674
This commit is contained in:
@@ -92,6 +92,7 @@
|
||||
#![feature(unsize)]
|
||||
#![feature(drop_in_place)]
|
||||
#![feature(fn_traits)]
|
||||
#![feature(const_fn)]
|
||||
|
||||
#![feature(needs_allocator)]
|
||||
|
||||
@@ -134,15 +135,6 @@ mod boxed_test;
|
||||
pub mod arc;
|
||||
pub mod rc;
|
||||
pub mod raw_vec;
|
||||
pub mod oom;
|
||||
|
||||
/// Common out-of-memory routine
|
||||
#[cold]
|
||||
#[inline(never)]
|
||||
#[unstable(feature = "oom", reason = "not a scrutinized interface",
|
||||
issue = "27700")]
|
||||
pub fn oom() -> ! {
|
||||
// FIXME(#14674): This really needs to do something other than just abort
|
||||
// here, but any printing done must be *guaranteed* to not
|
||||
// allocate.
|
||||
unsafe { core::intrinsics::abort() }
|
||||
}
|
||||
pub use oom::oom;
|
||||
|
||||
Reference in New Issue
Block a user