rust-lang / rust

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

Assertion failed while checking liveness #127362

Closed Larsouille25 closed 1 month ago

Larsouille25 commented 3 months ago

Code

    pub fn visit_expr(&mut self, expr: &Expression) -> Vec<Diag> {
        let mut diags = Vec::new();
        match &expr.expr {
            ExpressionInner::SymbolExpr(symbol) => 'out: {
                dbg!(symbol);
                let name = match symbol.s.borrow().clone() {
                    SymbolInner::Undefined(name) => name,
                    _ => continue 'out,
                }
                if let Some(found) = self.table.scope_lookup(&name) {
                    *symbol.s.borrow_mut() = found.s.borrow().clone();
                } else {
                    todo!("NOT FOUND DIAG HERE.");
                }
            }
            ExpressionInner::BinaryExpr { lhs, rhs, .. } => {
                diags.extend(self.visit_expr(lhs));
                diags.extend(self.visit_expr(rhs));
            }
            ExpressionInner::UnaryExpr { operand, .. } => {
                diags.extend(self.visit_expr(operand));
            }
            // we don't use the wildcard `_` pattern because it forces us to
            // adjust this code when a new expression is created
            ExpressionInner::IntLiteral(_)
            | ExpressionInner::BoolLiteral(_)
            | ExpressionInner::CharLiteral(_)
            | ExpressionInner::StrLiteral(_) => {}
        }
        diags
    }

the entire project can be found in the state that makes rustc panic here -> Larsouille25/rosa@fc6aab9e599961307cd7e63e825cb87a6af9bff5 (I'll try to isolate the code that makes the compiler crashes)

Meta

rustc --version --verbose:

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2

Error output

   Compiling rosac_sema v0.0.0 (/home/thibault/devel/rosa/internals/rosac_sema)
error: expected `;`, found keyword `if`
   --> internals/rosac_sema/src/name.rs:188:18
    |
188 |                 }
    |                  ^ help: add `;` here
189 |                 if let Some(found) = self.table.scope_lookup(&name) {
    |                 -- unexpected token

warning: unused import: `std::cell::RefCell`
  --> internals/rosac_sema/src/name.rs:10:5
   |
10 | use std::cell::RefCell;
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0696]: `continue` pointing to a labeled block
   --> internals/rosac_sema/src/name.rs:187:26
    |
183 |               ExpressionInner::SymbolExpr(symbol) => 'out: {
    |  ____________________________________________________-
184 | |                 dbg!(symbol);
185 | |                 let name = match symbol.s.borrow().clone() {
186 | |                     SymbolInner::Undefined(name) => name,
187 | |                     _ => continue 'out,
    | |                          ^^^^^^^^^^^^^ labeled blocks cannot be `continue`'d
...   |
193 | |                 }
194 | |             }
    | |_____________- labeled block the `continue` points to

warning: unused variable: `name`
   --> internals/rosac_sema/src/name.rs:109:14
    |
109 |         let (name, args, ret, block, loc) = match &decl.decl {
    |              ^^^^ help: if this is intentional, prefix it with an underscore: `_name`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `ret`
   --> internals/rosac_sema/src/name.rs:109:26
    |
109 |         let (name, args, ret, block, loc) = match &decl.decl {
    |                          ^^^ help: if this is intentional, prefix it with an underscore: `_ret`

thread 'rustc' panicked at compiler/rustc_passes/src/liveness/rwu_table.rs:62:9:
assertion failed: b.index() < self.live_nodes
stack backtrace:
 <it's in the backtrace section later>

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 (9b00956e5 2024-04-29) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [check_liveness] checking liveness of variables in `name::<impl at internals/rosac_sema/src/name.rs:16:1: 16:30>::visit_expr`
#1 [mir_built] building MIR for `name::<impl at internals/rosac_sema/src/name.rs:16:1: 16:30>::visit_expr`
#2 [check_unsafety] unsafety-checking `name::<impl at internals/rosac_sema/src/name.rs:16:1: 16:30>::visit_expr`
#3 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0696`.
warning: `rosac_sema` (lib) generated 3 warnings
error: could not compile `rosac_sema` (lib) due to 2 previous errors; 3 warnings emitted
Backtrace

``` 0: 0x7f0c90385892 - std::backtrace_rs::backtrace::libunwind::trace::he4ee80166a02c846 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x7f0c90385892 - std::backtrace_rs::backtrace::trace_unsynchronized::h476faccf57e88641 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f0c90385892 - std::sys_common::backtrace::_print_fmt::h430c922a77e7a59c at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f0c90385892 - ::fmt::hffecb437d922f988 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f0c903d6a6c - core::fmt::rt::Argument::fmt::hf3df69369399bfa9 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/rt.rs:142:9 5: 0x7f0c903d6a6c - core::fmt::write::hd9a8d7d029f9ea1a at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:1153:17 6: 0x7f0c9037a78f - std::io::Write::write_fmt::h0e1226b2b8d973fe at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/io/mod.rs:1843:15 7: 0x7f0c90385664 - std::sys_common::backtrace::_print::hd2df4a083f6e69b8 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f0c90385664 - std::sys_common::backtrace::print::he907f6ad7eee41cb at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f0c9038835b - std::panicking::default_hook::{{closure}}::h3926193b61c9ca9b 10: 0x7f0c903880b3 - std::panicking::default_hook::h25ba2457dea68e65 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:292:9 11: 0x7f0c8d02845d - std[e4dfbc2c3f4b09f1]::panicking::update_hook::>::{closure#0} 12: 0x7f0c90388ac0 - as core::ops::function::Fn>::call::h022ca2c0d8c21c9e at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9 13: 0x7f0c90388ac0 - std::panicking::rust_panic_with_hook::h0ad14d90dcf5224f at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13 14: 0x7f0c903887c9 - std::panicking::begin_panic_handler::{{closure}}::h4a1838a06f542647 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:649:13 15: 0x7f0c90385d66 - std::sys_common::backtrace::__rust_end_short_backtrace::h77cc4dc3567ca904 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18 16: 0x7f0c90388534 - rust_begin_unwind at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5 17: 0x7f0c903d2f85 - core::panicking::panic_fmt::h940d4fd01a4b4fd1 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14 18: 0x7f0c903d3043 - core::panicking::panic::h8ddd58dc57c2dc00 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:145:5 19: 0x7f0c8e98170c - ::propagate_through_expr 20: 0x7f0c8e97d3e8 - ::propagate_through_block 21: 0x7f0c8e980af1 - ::propagate_through_expr 22: 0x7f0c8e97d3aa - ::propagate_through_block 23: 0x7f0c8e984b17 - rustc_passes[4fc2ef7b3cf51af8]::liveness::check_liveness 24: 0x7f0c8e984129 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::> 25: 0x7f0c8e585ceb - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, true> 26: 0x7f0c8e59066f - rustc_query_impl[e4152ad88c3d6c78]::query_impl::check_liveness::get_query_incr::__rust_end_short_backtrace 27: 0x7f0c8e9997bb - rustc_mir_build[95b41b8ff12a5765]::build::mir_built 28: 0x7f0c8e999595 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::> 29: 0x7f0c8e33ffd5 - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, true> 30: 0x7f0c8e590516 - rustc_query_impl[e4152ad88c3d6c78]::query_impl::mir_built::get_query_incr::__rust_end_short_backtrace 31: 0x7f0c8e995315 - rustc_mir_build[95b41b8ff12a5765]::check_unsafety::check_unsafety 32: 0x7f0c8e995109 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::> 33: 0x7f0c8e585ceb - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, true> 34: 0x7f0c8e585837 - rustc_query_impl[e4152ad88c3d6c78]::query_impl::check_unsafety::get_query_incr::__rust_end_short_backtrace 35: 0x7f0c8eb11fbf - rustc_interface[ba2b6dc4c96cb491]::passes::analysis 36: 0x7f0c8eb118e5 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::> 37: 0x7f0c8f09d375 - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, true> 38: 0x7f0c8f09cf9c - rustc_query_impl[e4152ad88c3d6c78]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 39: 0x7f0c8edfc814 - rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler::, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0} 40: 0x7f0c8f13eb6e - std[e4dfbc2c3f4b09f1]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>> 41: 0x7f0c8f13e9ca - <::spawn_unchecked_, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#1} as core[836963c7c1decc11]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 42: 0x7f0c90392145 - as core::ops::function::FnOnce>::call_once::h19b9e642d37e7272 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9 43: 0x7f0c90392145 - as core::ops::function::FnOnce>::call_once::h97265befc434d3ae at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9 44: 0x7f0c90392145 - std::sys::pal::unix::thread::Thread::new::thread_start::h420dad5cf01a9f35 at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys/pal/unix/thread.rs:108:17 45: 0x7f0c8a0a91b7 - start_thread 46: 0x7f0c8a12b3cc - __GI___clone3 47: 0x0 - ```

matthiaskrgr commented 3 months ago

probably another case of https://github.com/rust-lang/rust/issues/121623

Larsouille25 commented 3 months ago

probably another case of #121623

Yeah I think you're right

jieyouxu commented 1 month ago

Thanks for the report, closing in favor of #121623.