rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.05k stars 888 forks source link

rustfmt crash #6329

Closed ajewellamz closed 2 months ago

ajewellamz commented 2 months ago

thread 'main' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order stack backtrace: 0: 0x109b33aa3 - ::fmt::haf41a54e7ed5fe07 1: 0x109b7e5cb - core::fmt::write::h526161fad96c5ad5 2: 0x109b2969e - std::io::Write::write_fmt::h4de0398536c8b0e4 3: 0x109b3634a - std::panicking::default_hook::{{closure}}::hffeef89117b5d267 4: 0x109b35ffa - std::panicking::default_hook::h2f20b53f3264c5d5 5: 0x112d8478c - std[b0f141cf2a512da3]::panicking::update_hook::<alloc[761ab33699ba4d62]::boxed::Box<rustc_driver_impl[42716081890564d0]::install_ice_hook::{closure#0}>>::{closure#0} 6: 0x109b37139 - std::panicking::rust_panic_with_hook::h7919e8c602131afa 7: 0x109b36942 - std::panicking::begin_panic_handler::{{closure}}::h7bd628128f542977 8: 0x109b33f79 - std::sys::backtrace::__rust_end_short_backtrace::ha2fdb908654ed930 9: 0x109b3658c - _rust_begin_unwind 10: 0x109b9941a - core::panicking::panic_fmt::h292eaa4d42e451fa 11: 0x109b80753 - core::slice::sort::shared::smallsort::panic_on_ord_violation::h6e977ec340ce4b47 12: 0x108d8b93b - core[84908f9229cb2e57]::slice::sort::stable::quicksort::quicksort::<rustfmt_nightly[90b5e423bc400076]::imports::UseTree, <rustfmt_nightly[90b5e423bc400076]::imports::UseTree as core[84908f9229cb2e57]::cmp::PartialOrd>::lt> 13: 0x108d890d6 - core[84908f9229cb2e57]::slice::sort::stable::drift::sort::<rustfmt_nightly[90b5e423bc400076]::imports::UseTree, <rustfmt_nightly[90b5e423bc400076]::imports::UseTree as core[84908f9229cb2e57]::cmp::PartialOrd>::lt> 14: 0x108d8830c - core[84908f9229cb2e57]::slice::sort::stable::driftsort_main::<rustfmt_nightly[90b5e423bc400076]::imports::UseTree, <rustfmt_nightly[90b5e423bc400076]::imports::UseTree as core[84908f9229cb2e57]::cmp::PartialOrd>::lt, alloc[761ab33699ba4d62]::vec::Vec<rustfmt_nightly[90b5e423bc400076]::imports::UseTree>> 15: 0x108e6b408 - <rustfmt_nightly[90b5e423bc400076]::visitor::FmtVisitor>::visit_items_with_reordering 16: 0x108e8579b - <rustfmt_nightly[90b5e423bc400076]::visitor::FmtVisitor>::visit_item 17: 0x108e69117 - <rustfmt_nightly[90b5e423bc400076]::visitor::FmtVisitor>::visit_items_with_reordering 18: 0x108e894f7 - <rustfmt_nightly[90b5e423bc400076]::visitor::FmtVisitor>::format_separate_mod 19: 0x108d02e08 - <rustfmt_nightly[90b5e423bc400076]::Session<std[b0f141cf2a512da3]::io::stdio::Stdout>>::format_input_inner::{closure#0} 20: 0x108d162a4 - rustfmt[a4088305e278d214]::format_and_emit_report::<std[b0f141cf2a512da3]::io::stdio::Stdout> 21: 0x108d14616 - rustfmt[a4088305e278d214]::execute 22: 0x108d1090a - rustfmt[a4088305e278d214]::main 23: 0x108cfe056 - std[b0f141cf2a512da3]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()> 24: 0x108cfe6ac - std[b0f141cf2a512da3]::rt::lang_start::<()>::{closure#0} 25: 0x109b1bd7f - std::rt::lang_start_internal::h8372644ac40c1e8b 26: 0x108d1747f - _main 27: 0x7ff810915418 -

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.81.0 (eeb90cda1 2024-09-04) running on x86_64-apple-darwin

query stack during panic: end of query stack

ytmimi commented 2 months ago

@ajewellamz can you please share a code snippet that we can use to recreate this panic.

ajewellamz commented 2 months ago

Sorry, no. It's a VERY large file (6MB), and I have no idea which part of it caused the problem. The error message said you would like a big report, so I supplied what I could. Feel free to close this issue is there's nothing you can do with it.

ytmimi commented 2 months ago

Unfortunately without a reproducible example there's nothing that can be done here.

mitsuhiko commented 1 month ago

I think this is related to #6333. They both crash in almost the same place (import reordering).