Skip to content

Broken MIR (debug info?) with mir-opt-level=2 #66077

Closed
@RalfJung

Description

@RalfJung

Miri sometimes ICEs when printing the backtrace of a failure with mir-opt-level=2:

RUST_BACKTRACE=1 ./miri run tests/compile-fail/deallocate-twice.rs -Zmir-opt-level=2

gives

  15: core::panicking::panic_bounds_check
             at src/libcore/panicking.rs:96
  16: <usize as core::slice::SliceIndex<[T]>>::index
             at /rustc/cba93685377bc74a2fde1eb8e7a086039b038e94/src/libcore/slice/mod.rs:2796
  17: core::slice::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/cba93685377bc74a2fde1eb8e7a086039b038e94/src/libcore/slice/mod.rs:2647
  18: <alloc::vec::Vec<T> as core::ops::index::Index<I>>::index
             at /rustc/cba93685377bc74a2fde1eb8e7a086039b038e94/src/liballoc/vec.rs:1861
  19: <rustc_index::vec::IndexVec<I,T> as core::ops::index::Index<I>>::index
             at /rustc/cba93685377bc74a2fde1eb8e7a086039b038e94/src/librustc_index/vec.rs:740
  20: rustc_mir::interpret::eval_context::InterpCx<M>::generate_stacktrace
             at /rustc/cba93685377bc74a2fde1eb8e7a086039b038e94/src/librustc_mir/interpret/eval_context.rs:755
  21: miri::eval::eval_main
             at src/eval.rs:225
  22: <miri::MiriCompilerCalls as rustc_driver::Callbacks>::after_analysis::{{closure}}
             at src/bin/miri.rs:52

What happens here is that the following indexing operation is out-of-bounds:

mir::ClearCrossCrate::Set(ref ivs) => Some(ivs[source_info.scope].lint_root),

This looks like broken MIR to me.

(This is not a new error, but somehow it seems I did not report it when this started happening quite a while ago.)

Cc @oli-obk @eddyb @wesleywiser

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-testsuiteArea: The testsuite used to check the correctness of rustcT-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

    Issue actions