tjausm / Jip

Symbolic execution engine written for the OOX language in Rust
1 stars 0 forks source link

Null forking #31

Closed tjausm closed 1 year ago

tjausm commented 1 year ago

Idea 1: true lazy

Add special LazyReference(ref, class) type to Symbolic expression:

LazyRef implements:

problem: how do we prevent lazyref from being instantiated in one place and not being instantiated in another? Is this even a problem?

solution: is not a problem. If one is initiated there must be a constraint indicating that ref is not null. Thus lazy refs will resolve to actual ref during constraint solving.

Implementation:

Idea 2: on declaration

fork only happens when initializing lazy objects as arguments of main(), accessing fields of lazy objects or when accessing arrays with lazy objects. Let those functions fork as follows:

Initializing lazy object Forks state, happens in init_lazy_object() -> (Reference, Reference, SymMemory) returning a null reference and a

accessing fields If we access a field of reference r that is null we push r == null to pc, call pc.conjunct() and if expression_unsatisfiable holds we drop path, otherwise return error.

Accessing Object Generates Fork if field is a lazy object

accessing arrays Generates Fork if it is array of lazy objects:

Forking routine:

  1. Use a type Fork<a> = No a | Yes a (Vec<State>)
  2. implement a straighten(queue) method on the Fork type that returns a and possibly pushes new state(s) to front of queue
  3. save initial state init_state each time when inspecting CFG node in SEE
  4. when entering a function that could fork, pass &init_state to it, and call straighten on the result
tjausm commented 1 year ago

access_array, access_object & stack_get are implemented. Still need to implement release and initialise and correct encoding of LazyReferences in smtlib

tjausm commented 1 year ago

Add LazyReference to simplifier