Skip to content
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

internal compiler error: assertion failed: (left == right) #2312

Closed
nano-o opened this issue Mar 22, 2023 · 2 comments · Fixed by #2994
Closed

internal compiler error: assertion failed: (left == right) #2312

nano-o opened this issue Mar 22, 2023 · 2 comments · Fixed by #2994
Assignees
Labels
[C] Bug This is a bug. Something isn't working. [F] Crash Kani crashed T-High Priority Tag issues that have high priority T-User Tag user issues / requests Z-Kani Compiler Issues that require some changes to the compiler

Comments

@nano-o
Copy link

nano-o commented Mar 22, 2023

Kani 0.24.0 crashes in the following scenario.
First clone https://github.com/nano-o/soroban-examples/tree/f5e6acc0e253aabe0a4da6f503ddefac1bcb1df5
Then cd increment and cargo kani --tests results in the crash below. It seems different from the other issues related to this codebase and already reported.

   Compiling soroban-increment-contract v0.0.0 (/tmp/test/soroban-examples/increment)
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read3str66_$LT$impl$u20$gimli..common..DebugStrOffsetsBase$LT$Offset$GT$$GT$29default_for_encoding_and_file17hb3726e820c2fcb0cE::1::var_1::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit17parse_unit_header17h2119e9f39e8e9e29E::1::var_89::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read7aranges30ArangeHeader$LT$R$C$Offset$GT$5parse17h32c93ff849e7f37cE::1::var_116::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E::1::var_2::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E::1::var_2::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E::1::var_2::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E::1::var_2::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E::1::var_2::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E::1::var_2::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E::1::var_2::encoding" }, typ: StructTag("tag-gimli::common::Encoding"), location: None }, field: "format" }, typ: StructTag("tag-_830235228548655530"), location: None }
Expr type
StructTag("tag-_830235228548655530")
Type from MIR
StructTag("tag-_1674468053301153474")
thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `Pointer { typ: StructTag("tag-_1674468053301153474") }`,
 right: `StructTag("tag-_1674468053301153474")`: Error: assign statement with unequal types lhs Pointer { typ: StructTag("tag-_1674468053301153474") } rhs StructTag("tag-_1674468053301153474")', cprover_bindings/src/goto_program/stmt.rs:170:9
stack backtrace:
error: internal compiler error: Kani unexpectedly panicked at panicked at 'assertion failed: `(left == right)`
                                  left: `Pointer { typ: StructTag("tag-_1674468053301153474") }`,
                                 right: `StructTag("tag-_1674468053301153474")`: Error: assign statement with unequal types lhs Pointer { typ: StructTag("tag-_1674468053301153474") } rhs StructTag("tag-_1674468053301153474")', cprover_bindings/src/goto_program/stmt.rs:170:9.

   0: rust_begin_unwind
             at /rustc/f3126500f25114ba4e0ac3e76694dd45a22de56d/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/f3126500f25114ba4e0ac3e76694dd45a22de56d/library/core/src/panicking.rs:64:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: cprover_bindings::goto_program::stmt::Stmt::assign
   5: cprover_bindings::goto_program::expr::Expr::assign
   6: kani_compiler::codegen_cprover_gotoc::codegen::statement::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_statement
   7: kani_compiler::codegen_cprover_gotoc::codegen::function::<impl kani_compiler::codegen_cprover_gotoc::context::goto_ctx::GotocCtx>::codegen_function
   8: std::thread::local::LocalKey<T>::with
   9: <kani_compiler::codegen_cprover_gotoc::compiler_interface::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  10: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  11: rustc_interface::passes::start_codegen
  12: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorGuaranteed>>
  13: <rustc_interface::queries::Queries>::ongoing_codegen
  14: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  15: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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] current codegen item: codegen_function: gimli::read::unit::parse_attribute::<gimli::read::endian_slice::EndianSlice<'_, gimli::endianity::LittleEndian>>
_ZN5gimli4read4unit15parse_attribute17hfdcf1498d0916a69E
[Kani] current codegen location: Loc { file: "/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.26.2/src/read/unit.rs", function: None, start_line: 1983, start_col: Some(1), end_line: 1987, end_col: Some(26) }
error: could not compile `soroban-increment-contract`
error: Failed to compile `soroban-increment-contract` due to an internal compiler error.: error: internal compiler error: Kani unexpectedly panicked at panicked at 'assertion failed: `(left == right)`
                                  left: `Pointer { typ: StructTag("tag-_1674468053301153474") }`,
                                 right: `StructTag("tag-_1674468053301153474")`: Error: assign statement with unequal types lhs Pointer { typ: StructTag("tag-_1674468053301153474") } rhs StructTag("tag-_1674468053301153474")', cprover_bindings/src/goto_program/stmt.rs:170:9.
@nano-o nano-o added the [C] Bug This is a bug. Something isn't working. label Mar 22, 2023
@zhassan-aws
Copy link
Contributor

Thanks for the bug report @nano-o. I ran into another crash when I tried those steps:

   Compiling soroban-increment-contract v0.0.0 (/home/ubuntu/examples/iss2312/soroban-examples/increment)
thread 'rustc' panicked at 'Function call does not type check:
func: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECs4jfBIKQc5HC_9rand_core::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "vtable" }, typ: Pointer { typ: StructTag("tag-_8188678315255410733::vtable") }, location: None }), typ: StructTag("tag-_8188678315255410733::vtable"), location: None }, field: "7" }, typ: Pointer { typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") } }, location: None }), typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") }, location: None }
args: [Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECs4jfBIKQc5HC_9rand_core::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "data" }, typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, location: None }]', cprover_bindings/src/goto_program/expr.rs:639:9
note: run with `RUST_BACKTRACE=1` environment variable to display a 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] current codegen item: codegen_function: <(dyn core::error::Error + 'static)>::is::<test::std::io::Error>
_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECs4jfBIKQc5HC_9rand_core
[Kani] current codegen location: Loc { file: "/home/ubuntu/.rustup/toolchains/nightly-2023-02-03-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/error.rs", function: None, start_line: 237, start_col: Some(5), end_line: 237, end_col: Some(49) }
error: internal compiler error: Kani unexpectedly panicked at panicked at 'Function call does not type check:
                                func: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECs4jfBIKQc5HC_9rand_core::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "vtable" }, typ: Pointer { typ: StructTag("tag-_8188678315255410733::vtable") }, location: None }), typ: StructTag("tag-_8188678315255410733::vtable"), location: None }, field: "7" }, typ: Pointer { typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") } }, location: None }), typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") }, location: None }
                                args: [Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECs4jfBIKQc5HC_9rand_core::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "data" }, typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, location: None }]', cprover_bindings/src/goto_program/expr.rs:639:9.

error: could not compile `soroban-increment-contract`
error: Failed to compile `soroban-increment-contract` due to an internal compiler error.: error: internal compiler error: Kani unexpectedly panicked at panicked at 'Function call does not type check:
                                func: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECs4jfBIKQc5HC_9rand_core::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "vtable" }, typ: Pointer { typ: StructTag("tag-_8188678315255410733::vtable") }, location: None }), typ: StructTag("tag-_8188678315255410733::vtable"), location: None }, field: "7" }, typ: Pointer { typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") } }, location: None }), typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") }, location: None }
                                args: [Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECs4jfBIKQc5HC_9rand_core::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "data" }, typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, location: None }]', cprover_bindings/src/goto_program/expr.rs:639:9.

which seems to be the same as #2260.

@zhassan-aws zhassan-aws added T-High Priority Tag issues that have high priority [F] Crash Kani crashed T-User Tag user issues / requests labels Mar 22, 2023
@zhassan-aws
Copy link
Contributor

zhassan-aws commented Mar 22, 2023

This is a minimal example that reproduces the second crash (Function call does not type check):

#[kani::proof]
fn main() {
    let e = std::io::Error::new(std::io::ErrorKind::Other, "");
    let d = &e as &(dyn std::error::Error + 'static);
    let _ = d.is::<std::io::Error>();
}
$ kani test.rs 
thread 'rustc' panicked at 'Function call does not type check:
func: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Dereference(Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECsgeTCl3KQVL6_4test::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "vtable" }, typ: Pointer { typ: StructTag("tag-_8188678315255410733::vtable") }, location: None }), typ: StructTag("tag-_8188678315255410733::vtable"), location: None }, field: "7" }, typ: Pointer { typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") } }, location: None }), typ: Code { parameters: [Parameter { typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, identifier: None, base_name: None }, Parameter { typ: StructTag("tag-_780701421438352834"), identifier: None, base_name: None }], return_type: StructTag("tag-_17152028392377036744") }, location: None }
args: [Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECsgeTCl3KQVL6_4test::1::var_4" }, typ: StructTag("tag-_8188678315255410733::FatPtr"), location: None }, field: "data" }, typ: Pointer { typ: TypeDef { name: "_8188678315255410733Inner", typ: StructTag("tag-Unit") } }, location: None }]', cprover_bindings/src/goto_program/expr.rs:639:9
note: run with `RUST_BACKTRACE=1` environment variable to display a 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] current codegen item: codegen_function: <(dyn std::error::Error + 'static)>::is::<std::io::Error>
_RINvMs1_NtCshRHXfUtHLAG_4core5errorDNtB6_5ErrorEL_2isNtNtNtCs5ZM2BB1cE5A_3std2io5error5ErrorECsgeTCl3KQVL6_4test
[Kani] current codegen location: Loc { file: "/home/ubuntu/.rustup/toolchains/nightly-2023-02-03-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/error.rs", function: None, start_line: 237, start_col: Some(5), end_line: 237, end_col: Some(49) }
error: /home/ubuntu/git/kani/target/kani/bin/kani-compiler exited with status exit status: 101

Haven't been able to reproduce the original one yet.

@celinval celinval added the Z-Kani Compiler Issues that require some changes to the compiler label Apr 5, 2023
@celinval celinval self-assigned this Apr 6, 2023
celinval added a commit that referenced this issue Feb 6, 2024
Use FnAbi instead of function signature when generating code for
function types. Properly check the `PassMode::Ignore`. For foreign
functions, instead of ignoring the declaration type, cast the arguments
and return value.

For now, we also ignore the caller location, since we don't currently
support tracking caller location. This change makes it easier for us to
do so. We might want to wait for this issue to get fixed so we can
easily add support using stable APIs:
rust-lang/project-stable-mir#62

Resolves #2260
Resolves #2312
Resolves #1365
Resolves #1350
feliperodri added a commit that referenced this issue Feb 9, 2024
## What's Changed
* `modifies` Clauses for Function Contracts by @JustusAdam in
#2800
* Fix ICEs due to mismatched arguments by @celinval in
#2994. Resolves the following
issues:
  * #2260
  * #2312
* Enable powf*, exp*, log* intrinsics by @tautschnig in
#2996
* Upgrade Rust toolchain to nightly-2024-01-24 by @celinval @feliperodri
@qinheping

**Full Changelog**:
kani-0.45.0...kani-0.46.0

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Signed-off-by: Felipe R. Monteiro <felisous@amazon.com>
Co-authored-by: Celina G. Val <celinval@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working. [F] Crash Kani crashed T-High Priority Tag issues that have high priority T-User Tag user issues / requests Z-Kani Compiler Issues that require some changes to the compiler
Projects
No open projects
Status: No status
Status: No status
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants