c2rust
c2rust copied to clipboard
PDG: Keep track of lifetimes of stack values
The dynamic analyzer keeps track of lifetimes of heap allocations by emitting Free
events for objects being deallocated. We need something similar for stack values, to prevent issues where two locals in different functions get the same pointer, e.g.
fn foo() {
let x = 32;
}
fn bar() {
// We may have `addr_of!(x) == addr_of!(y)` here.
let y = 42;
}
fn main() {
foo();
bar();
}
This can produce an incorrect PDG where x
and y
above have the same graph.