-
Notifications
You must be signed in to change notification settings - Fork 169
Tasks from PR #808 contain undefined behavior #813
Comments
Hi @MartinSpiessl, thanks for checking these overflow problems. I am not sure how to fix them. For example, sv-benchmarks/c/nla-digbench/divbin.c Line 30 in ea7880b
Suggestion ? |
There are two possible approaches:
Here, it seems that the worst case is when
So probably something like:
should work. B does not have to be limited, since if it is bigger than a, it will never be doubled. |
@nguyenthanhvuh Would it be possible for you to file a new pull request for fixing this? |
@dbeyer, yes, will create a PR in a couple of days. |
@MartinSpiessl I've made some changes and created a PR #837. Could you take a look to see if these changes fix the issues? Thanks, |
Sorry, I must have missed the notification for this issue.
All fixes except
Looks like the overflow is caused by:
|
Hi, the bound for the variables was reduced to half what it was before. Does this resolve the issue? |
I do not see any updates on |
Hi, the updates I was referring to can be seen at: https://github.com/nguyenthanhvuh/sv-benchmarks/blob/master/c/nla-digbench/lcm2.c where the variables a and b are bounded to 32768. Would that work? |
No, that doesn't work, off by one! With both upper values set to 32767 there is however no overflow anymore, so change 32768 to 32767 and it should be fine 👍 |
At least some of the tasks added in PR #808 contain overflows of signed integer variables, i.e. undefined behavior. Examples are
divbin.c
in line 30(multiplication of nondeterminisic signed integer with factor 2) andlcm1.c
in line 31(multiplication of two nondeterministic signed integers).I ran CPAchecker's overflow analysis for the tasks with nla-digibench-overflow.txt (had to name it
*.txt
because github does not allow uploading xml files -.-).The results with a timeout of 60 seconds look like this:
note that CPAchecker did not find the overflow in
lcm1.c
in time, so there could also be obvious overflows in tasks where CPAchecker did run into a timeout.knuth.c
failed because it still has preprocessor directives in it, but it contains an overflow in line 31 as well (calculation of8*n
wheren
is a non-deterministic signed integer).The text was updated successfully, but these errors were encountered: