Skip to content

Commit 3785303

Browse files
committed
Show backtrace on allocation failures when possible
And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.
1 parent 6b5af2a commit 3785303

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/fail/alloc/alloc_error_handler.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
memory allocation of 4 bytes failed
2+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3+
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
24
error: abnormal termination: the program aborted execution
35
--> RUSTLIB/std/src/alloc.rs:LL:CC
46
|
5-
LL | crate::process::abort()
6-
| ^^^^^^^^^^^^^^^^^^^^^^^ abnormal termination occurred here
7+
LL | crate::process::abort()
8+
| ^^^^^^^^^^^^^^^^^^^^^^^ abnormal termination occurred here
79
|
810
= note: BACKTRACE:
11+
= note: inside closure at RUSTLIB/std/src/alloc.rs:LL:CC
12+
= note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::alloc::rust_oom::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
913
= note: inside `std::alloc::rust_oom` at RUSTLIB/std/src/alloc.rs:LL:CC
1014
= note: inside `std::alloc::_::__rust_alloc_error_handler` at RUSTLIB/std/src/alloc.rs:LL:CC
1115
= note: inside `std::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC

0 commit comments

Comments
 (0)