← Back to context

Comment by uecker

4 days ago

I don't know yet. My current expectation from what I have seen is that lifetime analysis can be done fully automatic for most C code as long as it can be done independently from other program state, i.e. the checker has to reason only about the state of pointers and not also simultaneously about all other variables. I have seen quite promising work on this.

> lifetime analysis can be done fully automatic for most C code as long as it can be done independently from other program state

Is this an interprocedural or intraprocedural analysis?

> I have seen quite promising work on this.

Is this work public? I'm interested in seeing more!

  • It is interprocedural, but one obviously needs annotations for interfaces to libraries that are linked-in.

    One example of a project wich goes in this direction is this work: https://www.sei.cmu.edu/projects/ai-powered-memory-safety-fo...

    (I assume the AI is mostly marketing as it is not necessary)

    • Thanks for the link! That's an interesting approach indeed. If I'm reading the paper [0] correctly the concepts involved look pretty similar to what Rust uses. I think they turn the interprocedural analysis into an intraprocedural one as well by effectively deriving borrowing information from function implementations and attaching that to signatures for use by callers. It's a compatibility hazard, which is why Rust chose to not do the same, but in principle it makes it easier to derive more precise borrowing information.

      [0]: https://dl.acm.org/doi/epdf/10.1145/3814943.3816182

      6 replies →