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: No move_errors should be allowed in MIR borrowck #70934

Closed
jurkstas opened this issue Apr 8, 2020 · 25 comments · Fixed by #71587
Closed

ICE: No move_errors should be allowed in MIR borrowck #70934

jurkstas opened this issue Apr 8, 2020 · 25 comments · Fixed by #71587
Assignees
Labels
A-borrow-checker Area: The borrow checker 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) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jurkstas
Copy link

jurkstas commented Apr 8, 2020

I get an ICE when I try to build evolvim:

error: internal compiler error: No `move_errors` should be allowed in MIR borrowck
   --> evolvim-lib\./src/lib\neat\genome\mod.rs:100:13
    |
100 |             InputType::Eye(EYE[2]).clone(),
    |             ^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: No `move_errors` should be allowed in MIR borrowck
  --> evolvim-lib\./src/lib\neat\genome\mod.rs:99:13
   |
99 |             InputType::Eye(EYE[1]).clone(),
   |             ^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: No `move_errors` should be allowed in MIR borrowck
  --> evolvim-lib\./src/lib\neat\genome\mod.rs:98:13
   |
98 |             InputType::Eye(EYE[0]).clone(),
   |             ^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src\librustc_errors\lib.rs:357:17
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSliceMut as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: <rustc_errors::snippet::Style as core::fmt::Debug>::fmt
   8: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   9: rustc_driver::pretty::print_after_hir_lowering
  10: rustc_driver::pretty::print_after_hir_lowering
  11: rustc_driver::pretty::print_after_hir_lowering
  12: rustc_driver::pretty::print_after_hir_lowering
  13: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  14: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  15: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  16: _rust_maybe_catch_panic
  17: rustc_driver::pretty::print_after_hir_lowering
  18: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  19: std::sys::windows::thread::Thread::new
  20: BaseThreadInitThunk
  21: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

I tried stable, beta and nightly. All ended with an ICE.

>rustc --version --verbose
rustc 1.42.0 (b8cedc004 2020-03-09)
binary: rustc
commit-hash: b8cedc00407a4c56a3bda1ed605c6fc166655447
commit-date: 2020-03-09
host: x86_64-pc-windows-msvc
release: 1.42.0
LLVM version: 9.0
@jonas-schievink
Copy link
Contributor

Important detail: Only happens on the develop branch, not master

@jonas-schievink jonas-schievink added A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-prioritize Issue: Indicates that prioritization has been requested for this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Apr 8, 2020
@jonas-schievink
Copy link
Contributor

(bisecting)

@jurkstas
Copy link
Author

jurkstas commented Apr 8, 2020

Important detail: Only happens on the develop branch, not master

It happens with master branch as well if I do cargo update before building. Without it, it fails due to nalgebra issue before it even gets to evolvim-lib.

@jonas-schievink
Copy link
Contributor

Ah, I see

@jonas-schievink
Copy link
Contributor

regression in nightly-2019-08-17

f7af19c...bdfd698

@spastorino
Copy link
Member

@jonas-schievink great :). Unsure if you're bisecting this further, anyway pinging cleanup crew in case you are not doing it further and also to see if someone is able to get an mcve.

@rustbot ping cleanup

@rustbot
Copy link
Collaborator

rustbot commented Apr 8, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Apr 8, 2020
@jonas-schievink
Copy link
Contributor

There don't seem to be any prebuilt artifacts for that commit range, so I've stopped there.

@spastorino spastorino added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Apr 8, 2020
@spastorino
Copy link
Member

Assigning P-high meanwhile we don't have an mcve as discussed as part of WG-prioritization procedure.

@spastorino spastorino added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 9, 2020
@steffahn
Copy link
Member

steffahn commented Apr 10, 2020

pub fn f() -> () {
    const C: [S2; 1] = [S2];
    let _ = S1(C[0]).clone();
}

#[derive(Clone)]
pub struct S1(S2);

#[derive(Clone)]
pub struct S2;

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: No `move_errors` should be allowed in MIR borrowck
 --> src/lib.rs:3:13
  |
3 |     let _ = S1(C[0]).clone();
  |             ^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:357:17
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0 (b8cedc004 2020-03-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: could not compile `playground`.

To learn more, run the command again with --verbose.

@rustbot modify labels to -E-needs-mcve

@rustbot rustbot removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 10, 2020
@steffahn
Copy link
Member

steffahn commented Apr 10, 2020

The reduced example regresses at nightly-2019-09-29 (084beb8..488381c).

Edit2: For me, evolvim (develop branch) regresses on that nightly, too.


Edit:
I was trying to be more precise with git bisect. Weirdly, when compiling rustc myself, the regression only appeared around 2019-11-14 or so. For reference, see my results in detail below (with a few notes inserted), according to which f4edc81 and 997feac seem to be relevant. Interestingly, these appear to contain the jump of rustc version from 1.40.0-dev to 1.41.0-dev. I also couldn’t help but notice the commit message of 8783766 which makes me doubt that this bisection is leading anywhere.

git log after bisection
commit 0f12bad718bb8b1fb2b1b7267a02fffaef6e1e3c (HEAD) <- *Note*: this one also tested "bad"
Merge: a333eed7fc0 994d83666de
Author: bors <bors@rust-lang.org>
Date:   Wed Nov 13 00:42:19 2019 +0000

    Auto merge of #66156 - Mark-Simulacrum:stage0-step, r=pietroalbini
    
    Stage0 step
    
    r? @pietroalbini

commit 994d83666defc0cc6b0fde305d164fbf23433114
Author: Mark Rousskov <mark.simulacrum@gmail.com>
Date:   Tue Nov 12 16:37:22 2019 -0500

    Remove no longer needed mutability

commit f6832adadb84364ce0c81fa02910b3706f441abc
Author: Mark Rousskov <mark.simulacrum@gmail.com>
Date:   Wed Nov 6 15:17:02 2019 -0500

    Compiletest bump to stage0 bootstrap libtest

commit 8783766215c28a98eeb0487d865b8afa0ada797c
Author: Mark Rousskov <mark.simulacrum@gmail.com>
Date:   Tue Nov 5 11:16:46 2019 -0500

    Hopefully fix rustdoc build
    
    It's super unclear why this broke when we switched to beta but not
    previously -- but at least it's hopefully fixed now.

commit 997feacddd8f6e98003428265c665f7149c49a48 (refs/bisect/bad)
Author: Mark Rousskov <mark.simulacrum@gmail.com>
Date:   Wed Nov 6 08:09:55 2019 -0500

    Snap cfgs

commit f4edc81ac4944c2cd59e19fd90861a26dde94041 <- *Note*: does not compile!
Author: Mark Rousskov <mark.simulacrum@gmail.com>
Date:   Wed Nov 6 08:01:56 2019 -0500

    Bump version to 1.41

commit a333eed7fc0c903df9d6befcfb40af02148bf255 (refs/bisect/good-a333eed7fc0c903df9d6befcfb40af02148bf255)
Merge: 4f03f4a989d b4545a4ad62
Author: bors <bors@rust-lang.org>
Date:   Tue Nov 12 21:27:04 2019 +0000

    Auto merge of #60026 - Aaron1011:feature/miri-unwind, r=RalfJung,oli-obk
    
    Add hooks for Miri panic unwinding
    
    This commits adds in some additional hooks to allow Miri to properly
    handle panic unwinding. None of this should have any impact on CTFE mode
    
    This supports https://github.com/rust-lang/miri/pull/693

commit 4f03f4a989d1c8346c19dfb417a77c09b34408b8 (refs/bisect/good-4f03f4a989d1c8346c19dfb417a77c09b34408b8)
Merge: 5dda3ee9314 4bf0685cca1
Author: bors <bors@rust-lang.org>
Date:   Tue Nov 12 18:02:54 2019 +0000

    Auto merge of #65608 - matthewjasper:mir-eval-order, r=pnkfelix
    
    Fix MIR lowering evaluation order and soundness bug
    
    * Fixes a soundness issue with built-in index operations
    * Ensures correct evaluation order of assignment expressions where the RHS is a FRU or is a use of a local of reference type.
    * Removes an unnecessary symbol to string conversion
    
    closes #65909
    closes #65910

Edit3: Damn it, recompiling rustc didn’t make cargo realize that the code had to be recompiled and I didn’t really notice that it had just skipped compilation entirely all the time.

@steffahn
Copy link
Member

steffahn commented Apr 10, 2020

Even smaller:

struct S;

fn main() {
    &([S][0],);
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: No `move_errors` should be allowed in MIR borrowck
 --> src/main.rs:4:5
  |
4 |     &([S][0],);
  |     ^^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:357:17
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0 (b8cedc004 2020-03-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: could not compile `playground`.

To learn more, run the command again with --verbose.

@steffahn
Copy link
Member

regression in commit dfd365f (part of #64790)
cc @Centril
@rustbot modify labels: -E-needs-bisection

@rustbot rustbot removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Apr 11, 2020
@rustbot

This comment has been minimized.

1 similar comment
@rustbot

This comment has been minimized.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 11, 2020
@Mark-Simulacrum

This comment has been minimized.

@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 11, 2020
@Mark-Simulacrum

This comment has been minimized.

@rustbot

This comment has been minimized.

@Mark-Simulacrum Mark-Simulacrum removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 11, 2020
@Mark-Simulacrum

This comment has been minimized.

@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 11, 2020
@Centril
Copy link
Contributor

Centril commented Apr 13, 2020

Looks like this compiles but it shouldn't:

struct S;

fn foo() {
    &([S][0],);
}

Dumping the MIR for this you get:

fn  foo() -> () {
    let mut _0: ();                      // return place in scope 0 at src/lib.rs:3:10: 3:10
    let _1: &(S,);                       // in scope 0 at src/lib.rs:4:5: 4:15
    let mut _2: &(S,);                   // in scope 0 at src/lib.rs:4:5: 4:15

    bb0: {
        StorageLive(_1);                 // bb0[0]: scope 0 at src/lib.rs:4:5: 4:15
        _2 = const foo::promoted[0];     // bb0[1]: scope 0 at src/lib.rs:4:5: 4:15
                                         // ty::Const
                                         // + ty: &(S,)
                                         // + val: Unevaluated(DefId(0:5 ~ playground[4e22]::foo[0]), [], Some(promoted[0]))
                                         // mir::Constant
                                         // + span: src/lib.rs:4:5: 4:15
                                         // + literal: Const { ty: &(S,), val: Unevaluated(DefId(0:5 ~ playground[4e22]::foo[0]), [], Some(promoted[0])) }
        _1 = _2;                         // bb0[2]: scope 0 at src/lib.rs:4:5: 4:15
        StorageDead(_1);                 // bb0[3]: scope 0 at src/lib.rs:4:15: 4:16
        return;                          // bb0[4]: scope 0 at src/lib.rs:5:2: 5:2
    }
}

promoted[0] in  foo: &(S,) = {
    let mut _0: &(S,);                   // return place in scope 0 at src/lib.rs:4:5: 4:15
    let mut _1: (S,);                    // in scope 0 at src/lib.rs:4:6: 4:15
    let mut _2: S;                       // in scope 0 at src/lib.rs:4:7: 4:13
    let mut _3: [S; 1];                  // in scope 0 at src/lib.rs:4:7: 4:10
    let mut _4: S;                       // in scope 0 at src/lib.rs:4:8: 4:9
    let mut _5: usize;                   // in scope 0 at src/lib.rs:4:11: 4:12

    bb0: {
        _3 = [move _4];                  // bb0[0]: scope 0 at src/lib.rs:4:7: 4:10
        _5 = const 0usize;               // bb0[1]: scope 0 at src/lib.rs:4:11: 4:12
                                         // ty::Const
                                         // + ty: usize
                                         // + val: Value(Scalar(0x0000000000000000))
                                         // mir::Constant
                                         // + span: src/lib.rs:4:11: 4:12
                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
        _2 = move _3[_5];                // bb0[2]: scope 0 at src/lib.rs:4:7: 4:13
        (_1.0: S) = move _2;             // bb0[3]: scope 0 at src/lib.rs:4:6: 4:15
        _0 = &_1;                        // bb0[4]: scope 0 at src/lib.rs:4:5: 4:15
        return;                          // bb0[5]: scope 0 at src/lib.rs:4:5: 4:15
    }
}

Presumably, what should happen here is:

error[E0508]: cannot move out of type `[S; 1]`, a non-copy array
 --> src/lib.rs:4:6
  |
4 |    &([S][0],);
  |      ^^^^^^
  |      |
  |      cannot move out of here
  |      move occurs because value has type `S`, which does not implement the `Copy` trait

The delay_span_bug occurs here:

impl<'tcx> MirPass<'tcx> for ElaborateDrops {
    fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
        debug!("elaborate_drops({:?} @ {:?})", src, body.span);

        let def_id = src.def_id();
        let param_env = tcx.param_env(src.def_id()).with_reveal_all();
        let move_data = match MoveData::gather_moves(body, tcx, param_env) {
            Ok(move_data) => move_data,
            Err((move_data, _)) => {
                tcx.sess.delay_span_bug(
                    body.span,
                    "No `move_errors` should be allowed in MIR borrowck",
                );
                move_data
            }
        };

cc @oli-obk @matthewjasper

@spastorino
Copy link
Member

This issue is already prioritized as P-high removing I-prioritize label.

@spastorino spastorino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 13, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Apr 14, 2020

I guess we need to track down where error[E0508]: cannot move out of type [S; 1], a non-copy array is emitted and make that code also look at the MIR of promoteds.

We can't avoid that code from getting promoted without getting into an unfun game of whack-a-mole in the promotion code.

@Centril
Copy link
Contributor

Centril commented Apr 14, 2020

The error is constructed here:

/// Signal an error due to an attempt to move out of the interior
/// of an array or slice. `is_index` is None when error origin
/// didn't capture whether there was an indexing operation or not.
crate fn cannot_move_out_of_interior_noncopy(
&self,
move_from_span: Span,
ty: Ty<'_>,
is_index: Option<bool>,
) -> DiagnosticBuilder<'cx> {
let type_name = match (&ty.kind, is_index) {
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
(&ty::Slice(_), _) => "slice",
_ => span_bug!(move_from_span, "this path should not cause illegal move"),
};
let mut err = struct_span_err!(
self,
move_from_span,
E0508,
"cannot move out of type `{}`, a non-copy {}",
ty,
type_name,
);
err.span_label(move_from_span, "cannot move out of here");
err
}

which is called here:
self.cannot_move_out_of_interior_noncopy(span, ty, Some(*is_index))

and here:
self.cannot_move_out_of_interior_noncopy(span, ty, None)

@oli-obk
Copy link
Contributor

oli-obk commented Apr 14, 2020

hmmm... not sure what borrowck does to promoteds. I mean we basically declared all lifetimes to be static, but the same is true for the body of constants which we do run borrowck on. So... let's try to just run borrowck on promoteds and see how it goes.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 14, 2020

alternatively we just run the gather_moves logic on promoteds instead of full borrowck, as the latter may have a significant perf impact.

@matthewjasper matthewjasper self-assigned this Apr 19, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 4, 2020
… r=nikomatsakis

Report cannot move errors in promoted MIR

Closes rust-lang#70934
@bors bors closed this as completed in 4bde46e May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker 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) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

10 participants