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 when pass some invalid format string by proc-macro #80224

Closed
Riey opened this issue Dec 20, 2020 · 8 comments
Closed

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

Riey opened this issue Dec 20, 2020 · 8 comments
Labels
A-proc-macros Area: Procedural macros 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.

Comments

@Riey
Copy link

Riey commented Dec 20, 2020

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.

@Riey Riey 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 Dec 20, 2020
@Riey
Copy link
Author

Riey commented Dec 20, 2020

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

@matthiaskrgr
Copy link
Member

Could be the same as cause as #80134

@camelid camelid added the A-proc-macros Area: Procedural macros label Dec 20, 2020
@camelid
Copy link
Member

camelid commented Dec 20, 2020

Hopefully will be fixed with #80185.

@fanninpm
Copy link

Does this still give an ICE with the latest nightly?

@camelid
Copy link
Member

camelid commented Feb 12, 2021

@fanninpm
Copy link

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

@Enselic
Copy link
Member

Enselic commented Sep 7, 2023

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

@Riey
Copy link
Author

Riey commented Sep 7, 2023

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

No, I think this issue is now fixed.

@Riey Riey closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macros Area: Procedural macros 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.
Projects
None yet
Development

No branches or pull requests

5 participants