Skip to content

ICE entered unreachable code: Ty.. const &dyn Trait #3019

Closed as not planned
Closed as not planned

Description

@matthiaskrgr

I tried this code:

use std::fmt::Display;

const NO_ANN: &dyn Display = &70;

#[kani::proof]
fn main() {
    assert_eq!(NO_ANN.to_string(), "70");
}

using the following command line invocation:

kani file.rs

with Kani version: 0.46.0

I expected to see this happen: explanation

Instead, this happened: explanation

Kani Rust Verifier 0.46.0 (standalone)
thread 'rustc' panicked at kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs:310:22:
internal error: entered unreachable code: Ty { id: 11, kind: RigidTy(Dynamic([Binder { value: Trait(ExistentialTraitRef { def_id: TraitDef(DefId { id: 2, name: "std::fmt::Display" }), generic_args: GenericArgs([]) }), bound_vars: [] }], Region { kind: ReErased }, Dyn)) }
stack backtrace:
   0:     0x7fbadcc17e86 - std::backtrace_rs::backtrace::libunwind::trace::haa62de98ce20d13c
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fbadcc17e86 - std::backtrace_rs::backtrace::trace_unsynchronized::h4bc7f582e9f49dbd
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fbadcc17e86 - std::sys_common::backtrace::_print_fmt::h07d78988ae6e922d
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fbadcc17e86 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he72c24e459b4aee4
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fbadcc6a740 - core::fmt::rt::Argument::fmt::h9ff3b213e1468f5f
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/core/src/fmt/rt.rs:142:9
   5:     0x7fbadcc6a740 - core::fmt::write::h0ab1f59280077a18
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fbadcc0b7bf - std::io::Write::write_fmt::h2f48f6201433d434
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/io/mod.rs:1810:15
   7:     0x7fbadcc17c64 - std::sys_common::backtrace::_print::h710dac96d5446d07
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fbadcc17c64 - std::sys_common::backtrace::print::h22982b9f2c94c190
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fbadcc1a9f7 - std::panicking::default_hook::{{closure}}::h19052586580466eb
  10:     0x7fbadcc1a759 - std::panicking::default_hook::h9f3f4c25f2a49543
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/panicking.rs:292:9
  11:     0x55a40bb8b29d - kani_compiler::session::PANIC_HOOK::{{closure}}::{{closure}}::h62bee1eb7956b9f6
  12:     0x55a40bb8aaa3 - kani_compiler::codegen_cprover_gotoc::utils::debug::DEFAULT_HOOK::{{closure}}::{{closure}}::h252d31e703366824
  13:     0x7fbadcc1b146 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0ebb0eb5cf5e84f1
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/alloc/src/boxed.rs:2030:9
  14:     0x7fbadcc1b146 - std::panicking::rust_panic_with_hook::hb83cfb3ac729d1b2
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/panicking.rs:785:13
  15:     0x7fbadcc1ae92 - std::panicking::begin_panic_handler::{{closure}}::hf6588d71adde3329
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/panicking.rs:659:13
  16:     0x7fbadcc18386 - std::sys_common::backtrace::__rust_end_short_backtrace::hfa69dd6720275711
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/sys_common/backtrace.rs:171:18
  17:     0x7fbadcc1abe4 - rust_begin_unwind
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/panicking.rs:647:5
  18:     0x7fbadcc66e45 - core::panicking::panic_fmt::h3d775185360585e3
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/core/src/panicking.rs:72:14
  19:     0x55a40bb03404 - kani_compiler::codegen_cprover_gotoc::codegen::operand::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_const_ptr::h8e34f4e7d832cc8a
  20:     0x55a40bb015ee - kani_compiler::codegen_cprover_gotoc::codegen::operand::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::try_codegen_constant::hf98efd98acfac45a
  21:     0x55a40bb00d86 - kani_compiler::codegen_cprover_gotoc::codegen::operand::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_allocation::h4cdc94a8511effd6
  22:     0x55a40bb006aa - kani_compiler::codegen_cprover_gotoc::codegen::operand::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_operand_stable::h669d4e8bb4fb2d55
  23:     0x55a40bb11abb - kani_compiler::codegen_cprover_gotoc::codegen::rvalue::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_rvalue_stable::h03604d81673e65d8
  24:     0x55a40bb1ec34 - kani_compiler::codegen_cprover_gotoc::codegen::statement::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_statement::h9ef1fd17419243a3
  25:     0x55a40bb36b18 - kani_compiler::codegen_cprover_gotoc::utils::debug::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::call_with_panic_debug_info::h70ea6b1d619c790d
  26:     0x55a40bbf9e9a - kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend::codegen_items::h179e069baadeebc1
  27:     0x55a40bbb1430 - scoped_tls::ScopedKey<T>::set::h462dbe7b3063cb5c
  28:     0x55a40bbe91a4 - rustc_smir::rustc_internal::init::hdab7351afa62793a
  29:     0x55a40bbb4054 - stable_mir::compiler_interface::run::hdc01671daf50c78a
  30:     0x55a40bbfd62e - <kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::hd5728f8a33105c7d
  31:     0x7fbadb66aff0 - rustc_interface[79a3a7c6d29fbb15]::passes::start_codegen
  32:     0x7fbadb66a75c - <rustc_interface[79a3a7c6d29fbb15]::queries::Queries>::codegen_and_build_linker
  33:     0x7fbadb97a44a - rustc_interface[79a3a7c6d29fbb15]::interface::run_compiler::<core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>, rustc_driver_impl[27708ea34d8a9a18]::run_compiler::{closure#0}>::{closure#0}
  34:     0x7fbadbbe5986 - std[da4468a6436061de]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[79a3a7c6d29fbb15]::util::run_in_thread_with_globals<rustc_interface[79a3a7c6d29fbb15]::util::run_in_thread_pool_with_globals<rustc_interface[79a3a7c6d29fbb15]::interface::run_compiler<core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>, rustc_driver_impl[27708ea34d8a9a18]::run_compiler::{closure#0}>::{closure#0}, core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>>::{closure#0}, core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>>
  35:     0x7fbadbbe57b3 - <<std[da4468a6436061de]::thread::Builder>::spawn_unchecked_<rustc_interface[79a3a7c6d29fbb15]::util::run_in_thread_with_globals<rustc_interface[79a3a7c6d29fbb15]::util::run_in_thread_pool_with_globals<rustc_interface[79a3a7c6d29fbb15]::interface::run_compiler<core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>, rustc_driver_impl[27708ea34d8a9a18]::run_compiler::{closure#0}>::{closure#0}, core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>>::{closure#0}, core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2f78b8535a2e64fa]::result::Result<(), rustc_span[8cc10a3d00093188]::ErrorGuaranteed>>::{closure#1} as core[2f78b8535a2e64fa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7fbadcc24735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hda2c57e98ef914e1
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/alloc/src/boxed.rs:2016:9
  37:     0x7fbadcc24735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4c1ca1ffb3984aed
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/alloc/src/boxed.rs:2016:9
  38:     0x7fbadcc24735 - std::sys::pal::unix::thread::Thread::new::thread_start::h6dfa281031503fa8
                               at /rustc/7ffc697ce10f19447c0ce338428ae4b9bc0c041c/library/std/src/sys/pal/unix/thread.rs:108:17
  39:     0x7fbad69bd9eb - <unknown>
  40:     0x7fbad6a417cc - <unknown>
  41:                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: "others.rs", function: None, start_line: 6, start_col: Some(1), end_line: 6, end_col: Some(10) }
error: /home/matthias/.kani/kani-0.46.0/bin/kani-compiler exited with status exit status: 101

Activity

  1. added
    [C] Bug
    on Feb 11, 2024
  2. added theissue type on Apr 1, 2026
  3. feliperodri commented on Sep 25, 2026

    @feliperodri
    Member

    Triaged against main (de756c9, nightly-2026-09-23, Kani 0.68.0). no longer a crash: kani code.rs completes and reports the unsupported construct as a reachable failing check instead of panicking.

    Closing as no longer reproducible — please reopen if you can still hit it on main.

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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions