Skip to content

panic: autoharness: assertion failed: matches!(output.kind(), TyKind :: RigidTy(RigidTy::Int(IntTy::I32)) #4813

Closed

Description

@matthiaskrgr

I tried this code:

use std::io::{Read, BufReader, Result};

pub struct MalformedRead {}

impl Read for MalformedRead {
    fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
        Ok(buf.len() * 20)
    }
}

fn main() {
    let mut reader = BufReader::new(MalformedRead {});
    let mut buf = [0u8; 1024];

    for _ in 0..8 {
        let read = reader.read(&mut buf).unwrap();
        dbg!(read);
    }

    reader.read(&mut buf).unwrap();
    dbg!(buf);
}

using the following command line invocation:

RUST_BACKTRACE=1 cargo kani autoharness -Z autoharness

with Kani version:
see below
I expected to see this happen: explanation

Instead, this happened: explanation

Kani Rust Verifier 0.68.0 (cargo plugin)
CBMC 6.11.0
   Compiling cr v0.1.0 (/tmp/kan/cr)
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' (1670574) panicked at kani-compiler/src/intrinsics.rs:243:17:
assertion failed: matches!(output.kind(), TyKind :: RigidTy(RigidTy::Int(IntTy::I32)))
stack backtrace:
error: internal compiler error: Kani unexpectedly panicked at panicked at kani-compiler/src/intrinsics.rs:243:17:
                                assertion failed: matches!(output.kind(), TyKind :: RigidTy(RigidTy::Int(IntTy::I32))).

   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <kani_compiler::intrinsics::Intrinsic>::from_instance
   4: <kani_compiler::kani_middle::transform::rustc_intrinsics::RustcIntrinsicsPass as kani_compiler::kani_middle::transform::TransformPass>::transform
   5: <kani_compiler::kani_middle::transform::BodyTransformation>::body_ref
   6: <kani_compiler::kani_middle::reachability::MonoItemsCollector>::reachable_items
   7: kani_compiler::kani_middle::reachability::collect_reachable_items
   8: <kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend>::codegen_items
   9: <kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::{closure#0}
  10: rustc_public::compiler_interface::run::<rustc_public::rustc_internal::run<<kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::{closure#0}, alloc::boxed::Box<dyn core::any::Any>>::{closure#0}, alloc::boxed::Box<dyn core::any::Any>>
  11: rustc_public::rustc_internal::run::<<kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::{closure#0}, alloc::boxed::Box<dyn core::any::Any>>
  12: <kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  13: <rustc_interface::queries::Linker>::codegen_and_build_linker
  14: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}
  15: <rustc_thread_pool::job::StackJob<rustc_thread_pool::latch::LatchRef<rustc_thread_pool::latch::LockLatch>, <rustc_thread_pool::registry::Registry>::in_worker_cold<<rustc_thread_pool::thread_pool::ThreadPool>::install<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#5}::{closure#0}::{closure#1}::{closure#0}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> as rustc_thread_pool::job::Job>::execute
  16: <rustc_thread_pool::registry::WorkerThread>::wait_or_steal_until_cold
  17: <rustc_thread_pool::registry::ThreadBuilder>::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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] no current codegen item.
[Kani] no current codegen location.
error: could not compile `cr` (bin "cr"); 1 warning emitted

Caused by:
  process didn't exit successfully: `/home/matthias/.kani/kani-0.68.0/bin/kani-compiler --crate-name cr --edition=2024 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=317 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=070b91841e1a0e8b --out-dir /tmp/kan/cr/target/kani/x86_64-unknown-linux-gnu/debug/build/cr/ef7828976597afcb/out --target x86_64-unknown-linux-gnu -C incremental=/tmp/kan/cr/target/kani/x86_64-unknown-linux-gnu/debug/incremental -L dependency=/tmp/kan/cr/target/kani/debug/build/cr/ef7828976597afcb/out '-Cllvm-args=--reachability=all_fns --log-level=warn --assertion-reach-checks --enable-stubbing -Z autoharness -Z function-contracts -Z loop-contracts' -C overflow-checks=on -Z unstable-options -Z trim-diagnostic-paths=no -Z human_readable_cgu_names -Z always-encode-mir --cfg=kani -Z 'crate-attr=feature(register_tool)' -Z 'crate-attr=register_tool(kanitool)' --force-warn unstable_features --sysroot /home/matthias/.kani/kani-0.68.0 -L /home/matthias/.kani/kani-0.68.0/lib --extern 'force:kani' --extern 'noprelude,nounused:std=/home/matthias/.kani/kani-0.68.0/lib/libstd.rlib' -Ctarget-cpu=native -Zthreads=16 -C panic=abort -C symbol-mangling-version=v0 -Z panic_abort_tests=yes -Z mir-enable-passes=-RemoveStorageMarkers '--check-cfg=cfg(kani)' -Clinker=echo --kani-compiler -Cllvm-args=--check-version=0.68.0` (exit status: 101)
error: Failed to compile `cr` due to an internal compiler error.: error: internal compiler error: Kani unexpectedly panicked at panicked at kani-compiler/src/intrinsics.rs:243:17:
                                assertion failed: matches!(output.kind(), TyKind :: RigidTy(RigidTy::Int(IntTy::I32))).

Activity

  1. added theissue type on Sep 20, 2026
  2. self-assigned this
    on Sep 20, 2026
  3. added this to the Autoharness milestone on Sep 20, 2026
  4. matthiaskrgr commented on Sep 20, 2026

    @matthiaskrgr
    ContributorAuthor

    this one boils down to
    fn main() { dbg !() } lol

  5. feliperodri commented on Sep 25, 2026

    @feliperodri
    Member

    Triaged against main (de756c9): still reproduces, and #4813, #2684, #2497 and #2253 are all the same root cause — assert_sig_matches! for the catch_unwind intrinsic (kani-compiler/src/intrinsics.rs:243) still expects ... => RigidTy::Int(IntTy::I32), but the intrinsic now returns bool:

    // library/core/src/intrinsics/mod.rs
    pub unsafe fn catch_unwind<Data: ptr::Thin>(
        _try_fn: unsafe fn(*mut Data),
        _data: *mut Data,
        _catch_fn: unsafe fn(*mut Data, *mut u8),
    ) -> bool;

    So any program that reaches catch_unwind (thread::spawn(..).join(), BufReader, the async-waker reproducers here) takes the compiler down instead of getting the intended Unimplemented/#267 message. Fixing the expected return type in that one assertion should close all four. It also blocks autoharness --std over the standard library, which hits it while compiling proc_macro.

  6. added a commit that references this issue on Sep 29, 2026
    e47388f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[C] BugThis is a bug. Something isn't working.

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions