You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
-Z valid-value-checks: raw pointer dereference of a dyn Trait pointee is reported as unsupported #5215
Z-UnstableFeatureIssues that only occur if a unstable feature is enabled[F] Spurious FailureIssues that cause Kani verification to fail despite the code being correct.
With -Z valid-value-checks, any harness that reads through a raw pointer to a trait object fails on an unsupported check, so the property can't be claimed for code that uses dyn Trait. In verify-rust-std this blocks every downcast, downcast_unchecked and dyn Any deref harness of the Box challenge (model-checking/verify-rust-std#639): 10 of its 71 harnesses, and the only ones left failing once #5205 lands.
use std::any::Any;#[kani::proof]fndowncast_box_dyn_any(){let b:Box<dynAny> = Box::new(kani::any::<i32>());let _ = b.downcast::<i32>();}
This verifies without the flag. With -Z valid-value-checks, on Kani 53cb531 and on #5205 rebased onto main (053e0f5):
Failed Checks: Kani currently doesn't support checking validity of `raw pointer dereference` for `dyn std::any::Any`
File: ".../library/alloc/src/boxed/convert.rs", line 314, in std::boxed::convert::<impl std::boxed::Box<dyn std::any::Any>>::downcast_any::<i32>
The report comes from check_place_value and the deref path in kani-compiler/src/kani_middle/transform/check_values.rs: ty_validity_per_offset returns Err for a dyn pointee, whose concrete type is only known from the vtable. Here the flagged dereference is T::type_id(&this) in downcast_any, which dereferences the Box<dyn Any> to make the type_id call. That doesn't produce a value of the unknown concrete type: the cast back to a concrete type happens afterwards, in cast_unchecked, and that's where a validity check would apply.
One option is to skip the check for a dyn pointee at the dereference, and check validity when the pointer is cast to a concrete type. I haven't looked at whether the vtable could be used instead.
Z-UnstableFeatureIssues that only occur if a unstable feature is enabled[F] Spurious FailureIssues that cause Kani verification to fail despite the code being correct.
Activity