Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDG: Keep track of lifetimes of stack values #1117

Open
ahomescu opened this issue Aug 31, 2024 · 1 comment
Open

PDG: Keep track of lifetimes of stack values #1117

ahomescu opened this issue Aug 31, 2024 · 1 comment
Assignees
Labels
bug Something isn't working c2rust-analyze

Comments

@ahomescu
Copy link
Contributor

ahomescu commented Aug 31, 2024

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 ahomescu added bug Something isn't working c2rust-analyze labels Aug 31, 2024
@ahomescu ahomescu changed the title PDG: Keep track of lifetimes of static values PDG: Keep track of lifetimes of stack values Sep 9, 2024
@thedataking thedataking assigned thedataking and kkysen and unassigned thedataking Oct 7, 2024
@thedataking
Copy link
Contributor

thedataking commented Oct 7, 2024

Should investigate whether the "StorageLive" MIR node provides the necessary information for dynamic analysis. Do we get an event signifying the end of the lifetime of the stack allocation. If that is not a viable approach, we need to discuss possible alternative implementations before moving ahead with one of those.

@kkysen raised the question of whether we should more generally handle storage going out of scope (e.g. inside a function). We need to figure out whether we should solve the concrete issue for lighttpd or go directly for the more general solution. Depends on the complexity of solving the more general issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c2rust-analyze
Projects
None yet
Development

No branches or pull requests

4 participants
@ahomescu @thedataking @kkysen and others