Heapster: Translation of LLVM globals is fragile, depends on getelementptr
indices being zero
#1875
Labels
subsystem: crucible-llvm
Issues related to LLVM bitcode verification with crucible-llvm
subsystem: heapster
Issues specifically related to memory verification using Heapster
type: bug
Issues reporting bugs or unexpected/unwanted behavior
Given these files:
If you run
test.saw
, it will typecheck without issue:Now, let's change the definition of
@E
to index into the second element ofD
instead of the first:Now, if you run SAW, the resulting
test_gen.v
file will have a type error!In particular, here is the type error:
Why is this happening? If you look how Heapster translates global variables, you will come across this peculiar piece of code:
saw-script/heapster-saw/src/Verifier/SAW/Heapster/LLVMGlobalConst.hs
Lines 199 to 200 in 79f69bf
This will translate a constant
getelementptr
expression that indexes into an array, but only if it uses the index0
. Because we changed the code above to use index1
, we reach the catch-all error case below:saw-script/heapster-saw/src/Verifier/SAW/Heapster/LLVMGlobalConst.hs
Lines 206 to 208 in 79f69bf
Admittedly, this example is a contrived one, as I had to hand-write LLVM bitcode to trigger it. But I don't think it's totally unreasonable either—Clang could quite conceivably optimize some array constant–heavy code into something that looks like this. For this reason, I find the current translation of array constants in Heapster somewhat uncomfortable, as we seem to be skating on thin ice.
This issue aims to find a more robust way to implement global constant translation in Heapster that avoids this issue.
The text was updated successfully, but these errors were encountered: