-
Notifications
You must be signed in to change notification settings - Fork 22
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(engine) Attempt to fix double return bug. #1223
Conversation
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.
Thanks, that looks great to me :)
Let's merge whenever libcrux is green!
This needs a bit more testing. Let's create a branch/PR for libcrux where we remove all instances of the workaround (these are marked by a comment referencing #720) and make sure it still laxes. |
I started a libcrux branch called |
The job failed, here is a reproducer: #[hax_lib::fstar::verification_status(panic_free)]
fn looping(array: &mut [u8; 5]) {
for i in 0..array.len() {
array[i] = i as u8;
}
} Open this code snippet in the playground
|
I went with the actual fix in |
This succeeds 🥳 . However this reveals another bug: fn range() {
let mut count = 0u8;
for i in 0u8..10u8 {
hax_lib::loop_invariant!(|i: u8| i <= 10);
count = i;
}
}
fn f() {
range()
} Open this code snippet in the playground |
I implemented a fix that binds all expression of type unit in |
17ed29f
to
c61f2d3
Compare
I improved a bit to check if there are side effects before changing anything. It is less disruptive to test snapdhots but there is still a diff in a few places. @W95Psp do you think this is ok? |
c61f2d3
to
4f5c139
Compare
Let's deal with this in a separate issue (#1231). And merge the fix for this one now. |
This is an attempt to make things better for #720.
As far as we know, this bug happens when there is a loop with side effects at the end of a function. Then
AndMutDefSite
transforms this to:And
LocalMutation
transforms this binding to:but the transformation of the loop is made in such a way that here
<loop>
has the type of <modified_var>.This fix is modifying
AndMutDefSite
so that if the expression has type unit, instead of the previous binding it produces:This works better with the assumptions of
LocalMutation
and fixes the bug (at least for the last reproducer that I added as a test). A more in depth rework of both those phases with a formalization of the invariants would be a better long-term solution.