c2rust icon indicating copy to clipboard operation
c2rust copied to clipboard

PDG: Keep track of lifetimes of stack values

Open ahomescu opened this issue 5 months ago • 1 comments

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.

ahomescu avatar Aug 31 '24 05:08 ahomescu