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

MIR validation ICE: Use of local which has no storage #118990

Closed
saethlin opened this issue Dec 15, 2023 · 3 comments · Fixed by #119077
Closed

MIR validation ICE: Use of local which has no storage #118990

saethlin opened this issue Dec 15, 2023 · 3 comments · Fixed by #119077
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

@saethlin
Copy link
Member

saethlin commented Dec 15, 2023

struct CompileError;

impl Drop for CompileError {
    fn drop(&mut self) {}
}

impl CompileError {
    fn throw(&self) {}
}

fn main() {
    'code: {
        break 'code;
        CompileError.throw()
    };
}

Build with

-Zvalidate-mir
error: internal compiler error: broken MIR in Item(DefId(0:9 ~ ice[5cf9]::main)) (before pass CheckPackedRef) at bb4[0]:
                                use of local _3, which has no storage here
  --> src/main.rs:15:6
   |
15 |     };
   |      ^

// MIR for `main` after built

fn main() -> () {
    let mut _0: ();
    let _1: ();
    let mut _2: &CompileError;
    let _3: CompileError;

    bb0: {
        StorageLive(_1);
        _1 = const ();
        goto -> bb3;
    }

    bb1: {
        StorageLive(_2);
        StorageLive(_3);
        _3 = CompileError;
        _2 = &_3;
        _1 = CompileError::throw(move _2) -> [return: bb2, unwind: bb6];
    }

    bb2: {
        StorageDead(_2);
        goto -> bb4;
    }

    bb3: {
        goto -> bb4;
    }

    bb4: {
        drop(_3) -> [return: bb5, unwind: bb7];
    }

    bb5: {
        StorageDead(_3);
        StorageDead(_1);
        _0 = const ();
        return;
    }

    bb6 (cleanup): {
        drop(_3) -> [return: bb7, unwind terminate(cleanup)];
    }

    bb7 (cleanup): {
        resume;
    }
}
@saethlin saethlin added the C-bug Category: This is a bug. label Dec 15, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 15, 2023
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining labels Dec 15, 2023
@saethlin saethlin changed the title Use of local which has no storage in flexar 1.2.5 MIR validation ICE: Use of local which has no storage Dec 17, 2023
@tmiasko tmiasko added the -Zvalidate-mir Unstable option: MIR validation label Dec 17, 2023
@matthiaskrgr
Copy link
Member

Regression in nightly-2022-08-26

found 6 bors merge commits in the specified range
commit[0] 2022-08-24: Auto merge of #100963 - matthiaskrgr:rollup-pjr0lb3, r=matthiaskrgr
commit[1] 2022-08-24: Auto merge of #99946 - tmiasko:elide-storage-makers, r=oli-obk
commit[2] 2022-08-25: Auto merge of #100977 - JohnTitor:rollup-8hc7rxh, r=JohnTitor
commit[3] 2022-08-25: Auto merge of #100436 - jyn514:macro-query-system, r=cjgillot
commit[4] 2022-08-25: Auto merge of #100571 - cjgillot:mir-cost-visit, r=compiler-errors
commit[5] 2022-08-25: Auto merge of #100911 - tmiasko:update-stdarch, r=Amanieu
ERROR: no CI builds available between addacb5 and 7480389 within last 167 days

#99946 looks quite suspicious cc @tmiasko

@tmiasko
Copy link
Contributor

tmiasko commented Dec 18, 2023

@matthiaskrgr that bisection stopped at #![feature(label_break_value)] stabilization from #100977, didn't it?

@matthiaskrgr
Copy link
Member

good catch, with ! rustc /tmp/crash.rs -Zvalidate-mir -Zcrate-attr="feature(label_break_value)" |& grep -Ii "panic"
this bisects to

Regression in nightly-2020-11-02
commit[0] 2020-10-31: Auto merge of #78594 - m-ou-se:rollup-h5c8frs, r=m-ou-se
commit[1] 2020-11-01: Auto merge of #78147 - tmiasko:validate-storage, r=jonas-schievink
commit[2] 2020-11-01: Auto merge of #78420 - estebank:suggest-assoc-fn, r=petrochenkov
commit[3] 2020-11-01: Auto merge of #78531 - cuviper:unwrap-metadata, r=tmandry
commit[4] 2020-11-01: Auto merge of #78623 - m-ou-se:rollup-m6y5j0m, r=m-ou-se
commit[5] 2020-11-01: Auto merge of #78553 - Nadrieril:fix-78549, r=varkor
commit[6] 2020-11-01: Auto merge of #75534 - Aaron1011:feature/new-future-breakage, r=pnkfelix
ERROR: no CI builds available between 4f7612a and b202532 within last 167 days

so maybe #78147 ? :D

@bors bors closed this as completed in 7dd0955 Dec 23, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 23, 2023
Rollup merge of rust-lang#119077 - tmiasko:lint, r=cjgillot

Separate MIR lints from validation

Add a MIR lint pass, enabled with -Zlint-mir, which identifies undefined or
likely erroneous behaviour.

The initial implementation mostly migrates existing checks of this nature from
MIR validator, where they did not belong (those checks have false positives and
there is nothing inherently invalid about MIR with undefined behaviour).

Fixes rust-lang#104736
Fixes rust-lang#104843
Fixes rust-lang#116079
Fixes rust-lang#116736
Fixes rust-lang#118990
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.

4 participants