-
Notifications
You must be signed in to change notification settings - Fork 92
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
Fix issues with how we compute DST size #3687
base: main
Are you sure you want to change the base?
Conversation
1. Add proper bounds check for `size_of_val` intrinsics. 2. Refactor how we compute size of the object in our mem predicates. 3. Provide user visible methods to try to retrieve the size of the object if known and valid.
b47ae6d
to
f805e34
Compare
kani-compiler/src/kani_middle/abi.rs
Outdated
} | ||
RigidTy::Tuple(tys) => { | ||
// We have to recurse and get the maximum alignment of all sized portions. | ||
let last_ty = tys.last().expect("Expected unsized tail"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: Fix this. The order of fields is not guaranteed, and we need to use similar logic as the Adt
logic to get the last field.
- Assume for now that we cannot compute foreign object size.
let model = match intrinsic { | ||
Intrinsic::SizeOfVal => self.models[&KaniModel::SizeOfVal], | ||
Intrinsic::MinAlignOfVal => self.models[&KaniModel::AlignOfVal], | ||
// The rest is handled in hooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// The rest is handled in hooks. | |
// The rest is handled in codegen. |
FYI, I'm going to create a fix for the std in a separate PR. Also I think I could break down this PR into two if needed. |
Sorry for the big change. They were all somewhat connected to size of DST.
size_of_val
andalign_of_val
intrinsics.checked_size_of_raw
andchecked_align_of_raw
.from_raw_ptr
in our tests.Fixes #3612
Fixes #3616
Fixes #3627
Fixes #3638
Fixes #3615
Call-outs
There's a bit of refactoring here on how to handle
size_of_val
intrinsics to reuse the same logic as the new predicates. Otherwise we would have to apply two fixes and keep maintaining them both. Note that I haven't deleted the code used bythe intrinsic yet, since that is still used in the raw pointer to reference checks. I will do that in a follow up PR.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.