flowistry icon indicating copy to clipboard operation
flowistry copied to clipboard

Extend flowistry to types with interior mutability

Open jyn514 opened this issue 2 years ago • 4 comments

You mentioned two things during your thesis defense:

  1. There are two analyses that flowistry supports: whole-program analysis, and (very accurate) heuristics using the lifetime annotations people already provide for the borrow checker.
  2. The lifetime annotations only work for exterior mutability; things like AtomicUsize::set are not considered by flowistry to affect the data flow of the program.

I think it would be possible to extend this to interior mutability by using the intra-procedural analysis that looks into dependencies, but only for types which have interior mutability. The compiler already knows statically which types have interior mutability, because they have to contain an UnsafeCell (anything else is already undefined behavior).

jyn514 avatar May 06 '22 23:05 jyn514

The compiler already knows statically which types have interior mutability, because they have to contain an UnsafeCell (anything else is already undefined behavior).

That's true only for owned types though, something like NonNull<T> or *mut T can also mutate the value.

WaffleLapkin avatar May 09 '22 13:05 WaffleLapkin

@WaffleLapkin those types aren't using interior mutability, they're using unsafe. Writing to a *mut T when you only have a &T is undefined behavior. So flowistry can just treat them like normal types.

jyn514 avatar May 09 '22 14:05 jyn514

@jyn514 pointers can point to the heap, they not necessarily come from &T . Or they can actually point to an UnsafeCell somewhere, they were just casted to point to T (that's ok because UnsafeCell is repr(transparent)).

WaffleLapkin avatar May 09 '22 14:05 WaffleLapkin

@WaffleLapkin ah, sure. But I think it's ok to support interior mutability without first supporting raw pointers, the second will be much more difficult (it probably will require whole-program analysis).

jyn514 avatar May 09 '22 14:05 jyn514