Don't use projectLLVM_bv
for zero-extending or truncating pointers
#41
Labels
bug
Something isn't working
projectLLVM_bv
for zero-extending or truncating pointers
#41
Several parts of
stubs
employ an anti-pattern where we use theprojectLLVM_bv
function immediately followed byllvmPointer_bv
for the purposes of zero-extending or truncating a pointer value. Here is one part ofstubs
that does this:stubs/stubs-common/src/Stubs/FunctionOverride/AArch32/Linux.hs
Lines 161 to 169 in 56851fc
(Note that
bvToPtr
is defined in terms ofllvmPointer_bv
.)This is wrong when dealing with pointer arguments, as
projectLLVM_bv
will throw an assertion failure when the argument is a pointer. It would be more correct to project out the block number and offset (without making an assertion), adjust the offset accordingly, then reconstruct a pointer with the same block number and the adjusted offset.It's only by sheer luck that we've managed to avoid triggering these assertion failures up until now, but I have managed to trigger this error as part of ongoing work to support PowerPC (#38). As such, I plan to fix this as part of #38.
See also #40, which is about improving the error messages in situations where we really do need to assert that a pointer is a bitvector (unlike the scenario described in this issue, where we can work with both pointers and bitvectors alike).
The text was updated successfully, but these errors were encountered: