Skip to content

add test for backtrace with global allocator #2177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/pass/backtrace-global-alloc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// compile-flags: -Zmiri-disable-isolation

#![feature(backtrace)]

use std::alloc::System;
use std::backtrace::Backtrace;

#[global_allocator]
static GLOBAL_ALLOCATOR: System = System;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So even using the System allocator failed before?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, we distinguish C allocations from Rust allocations. Makes sense.


fn main() {
eprint!("{}", Backtrace::capture());
}
28 changes: 28 additions & 0 deletions tests/pass/backtrace-global-alloc.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
0: main
at $DIR/backtrace-global-alloc.rs:LL:CC
1: <fn() as std::ops::FnOnce<()>>::call_once - shim(fn())
at RUSTLIB/core/src/ops/function.rs:LL:CC
2: std::sys_common::backtrace::__rust_begin_short_backtrace
at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
3: std::rt::lang_start::{closure#0}
at RUSTLIB/std/src/rt.rs:LL:CC
4: std::ops::function::impls::call_once
at RUSTLIB/core/src/ops/function.rs:LL:CC
5: std::panicking::r#try::do_call
at RUSTLIB/std/src/panicking.rs:LL:CC
6: std::panicking::r#try
at RUSTLIB/std/src/panicking.rs:LL:CC
7: std::panic::catch_unwind
at RUSTLIB/std/src/panic.rs:LL:CC
8: std::rt::lang_start_internal::{closure#2}
at RUSTLIB/std/src/rt.rs:LL:CC
9: std::panicking::r#try::do_call
at RUSTLIB/std/src/panicking.rs:LL:CC
10: std::panicking::r#try
at RUSTLIB/std/src/panicking.rs:LL:CC
11: std::panic::catch_unwind
at RUSTLIB/std/src/panic.rs:LL:CC
12: std::rt::lang_start_internal
at RUSTLIB/std/src/rt.rs:LL:CC
13: std::rt::lang_start
at RUSTLIB/std/src/rt.rs:LL:CC