[FEATURE REQUEST] Pointer arithmetic #127
Labels
⁉ priority:p2
Priority planning - level 2
🔍 scope:analysis
Work regarding abstract domains or fixpoint algorithms
🏨 scope:infrastructure
Work regarding the general infrastructure and functioning of LiSA
🎆 type:feature
New feature or request
Milestone
Memory model
To add support for pointers, we first have to reshape the memory model. Instead of having only the heap, the memory is now partitioned in heap and stack.
Identifiers
To reflect this change, the hierarchy of the
Identifier
symbolic expression has to change:Identifier
Variable
: a real variable of the programMemoryLocation
: a generic location in the program memory (hn
orsn
)StackElement
: a location on the stack (sn
)HeapLocation
: a location in the heap (hn
)MaskedIdentifier
: a compound identifier referencing another oneAddress
: the address of another identifierOutOfScopeIdentifier
: an identifier that has been scoped by a call or similar construct, that the code cannot directly accessMemory Expressions
The
HeapExpression
s must now accommodate also operations on other parts of the memory:MemoryExpression
Allocation
: an expression that allocates a new memory region. Corresponds tonew
/malloc
/.... Always rewrites to aMemoryLocation
HeapAllocation
: an expression that allocates a new heap region. Always rewrites to aHeapLocation
StackAllocation
: an expression that allocates a new stack region. Always rewrites to aStackElement
GetAddress(e)
: gets the address of an expressione
. Corresponds to&e
. Always rewrites to anAddress
.e
can be an arbitrary expression.Dereference(e)
: dereferences an address to get to the memory location. Corresponds to*e
.e
must be anAddress
. Always rewrites to anIdentifier
Traverse(r, e)
: gets from one location to another one. Corresponds tor.e
/r[e]
/.... Always rewrites to aMemoryLocation
.r
must be anAddress
.e
can be a string, aGlobal
, or an arbitrary expression.Having a generic expression in
Traverse
andGetAddress
enables usage of pointer arithmetics and tracking of fields in dynamic objects. AMemoryDomain
can use itsSemanticOracle
to evaluate the expression, obtaining an instance ofLattice
that represents the location accessed.Memory Domains
The current memory abstractions are
Monolithic
,ProgramPointBased
, andFieldSensitiveProgramPointBased
.Monolithic
is fine as-is, since everything is the same locations.PogramPointBased
does not distinguish between different sub-locations, so it does not require modifications forTraverse
. Instead, forGetAddress
the evaluation can be reduced to the evaluation of their root location (e.g.,&(x+1)
is the same of&x
).FieldSensitiveProgramPointBased
can instead track sub-locations, but at the current state can only track syntactic ones:x.f
works if f is a field, butx[n]
does not work ifn
is a variable. This can still be acceptable on some programs that only manipulate objects with statically known fields. While the obvious endgame is to implement a shape analysis, a middle-ground implementation can be this one, that is basically a field sensitive implementation ofProgramPointBased
that uses lattice instances for fields.Still to discuss
The text was updated successfully, but these errors were encountered: