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

Skipping too many frames #155

Closed
smessmer opened this issue Oct 5, 2024 · 2 comments
Closed

Skipping too many frames #155

smessmer opened this issue Oct 5, 2024 · 2 comments

Comments

@smessmer
Copy link

smessmer commented Oct 5, 2024

I set up a sample panic somewhere in my code base, ran with cargo run --release, and caught it with the following custom panic handler:

pub fn show_backtrace_on_panic() {
    std::panic::set_hook(Box::new(|panic_info| {
        let backtrace = std::backtrace::Backtrace::force_capture();
        eprintln!("{panic_info}");
        eprintln!("\nBacktrace:\n{backtrace}");
    }));
}

Which showed me this backtrace:

Backtrace:
   0: cryfs_cli_utils::panic_handler::show_backtrace_on_panic::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::begin_panic_handler::{{closure}}
   3: std::sys_common::backtrace::__rust_end_short_backtrace
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: cryfs_cryfs::config::encryption::decrypt
   7: cryfs_cryfs::config::loader::load_or_create
   8: <cryfs_cli::cli::Cli as cryfs_cli_utils::application::Application>::main
   9: cryfs_cli_utils::application::run
  10: std::sys_common::backtrace::__rust_begin_short_backtrace
  11: main
  12: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  13: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:360:3
  14: _start

Frames 0..=5 are useless here, but starting from frame 6, the frames are relevant.

However, using human-panic, I got this backtrace, which skips frame 6:

"backtrace" = """
   0: 0x57a214f25d51 - cryfs_cryfs::config::loader::load_or_create::h0164e15f3c7e3b2f
   1: 0x57a214eba0f8 - <cryfs_cli::cli::Cli as cryfs_cli_utils::application::Application>::main::h857c34904cb9b5d6
   2: 0x57a214d42d65 - cryfs_cli_utils::application::run::h524b32ee2ef4b9b3
   3: 0x57a214d399c3 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha12c550ae26c7977
   4: 0x57a214d3a260 - main
   5: 0x79c6fac2a1ca - __libc_start_call_main
                at ./csu/../sysdeps/nptl/libc_start_call_main.h:58
   6: 0x79c6fac2a28b - __libc_start_main_impl
                at ./csu/../csu/libc-start.c:360
   7: 0x57a214c81455 - _start
   8:        0x0 - <unresolved>"""

Seems like it's skipping one frame too many.

@epage
Copy link
Collaborator

epage commented Oct 10, 2024

#158 made improvements to what gets skipped and has been released in v2.0.2. Could you test it out?

@smessmer
Copy link
Author

Thanks, confirmed this fixes it

smessmer added a commit to cryfs/cryfs that referenced this issue Oct 17, 2024
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

No branches or pull requests

2 participants