Closed aytey closed 5 years ago
@andrewvaughanj Good catch!
The issue here is indeed the udiv
function in testbv.c
, which obviously must use UINT64_MAX
since the types are uint64_t
. Good question why this came up with Windows, but not with Linux. In theory, rand()
should return 0 on occasion, but very rarely so, probably. So yes, maybe it is less random on Windows?
I fixed the tests a bit differently than you suggested. Can you check if you still encounter problems with https://github.com/Boolector/boolector/commit/f689fbbfe820392d35e26be368f9d87d2dbdb037?
@aniemetz thanks for taking a look!
Everything now looks good to me (the important thing was the UINT32_MAX
change):
Finished 1300 tests:
Number of tests skipped: 19
Number of tests succeeded: 1281
Number of files successfully compared: 775/775
Great! Thanks for checking!
When targeting 32-bit Windows (I have not tried 64-bit Windows, sorry), I get an assertion error when running
./bin/test.exe udiv_bitvec
.To diagnose this failure, I modified
test/testbv.c
as follows (the print ofbv1
andbv2
is superfluous, given the print ofa1
anda2
, but that shouldn't change anything):and I get the following output:
So, of the
100000
tests that get run, we only seeassert
ion failures whena2
is0
.This particular test does this:
where the last argument is the bit-width (
33
in this case). Furthermore the functionudiv
looks like this:So, for
udiv
, if the second argument (==bv2
) is0
, then it returns something based off ofUINT32_MAX
, while I imagine (and I haven't checked) thatbtor_bv_udiv
is "width agnostic". Furthermore, all of the variables inside of the functionbinary_bitvec
(the callee ofudiv
) areuint64_t
s.Interestingly, when I run this test (with these prints) on 32-bit Linux, then the lowest value I get for
bv1
/a1
is48121
and the lowest forbv2
/a2
is96199
(i.e., I never seem to get0
forbv2
).If I create a hand-written test on any Linux architecture (both 32-bit and 64-bit) that does something like this:
(rather than the call to
random_bv
) then I do see this failure (again, on any Linux architecture).Importantly: if I change the function
udiv
to do its modulo calculation based up onUINT64_MAX
then the tests no longer fail!Some questions:
random_bv
can return 0?random_bv
never returns 0 on Linux, but does on Windows (mayberand()
is just "less random" on Windows)?bv2
being 0?udiv
does its modulo calculations based offUINT32_MAX
when working on 64-bit operands?If you are happy, I would suggest that we:
udiv_bitvec
, but wherebv2
is always hard-coded to be0
(maybe something like:udiv_bitvec_zero
)udiv
function to base its calculations off ofUINT64_MAX
I am more than happy to do this work.