Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matklad/backtrace-on-stack-overflow
https://github.com/matklad/backtrace-on-stack-overflow
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/matklad/backtrace-on-stack-overflow
- Owner: matklad
- License: apache-2.0
- Created: 2020-11-04T13:43:23.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-04T11:17:42.000Z (5 months ago)
- Last Synced: 2024-10-30T20:08:01.909Z (21 days ago)
- Language: Rust
- Size: 12.7 KB
- Stars: 36
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# backtrace-on-stack-overflow
By default, Rust aborts on stackoverflow without printing a backtrace:
```console
λ bat src/main.rs
fn main() {
f(92)
}fn f(x: u64) {
f(x)
}
λ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/so`thread 'main' has overflowed its stack
fatal runtime error: stack overflow
fish: Job 1, 'cargo run' terminated by signal SIGABRT (Abort)
```This crate fixes this:
```console
λ bat src/main.rs
fn main() {
unsafe { backtrace_on_stack_overflow::enable() };
f(92)
}fn f(x: u64) {
f(x)
}
λ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/so`
Stack Overflow:
0: backtrace_on_stack_overflow::handle_sigsegv
at /home/matklad/p/backtrace-on-stack-overflow/src/lib.rs:33:40
1:
2: so::f
at src/main.rs:6
3: so::f
at src/main.rs:7:5
4: so::f
at src/main.rs:7:5
5: so::f
at src/main.rs:7:5
6: so::f
at src/main.rs:7:5
7: so::f
at src/main.rs:7:5
8: so::f
at src/main.rs:7:5
9: so::f
at src/main.rs:7:5
10: so::f
at src/main.rs:7:5
```This crate works for debugging, but is unsuited for being enabled in production.