Skip to content
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

The new rotl functions can exhibit undefined behavior when amt = 0. #6

Open
weaversa opened this issue May 30, 2020 · 0 comments
Open

Comments

@weaversa
Copy link

The new rotl functions can exhibit UB when amt = 0.

$ make prove
clang xxhash32-ref.c -o xxhash32-ref.bc -c -emit-llvm -Wno-long-long -O1 -std=c90
clang xxhash64-ref.c -o xxhash64-ref.bc -c -emit-llvm -Wno-long-long -O1 -std=c90
saw saw/xxhash32.saw
[18:12:55.128] Loading file "xxhash-clean/saw/xxhash32.saw"
[18:12:55.130] Loading file "xxhash-clean/saw/llvm.saw"
[18:12:55.426] Verifying XXH_rotl32 ...
[18:12:55.426] Simulating XXH_rotl32 ...
[18:12:55.430] Checking proof obligations XXH_rotl32 ...
[18:12:55.439] Subgoal failed: XXH_rotl32 safety assertion:
LLVM Poison value created
The second operand of `lshr` was equal to or greater than the number of
bits in the first operand
in XXH_rotl32 at internal
Details:
Undefined behavior encountered: 
LLVM Poison value created
The second operand of `lshr` was equal to or greater than the number of
bits in the first operand
Reference: 
The LLVM language reference, version8
‘lshr’ Instruction (Semantics)
Document URL: https://llvm.org/docs/LangRef.html

[18:12:55.439] SolverStats {solverStatsSolvers = fromList ["SBV->Z3"], solverStatsGoalSize = 30}
[18:12:55.439] ----------Counterexample----------
[18:12:55.439]   amt: 0
[18:12:55.440] ----------------------------------
[18:12:55.440] Stack trace:
"llvm_verify" (xxhash-clean/saw/xxhash32.saw:41:22-41:33):
"crucible_llvm_verify" (xxhash-clean/saw/llvm.saw:37:3-37:23):
Proof failed.
make: *** [prove] Error 2

Originally posted by @weaversa in #2 (comment)
I don't know if you saw the comment on the closed issue so I opened a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant