Repository navigation
MIR generator compiler panic #52792
Copy link
Copy link
Closed
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-coroutinesArea: CoroutinesArea: CoroutinesI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Description
error: internal compiler error: librustc_mir/transform/generator.rs:506: Broken MIR: generator contains type fidl_fuchsia_bluetooth::Status in MIR, but typeck only knows about for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8> {fidl_fuchsia_bluetooth_control::ControlRequestStream, std::sync::Arc<parking_lot::RwLock<control_service::ControlServiceState>>, futures::stream::Next<'r, fidl_fuchsia_bluetooth_control::ControlRequestStream>, std::mem::PinMut<'s, futures::stream::Next<'t0, fidl_fuchsia_bluetooth_control::ControlRequestStream>>, for<'t9, 't10> fn(&'t9 mut std::mem::PinMut<'t10, futures::stream::Next<'t1, fidl_fuchsia_bluetooth_control::ControlRequestStream>>) -> futures::Poll<<futures::stream::Next<'t1, fidl_fuchsia_bluetooth_control::ControlRequestStream> as futures::Future>::Output> {std::future::poll_in_task_cx::<futures::stream::Next<'t1, fidl_fuchsia_bluetooth_control::ControlRequestStream>>}, &'t2 mut std::mem::PinMut<'t3, futures::stream::Next<'t4, fidl_fuchsia_bluetooth_control::ControlRequestStream>>, futures::Poll<std::option::Option<std::result::Result<fidl_fuchsia_bluetooth_control::ControlRequest, fidl::Error>>>, (), std::option::Option<std::result::Result<fidl_fuchsia_bluetooth_control::ControlRequest, fidl::Error>>, std::result::Result<fidl_fuchsia_bluetooth_control::ControlRequest, fidl::Error>, fn(std::result::Result<fidl_fuchsia_bluetooth_control::ControlRequest, fidl::Error>) -> std::result::Result<<std::result::Result<fidl_fuchsia_bluetooth_control::ControlRequest, fidl::Error> as std::ops::Try>::Ok, <std::result::Result<fidl_fuchsia_bluetooth_control::ControlRequest, fidl::Error> as std::ops::Try>::Error> {<std::result::Result<fidl_fuchsia_bluetooth_control::ControlRequest, fidl::Error> as std::ops::Try>::into_result}, fidl_fuchsia_bluetooth_control::ControlRequest, std::string::String, fidl_fuchsia_bluetooth_control::ControlConnectResponder, fidl_fuchsia_bluetooth_control::ControlIsBluetoothAvailableResponder, std::option::Option<fidl::endpoints2::ClientEnd<fidl_fuchsia_bluetooth_control::PairingDelegateMarker>>, fidl_fuchsia_bluetooth_control::ControlSetPairingDelegateResponder, fidl_fuchsia_bluetooth_control::ControlGetAdaptersResponder, fidl_fuchsia_bluetooth_control::ControlSetActiveAdapterResponder, bool, fidl_fuchsia_bluetooth_control::ControlRequestDiscoveryResponder, fidl_fuchsia_bluetooth_control::ControlGetKnownRemoteDevicesResponder, fidl_fuchsia_bluetooth_control::ControlGetActiveAdapterInfoResponder, std::option::Option<std::string::String>, fidl_fuchsia_bluetooth_control::ControlSetNameResponder, parking_lot::RwLockWriteGuard<'t5, control_service::ControlServiceState>, fn(std::result::Result<fidl_fuchsia_bluetooth::Status, fidl::Error>) -> std::result::Result<<std::result::Result<fidl_fuchsia_bluetooth::Status, fidl::Error> as std::ops::Try>::Ok, <std::result::Result<fidl_fuchsia_bluetooth::Status, fidl::Error> as std::ops::Try>::Error> {<std::result::Result<fidl_fuchsia_bluetooth::Status, fidl::Error> as std::ops::Try>::into_result}, impl futures::Future, std::mem::PinMut<'t6, impl futures::Future>, for<'t9, 't10> fn(&'t9 mut std::mem::PinMut<'t10, impl futures::Future>) -> futures::Poll<<impl futures::Future as futures::Future>::Output> {std::future::poll_in_task_cx::<impl futures::Future>}, &'t7 mut std::mem::PinMut<'t8, impl futures::Future>, futures::Poll<std::result::Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>}
--> src/control_service.rs:27:112
|
27 | pub async fn make_control_service(hd: Arc<RwLock<HostDispatcher>>, chan: fasync::Channel) -> Result<(), Error> {
| ________________________________________________________________________________________________________________^
28 | | let mut requests = ControlRequestStream::from_channel(chan);
29 | |
30 | | let state = Arc::new(RwLock::new(ControlServiceState {
... |
176 | | // .recover(|e| eprintln!("error running service: {:?}", e))
177 | | }
| |_^
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:518:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.29.0-dev running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C linker=/usr/local/google/home/bwb/fuchsia/buildtools/linux-x64/clang/bin/clang -C incremental -C link-arg=--target=x86_64-unknown-fuchsia -C link-arg=--sysroot=/usr/local/google/home/bwb/fuchsia/out/release-x64/sdks/zircon_sysroot/arch/x64/sysroot --crate-type bin
note: some of the compiler flags provided by cargo are hidden
Reacted by Taylor Cramer
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-coroutinesArea: CoroutinesArea: CoroutinesI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Activity
benbrittain commentedon Jul 27, 2018
cc @cramertj
cramertj commentedon Jul 27, 2018
cc @Zoxc
benbrittain commentedon Jul 27, 2018
cramertj commentedon Jul 30, 2018
@Zoxc I'm hitting this a lot at the moment-- any idea what the cause might be? I'd love to help get this resolved.
cramertj commentedon Jul 30, 2018
I'm sometimes able to fix it by moving conditions that
await!()out of the body of anif letexpression.cramertj commentedon Jul 30, 2018
It also seems to have regressed between a1e6bc and 866a71-- updating the compiler caused this to happen in more places.
cramertj commentedon Jul 30, 2018
Possibly related to #52597 ? cc @oli-obk
cramertj commentedon Jul 30, 2018
Trying to fix in more places and it looks like it's always related to
await!temporaries-- if I makelet x = await!(...);it and then usexin the place I was usingawait!(...)it usually solves the issue.cramertj commentedon Jul 30, 2018
Smaller example: (playground)
aturon commentedon Jul 30, 2018
cc @rust-lang/compiler @alexcrichton this is blocking roll out of async/await in Fuchsia
cramertj commentedon Jul 30, 2018
@Zoxc Looked at this and pointed out that it looks like typechecking thinks that
optisn't live at theyieldpoint (which is correct) but that MIR thinks it is live (which is incorrect). I tried searching through the diff to see if there were any related PRs, but so far the only thing I've found that touches MIR is #52597, which seems like it shouldn't be related.cramertj commentedon Jul 30, 2018
@cavedweller Is working on bisecting this.
Zoxc commentedon Jul 30, 2018
I think the problem is that
optis borrowed byis_some()and because of this the generator transformationonly uses
StorageLiveandStorageDeadstatements to calculate liveness. However we generate aStorageLivestatement foroptbefore its initialiser which contains theyieldstatement. Sooptappears live during theyieldstatement, even though its storage isn't used for anything.cramertj commentedon Jul 31, 2018
Bisection pointed to #52681 as the PR that made this worse (more code ICEs now), although the minimal test case still fails before and after. cc @pnkfelix
benbrittain commentedon Jul 31, 2018
minimal repro:
https://play.rust-lang.org/?gist=d1f01976c58de78d6d076af9c878ea8c&version=nightly&mode=debug&edition=2018
This ICE only surfaces after #52681
benbrittain commentedon Jul 31, 2018
using
.unwrap()instead of?makes the ICE "go away"eddyb commentedon Jul 31, 2018
@Zoxc Ah you need at the very least to use
StorageDeadand initializations, notStorageLive.AFAIK the type of a variable could be dead at a
StorageLive(lifetimes not ready yet).Arguably you could also have the time before moving out and a reinitialization also count as dead, e.g.
x = {yield x.into_iter().count(); x = vec![]; }doesn't really need to keepxalive.Rollup merge of rust-lang#52915 - Zoxc:refine-gen-borrow-analysis, r=…