Skip to content

panic: uninit checks assertion failed: 128 == 64 #4850

Open

Description

@matthiaskrgr

I tried this code:

trait Structure<E> {
    type RefTarget: ?Sized;
    type FfiPtr;
    unsafe fn borrow_from_ffi_ptr<'a>(ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget>;
}
enum Slice {}
impl<E> Structure<E> for Slice
where
    E: Encoding,
{
    type RefTarget = [E];
    type FfiPtr = (*const E::FfiUnit, usize);
    unsafe fn borrow_from_ffi_ptr<'a>(_ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget> {
        panic!()
    }
}
trait Encoding {
    type Unit;
    type FfiUnit;
}
enum Utf16 {}
impl Encoding for Utf16 {
    type Unit = Utf16Unit;
    type FfiUnit = u16;
}
struct Utf16Unit;
struct SUtf16Str {
    _data: <Slice as Structure<Utf16>>::RefTarget,
}
impl SUtf16Str {
    unsafe fn from_ptr<'a>(ptr: <Slice as Structure<Utf16>>::FfiPtr) -> Option<&'a Self> {
        std::mem::transmute(ptr)
    }
}
fn main() {
    const TEXT_U16: &[u16] = &[];
    _ = unsafe { SUtf16Str::from_ptr((TEXT_U16.as_ptr(), TEXT_U16.len())) }
}

using the following command line invocation:

 RUST_BACKTRACE=full  RUSTFLAGS="--edition=2021"  kani autoharness -Zautoharness code.rs --run-sanity-checks  -Zunstable-options   -Zuninit-checks  -Zuninit-checks

with Kani version:

I expected to see this happen: explanation

Instead, this happened: explanation

Kani Rust Verifier 0.68.0 (standalone)
CBMC 6.11.0
warning: trait `Structure` is never used
 --> code.rs:1:7
  |
1 | trait Structure<E> {
  |       ^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: enum `Slice` is never used
 --> code.rs:6:6
  |
6 | enum Slice {}
  |      ^^^^^

warning: trait `Encoding` is never used
  --> code.rs:17:7
   |
17 | trait Encoding {
   |       ^^^^^^^^

warning: enum `Utf16` is never used
  --> code.rs:21:6
   |
21 | enum Utf16 {}
   |      ^^^^^

warning: struct `Utf16Unit` is never constructed
  --> code.rs:26:8
   |
26 | struct Utf16Unit;
   |        ^^^^^^^^^

warning: struct `SUtf16Str` is never constructed
  --> code.rs:27:8
   |
27 | struct SUtf16Str {
   |        ^^^^^^^^^

warning: associated function `from_ptr` is never used
  --> code.rs:31:15
   |
30 | impl SUtf16Str {
   | -------------- associated function in this implementation
31 |     unsafe fn from_ptr<'a>(ptr: <Slice as Structure<Utf16>>::FfiPtr) -> Option<&'a Self> {
   |               ^^^^^^^^

warning: function `main` is never used
  --> code.rs:35:4
   |
35 | fn main() {
   |    ^^^^

warning: use of an unstable feature
 --> <crate attribute>:1:12
  |
1 | #![feature(register_tool)]
  |            ^^^^^^^^^^^^^
  |
  = note: requested on the command line with `--force-warn unstable-features`


thread 'rustc' (3390414) panicked at cprover_bindings/src/goto_program/expr.rs:1120:9:
assertion `left == right` failed
  left: 128
 right: 64
stack backtrace:
   0:     0x7fdf156c53f6 - <<std[b8564071bfb80320]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b218925afaf52552]::fmt::Display>::fmt
   1:     0x7fdf15e0aca3 - core[b218925afaf52552]::fmt::write
   2:     0x7fdf156daa1c - <std[b8564071bfb80320]::sys::stdio::unix::Stderr as core[b218925afaf52552]::io::write::Write>::write_fmt
   3:     0x7fdf1569868a - std[b8564071bfb80320]::panicking::default_hook::{closure#0}
   4:     0x7fdf156b96a3 - std[b8564071bfb80320]::panicking::default_hook
   5:     0x5597cd6a5f40 - kani_compiler[980edcef3ed27b2]::session::PANIC_HOOK::{closure#0}::{closure#0}
   6:     0x5597cd6a63a0 - kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::utils::debug::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:     0x7fdf156b9b42 - std[b8564071bfb80320]::panicking::panic_with_hook
   8:     0x7fdf15698742 - std[b8564071bfb80320]::panicking::panic_handler::{closure#0}
   9:     0x7fdf156903a9 - std[b8564071bfb80320]::sys::backtrace::__rust_end_short_backtrace::<std[b8564071bfb80320]::panicking::panic_handler::{closure#0}, !>
  10:     0x7fdf1569a14d - __rustc[f325e6f53f8e9f03]::rust_begin_unwind
  11:     0x7fdf122cb57c - core[b218925afaf52552]::panicking::panic_fmt
  12:     0x7fdf13fbb0f3 - core[b218925afaf52552]::panicking::assert_failed_inner
  13:     0x7fdf13fb10a5 - core[b218925afaf52552]::panicking::assert_failed::<u64, u64>
  14:     0x5597cd7d971f - <cprover_bindings[cc03a3a0ad66a1a8]::goto_program::expr::Expr>::transmute_to
  15:     0x5597cd4442df - <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_rvalue_stable
  16:     0x5597cd47ca27 - <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_statement
  17:     0x5597cd45aa51 - <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_function
  18:     0x5597cd5e2251 - <std[b8564071bfb80320]::thread::local::LocalKey<core[b218925afaf52552]::cell::RefCell<(core[b218925afaf52552]::option::Option<alloc[1fd94160f0f4009f]::boxed::Box<dyn core[b218925afaf52552]::ops::function::Fn<(), Output = alloc[1fd94160f0f4009f]::string::String>>>, core[b218925afaf52552]::option::Option<cprover_bindings[cc03a3a0ad66a1a8]::goto_program::location::Location>)>>>::with::<<kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::call_with_panic_debug_info<rustc_public[982db8fb9120de79]::mir::mono::InstanceDef, <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend>::codegen_items::{closure#4}::{closure#4}, <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend>::codegen_items::{closure#4}::{closure#5}>::{closure#0}, ()>
  19:     0x5597cd5392eb - <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend>::codegen_items
  20:     0x5597cd5363fd - <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa[6aa05fb22a8957d5]::traits::backend::CodegenBackend>::codegen_crate::{closure#0}
  21:     0x5597cd5a5c15 - rustc_public[982db8fb9120de79]::compiler_interface::run::<rustc_public[982db8fb9120de79]::rustc_internal::run<<kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa[6aa05fb22a8957d5]::traits::backend::CodegenBackend>::codegen_crate::{closure#0}, alloc[1fd94160f0f4009f]::boxed::Box<dyn core[b218925afaf52552]::any::Any>>::{closure#0}, alloc[1fd94160f0f4009f]::boxed::Box<dyn core[b218925afaf52552]::any::Any>>
  22:     0x5597cd6be7c5 - rustc_public[982db8fb9120de79]::rustc_internal::run::<<kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa[6aa05fb22a8957d5]::traits::backend::CodegenBackend>::codegen_crate::{closure#0}, alloc[1fd94160f0f4009f]::boxed::Box<dyn core[b218925afaf52552]::any::Any>>
  23:     0x5597cd542bb9 - <kani_compiler[980edcef3ed27b2]::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa[6aa05fb22a8957d5]::traits::backend::CodegenBackend>::codegen_crate
  24:     0x7fdf1714db8c - <rustc_interface[4089758db528eb1a]::queries::Linker>::codegen_and_build_linker
  25:     0x7fdf1714448a - rustc_interface[4089758db528eb1a]::interface::run_compiler::<(), rustc_driver_impl[f578478d149be60]::run_compiler::{closure#0}>::{closure#2}
  26:     0x7fdf171c1e64 - std[b8564071bfb80320]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4089758db528eb1a]::util::run_in_thread_with_globals<rustc_interface[4089758db528eb1a]::util::run_in_thread_pool_with_globals<rustc_interface[4089758db528eb1a]::interface::run_compiler<(), rustc_driver_impl[f578478d149be60]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  27:     0x7fdf171c1c2d - <std[b8564071bfb80320]::thread::lifecycle::spawn_unchecked<rustc_interface[4089758db528eb1a]::util::run_in_thread_with_globals<rustc_interface[4089758db528eb1a]::util::run_in_thread_pool_with_globals<rustc_interface[4089758db528eb1a]::interface::run_compiler<(), rustc_driver_impl[f578478d149be60]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b218925afaf52552]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7fdf171bf907 - <std[b8564071bfb80320]::sys::thread::unix::Thread>::new::thread_start
  29:     0x7fdf104980a2 - <unknown>
  30:     0x7fdf1052080c - <unknown>
  31:                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: code::SUtf16Str::from_ptr::<'_>
_RNvMs0_CslKp9iu2Gnli_4codeNtB5_9SUtf16Str8from_ptr
[Kani] current codegen location: Loc { file: "code.rs", function: None, start_line: 31, start_col: Some(5), end_line: 31, end_col: Some(89), pragmas: [] }
warning: 9 warnings emitted

error: /home/matthias/.kani/kani-0.68.0/bin/kani-compiler exited with status exit status: 101

Activity

  1. added
    [C] Bug
    on Sep 24, 2026
  2. added theissue type on Sep 25, 2026
  3. added this to the Autoharness milestone on Sep 25, 2026
  4. srivatsansamraj commented on Oct 5, 2026

    @srivatsansamraj
    Contributor

    On main 1640445da the reproducer with the issue's command no longer panics and ends in ordinary failed checks, and reverting #4815 on 4e31125fd brought the panic back at goto_program/expr.rs:1120, so #4815 fixed this and the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] Bug[F] Crash

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions