Skip to content

Commit 83e1c37

Browse files
authored
Document unwinding limitations (#407)
* Document unwinding limitations Following the discussion in #397 seems like this is a missing section of the documentation! It seems worthwhile to document some pitfalls and mitigations if possible. * Update split-debuginfo support to nightly
1 parent 710fc18 commit 83e1c37

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

.github/workflows/main.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ jobs:
8787
if: contains(matrix.os, 'ubuntu')
8888
- run: RUSTFLAGS="-C link-arg=-Wl,--compress-debug-sections=zlib-gnu" cargo test --features gimli-symbolize
8989
if: contains(matrix.os, 'ubuntu')
90-
- run: cargo clean && RUSTFLAGS="-Z run-dsymutil=no" cargo test --features gimli-symbolize
90+
- run: cargo clean && RUSTFLAGS="-C split-debuginfo=unpacked" cargo test --features gimli-symbolize
9191
if: matrix.thing == 'macos-nightly'
92-
- run: cargo clean && RUSTFLAGS="-Z split-dwarf=split -C save-temps" cargo test --features gimli-symbolize
92+
- run: cargo clean && RUSTFLAGS="-C split-debuginfo=unpacked -Zunstable-options" cargo test --features gimli-symbolize
93+
if: matrix.thing == 'nightly'
94+
- run: cargo clean && RUSTFLAGS="-C split-debuginfo=packed -Zunstable-options" cargo test --features gimli-symbolize
9395
if: matrix.thing == 'nightly'
9496
- run: cargo build --manifest-path crates/as-if-std/Cargo.toml
9597

src/lib.rs

+45
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,51 @@
4040
//! }
4141
//! # }
4242
//! ```
43+
//!
44+
//! # Backtrace accuracy
45+
//!
46+
//! This crate implements best-effort attempts to get the native backtrace. This
47+
//! is not always guaranteed to work, and some platforms don't return any
48+
//! backtrace at all. If your application requires accurate backtraces then it's
49+
//! recommended to closely evaluate this crate to see whether it's suitable
50+
//! for your use case on your target platforms.
51+
//!
52+
//! Even on supported platforms, there's a number of reasons that backtraces may
53+
//! be less-than-accurate, including but not limited to:
54+
//!
55+
//! * Unwind information may not be available. This crate primarily implements
56+
//! backtraces by unwinding the stack, but not all functions may have
57+
//! unwinding information (e.g. DWARF unwinding information).
58+
//!
59+
//! * Rust code may be compiled without unwinding information for some
60+
//! functions. This can also happen for Rust code compiled with
61+
//! `-Cpanic=abort`. You can remedy this, however, with
62+
//! `-Cforce-unwind-tables` as a compiler option.
63+
//!
64+
//! * Unwind information may be inaccurate or corrupt. In the worst case
65+
//! inaccurate unwind information can lead this library to segfault. In the
66+
//! best case inaccurate information will result in a truncated stack trace.
67+
//!
68+
//! * Backtraces may not report filenames/line numbers correctly due to missing
69+
//! or corrupt debug information. This won't lead to segfaults unlike corrupt
70+
//! unwinding information, but missing or malformed debug information will
71+
//! mean that filenames and line numbers will not be available. This may be
72+
//! because debug information wasn't generated by the compiler, or it's just
73+
//! missing on the filesystem.
74+
//!
75+
//! * Not all platforms are supported. For example there's no way to get a
76+
//! backtrace on WebAssembly at the moment.
77+
//!
78+
//! * Crate features may be disabled. Currently this crate supports using Gimli
79+
//! libbacktrace on non-Windows platforms for reading debuginfo for
80+
//! backtraces. If both crate features are disabled, however, then these
81+
//! platforms will generate a backtrace but be unable to generate symbols for
82+
//! it.
83+
//!
84+
//! In most standard workflows for most standard platforms you generally don't
85+
//! need to worry about these caveats. We'll try to fix ones where we can over
86+
//! time, but otherwise it's important to be aware of the limitations of
87+
//! unwinding-based backtraces!
4388
4489
#![doc(html_root_url = "https://docs.rs/backtrace")]
4590
#![deny(missing_docs)]

0 commit comments

Comments
 (0)