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 DefId" when assigning mismatched closure to FnMut #53448

Closed
earthengine opened this issue Aug 17, 2018 · 6 comments · Fixed by #77741
Closed

ICE: "broken MIR in DefId" when assigning mismatched closure to FnMut #53448

earthengine opened this issue Aug 17, 2018 · 6 comments · Fixed by #77741
Assignees
Labels
A-closures Area: Closures (`|…| { … }`) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-unboxed_closures `#![feature(unboxed_closures)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@earthengine
Copy link

earthengine commented Aug 17, 2018

The following code

#![feature(unboxed_closures)]

trait Lt<'a> {
    type T;
}
impl<'a> Lt<'a> for () {
    type T = ();
}

fn main() {
    let v:<() as Lt<'_>>::T = ();
    let f:&mut FnMut<(_,),Output=()> = &mut |_:<() as Lt<'_>>::T|{};
    f(v);
}

causes panic with message

cannot access a scoped thread local variable without calling `set` first

which is irrelevant to the code. Simply modify link_binary function in src\librustc_codegen_llvm\back\link.rs to make it panic before return, will then output some result that says

query stack during panic:
end of query stack
error: internal compiler error: broken MIR in DefId(0/0:7 ~ hrtb_fn_parameters[317d]::main[0]) (_7 = &mut (*_2)): bad assignment (&mut dyn std::ops::FnMut(()) = &mut dyn std::ops::FnMut(<() as Lt<'_>>::T)): NoSolution
  --> src/test\run-pass\hrtb-fn-parameters.rs:23:5
   |
23 |     f(v);
   |   

This is a variation of #53420 aka #29997, but is more serious and we should fix this first to make it at least emit the real error.

The proper fix of this issue, is NOT to make the code above compile; instead, it should give ICE with proper messages instead of something irrelevant so that we ensure we can get useful information from ICEs all the time, and the ICE is to be fixed after #53420 aka #29997.

@earthengine earthengine changed the title Compiler unexpected panic when MIRI verification fail in a certain situation ICE with code irrelevant message - cannot access a scoped thread local variable without calling set first Aug 22, 2018
@earthengine
Copy link
Author

earthengine commented Aug 31, 2018

New error messages after PR #53624 :

error: internal compiler error: broken MIR in DefId(0/0:7 ~ playground[3845]::main[0]) (_7 = &mut (*_2)): bad assignment (&mut dyn std::ops::FnMut(()) = &mut dyn std::ops::FnMut(<() as Lt<'_>>::T)): NoSolution
  --> src/main.rs:13:5
   |
13 |     f(v);
   | 

@oli-obk oli-obk added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Aug 31, 2018
@matthewjasper matthewjasper added A-NLL Area: Non-lexical lifetimes (NLL) NLL-complete Working towards the "valid code works" goal and removed NLL-complete Working towards the "valid code works" goal labels Sep 2, 2018
@matthewjasper
Copy link
Contributor

Marking with A-NLL since this is an issue with MIR typeck, even though this happens without nll.

@pnkfelix pnkfelix added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Sep 18, 2018
@pnkfelix
Copy link
Member

self-assigning for preliminary investigation

@pnkfelix pnkfelix self-assigned this Sep 18, 2018
@pnkfelix
Copy link
Member

Discussed with @nikomatsakis. He theorizes it is part of collection of bugs around normalization. Its not really an A-NLL thing. So I'm removing that label.

@pnkfelix pnkfelix removed the A-NLL Area: Non-lexical lifetimes (NLL) label Sep 25, 2018
@pnkfelix pnkfelix changed the title ICE with code irrelevant message - cannot access a scoped thread local variable without calling set first ICE: "broken MIR in DefId" when assigning mismatched closure to FnMut Oct 4, 2018
@pnkfelix
Copy link
Member

the bug described here should block any hypothetical stabilization of unbox closures, cc: #29625

but since that is an unstable feature, and the bug here seems isolated to people making use of that feature, I'm going to triage this as P-medium for now.

@pnkfelix pnkfelix added the P-medium Medium priority label May 17, 2019
@jonas-schievink jonas-schievink added A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. labels Aug 6, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Oct 25, 2019
@Centril Centril added the F-unboxed_closures `#![feature(unboxed_closures)]` label Nov 5, 2019
@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 7, 2020
@JohnTitor
Copy link
Member

Triage: This is no longer ICE with the latest nightly, marking as E-needs-test.

@bors bors closed this as completed in 5565241 Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-unboxed_closures `#![feature(unboxed_closures)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants