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

Crash during rustfmt #6378

Open
douweschulte opened this issue Oct 29, 2024 · 2 comments
Open

Crash during rustfmt #6378

douweschulte opened this issue Oct 29, 2024 · 2 comments
Labels
needs-mcve needs a Minimal Complete and Verifiable Example

Comments

@douweschulte
Copy link

I ran cargo fmt on a crate and this was the response.

thread 'main' panicked at src\tools\rustfmt\src\items.rs:548:10:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7ffd0db30f51 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffd0db30f51 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffd0db30f51 - std::sys::backtrace::_print_fmt
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\sys\backtrace.rs:66
   3:     0x7ffd0db30f51 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\sys\backtrace.rs:39
   4:     0x7ffd0db62629 - core::fmt::rt::Argument::fmt
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\fmt\rt.rs:177
   5:     0x7ffd0db62629 - core::fmt::write
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\fmt\mod.rs:1178
   6:     0x7ffd0db27117 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\io\mod.rs:1823
   7:     0x7ffd0db34069 - std::panicking::default_hook::closure$1
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:266
   8:     0x7ffd0db33bec - std::panicking::default_hook
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:293
   9:     0x7ffd0f085e40 - memchr
  10:     0x7ffd0db34a7b - alloc::boxed::impl$50::call
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/alloc\src\boxed.rs:2245
  11:     0x7ffd0db34a7b - std::panicking::rust_panic_with_hook
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:805
  12:     0x7ffd0db3484f - std::panicking::begin_panic_handler::closure$0
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:664
  13:     0x7ffd0db31a0f - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\sys\backtrace.rs:170
  14:     0x7ffd0db34496 - std::panicking::begin_panic_handler
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:662
  15:     0x7ffd108f47d4 - core::panicking::panic_fmt
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:74
  16:     0x7ffd108f487d - core::panicking::panic
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:148
  17:     0x7ffd108f473e - core::option::unwrap_failed
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\option.rs:2015
  18:     0x7ff737826bea - <unknown>
  19:     0x7ff7378976b0 - <unknown>
  20:     0x7ff7378779ed - <unknown>
  21:     0x7ff73789cfd6 - <unknown>
  22:     0x7ff7376c3b7a - <unknown>
  23:     0x7ff7376f3290 - <unknown>
  24:     0x7ff7376ee98d - <unknown>
  25:     0x7ff7376ea332 - <unknown>
  26:     0x7ff7376dd006 - <unknown>
  27:     0x7ff7376dd6cc - <unknown>
  28:     0x7ffd0db17ff9 - std::rt::lang_start_internal::closure$2
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\rt.rs:143
  29:     0x7ffd0db17ff9 - std::panicking::try::do_call
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:554
  30:     0x7ffd0db17ff9 - std::panicking::try
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:518
  31:     0x7ffd0db17ff9 - std::panic::catch_unwind
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panic.rs:345
  32:     0x7ffd0db17ff9 - std::rt::lang_start_internal
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\rt.rs:143
  33:     0x7ff7376f46cc - <unknown>
  34:     0x7ff737a0de50 - <unknown>
  35:     0x7ffdf5b6257d - BaseThreadInitThunk
  36:     0x7ffdf778af08 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: rustc 1.82.0 (f6e511eec 2024-10-15) running on x86_64-pc-windows-msvc

query stack during panic:
end of query stack

I was working on the following codebase [github.com/douweschulte/mzdata] and made a snapshot commit of the state when the crash happened. If I can help by providing more information let me know.

@ytmimi
Copy link
Contributor

ytmimi commented Oct 29, 2024

@douweschulte Thanks for reaching out and reporting the crash. It would be really helpful to provide a minimal code snippet that reproduces the crash, otherwise it's going to be a lot harder to get to the bottom of this issue.

It would also be helpful to know what version of rustfmt you were using and if you were using any configuration options.

@ytmimi ytmimi added the needs-mcve needs a Minimal Complete and Verifiable Example label Oct 29, 2024
@ytmimi
Copy link
Contributor

ytmimi commented Oct 29, 2024

Based off of the info in the backtrace I suspect this is related to #5738, possibly a duplicate.

ding-young added a commit to ding-young/rustfmt that referenced this issue Nov 29, 2024
- related issues: rust-lang#5738, rust-lang#6137, rust-lang#6318, rust-lang#6378
- instead of calling unwrap(), restore original snippet when we fail to format generics in enum
- we need to propagate this rewrite failure later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-mcve needs a Minimal Complete and Verifiable Example
Projects
None yet
Development

No branches or pull requests

2 participants