Description
Calling min with non-empty extra constraints results in an incorrect value, because the expression is found in _min_exhausted and cached results are incorrectly used to calculate the minimum.
A simple reproducer:
import claripy
s = claripy.Solver()
x = claripy.BVS("x", 64)
y = claripy.BVS("y", 64)
s.add(x - y >= 4)
s.add(y > 0)
print(s.min(x))
print(s.min(x, extra_constraints=[x > 1]))
The last line prints 3 even though the correct answer is 2.
A simple solution would skip checking _min_exhausted and using cached results when extra constraints are passed. A related bug seems to has been fixed previously in 9d4b861.
The issue also seems to apply to max and possibly eval.
Steps to reproduce the bug
No response
Environment
No response
Additional context
No response
Description
Calling
minwith non-empty extra constraints results in an incorrect value, because the expression is found in_min_exhaustedand cached results are incorrectly used to calculate the minimum.A simple reproducer:
The last line prints 3 even though the correct answer is 2.
A simple solution would skip checking
_min_exhaustedand using cached results when extra constraints are passed. A related bug seems to has been fixed previously in 9d4b861.The issue also seems to apply to
maxand possiblyeval.Steps to reproduce the bug
No response
Environment
No response
Additional context
No response