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

Miette panic handler missing lines #92

Closed
sophiajt opened this issue Nov 13, 2021 · 1 comment
Closed

Miette panic handler missing lines #92

sophiajt opened this issue Nov 13, 2021 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sophiajt
Copy link
Sponsor Contributor

Noticed that sometimes miette is missing lines in the panic when you use Miette's custom handler.

Here's one example:

Miette:

  × Main thread panicked.
  ├─▶ at crates/nu-protocol/src/engine/stack.rs:46:9
  ╰─▶ variable not found
         0: 0x56147c2f1d38 - engine_q::main::h85b5921abc527ed0
                      at /home/jt/Source/engine-q/src/main.rs:185
         1: 0x56147c2ecf9b -
      core::ops::function::FnOnce::call_once::h70b5d4743a54f260
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/core/src/ops/function.rs:227
         2: 0x56147c2e701e -
      std::sys_common::backtrace::__rust_begin_short_backtrace::h9da7e7484d516
      5ac
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/sys_common/backtrace.rs:123
         3: 0x56147c2ee141 - std::rt::lang_start::
      {{closure}}::hc474539033f905d0
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/rt.rs:145
         4: 0x56147ce4f181 - core::ops::function::impls::<impl
      core::ops::function::FnOnce<A> for &F>::call_once::h42d3791e66d196c0
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/core/src/ops/function.rs:259
                       - std::panicking::try::do_call::hc3bcb188e535517f
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
            at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/panicking.rs:406
                       - std::panicking::try::hb1edf04d4a7097ab
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/panicking.rs:370
                       - std::panic::catch_unwind::h75ed941ac0d36d57
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/panic.rs:133
                       - std::rt::lang_start_internal::
      {{closure}}::hc702b3389af4cbea
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/rt.rs:128
                       - std::panicking::try::do_call::h53276a03c7fe2ebc
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/panicking.rs:406
                       - std::panicking::try::ha9e37f45dc542517
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/panicking.rs:370
                       - std::panic::catch_unwind::h182647595766fee7
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/panic.rs:133
                       - std::rt::lang_start_internal::h571831ebdba142de
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/rt.rs:128
         5: 0x56147c2ee110 - std::rt::lang_start::h58c5b562df81656b
                      at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/
      library/std/src/rt.rs:144
         6: 0x56147c2f5f5c - main
         7: 0x7fe5016fa0b3 - __libc_start_main
         8: 0x56147c2e5f4e - _start
         9:        0x0 - <unresolved>

Compared to:

   0: std::panicking::begin_panic
             at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/library/std/src/panicking.rs:525:12
   1: nu_protocol::engine::stack::Stack::get_var
             at ./crates/nu-protocol/src/engine/stack.rs:46:9
   2: nu_protocol::engine::stack::Stack::get_config
             at ./crates/nu-protocol/src/engine/stack.rs:89:22
   3: <nu_command::viewers::table::Table as nu_protocol::engine::command::Command>::run
             at ./crates/nu-command/src/viewers/table.rs:35:22
   4: engine_q::print_value
             at ./src/main.rs:286:25
   5: engine_q::eval_source
             at ./src/main.rs:389:31
   6: engine_q::main
             at ./src/main.rs:185:21
   7: core::ops::function::FnOnce::call_once
             at /rustc/936238a92b2f9d6e7afe7dda69b4afd903f96399/library/core/src/ops/function.rs:227:5

Miette has more lines, but the rustc panic handler shows more of the lines that happened inside of the user code. I've seen this in both stable and nightly rustc.

@zkat zkat added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Nov 15, 2021
@zkat
Copy link
Owner

zkat commented Nov 15, 2021

The code for this is here: https://github.com/zkat/miette/blob/main/src/panic.rs#L37-L86

I wonder what's going on. It sure looks like miette is just skipping over most of the user code here. :(

@zkat zkat closed this as completed in 32bfcdb Mar 31, 2023
zkat added a commit that referenced this issue Mar 31, 2023
zkat added a commit that referenced this issue Mar 31, 2023
zkat added a commit that referenced this issue Mar 31, 2023
zkat added a commit that referenced this issue Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants