Skip to content

ICE: index out of bounds in librustc_span/hygiene.rs possibly caused by LTO #71639

Closed
@Vlad-Shcherbina

Description

@Vlad-Shcherbina

To reproduce

Run the following commands:

git clone https://github.com/Vlad-Shcherbina/rusty_sand.git
cd rusty_sand
git checkout e8a2513
RUST_BACKTRACE=1 cargo build --release

Meta

rustc --version --verbose:

binary: rustc
commit-hash: 2d03399f53d28a8be645625376c0c9fbe601a01d
commit-date: 2020-04-27
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 30 but the index is 122', src/librustc_span/hygiene.rs:181:9
Backtrace

   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1504
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
  12: rust_begin_unwind
             at src/libstd/panicking.rs:385
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:89
  14: core::panicking::panic_bounds_check
             at src/libcore/panicking.rs:65
  15: rustc_span::hygiene::HygieneData::expn_data
  16: scoped_tls::ScopedKey<T>::with
  17: rustc_codegen_ssa::back::write::SharedEmitterMain::check
  18: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::join_codegen
  19: rustc_interface::queries::Linker::link
  20: rustc_interface::interface::run_compiler_in_existing_thread_pool
  21: scoped_tls::ScopedKey<T>::set
  22: rustc_ast::attr::with_globals

Speculation

This could be related to LTO, because the bug was triggered when I added

[profile.release]
codegen-units = 1
lto = true

to my Cargo.toml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)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.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions