Skip to content

Commit 5c97193

Browse files
committed
Print backtrace instead of panicking
1 parent 1a13d11 commit 5c97193

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libstd/alloc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ pub fn take_alloc_error_hook() -> fn(Layout) {
202202
/// This lives in `libstd` so that we can call `dumb_print`.
203203
///
204204
/// This hook prints out a message like the default error hook,
205-
/// but then panics to generate a backtrace. If we are completely
206-
/// out of memory, panicking and/or backtrace generation may fail:
205+
/// and then attempts to print a backtrace (without panicking).
206+
/// If we are completely out of memory, backtrace generation may fail:
207207
/// this is fine, since the backtrace is best-effort only. We
208208
/// are guaranteed to print the actual error message, though.
209209
#[doc(hidden)]
210210
#[unstable(feature = "alloc_internals", issue = "0")]
211211
pub fn rustc_alloc_error_hook(layout: Layout) {
212212
dumb_print(format_args!("memory allocation of {} bytes failed. backtrace:", layout.size()));
213-
panic!();
213+
dumb_print(format_args!("{:?}", crate::backtrace::Backtrace::capture()));
214214
}
215215

216216
fn default_alloc_error_hook(layout: Layout) {

0 commit comments

Comments
 (0)