Christian Gram Kalhauge
What does it mean for two variables to be dependent?
What is the primary problem when doing unbounded static analysis?
Why do we need a widening operator?
@Case("(0) -> ok")
@Case("(1) -> ok")
public static int safeDivByN(int n) {
if (n != 0) {
return 1 / n;
}
return 0;
}| Offset | Instruction | Abstract State |
|---|---|---|
000 | load:I 0 | |
001 | ifz eq 6 | |
002 | push:I 1 | |
003 | load:I 0 | |
004 | binary:I div | |
005 | return:I | |
006 | push:I 0 | |
007 | return:I |
| Offset | Instruction | Abstract State |
|---|---|---|
000 | load:I 0 | |
001 | ifz eq 6 | |
002 | push:I 1 | |
003 | load:I 0 | |
004 | binary:I div | |
005 | return:I | |
006 | push:I 0 | |
007 | return:I |
@Case("(0, 0) -> ok")
@Case("(1, 1) -> ok")
public static int safeDivAByB(int a, int b) {
if (a >= 0) {
if (b > a) {
return a / b
}
}
return 0;
}Given a function , that is monotone over then the minimal fixed point is the least st.
means , where is applied times.
void example() {
int i = 0;
while (i >= 0) {
i = i + 1;
}
}| State | Comment |
|---|---|
int i = 0 | |
see that i >= 0 | |
i = i + 1 | |
| loop back | |
see that i >= 0 | |
i = i + 1 | |
| loop back | |
| ... | ... |
An operator
def step(self) -> tuple[PC, set[str]]:
# Pop from worklist
pc = self.worklist.pop()
for res in manystep(self.bc, pc, self.states[pc]):
pc_, st = res
before = self.states.get(pc_, st)
after = before | st
if pc_ not in self.states or after != before:
self.states[pc_] = after
# Update worklist
self.worklist.append(pc_)
# ...void fn(int x) {
int i = 0;
if (x == 0) {
i += 1;
} else {
i -= 1:
}
// Many operations on i.
}void fn() {
int i = 0;
while (i < 100) {
i += 1;
}
// Many operations on i.
}The control flow graph of the example code.
What does it mean for two variables to be dependent?
What is the primary problem when doing unbounded static analysis?
Why do we need a widening operator?