-
Notifications
You must be signed in to change notification settings - Fork 97
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
Kani crashes when handling code related to AtomicPtr #3042
Comments
Found by @zhassan-aws , this seems to be the change commit in rust that likely caused the panic: rust-lang/rust@b17491c |
FYI, the test case was based on the test here: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicPtr.html#method.fetch_byte_sub |
Hi @qinheping, did you make any progress in this issue? I would be fantastic if we could fix the M1 job sooner rather than later. Let me know if you have any questions. |
The atomic intrinsics such us #![feature(core_intrinsics)]
use std::intrinsics::{
atomic_xsub_relaxed
};
#[kani::proof]
fn main() {
let mut a = 1 as u8;
let mut ptr: *mut u8 = &mut a;
let ptr_ptr: *mut *mut u8 = &mut ptr;
unsafe {
let x = atomic_xsub_relaxed(ptr_ptr, ptr);
}
} We might need to also support such arguments in https://github.com/model-checking/kani/blob/main/kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs#L243 |
Fetch functions of atomic_ptr calls atomic intrinsics functions with pointer-type arguments (invalid_mut), which will cause typecheck failures. The change in this commit add support of pointer-type arguments into codegen_atomic_binop to fix the issue. The new codegen_atomic_binop will cast pointer arguments to size_t, apply op on them, and then cast the op result back to the pointer type. Fix the issue model-checking#3042.
Fetch functions of `atomic_ptr` calls atomic intrinsic functions with pointer-type arguments (`invalid_mut`), which will cause typecheck failures. The change in this commit add support of pointer-type arguments into `codegen_atomic_binop` to fix the issue. The new `codegen_atomic_binop` will cast pointer arguments to `size_t`, apply op on them, and then cast the op result back to the pointer type. The new test include all fetch functions of `atomic_ptr` except for `fetch_ptr_add` and `fetch_ptr_sub`, which do not call intrinsic functions. Resolves #3042. --------- Co-authored-by: Adrian Palacios <[email protected]> Co-authored-by: Zyad Hassan <[email protected]>
Caught by the M1 regression, Kani seems to crash when handling harness that use atomic pointers.
Here is a minimal example that causes the crash, in both linux and mac versions of Kani
This is the crash
using the following command line invocation:
with Kani version: 0.46.0, 0.45.0, 0.42.0 (and possible older versions).
The text was updated successfully, but these errors were encountered: