-
Notifications
You must be signed in to change notification settings - Fork 123
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
What4 panic - bvSliceLE #1359
Comments
Interesting. I can reproduce this using Cryptol 2.13.0 but not 2.12.0. |
Ah, but that's simply because the implementation of
Then I can reproduce the panic using either Cryptol 2.12.0 or 2.13.0:
|
A slightly smaller example that doesn't require
|
I'm going to take a look at this real quick... |
This tells me that the |
I'm not sure what's going on here; it's clearly got something to do with the translation of |
I think I see what is going on here. This is a Cryptol bug, not a What4 one, so I've moved the issue accordingly. The issue arises due to a bug in the way the cryptol/src/Cryptol/Eval/What4.hs Lines 512 to 515 in 8cca245
Will construct a mux of all possible indices from cryptol/src/Cryptol/Eval/What4.hs Lines 538 to 547 in 8cca245
The implementation of Note that this bug does not occur if the type of cryptol/src/Cryptol/Eval/What4.hs Lines 577 to 582 in 8cca245
The SBV backend also subtracts 1 from diff --git a/src/Cryptol/Eval/What4.hs b/src/Cryptol/Eval/What4.hs
index 0e6bc98f..bedd7139 100644
--- a/src/Cryptol/Eval/What4.hs
+++ b/src/Cryptol/Eval/What4.hs
@@ -541,9 +541,9 @@ indexFront_int sym mblen _a xs ix idx
-- integer is unbounded, there isn't much we can do.
maxIdx =
case (mblen, ix) of
- (Nat n, TVIntMod m) -> Just (min (toInteger n) (toInteger m))
- (Nat n, _) -> Just n
- (_ , TVIntMod m) -> Just m
+ (Nat n, TVIntMod m) -> Just (min (toInteger n) (toInteger m) - 1)
+ (Nat n, _) -> Just (n - 1)
+ (_ , TVIntMod m) -> Just (m - 1)
_ -> Nothing
indexFront_segs ::
W4.IsSymExprBuilder sym => (Curiously, there are also special cases for when the index is |
Nice find @RyanGlScott, I'm sure that code is my fault. I think the On the other side of the bound, are we always guaranteed to call these functions with |
I believe that by the time that |
These cases for `Z m` indices in the What4 implementation of `(@)` are unreachable by virtue of the fact that the index must be `Integral`. Let's remove them to make the code simpler. See #1359 (comment) for where this was originally noticed.
In the case where the index is a symbolic `Integer` and the sequence is of length `n`, the What4 backend mistakenly chose `n` to be the largest possible index. This corrects it to instead be `n - 1`. Fixes #1359.
The text was updated successfully, but these errors were encountered: