Skip to content
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

Display captured backtrace when available #2504

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

matheus-consoli
Copy link
Member

Tries to capture and display the backtrace when the system crashes.

Note tho, that in the current state, it seems that tauri is somehow messing with the backtrace, so if the core crashes, it only captures an empty backtrace - I'm still not sure why, and I will investigate more later.

But with this added code, we at least start capturing the stacktrace, and when we figure out the tauri issue or move the core to a daemon architecture, it will emit the stacktrace.

As an example, if we create core/src/bin/a.rs:

use sd_core::Node;

fn main() {
	let _guard = Node::init_logger("./").unwrap();
	panic!("ops");
}

and run the application RUST_BACKTRACE=1 cargo run, it will emit the backtrace:

Collapsed
2024-05-24T16:53:29.496031Z ERROR sd_core: core/src/lib.rs:243: panicked at core/src/bin/backtrace.rs:5:5:
ops panic.file="core/src/bin/backtrace.rs:5" panic.column=5
2024-05-24T16:53:29.500813Z ERROR sd_core: core/src/lib.rs:252:    0: sd_core::Node::init_logger::{{closure}}
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
   2: std::panicking::rust_panic_with_hook
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:649:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18
   5: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   6: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   7: backtrace::main
   8: core::ops::function::FnOnce::call_once
   9: std::sys_common::backtrace::__rust_begin_short_backtrace
  10: std::rt::lang_start::{{closure}}
  11: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:284:13
  12: std::panicking::try::do_call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
  13: std::panicking::try
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
  14: std::panic::catch_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
  15: std::rt::lang_start_internal::{{closure}}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:148:48
  16: std::panicking::try::do_call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
  17: std::panicking::try
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
  18: std::panic::catch_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
  19: std::rt::lang_start_internal
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:148:20
  20: std::rt::lang_start
  21: main
  22: <unknown>
  23: __libc_start_main
  24: _start

@matheus-consoli matheus-consoli requested a review from a team as a code owner May 24, 2024 16:55
Copy link

vercel bot commented May 24, 2024

@matheus-consoli is attempting to deploy a commit to the Spacedrive Team on Vercel.

A member of the Team first needs to authorize it.

@utkubakir utkubakir added this pull request to the merge queue Jun 4, 2024
Merged via the queue into spacedriveapp:main with commit 76bb317 Jun 4, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants