3 releases

0.1.2 Jan 2, 2023
0.1.1 Mar 6, 2020
0.1.0 Sep 15, 2019

#385 in Debugging

Download history 29/week @ 2023-11-20 45/week @ 2023-11-27 48/week @ 2023-12-04 57/week @ 2023-12-11 42/week @ 2023-12-18 65/week @ 2023-12-25 120/week @ 2024-01-01 191/week @ 2024-01-08 154/week @ 2024-01-15 90/week @ 2024-01-22 101/week @ 2024-01-29 80/week @ 2024-02-05 62/week @ 2024-02-12 108/week @ 2024-02-19 141/week @ 2024-02-26 164/week @ 2024-03-04

482 downloads per month
Used in 5 crates (4 directly)

GPL-3.0-or-later

19KB
135 lines

pipeline crates.io Docs rustc

coredump

coredump is a crate to make a Rust program create a core dump when it encounters a panic.

Why?

By default, when a Rust program panics it will print a backtrace and terminate the program. There are a few situations when this behavior is not sufficient or desired, including when:

  • you want to make sure that you are able to root cause problems based on bug reports and a backtrace alone may not be enough
  • you cannot get the backtrace of a panic, for example, because it is printed to the terminal's alternate screen or otherwise not available

coredump caters to those and more cases. It should combine with and may be a nice addition to other crates involved in the panic path, such as human-panic.

Usage

The crate works by registering a custom panic handler that will run after the previously installed (or default) one. Registration of this custom handler is as simple as invoking:

register_panic_handler()

early during program initialization (ideally before any panic may happen).

After a panic has happened, the core file can be investigated using gdb(1), like so:

$ rust-gdb <paniced-binary> <core-file>

By default a core file as created by this crate will reside in the system's temp directory, but this behavior may be overwritten by system configuration.

Limitations

By design, this crate is concerned only with regular (language level) panics. Segmentation violations or other problems are not covered by its approach. The application using this crate also will have to be compiled with proper unwinding support and not just abort execution (unwinding is the case by default but could be overwritten by adding panic = 'abort' to the profile being compiled against).

Also note that while core dumping support is present on many systems, many factors play into the ability of a system to create an application core dump. A lot of these factors are out of this crate's control, both in the sense that they cannot be changed but also that they may potentially not even be checkable at runtime. The full list of requirements the system must meet is detailed in core(5).

Dependencies