about summary refs log tree commit diff
path: root/library/std/src/backtrace.rs
AgeCommit message (Collapse)AuthorLines
2025-04-27use generic Atomic type where possibleChristopher Durham-2/+2
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-09update cfgsBoxy-1/+1
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-0/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-1/+1
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-06-16std: move `sys_common::backtrace` to `sys`joboet-1/+1
2024-06-12Require any function with a tait in its signature to actually constrain a ↵Oli Scherer-28/+32
hidden type
2024-02-21rename ptr::invalid -> ptr::without_provenanceRalf Jung-1/+1
also introduce ptr::dangling matching NonNull::dangling
2024-01-19Rollup merge of #118798 - GnomedDev:use-atomicu8-backtrace, r=NilstriebMatthias Krüger-3/+3
Use AtomicU8 instead of AtomicUsize in backtrace.rs Just a small inefficiency I saw when looking at std sources.
2023-12-10Use AtomicU8 instead of AtomicUsize in backtrace.rsDavid Thomas-3/+3
2023-12-10remove redundant importssurechen-1/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-14Move SGX-specific image base logic to sys_commonMohsen Zohrevandi-6/+2
2023-11-14Adjust frame IP in backtraces relative to image base for SGX targetMohsen Zohrevandi-0/+5
2023-07-31Implement UnwindSafe and RefUnwindSafe for BacktraceKonrad Borowski-1/+2
Backtrace doesn't have visible mutable state.
2023-07-26std: add auto traits to TAIT boundjoboet-1/+6
2023-04-27std: use `LazyLock` to lazily resolve backtracesjoboet-50/+13
2022-12-30Replace libstd, libcore, liballoc in docs.jonathanCogan-4/+4
2022-10-13std: use `sync::Mutex` for internal staticsjoboet-4/+2
2022-10-04fix backtrace small typoRageking8-3/+3
2022-09-26replace stabilization placeholdersPietro Albini-13/+13
2022-08-27Adjust backtrace stabilization version to CURRENT_RUSTC_VERSIONest31-13/+13
2022-08-11Add stability attributes to BacktraceStatus variantsTheodore Dubois-0/+3
Fixes #100399
2022-08-09Apply suggestions from code reviewJane Losare-Lusby-10/+10
2022-08-02Stabilize backtraceTheodore Dubois-7/+11
2022-03-29revert changes that cast functions to raw pointers, portability hazardAria Beingessner-2/+2
2022-03-29Make some linux/unix APIs better conform to strict provenance.Alexis Beingessner-1/+1
This largely makes the stdlib conform to strict provenance on Ubuntu. Some hairier things have been left alone for now.
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-4/+4
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2021-12-20Change Backtrace::enabled atomic from SeqCst to RelaxedDavid Tolnay-3/+3
2021-10-30Add #[must_use] to remaining std functions (A-N)John Kugelman-0/+3
2021-07-29Fix may not to appropriate might not or must notAli Malik-3/+3
2021-06-07make both panic display formats collapse framesAshley Mannix-3/+2
2021-01-23Add Frames iterator for BacktraceSean Chen-1/+20
2021-01-06use Once instead of Mutex to manage capture resolutionAshley Mannix-9/+35
This allows us to return borrows of the captured backtrace frames that are tied to a borrow of the Backtrace itself, instead of to some short-lived Mutex guard. It also makes it semantically clearer what synchronization is needed on the capture.
2020-11-15Add column number support to Backtraceest31-2/+9
Backtrace frames might include column numbers. Print them if they are included.
2020-10-07For backtrace, use StaticMutex instead of a raw sys Mutex.Mara Bos-2/+4
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-52/+3
Also doing fmt inplace as requested.
2020-07-28std: Switch from libbacktrace to gimliAlex Crichton-11/+10
This commit is a proof-of-concept for switching the standard library's backtrace symbolication mechanism on most platforms from libbacktrace to gimli. The standard library's support for `RUST_BACKTRACE=1` requires in-process parsing of object files and DWARF debug information to interpret it and print the filename/line number of stack frames as part of a backtrace. Historically this support in the standard library has come from a library called "libbacktrace". The libbacktrace library seems to have been extracted from gcc at some point and is written in C. We've had a lot of issues with libbacktrace over time, unfortunately, though. The library does not appear to be actively maintained since we've had patches sit for months-to-years without comments. We have discovered a good number of soundness issues with the library itself, both when parsing valid DWARF as well as invalid DWARF. This is enough of an issue that the libs team has previously decided that we cannot feed untrusted inputs to libbacktrace. This also doesn't take into account the portability of libbacktrace which has been difficult to manage and maintain over time. While possible there are lots of exceptions and it's the main C dependency of the standard library right now. For years it's been the desire to switch over to a Rust-based solution for symbolicating backtraces. It's been assumed that we'll be using the Gimli family of crates for this purpose, which are targeted at safely and efficiently parsing DWARF debug information. I've been working recently to shore up the Gimli support in the `backtrace` crate. As of a few weeks ago the `backtrace` crate, by default, uses Gimli when loaded from crates.io. This transition has gone well enough that I figured it was time to start talking seriously about this change to the standard library. This commit is a preview of what's probably the best way to integrate the `backtrace` crate into the standard library with the Gimli feature turned on. While today it's used as a crates.io dependency, this commit switches the `backtrace` crate to a submodule of this repository which will need to be updated manually. This is not done lightly, but is thought to be the best solution. The primary reason for this is that the `backtrace` crate needs to do some pretty nontrivial filesystem interactions to locate debug information. Working without `std::fs` is not an option, and while it might be possible to do some sort of trait-based solution when prototyped it was found to be too unergonomic. Using a submodule allows the `backtrace` crate to build as a submodule of the `std` crate itself, enabling it to use `std::fs` and such. Otherwise this adds new dependencies to the standard library. This step requires extra attention because this means that these crates are now going to be included with all Rust programs by default. It's important to note, however, that we're already shipping libbacktrace with all Rust programs by default and it has a bunch of C code implementing all of this internally anyway, so we're basically already switching already-shipping functionality to Rust from C. * `object` - this crate is used to parse object file headers and contents. Very low-level support is used from this crate and almost all of it is disabled. Largely we're just using struct definitions as well as convenience methods internally to read bytes and such. * `addr2line` - this is the main meat of the implementation for symbolication. This crate depends on `gimli` for DWARF parsing and then provides interfaces needed by the `backtrace` crate to turn an address into a filename / line number. This crate is actually pretty small (fits in a single file almost!) and mirrors most of what `dwarf.c` does for libbacktrace. * `miniz_oxide` - the libbacktrace crate transparently handles compressed debug information which is compressed with zlib. This crate is used to decompress compressed debug sections. * `gimli` - not actually used directly, but a dependency of `addr2line`. * `adler32`- not used directly either, but a dependency of `miniz_oxide`. The goal of this change is to improve the safety of backtrace symbolication in the standard library, especially in the face of possibly malformed DWARF debug information. Even to this day we're still seeing segfaults in libbacktrace which could possibly become security vulnerabilities. This change should almost entirely eliminate this possibility whilc also paving the way forward to adding more features like split debug information. Some references for those interested are: * Original addition of libbacktrace - #12602 * OOM with libbacktrace - #24231 * Backtrace failure due to use of uninitialized value - #28447 * Possibility to feed untrusted data to libbacktrace - #21889 * Soundness fix for libbacktrace - #33729 * Crash in libbacktrace - #39468 * Support for macOS, never merged - ianlancetaylor/libbacktrace#2 * Performance issues with libbacktrace - #29293, #37477 * Update procedure is quite complicated due to how many patches we need to carry - #50955 * Libbacktrace doesn't work on MinGW with dynamic libs - #71060 * Segfault in libbacktrace on macOS - #71397 Switching to Rust will not make us immune to all of these issues. The crashes are expected to go away, but correctness and performance may still have bugs arise. The gimli and `backtrace` crates, however, are actively maintained unlike libbacktrace, so this should enable us to at least efficiently apply fixes as situations come up.
2020-07-27mv std libs to library/mark-0/+493