See https://bugs.llvm.org/show_bug.cgi?id=46128
The crash was caused by incorect assumptions on a and a + 1
that resulted in knowing something about a (that it is exactly -1)
and only knowing about a + 1 that it is non-zero.
"constraints": [ { "symbol": "reg_$0<int a>", "range": "{ [-1, -1] }" }, { "symbol": "(reg_$0<int a>) + 1", "range": "{ [-2147483648, -1], [1, 2147483647] }" } ],
The problem was fixed by replacing plain assume on symbol with assume on
binary operator (test for "a==0" instead of "a").
An additional check was inserted at place of the assertion to prevent
similar crashes.
A test that triggers this last case is missing now.
The added test causes no problem because at start of the second loop
"c" can not be zero because the previous assumption made by the checker
(that did not work correct before the fix).
If we aim for a better fix, can we reduce the number of assumptions we make from 2 to 1? Like, it's ok if it's imperfect; 1 imperfect assumption is better than 2 imperfect assumptions.
The mental model i'm following here is that every path-sensitive bug can be thought of as a single formula over symbolic expressions. Eg., division by zero is the formula "$denominator == 0" is definitely true, double close is "is_closed($file_being_closed)", division by tainted value is "$denominator == 0" is possibly true AND "is_tainted($denominator)". I'd like you to write down the single formula that represents your bug and perform a single assume() over that and use the result of such assume as an ultimate source of truth. If such assume is not working correctly, let's think how to fix the assume rather than pile up more assumes in every checker to manually cross-check each other.