model-checking / kani

Kani Rust Verifier
https://model-checking.github.io/kani
Apache License 2.0
2.13k stars 83 forks source link

ICE; unimplemented: box move closure #2731

Open matthiaskrgr opened 1 year ago

matthiaskrgr commented 1 year ago

I tried this code:

#[kani::proof]
pub fn main() {
    let mut x = 1;
    let _thunk = Box::new(move|| { x = 2; });
}

using the following command line invocation:

 RUSTFLAGS="-Zmir-opt-level=2" RUST_BACKTRACE=full RUSTC_WRAPPER="" cargo kani

with Kani version: 0.35.0

I expected to see this happen: explanation

Instead, this happened: explanation

Kani Rust Verifier 0.35.0 (cargo plugin)
   Compiling kani v0.1.0 (/tmp/kani)
warning: value assigned to `x` is never read
 --> src/main.rs:4:36
  |
4 |     let _thunk = Box::new(move|| { x = 2; });
  |                                    ^
  |
  = help: maybe it is overwritten before being read?
  = note: `#[warn(unused_assignments)]` on by default

warning: unused variable: `x`
 --> src/main.rs:4:36
  |
4 |     let _thunk = Box::new(move|| { x = 2; });
  |                                    ^
  |
  = help: did you mean to capture by reference instead?
  = note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs:428:18:
not implemented
stack backtrace:
error: internal compiler error: Kani unexpectedly panicked at panicked at kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs:428:18:
                                not implemented.

   0:     0x7f8d7f16329c - std::backtrace_rs::backtrace::libunwind::trace::h28e11dce06475f43
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8d7f16329c - std::backtrace_rs::backtrace::trace_unsynchronized::h21f22a3bfa3fb013
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8d7f16329c - std::sys_common::backtrace::_print_fmt::hafc6985e93f76ae0
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f8d7f16329c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h36c63275fbd3f0f8
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8d7f1c93ec - core::fmt::rt::Argument::fmt::h9b33518f8511caca
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/core/src/fmt/rt.rs:138:9
   5:     0x7f8d7f1c93ec - core::fmt::write::h67226f5192a09eca
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f8d7f155d2e - std::io::Write::write_fmt::h744b3076c6ca0e52
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/io/mod.rs:1714:15
   7:     0x7f8d7f163084 - std::sys_common::backtrace::_print::h4bcc2e79e4348aa6
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8d7f163084 - std::sys_common::backtrace::print::h74142c12abe5e25d
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f8d7f16617a - std::panicking::panic_hook_with_disk_dump::{{closure}}::h7d3e65abd6cf3378
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/panicking.rs:278:22
  10:     0x7f8d7f165e67 - std::panicking::panic_hook_with_disk_dump::h5bbd6ac133545f46
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/panicking.rs:312:9
  11:     0x55ede993f2dd - kani_compiler::session::PANIC_HOOK::{{closure}}::{{closure}}::h5067a4a6926df452
  12:     0x55ede993f5cd - kani_compiler::session::JSON_PANIC_HOOK::{{closure}}::{{closure}}::h449e03c79d4f70ea
  13:     0x55ede993e463 - kani_compiler::codegen_cprover_gotoc::utils::debug::DEFAULT_HOOK::{{closure}}::{{closure}}::hbc7dbed47af55a6e
  14:     0x7f8d7f166a20 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbc8f8f631658dcc9
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/alloc/src/boxed.rs:2021:9
  15:     0x7f8d7f166a20 - std::panicking::rust_panic_with_hook::h7b16b439ec100c23
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/panicking.rs:733:13
  16:     0x7f8d7f166761 - std::panicking::begin_panic_handler::{{closure}}::hd03f21e4b251a35c
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/panicking.rs:619:13
  17:     0x7f8d7f1637c6 - std::sys_common::backtrace::__rust_end_short_backtrace::he8aad725f5dd71ab
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/sys_common/backtrace.rs:170:18
  18:     0x7f8d7f1664f2 - rust_begin_unwind
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/panicking.rs:617:5
  19:     0x7f8d7f1c57f3 - core::panicking::panic_fmt::h37323eb5862b87ad
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/core/src/panicking.rs:67:14
  20:     0x7f8d7f1c5883 - core::panicking::panic::ha74a0707102dff8d
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/core/src/panicking.rs:117:5
  21:     0x55ede98dfcd0 - kani_compiler::codegen_cprover_gotoc::codegen::operand::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_scalar::h866d7c01955cc5f4
  22:     0x55ede98dd538 - kani_compiler::codegen_cprover_gotoc::codegen::operand::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_operand::h2c59c4b345bfb21b
  23:     0x55ede999e72f - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h6f9cf1d4f5574ff0
  24:     0x55ede9926785 - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::h59425a7a355828fa
  25:     0x55ede98fba75 - kani_compiler::codegen_cprover_gotoc::codegen::statement::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_funcall_args::h0e50b2fdee2adc26
  26:     0x55ede98f8b65 - kani_compiler::codegen_cprover_gotoc::codegen::statement::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_terminator::h061f66ae0a57f0f2
  27:     0x55ede98b4135 - kani_compiler::codegen_cprover_gotoc::codegen::block::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_block::h59b22828e30bde2e
  28:     0x55ede990cb1b - kani_compiler::codegen_cprover_gotoc::utils::debug::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::call_with_panic_debug_info::hc4985c898bede1f1
  29:     0x55ede99ceaae - kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend::codegen_items::h71130359840cd186
  30:     0x55ede99d35a5 - <kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h25888e407b1b3e70
  31:     0x7f8d8160d3c2 - <rustc_session[a6bdf9a4b51671a9]::session::Session>::time::<alloc[10a91b7ea9db36b6]::boxed::Box<dyn core[3ec4812ddef0ef93]::any::Any>, rustc_interface[39ac7ec62dd85acc]::passes::start_codegen::{closure#0}>
  32:     0x7f8d8160cf1b - rustc_interface[39ac7ec62dd85acc]::passes::start_codegen
  33:     0x7f8d81607bba - <rustc_middle[9074e8ddcc94940f]::ty::context::GlobalCtxt>::enter::<<rustc_interface[39ac7ec62dd85acc]::queries::Queries>::ongoing_codegen::{closure#0}, core[3ec4812ddef0ef93]::result::Result<alloc[10a91b7ea9db36b6]::boxed::Box<dyn core[3ec4812ddef0ef93]::any::Any>, rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>>
  34:     0x7f8d81607066 - <rustc_interface[39ac7ec62dd85acc]::interface::Compiler>::enter::<rustc_driver_impl[e8f28f10c524a0ae]::run_compiler::{closure#1}::{closure#2}, core[3ec4812ddef0ef93]::result::Result<core[3ec4812ddef0ef93]::option::Option<rustc_interface[39ac7ec62dd85acc]::queries::Linker>, rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>>
  35:     0x7f8d81604338 - std[98f21c237d3a11b9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[39ac7ec62dd85acc]::util::run_in_thread_pool_with_globals<rustc_interface[39ac7ec62dd85acc]::interface::run_compiler<core[3ec4812ddef0ef93]::result::Result<(), rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>, rustc_driver_impl[e8f28f10c524a0ae]::run_compiler::{closure#1}>::{closure#0}, core[3ec4812ddef0ef93]::result::Result<(), rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3ec4812ddef0ef93]::result::Result<(), rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>>
  36:     0x7f8d81603ac5 - <<std[98f21c237d3a11b9]::thread::Builder>::spawn_unchecked_<rustc_interface[39ac7ec62dd85acc]::util::run_in_thread_pool_with_globals<rustc_interface[39ac7ec62dd85acc]::interface::run_compiler<core[3ec4812ddef0ef93]::result::Result<(), rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>, rustc_driver_impl[e8f28f10c524a0ae]::run_compiler::{closure#1}>::{closure#0}, core[3ec4812ddef0ef93]::result::Result<(), rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3ec4812ddef0ef93]::result::Result<(), rustc_span[7b07eadf6d8a61c8]::ErrorGuaranteed>>::{closure#1} as core[3ec4812ddef0ef93]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7f8d7f171225 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d092cb8decc581e
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/alloc/src/boxed.rs:2007:9
  38:     0x7f8d7f171225 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h88f1cce7655d0913
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/alloc/src/boxed.rs:2007:9
  39:     0x7f8d7f171225 - std::sys::unix::thread::Thread::new::thread_start::h775d92d70f807a4c
                               at /rustc/d06ca0ffaf4ac72732665f99dd9ad962194cd0b3/library/std/src/sys/unix/thread.rs:108:17
  40:     0x7f8d7ec8c9eb - <unknown>
  41:     0x7f8d7ed10dfc - <unknown>
  42:                0x0 - <unknown>

Kani unexpectedly panicked during compilation.
Please file an issue here: https://github.com/model-checking/kani/issues/new?labels=bug&template=bug_report.md

[Kani] current codegen item: codegen_function: main
main
[Kani] current codegen location: Loc { file: "/tmp/kani/src/main.rs", function: None, start_line: 2, start_col: Some(1), end_line: 2, end_col: Some(14) }
error: could not compile `kani` (bin "kani"); 3 warnings emitted
error: Failed to compile `kani` due to an internal compiler error.: error: internal compiler error: Kani unexpectedly panicked at panicked at kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs:428:18:
                                not implemented.
adpaco-aws commented 1 year ago

Thanks @matthiaskrgr ! Adding the "Crash" label to this issue.

matthiaskrgr commented 10 months ago

triage: still crashing with 0.40