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

broken mir with -Zvalidate-mir #79066

Closed
matthiaskrgr opened this issue Nov 15, 2020 · 1 comment · Fixed by #79193
Closed

broken mir with -Zvalidate-mir #79066

matthiaskrgr opened this issue Nov 15, 2020 · 1 comment · Fixed by #79193
Labels
-Zvalidate-mir Unstable option: MIR validation A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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

@matthiaskrgr
Copy link
Member

I think all of these happen since #78969

Code

./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs

// check-pass
// compile-flags: --emit=mir,link
// Force mir to be emitted, to ensure that const
// propagation doesn't ICE on a function
// with an 'impossible' body. See issue #67696
// Inconsistent bounds with trait implementations

#![feature(trivial_bounds)]
#![allow(unused)]

trait A {
    fn foo(&self) -> Self where Self: Copy;
}

impl A for str {
    fn foo(&self) -> Self where Self: Copy { *"" }
}

impl A for i32 {
    fn foo(&self) -> Self { 3 }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (75042566d 2020-11-15)
binary: rustc
commit-hash: 75042566d1c90d912f22e4db43b6d3af98447986
commit-date: 2020-11-15
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (input to phase Const) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (after CheckPackedRef in phase Const) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (after CheckConstItemMutation in phase Const) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (after FunctionItemReferences in phase Const) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (after SimplifyCfg-initial in phase Const) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (after SanityCheck in phase Const) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (input to phase ConstPromotion) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (after PromoteTemps in phase ConstPromotion) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:6 ~ trivial_bounds_inconsistent_associated_functions[317d]::{impl#0}::foo), const_param_did: None }) (after SimplifyCfg-promote-consts in phase ConstPromotion) at bb0[2]:
`Operand::Copy` with non-`Copy` type str
  --> ./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs:16:46
   |
16 |     fn foo(&self) -> Self where Self: Copy { *"" }
   |                                              ^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:121: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.50.0-nightly (75042566d 2020-11-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z validate-mir

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:     0x7fe3adac99a0 - std::backtrace_rs::backtrace::libunwind::trace::h448c56741b6011d3
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
   1:     0x7fe3adac99a0 - std::backtrace_rs::backtrace::trace_unsynchronized::h2d26397c5720fdbb
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe3adac99a0 - std::sys_common::backtrace::_print_fmt::h720a2f61f75b9f58
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fe3adac99a0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8d62bbfda6d5c836
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fe3adb3ad5c - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/core/src/fmt/mod.rs:1078:17
   5:     0x7fe3adabb602 - std::io::Write::write_fmt::h16a9fe7680ac245c
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/io/mod.rs:1521:15
   6:     0x7fe3adacea05 - std::sys_common::backtrace::_print::h9ba51a6db618de7d
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fe3adacea05 - std::sys_common::backtrace::print::h5f20e41c85e91716
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fe3adacea05 - std::panicking::default_hook::{{closure}}::h5b7294ca19e8edab
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/panicking.rs:208:50
   9:     0x7fe3adace6a8 - std::panicking::default_hook::hb3948d1f74b6ff4c
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/panicking.rs:227:9
  10:     0x7fe3ae3ae9d8 - rustc_driver::report_ice::h7d9ce14184308134
  11:     0x7fe3adacf306 - std::panicking::rust_panic_with_hook::h55d23fef0ad751bc
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/panicking.rs:597:17
  12:     0x7fe3adacee27 - std::panicking::begin_panic_handler::{{closure}}::h56ae74c6dea6e141
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/panicking.rs:499:13
  13:     0x7fe3adac9e3c - std::sys_common::backtrace::__rust_end_short_backtrace::h3c4721f56689fae4
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fe3adaced89 - rust_begin_unwind
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/panicking.rs:495:5
  15:     0x7fe3adaced3b - std::panicking::begin_panic_fmt::h447a9fe10c3ac155
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/panicking.rs:437:5
  16:     0x7fe3b145a571 - rustc_errors::HandlerInner::flush_delayed::h378d929150a8afde
  17:     0x7fe3b1456911 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::he9417dbf073870c1
  18:     0x7fe3ae39d646 - core::ptr::drop_in_place::hcca6b73a46593a76
  19:     0x7fe3ae3995c1 - core::ptr::drop_in_place::h8e4d07c90ff848eb
  20:     0x7fe3ae3a2496 - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hc074b46388eddb39
  21:     0x7fe3ae3b990d - core::ptr::drop_in_place::hbbb827a2ac85e252
  22:     0x7fe3ae3b1123 - rustc_span::with_source_map::h29633e90c8bdca16
  23:     0x7fe3ae3c4632 - rustc_interface::interface::create_compiler_and_run::h646ae36fd2c94a87
  24:     0x7fe3ae3b21ea - rustc_span::with_session_globals::hda575f9d899f5c60
  25:     0x7fe3ae3c9eaf - std::sys_common::backtrace::__rust_begin_short_backtrace::hc0d91feb93491fb8
  26:     0x7fe3ae32f218 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h425334629854e612
  27:     0x7fe3adadf2aa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9e7afb7a0a438236
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/alloc/src/boxed.rs:1307:9
  28:     0x7fe3adadf2aa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70c646c4271337a1
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/alloc/src/boxed.rs:1307:9
  29:     0x7fe3adadf2aa - std::sys::unix::thread::Thread::new::thread_start::h35d2b8d36f210d02
                               at /rustc/75042566d1c90d912f22e4db43b6d3af98447986/library/std/src/sys/unix/thread.rs:71:17
  30:     0x7fe3ad9d83e9 - start_thread
  31:     0x7fe3ad8f5293 - __GI___clone
  32:                0x0 - <unknown>

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.50.0-nightly (75042566d 2020-11-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z validate-mir

query stack during panic:
end of query stack

The following samples also did not crash with -Zvalidate-mir with rustc 1.50.0-nightly (98d66340d 2020-11-14) but do crash with rustc 1.50.0-nightly (75042566d 2020-11-15)

./src/test/ui/consts/issue-67696-const-prop-ice.rs

// check-pass
// compile-flags: --emit=mir,link
// Checks that we don't ICE due to attempting to run const prop
// on a function with unsatisifable 'where' clauses

#![allow(unused)]

trait A {
    fn foo(&self) -> Self where Self: Copy;
}

impl A for [fn(&())] {
    fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) }
}

impl A for i32 {
    fn foo(&self) -> Self { 3 }
}

fn main() {}

./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-well-formed.rs

// run-pass
// Test that inconsistent bounds are used in well-formedness checks
#![feature(trivial_bounds)]

use std::fmt::Debug;

pub fn foo() where Vec<str>: Debug, str: Copy {
    //~^ WARNING Debug does not depend on any type or lifetime
    //~| WARNING Copy does not depend on any type or lifetime
    let x = vec![*"1"];
    println!("{:?}", x);
}

fn main() {}

./src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs

// check-pass
// Check tautalogically false `Copy` bounds
#![feature(trivial_bounds)]

fn copy_string(t: String) -> String where String: Copy { //~ WARNING trivial_bounds
    is_copy(&t);
    let x = t;
    drop(t);
    t
}

fn copy_out_string(t: &String) -> String where String: Copy { //~ WARNING trivial_bounds
    *t
}

fn copy_string_with_param<T>(x: String) where String: Copy { //~ WARNING trivial_bounds
    let y = x;
    let z = x;
}

// Check that no reborrowing occurs
fn copy_mut<'a>(t: &&'a mut i32) -> &'a mut i32 where for<'b> &'b mut i32: Copy {
    //~^ WARNING trivial_bounds
    is_copy(t);
    let x = *t;
    drop(x);
    x
}

fn is_copy<T: Copy>(t: &T) {}


fn main() {}
@matthiaskrgr matthiaskrgr 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 15, 2020
@jonas-schievink jonas-schievink added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html -Zvalidate-mir Unstable option: MIR validation labels Nov 15, 2020
@jonas-schievink
Copy link
Contributor

cc @tmiasko

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 19, 2020
…avidtwco

Revert rust-lang#78969 "Normalize function type during validation"

Closes rust-lang#79066.
Reopens rust-lang#78442.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 19, 2020
…avidtwco

Revert rust-lang#78969 "Normalize function type during validation"

Closes rust-lang#79066.
Reopens rust-lang#78442.
@bors bors closed this as completed in 084fc29 Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zvalidate-mir Unstable option: MIR validation A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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

Successfully merging a pull request may close this issue.

2 participants