<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54272>54272</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Infeasible state causing crash with alpha.unix.cstring.UninitializedRead
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:static analyzer,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
martong,
steakhal
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
martong
</td>
</tr>
</table>
<pre>
Here is the minimal reproducer on d5106c8f973b
```
// RUN: %clang_analyze_cc1 %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=alpha.unix.cstring.OutOfBounds,alpha.unix.cstring.UninitializedRead \
// RUN: -analyzer-checker=debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -verify
typedef struct {
char a[1024];
} b;
int c;
b *invalidate();
int d() {
b *a = invalidate();
if (c < 1024)
return 0;
int f = c & ~3, g = f;
g--;
if (g)
return 0;
// Parent state is already infeasible.
// clang_analyzer_printState();
// "constraints": [
// { "symbol": "(derived_$3{conj_$0{int, LC1, S728, #1},c}) & -4", "range": "{ [1, 1] }" },
// { "symbol": "derived_$3{conj_$0{int, LC1, S728, #1},c}", "range": "{ [1024, 2147483647] }" }
// ],
memmove(a->a, &a->a[f], c - f); // CRASH, both true and false states are nullptr!
return 0;
}
```
This bug is yet another manifestation of an underlying API issue: We should have an API for the checkers where only `assumeDual` like functions are allowed. In that case we could return a nonnull state for at least one of the true/false cases. Besides that we should mark and handle the infeasible state in `addTransition`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVV1v2zoM_TXOCxHDke04echDk3RYgeFuaDfssVAs2tYqy4Ekp8t-_aVkJ82y3rsOAwzLkvhxSB7Su04cV-_RIEgLrkFopZYtV2BwbzrRl2ig0yDyWTIvF9WySHcQJdsouRnf82R8hi17Rw_cf_knSm8gYnmpuK4fuebq-AMfy3LmDy1E-eY1BYDp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