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
Kani implementation of drop for Struct<dyn T> is broken #1072
T-High PriorityTag issues that have high priority[C] BugThis is a bug. Something isn't working.[F] Spurious FailureIssues that cause Kani verification to fail despite the code being correct.
We were handling drop_in_place incorrectly when the object to be dropped had type Struct like in the example below.
For now, we are going to codegen unimplemented, so if this code is reachable, the verification will fail.
I tried this code:
use std::rc::Rc;pubtraitDummyTrait{}pubstructWrapper<T: ?Sized>{pubw_id:u128,pubinner:T,}impl<T: ?Sized>DropforWrapper<T>{fndrop(&mutself){assert_eq!(self.w_id,0);}}structDummyImpl{pubid:u128,}implDummyTraitforDummyImpl{}implDropforDummyImpl{fndrop(&mutself){assert_eq!(self.id,1);}}#[kani::proof]fncheck_drop_dyn(){let original = Rc::new(Wrapper{w_id:0,inner:DummyImpl{id:1}});let _wrapper =
unsafe{Rc::from_raw(Rc::into_raw(original)as*constWrapper<dynDummyTrait>)};}
using the following command line invocation:
kani check.rs
with Kani version:
I expected to see this happen: Harness should succeed.
Instead, this happened:
With codegen unimplemented check, this harness fails with:
Failed Checks: drop unsized struct: Wrapper<dyn DummyTrait>
Without codegen unimplemented check, this harness fails with:
I think the fix for this MIGHT be to refactor the "virtual table drop" code to actually call the normal virtual table invocation code, instead of sort of duplicating it, apparently incorrectly. I'm not sure if that's the only issue here however.
Also, this refactoring is not quite as straightforward as it sounds for uninteresting reasons: drop returns unit/void, but our existing virtual table function invocation code expects a Place to store the return value. So THAT in turn needs refactoring to separate out those two steps, which in turn suggests some refactorings to codegen_function...
T-High PriorityTag issues that have high priority[C] BugThis is a bug. Something isn't working.[F] Spurious FailureIssues that cause Kani verification to fail despite the code being correct.
Activity
tedinski commentedon Jul 29, 2022
I think the fix for this MIGHT be to refactor the "virtual table drop" code to actually call the normal virtual table invocation code, instead of sort of duplicating it, apparently incorrectly. I'm not sure if that's the only issue here however.
Also, this refactoring is not quite as straightforward as it sounds for uninteresting reasons: drop returns unit/void, but our existing virtual table function invocation code expects a
Placeto store the return value. So THAT in turn needs refactoring to separate out those two steps, which in turn suggests some refactorings tocodegen_function...