Unsound congruence domain arithmetic #1587
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I inspected the first
ERROR (both branches dead)
result after #1579 on sv-benchmarks and it lead to unsound congruence domain arithmetic which presents itself as both branches dead in a reduced sv-benchmarks program (in this PR).It's from a hardness task, and those make up 72 of the 81 cases from a nightly run. I didn't check others because they might all be for the same reason.
In particular, the unsound operations are visible from this tracing output:
For context, this is about
sub
being implemented asanalyzer/src/cdomain/value/cdomains/intDomain.ml
Line 3129 in 060004c
where
neg
involves amul
:analyzer/src/cdomain/value/cdomains/intDomain.ml
Line 3102 in 060004c
In fact, there are multiple problems visible here:
3ℤ - (1+3ℤ) = ℤ
(should be2+3ℤ
?) and3ℤ - 2 = 3ℤ
(should be1+3ℤ
?). I'm not sure if this is unsound because of the indirect definition ofsub
or what.4294967295 * 2 = 8589934590
. Seems like this result should also be reduced modulo 4294967296.There's a
normalize
function in the congruence domain, but the arithmetic operations don't seem to call it in all cases.