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

ICE: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after InstCombine in phase Optimization) at bb0[2]: Operand::Copy with non-Copy type &i32 #78806

Closed
chengniansun opened this issue Nov 6, 2020 · 10 comments
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

#![feature(no_core, lang_items)]
#![no_core]
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[no_mangle]
fn test() {
    &1;
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (9d78d1d02 2020-11-05)
binary: rustc
commit-hash: 9d78d1d02761b906038ba4d54c5f3427f920f5fb
commit-date: 2020-11-05
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after InstCombine in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after ConstProp in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after SimplifyBranches-after-const-prop in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after EarlyOtherwiseBranch in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after SimplifyComparisonIntegral in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after SimplifyArmIdentity in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after SimplifyBranchSame in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after DestinationPropagation in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after SimplifyBranches-final in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after RemoveNoopLandingPads in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after SimplifyCfg-final in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ reduced_mutant[8787]::test), const_param_did: None }) (after RenameReturnPlace in phase Optimization) at bb0[2]:
`Operand::Copy` with non-`Copy` type &i32
 --> reduced_mutant.rs:9:5
  |
9 |     &1;
  |     ^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:171:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:974:13
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.49.0-nightly (9d78d1d02 2020-11-05) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=1 -Z new-llvm-pass-manager=yes -Z unsound-mir-opts=yes -Z verify-llvm-ir=yes -Z validate-mir=yes -Z polonius=yes -Z polymorphize=yes -C debuginfo=2 -C opt-level=1 --crate-type staticlib

query stack during panic:
end of query stack
Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:974:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d78d1d02761b906038ba4d54c5f3427f920f5fb/library/std/src/panicking.rs:495:5
   1: std::panicking::begin_panic_fmt
             at /rustc/9d78d1d02761b906038ba4d54c5f3427f920f5fb/library/std/src/panicking.rs:437:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place
   5: core::ptr::drop_in_place
   6: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place
   8: rustc_span::with_source_map
   9: rustc_interface::interface::create_compiler_and_run
  10: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses

@chengniansun chengniansun 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 Nov 6, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Nov 8, 2020
@camelid camelid added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 10, 2020
@tmiasko
Copy link
Contributor

tmiasko commented Nov 10, 2020

The InstCombine transformation operates under assumption that &T will implement Copy trait. The code example uses a custom core (#![no_core] feature) which does not provide such implementation, which is subsequently detected by MIR validator -Zvalidate-mir. I would consider this to be essentially an unsupported configuration and not a bug.

I would recommend generating test cases without #![no_core] or #[lang = ...], those are implementation details of standard library that will likely lead to bugs of limited practical significance.

@camelid
Copy link
Member

camelid commented Nov 10, 2020

Also: @chengniansun I am not able to reproduce this ICE on the latest nightly. What command are you running, and can you still reproduce this?

EDIT: Oops, I missed that this was explicitly running the MIR validator. It would be great if you could mention that in the summary in the future!

@camelid
Copy link
Member

camelid commented Nov 11, 2020

Note that the MIR validator only fails with #[no_mangle], which seems pretty bizarre.

@jonas-schievink
Copy link
Contributor

#[no_mangle] triggers codegen, which requests the optimized MIR

@jonas-schievink
Copy link
Contributor

This is #9307, so closing in favor of that

@camelid camelid removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 11, 2020
@camelid
Copy link
Member

camelid commented Nov 11, 2020

In case anyone's curious, this is the bisection:


searched nightlies: from nightly-2020-01-01 to nightly-2020-11-09
regressed nightly: nightly-2020-11-02
searched commits: from 4f7612a to b202532
regressed commit: a6403b0

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-apple-darwin
Reproduce with:

cargo bisect-rustc --preserve --regress=ice --start=2020-01-01 --end=2020-11-09 -- rustc -- -Zvalidate-mir 

However, the "regressed commit" is actually just a new MIR validation that was catching an existing bug, so it doesn't mean anything.

@chengniansun
Copy link
Author

Thanks, everyone, for the analysis.

I have disabled the validation of mir on my end in the future testing.

@camelid
Copy link
Member

camelid commented Nov 11, 2020

Well the MIR validator will still help you catch bugs, it's just that this particular bug is not significant because the code is somewhat bizarre.

@jonas-schievink
Copy link
Contributor

Yes, I'd rather suggest not using #[lang] attributes, since they often just lead to #9307 again, especially with automated testing.

@chengniansun
Copy link
Author

Thanks, @camelid and @jonas-schievink .

I will enable this flag later. Currently my testing infrastructure has some problems with extracting crash signatures from stderr. This mainly because the ICE message usually contains some details about the program under compilation, and I rely on crash signatures to cluster duplicates.

Moreover, sometimes, the ICE message and the panic message contains absolute paths of the source files in the rust compiler, such as /rustc/<hash code>/......./sty.rs.

When I address the problem above, I will enable this flag again.

Thank you for your advices. I learned something new today.

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) ❄️ 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