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

Format string/argument mismatch triggers internal compiler error #81006

Closed
illdefined opened this issue Jan 14, 2021 · 5 comments · Fixed by #81071
Closed

Format string/argument mismatch triggers internal compiler error #81006

illdefined opened this issue Jan 14, 2021 · 5 comments · Fixed by #81071
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@illdefined
Copy link

Code

fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
	write!(formatter, "{}\t{} → {}\t{} → {}\t{} MHz\t{}\t{} dB\t{} km\tSpotQ {}",
		 self.datetime().format("%Y-%m-%d %H:%M"), self.call_tx, self.call_rx, self.grid_tx, self.grid_rx,
		 self.frequency, self.snr, self.distance, self.spotq())
}

This is the smallest set of lines from the original source file (main.rs) successfully triggering the error. Please note the mismatch between the number of specifiers in the format string and arguments. It should obviously not compile, but I assume that it shouldn’t make rustc panic either.

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (a62a76047 2021-01-13)
binary: rustc
commit-hash: a62a76047ea24aad7639f14eb3ce0e620b77bdb7
commit-date: 2021-01-13
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly

Error output

   Compiling wsprspots v0.0.0 (/home/mvs/dev/wsprspots)
     Running `rustc --crate-name wsprspots --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=5a5ee821a8682d77 -C extra-filename=-5a5ee821a8682d77 --out-dir /home/mvs/dev/wsprspots/target/debug/deps -C incremental=/home/mvs/dev/wsprspots/target/debug/incremental -L dependency=/home/mvs/dev/wsprspots/target/debug/deps --extern chrono=/home/mvs/dev/wsprspots/target/debug/deps/libchrono-17cafa07620ac2ec.rlib --extern modtype=/home/mvs/dev/wsprspots/target/debug/deps/libmodtype-e0d3136fe7f906b6.rlib --extern num_derive=/home/mvs/dev/wsprspots/target/debug/deps/libnum_derive-b4389402009fb568.so --extern num_traits=/home/mvs/dev/wsprspots/target/debug/deps/libnum_traits-a8f43e054a44200b.rlib --extern unicase=/home/mvs/dev/wsprspots/target/debug/deps/libunicase-8061b82d10a13ade.rlib`
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1511:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (a62a76047 2021-01-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `wsprspots`

Caused by:
  process didn't exit successfully: `rustc --crate-name wsprspots --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=5a5ee821a8682d77 -C extra-filename=-5a5ee821a8682d77 --out-dir /home/mvs/dev/wsprspots/target/debug/deps -C incremental=/home/mvs/dev/wsprspots/target/debug/incremental -L dependency=/home/mvs/dev/wsprspots/target/debug/deps --extern chrono=/home/mvs/dev/wsprspots/target/debug/deps/libchrono-17cafa07620ac2ec.rlib --extern modtype=/home/mvs/dev/wsprspots/target/debug/deps/libmodtype-e0d3136fe7f906b6.rlib --extern num_derive=/home/mvs/dev/wsprspots/target/debug/deps/libnum_derive-b4389402009fb568.so --extern num_traits=/home/mvs/dev/wsprspots/target/debug/deps/libnum_traits-a8f43e054a44200b.rlib --extern unicase=/home/mvs/dev/wsprspots/target/debug/deps/libunicase-8061b82d10a13ade.rlib` (exit code: 101)
Backtrace

stack backtrace:
   0:     0x6c74e9295ac7 - std::backtrace_rs::backtrace::libunwind::trace::h8bc78f7bc1f75bdb
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x6c74e9295ac7 - std::backtrace_rs::backtrace::trace_unsynchronized::ha4c961c9576f95ba
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x6c74e9295ac7 - std::sys_common::backtrace::_print_fmt::hc20cfdc233d6eb02
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x6c74e9295ac7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h04bea14549780a0f
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x6c74e930668c - core::fmt::write::h3868db8542c90941
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/core/src/fmt/mod.rs:1078:17
   5:     0x6c74e9287912 - std::io::Write::write_fmt::h55dd75636eef6a5c
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/io/mod.rs:1518:15
   6:     0x6c74e9299795 - std::sys_common::backtrace::_print::h6439e8525077c7da
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x6c74e9299795 - std::sys_common::backtrace::print::h02b685f728ce3931
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x6c74e9299795 - std::panicking::default_hook::{{closure}}::h7c29625065fafae1
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/panicking.rs:208:50
   9:     0x6c74e92992f3 - std::panicking::default_hook::hba441710bb71f4d5
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/panicking.rs:225:9
  10:     0x6c74e9b025fb - rustc_driver::report_ice::hbf489e015c4ca80e
  11:     0x6c74e929a096 - std::panicking::rust_panic_with_hook::ha936eb00e51bc4d9
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/panicking.rs:595:17
  12:     0x6c74e9299b87 - std::panicking::begin_panic_handler::{{closure}}::hcd15140e0238536e
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/panicking.rs:495:13
  13:     0x6c74e9295f8c - std::sys_common::backtrace::__rust_end_short_backtrace::hb13a021bb64823a1
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x6c74e9299b19 - rust_begin_unwind
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/panicking.rs:493:5
  15:     0x6c74e9302aa1 - core::panicking::panic_fmt::h20225113c4a2f8fd
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/core/src/panicking.rs:92:14
  16:     0x6c74e93029ed - core::panicking::panic::h35b77276aa4b0c12
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/core/src/panicking.rs:50:5
  17:     0x6c74ebe475b7 - rustc_span::SourceFile::lookup_file_pos::hca092a67fb0031d9
  18:     0x6c74ebe4766c - rustc_span::SourceFile::lookup_file_pos_with_col_display::h3585daf91a74d168
  19:     0x6c74ebe45431 - rustc_span::source_map::SourceMap::lookup_char_pos::hc2c23ee4eeedf37d
  20:     0x6c74eb2f1365 - rustc_errors::emitter::EmitterWriter::get_multispan_max_line_num::h64494719c5f79210
  21:     0x6c74eb2eed8e - <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic::h73ba5da66cba0737
  22:     0x6c74eb306520 - rustc_errors::json::Diagnostic::from_errors_diagnostic::h532f5d6f5adb4036
  23:     0x6c74eb30601a - <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic::h0fcfeff719ad096f
  24:     0x6c74ecab0b48 - rustc_errors::HandlerInner::emit_diagnostic::he36ed20f4ba26d16
  25:     0x6c74ecaae2ce - rustc_errors::diagnostic_builder::DiagnosticBuilder::emit::h4eae571a83ebb272
  26:     0x6c74ec14ed01 - rustc_builtin_macros::format::expand_preparsed_format_args::h162948f004210a17
  27:     0x6c74ec149695 - rustc_builtin_macros::format::expand_format_args_impl::h0e2d30ee8f53180f
  28:     0x6c74ebaf72ce - rustc_expand::expand::MacroExpander::fully_expand_fragment::hc2657998420a5860
  29:     0x6c74ec690f23 - rustc_expand::expand::MacroExpander::expand_crate::h25e62317ccfc4352
  30:     0x6c74ebec3a9c - rustc_session::utils::<impl rustc_session::session::Session>::time::h4cf203ed483bf6d5
  31:     0x6c74ebed6d6c - rustc_interface::passes::configure_and_expand_inner::h4a06f884f895ae41
  32:     0x6c74ebecd595 - rustc_interface::passes::configure_and_expand::{{closure}}::h9dc312976a6db7c5
  33:     0x6c74ebec6c8d - rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new::h10289f175e99384e
  34:     0x6c74ebed63fb - rustc_interface::passes::configure_and_expand::h98b27d9bf6bf3cc2
  35:     0x6c74ebeeb01d - rustc_interface::queries::Queries::expansion::hdb40485aaf20247f
  36:     0x6c74ebe84b40 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h218ca720d3205e5f
  37:     0x6c74ebe7a904 - rustc_span::with_source_map::h4befef2d05638fd3
  38:     0x6c74ebe85fea - rustc_interface::interface::create_compiler_and_run::h590e12a25d2eb81f
  39:     0x6c74ebe7b157 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf43b1d3900929834
  40:     0x6c74ebe5fbaa - core::ops::function::FnOnce::call_once{{vtable.shim}}::hd515068460c27675
  41:     0x6c74e92aa2ba - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8ffdf8dc1f37e360
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/alloc/src/boxed.rs:1484:9
  42:     0x6c74e92aa2ba - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h74f6ec149ce6acc8
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/alloc/src/boxed.rs:1484:9
  43:     0x6c74e92aa2ba - std::sys::unix::thread::Thread::new::thread_start::h565bef3956c58d58
                               at /rustc/a62a76047ea24aad7639f14eb3ce0e620b77bdb7/library/std/src/sys/unix/thread.rs:71:17
  44:     0x6c74e91bb526 - <unknown>
  45:     0x6c74e90d5d63 - clone
  46:                0x0 - <unknown>

@illdefined illdefined added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 14, 2021
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 14, 2021
@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 14, 2021
@apiraino
Copy link
Contributor

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@ojeda
Copy link
Contributor

ojeda commented Jan 14, 2021

It also breaks stable. Reduced:

fn f() {
    format!("→{} \t")
}

JohnTitor added a commit to JohnTitor/glacier that referenced this issue Jan 15, 2021
JohnTitor added a commit to JohnTitor/glacier that referenced this issue Jan 15, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 15, 2021
@osa1
Copy link
Contributor

osa1 commented Jan 16, 2021

Fix at #81071

osa1 added a commit to osa1/rust that referenced this issue Jan 16, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this issue Jan 16, 2021
rustc_parse_format: Fix character indices in find_skips

Fixes rust-lang#81006
@osa1
Copy link
Contributor

osa1 commented Jan 17, 2021

The fix is in, should we close this?

@tesuji
Copy link
Contributor

tesuji commented Jan 17, 2021

The issue will be closed when the patch landed.

m-ou-se added a commit to m-ou-se/rust that referenced this issue Jan 17, 2021
rustc_parse_format: Fix character indices in find_skips

Fixes rust-lang#81006
@bors bors closed this as completed in 9111e9d Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants