rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.64k stars 12.49k forks source link

ICE: `b.index() < self.live_nodes` #121623

Open matthiaskrgr opened 6 months ago

matthiaskrgr commented 6 months ago

auto-reduced (treereduce-rust):

fn main() {
    match () {
        _ => 'b: {
            continue 'b;
        }
    }
}

original:

fn main() {
    struct Foo { x: isize }
    match (Foo { x: 10 }) {
        Foo { ref x: ref x } => {}, //~ ERROR expected `,`
        _ => {
    'b: {
        continue 'b; //~ ERROR `continue` pointing to a labeled block
    }
}
    }
}

Version information

rustc 1.78.0-nightly (26cd5d862 2024-02-25)
binary: rustc
commit-hash: 26cd5d862e22c013ecb3396b177d3af80e95c836
commit-date: 2024-02-25
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command: /home/matthias/.rustup/toolchains/master/bin/rustc

Program output

``` error[E0696]: `continue` pointing to a labeled block --> /tmp/icemaker_global_tempdir.5rkJyKlhWneU/rustc_testrunner_tmpdir_reporting.DS0B2iBa0Zdm/mvce.rs:4:13 | 3 | _ => 'b: { | ______________- 4 | | continue 'b; | | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d 5 | | } | |_________- labeled block the `continue` points to thread 'rustc' panicked at compiler/rustc_passes/src/liveness/rwu_table.rs:62:9: assertion failed: b.index() < self.live_nodes stack backtrace: 0: 0x7f1597b8ca06 - std::backtrace_rs::backtrace::libunwind::trace::h2b754d54d1bde505 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5 1: 0x7f1597b8ca06 - std::backtrace_rs::backtrace::trace_unsynchronized::h543e1ca101948fd5 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f1597b8ca06 - std::sys_common::backtrace::_print_fmt::h530a113cbf476cc2 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f1597b8ca06 - ::fmt::hdaaebae0c7e457dd at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f1597bdd98c - core::fmt::rt::Argument::fmt::h986a5c541218a991 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/fmt/rt.rs:142:9 5: 0x7f1597bdd98c - core::fmt::write::h0480b093981ac277 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/fmt/mod.rs:1120:17 6: 0x7f1597b813cf - std::io::Write::write_fmt::he3dd140cfd4aef89 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/io/mod.rs:1846:15 7: 0x7f1597b8c7b4 - std::sys_common::backtrace::_print::hdac374456098a97e at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f1597b8c7b4 - std::sys_common::backtrace::print::ha7f20ab884506926 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f1597b8f4fb - std::panicking::default_hook::{{closure}}::h300a405277525f5d 10: 0x7f1597b8f249 - std::panicking::default_hook::hde1c193b2da6a81c at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:292:9 11: 0x7f159aa8892c - std[555420183d371a7f]::panicking::update_hook::>::{closure#0} 12: 0x7f1597b8fc60 - as core::ops::function::Fn>::call::h68a9e4d741c266fd at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/alloc/src/boxed.rs:2030:9 13: 0x7f1597b8fc60 - std::panicking::rust_panic_with_hook::h8ba518db0741b55a at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:783:13 14: 0x7f1597b8f969 - std::panicking::begin_panic_handler::{{closure}}::ha55fc9dde68cbcf7 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:649:13 15: 0x7f1597b8cee6 - std::sys_common::backtrace::__rust_end_short_backtrace::h6838138199d9ac3e at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:171:18 16: 0x7f1597b8f6d4 - rust_begin_unwind at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:645:5 17: 0x7f1597bd9ea5 - core::panicking::panic_fmt::hb9e36ea683b16cf8 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/panicking.rs:72:14 18: 0x7f1597bd9f63 - core::panicking::panic::h7d14ca7420fbd005 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/panicking.rs:144:5 19: 0x7f159c6ea24a - ::propagate_through_expr 20: 0x7f159c6e710b - ::propagate_through_block 21: 0x7f159c64cfe6 - rustc_passes[c523e52c217c408]::liveness::check_liveness 22: 0x7f159c64c727 - rustc_query_impl[2c9e1b0525c9d953]::plumbing::__rust_begin_short_backtrace::> 23: 0x7f159c64b888 - rustc_query_system[dfd6c8aac03f3724]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2c9e1b0525c9d953]::plumbing::QueryCtxt, false> 24: 0x7f159c64b4bf - rustc_query_impl[2c9e1b0525c9d953]::query_impl::check_liveness::get_query_non_incr::__rust_end_short_backtrace 25: 0x7f159c49ba5a - rustc_mir_build[e37b6b80862e17d9]::build::mir_built 26: 0x7f159c49b7ab - rustc_query_impl[2c9e1b0525c9d953]::plumbing::__rust_begin_short_backtrace::> 27: 0x7f159c10e570 - rustc_query_system[dfd6c8aac03f3724]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2c9e1b0525c9d953]::plumbing::QueryCtxt, false> 28: 0x7f159c10dfcc - rustc_query_impl[2c9e1b0525c9d953]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace 29: 0x7f159c291b5b - rustc_mir_build[e37b6b80862e17d9]::check_unsafety::check_unsafety 30: 0x7f159c291977 - rustc_query_impl[2c9e1b0525c9d953]::plumbing::__rust_begin_short_backtrace::> 31: 0x7f159c64b80a - rustc_query_system[dfd6c8aac03f3724]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2c9e1b0525c9d953]::plumbing::QueryCtxt, false> 32: 0x7f159c64b54f - rustc_query_impl[2c9e1b0525c9d953]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace 33: 0x7f159ca05bab - rustc_interface[27abfdff6e6b27c2]::passes::analysis 34: 0x7f159ca05619 - rustc_query_impl[2c9e1b0525c9d953]::plumbing::__rust_begin_short_backtrace::> 35: 0x7f159cb1f8e5 - rustc_query_system[dfd6c8aac03f3724]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2c9e1b0525c9d953]::plumbing::QueryCtxt, false> 36: 0x7f159cb1f649 - rustc_query_impl[2c9e1b0525c9d953]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 37: 0x7f159cb2eb16 - rustc_interface[27abfdff6e6b27c2]::interface::run_compiler::, rustc_driver_impl[633500a3532990b7]::run_compiler::{closure#0}>::{closure#0} 38: 0x7f159cdc8cc5 - std[555420183d371a7f]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[633500a3532990b7]::run_compiler::{closure#0}>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>> 39: 0x7f159cdc8af2 - <::spawn_unchecked_, rustc_driver_impl[633500a3532990b7]::run_compiler::{closure#0}>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#1} as core[421030ac42e8f54b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 40: 0x7f1597b99635 - as core::ops::function::FnOnce>::call_once::h176656733d324092 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/alloc/src/boxed.rs:2016:9 41: 0x7f1597b99635 - as core::ops::function::FnOnce>::call_once::h2cb067df8c4b40c7 at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/alloc/src/boxed.rs:2016:9 42: 0x7f1597b99635 - std::sys::pal::unix::thread::Thread::new::thread_start::h9c4fa792b58c770f at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys/pal/unix/thread.rs:108:17 43: 0x7f159798155a - 44: 0x7f15979fea3c - 45: 0x0 - error: 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.78.0-nightly (26cd5d862 2024-02-25) running on x86_64-unknown-linux-gnu query stack during panic: #0 [check_liveness] checking liveness of variables in `main` #1 [mir_built] building MIR for `main` #2 [check_unsafety] unsafety-checking `main` #3 [analysis] running analysis passes on this crate end of query stack error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0696`. ```

What42Pizza commented 5 months ago

I've also gotten this error, and I've found another way to get it:

fn main() {
    'a: {
        for _ in 0..0 {
            continue 'a;
        }
    }
}
dotjpg3141 commented 3 months ago

Got the same panic for this code:

fn main() {
    let i = 5;
    'a: {
        continue 'a;
    }
}
jieyouxu commented 3 weeks ago

Looks like improper error tainting

jieyouxu commented 3 weeks ago

AAnother case: #127362.