BANDA / Issue 544BANDA incorrectly dismisses the assertion alarm at line 39.
The base analyzer flagged an assertion in a Juliet C program. BANDA checked that alarm and dismissed it, even though the program reaches line 39 with a value that makes the assertion false.
What does the program do?
In the original Juliet source, line 39 multiplies data by two and stores the result in a char. The benchmark inserted benchmark_assert immediately before that multiplication on the same line, then obfuscated the identifiers. The excerpt shows the instrumented source before obfuscation. Obfuscated C from the analyzed case
CWE190_Integer_Overflow__char_max_multiply_32.c · Source lines 22–43. Line 39 is laid out across several rows for readability.22 void CWE190_Integer_Overflow__char_max_multiply_32_bad()
23 {
24 char data;
25 char *dataPtr1 = &data;
26 char *dataPtr2 = &data;
27 data = ' ';
28 {
29 char data = *dataPtr1;
30 /* POTENTIAL FLAW: Use the maximum size of the data type */
31 data = CHAR_MAX;
32 *dataPtr1 = data;
33 }
34 {
35 char data = *dataPtr2;
36 if(data > 0) /* ensure we won't have an underflow */
37 {
38 /* POTENTIAL FLAW: if (data*2) > CHAR_MAX, this will overflow */
39 benchmark_assert(
(2) == 0 ||
((2) > 0
? ((data) <= 0 ||
(data) <= CHAR_MAX / (2))
: ((data) >= 0 ||
(data) >= CHAR_MAX / (2)))
);
char result = data * 2;
40 printHexCharLine(result);
41 }
42 }
43 }
Lines 24–32. Lines 25 and 26 assign both pointers the address of the outer data. Line 29 declares a second data inside the braces. Line 31 sets this inner variable to CHAR_MAX, which is 255 on the benchmark target. Line 32 copies that value through dataPtr1 into the outer byte. The outer byte keeps 255 when the block ends.
Lines 35–36. Line 35 reads that same outer byte through dataPtr2 into a new block-local data. Its value is 255. The test data > 0 therefore takes execution to line 39.
Line 39. benchmark_assert checks the condition before the multiplication. Since the multiplier is 2, (2) == 0 is false and (2) > 0 selects the first arm of the conditional. Integer division gives CHAR_MAX / 2 = 127. The remaining test is 255 <= 0 || 255 <= 127. Both comparisons are false, so the assertion fails.
What did BANDA get wrong?
| Tool | What it evaluated | Result at 39:13 |
| SVF-AE verifier | The assertion condition | [0, 0] means its only possible value is zero (false). The reported reason, ae-must-fail-if-reached, means every execution reaching this assertion fails it. |
| BANDA | The reported alarm | refuted. BANDA dismissed the failure. The execution above reaches it. |
What evidence points to cast handling?
The prepared LLVM input already substitutes the stored byte directly at its uses. The source-level write and read have disappeared from this function. Three comparisons each receive their own conversion of the same eight bits.
Selected instructions in execution order. Block labels, intervening instructions and debug metadata omitted. Original prepared LLVM input; ① Positive branch (C line 36)
%conv = zext i8 -1 to i32
%cmp = icmp sgt i32 %conv, 0
; ② Comparison with zero (C line 39)
%conv4 = zext i8 -1 to i32
%cmp5 = icmp sle i32 %conv4, 0
; ③ Comparison with 127 (C line 39)
%conv7 = zext i8 -1 to i32
%cmp8 = icmp sle i32 %conv7, 127
zext i8 -1 to i32 fills the upper 24 bits with zeros, giving 255. For each of the three uses above, we tested both the original cast and add i32 255, 0, which gives the same value. All eight runs used the original validator image, alarm file, and control flow.
Why BANDA dismisses the alarm
At revision ffe4fc95, BANDA reads a non-Boolean integer constant using its signed value. For the byte 11111111, that produces −1. When the frontend translates ZEXT, it passes that literal to the integer-cast builder and accepts the builder’s default .identity semantics. This represents the result as −1. LLVM requires 255. Constant projection · Cast translation · Builder default
To reach a failing assertion the value at ① must be positive, the value at ② must exceed zero, and the value at ③ must exceed 127. The incorrect −1 violates each requirement independently. In the over-approximating backward analysis, a cast from a literal checks that literal against the required destination range and returns infeasible when the check fails. Leaving even one of these three casts in the input was enough to produce the false refutation. Backward cast transfer
Expected behavior
The original prepared input is the regression case. BANDA should preserve the failing execution as possible. If it cannot determine the cast’s value precisely enough to decide the alarm, it should leave the alarm unresolved.