Skip to content

Assertion failed while checking liveness #127362

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

Closed
thi8v opened this issue Jul 5, 2024 · 3 comments
Closed

Assertion failed while checking liveness #127362

thi8v opened this issue Jul 5, 2024 · 3 comments
Labels
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

@thi8v
Copy link

thi8v commented Jul 5, 2024

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 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::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::<alloc[1adba907b9db1888]::boxed::Box<rustc_driver_impl[24a943716c49befe]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f0c90388ac0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::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 - <rustc_passes[4fc2ef7b3cf51af8]::liveness::Liveness>::propagate_through_expr
  20:     0x7f0c8e97d3e8 - <rustc_passes[4fc2ef7b3cf51af8]::liveness::Liveness>::propagate_through_block
  21:     0x7f0c8e980af1 - <rustc_passes[4fc2ef7b3cf51af8]::liveness::Liveness>::propagate_through_expr
  22:     0x7f0c8e97d3aa - <rustc_passes[4fc2ef7b3cf51af8]::liveness::Liveness>::propagate_through_block
  23:     0x7f0c8e984b17 - rustc_passes[4fc2ef7b3cf51af8]::liveness::check_liveness
  24:     0x7f0c8e984129 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::check_liveness::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 0usize]>>
  25:     0x7f0c8e585ceb - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::VecCache<rustc_span[a4517f2b2e65298c]::def_id::LocalDefId, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 0usize]>>, 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::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>
  29:     0x7f0c8e33ffd5 - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::VecCache<rustc_span[a4517f2b2e65298c]::def_id::LocalDefId, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>, 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::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 0usize]>>
  33:     0x7f0c8e585ceb - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::VecCache<rustc_span[a4517f2b2e65298c]::def_id::LocalDefId, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 0usize]>>, 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::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7f0c8f09d375 - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::SingleCache<rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 1usize]>>, 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::<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}
  40:     0x7f0c8f13eb6e - std[e4dfbc2c3f4b09f1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, 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 - <<std[e4dfbc2c3f4b09f1]::thread::Builder>::spawn_unchecked_<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, 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 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h19b9e642d37e7272
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
  43:     0x7f0c90392145 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::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 - <unknown>

@thi8v thi8v added 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. labels Jul 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 5, 2024
@matthiaskrgr
Copy link
Member

probably another case of #121623

@thi8v
Copy link
Author

thi8v commented Jul 5, 2024

probably another case of #121623

Yeah I think you're right

@jieyouxu jieyouxu added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Aug 5, 2024
@jieyouxu
Copy link
Member

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

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

No branches or pull requests

4 participants