Skip to content

Crash when pass some invalid format string by proc-macro #80224

@Riey

Description

@Riey

Code

use thiserror::Error;

#[derive(Debug, Error)]
pub enum LexicalError {
    #[error("{0.what}ㅇ")]
    InvalidCode(i32),
}

Meta

rustc 1.48.0 (7eac88a 2020-11-16)
binary: rustc
commit-hash: 7eac88a
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0

it also occured in nightly-2020-11-25

Error output

Compiling ice-example v0.1.0 (/home/riey/repos/ice-example)
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/source_map.rs:950:17
Backtrace

stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_span::source_map::SourceMap::bytepos_to_file_charpos
   2: rustc_span::source_map::SourceMap::lookup_char_pos
   3: rustc_errors::emitter::EmitterWriter::get_multispan_max_line_num
   4: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   5: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
   6: rustc_errors::HandlerInner::emit_diagnostic
   7: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
   8: rustc_builtin_macros::format::expand_preparsed_format_args
   9: rustc_builtin_macros::format::expand_format_args_impl
  10: rustc_expand::expand::MacroExpander::fully_expand_fragment
  11: rustc_expand::expand::MacroExpander::expand_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::configure_and_expand_inner
  14: rustc_interface::passes::configure_and_expand::{{closure}}
  15: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  16: rustc_interface::passes::configure_and_expand
  17: rustc_interface::queries::Queries::expansion
  18: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  19: rustc_span::with_source_map
  20: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.48.0 (7eac88abb 2020-11-16) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
error: could not compile `ice-example`

To learn more, run the command again with --verbose.

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Dec 20, 2020
Riey

Riey commented on Dec 20, 2020

@Riey
Author

I think generated code is look like this but it doesn't get ICE just compile error

matthiaskrgr

matthiaskrgr commented on Dec 20, 2020

@matthiaskrgr
Member

Could be the same as cause as #80134

camelid

camelid commented on Dec 20, 2020

@camelid
Member

Hopefully will be fixed with #80185.

fanninpm

fanninpm commented on Feb 11, 2021

@fanninpm

Does this still give an ICE with the latest nightly?

fanninpm

fanninpm commented on Feb 12, 2021

@fanninpm

@camelid Unfortunately, there's no straightforward way to add it to the glacier, as it depends on an external crate.

Enselic

Enselic commented on Sep 7, 2023

@Enselic
Member

Triage: The reproducer does not work any longer. Can you still reproduce this ICE?

Riey

Riey commented on Sep 7, 2023

@Riey
Author

Triage: The reproducer does not work any longer. Can you still reproduce this ICE?

No, I think this issue is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Enselic@matthiaskrgr@Riey@fanninpm@camelid

        Issue actions

          Crash when pass some invalid format string by proc-macro · Issue #80224 · rust-lang/rust