Skip to content

Commit

Permalink
abort instead of failing in concolic execution when encountering a
Browse files Browse the repository at this point in the history
limitation of the memory model as it's already done in symbolic
  • Loading branch information
zapashcanon committed Jun 15, 2024
1 parent 562d57e commit 373e424
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/concolic/concolic_wasm_ffi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,34 +83,36 @@ module M :

open Expr

let i32 (v : Value.int32) =
let abort () : unit Choice.t = Choice.abort

let i32 (v : Value.int32) : int32 Choice.t =
(* TODO: select_i32 ? *)
(* let+ v = Choice.select_i32 v in *)
(* let n = v.c in *)
(* let x = Choice.assume (Value.I32.eq v (Value.const_i32 n)) in *)
match view v.symbolic with
| Val (Num (I32 v)) -> v
| Val (Num (I32 v)) -> Choice.return v
| _ ->
Log.err {|alloc: cannot allocate base pointer "%a"|} Expr.pp v.symbolic
Log.debug2 {|alloc: cannot allocate base pointer "%a"|} Expr.pp v.symbolic;
Choice.bind (abort ()) (fun () -> assert false)

let ptr (v : Value.int32) =
let ptr (v : Value.int32) : int32 Choice.t =
match view v.symbolic with
| Ptr (b, _) -> b
| Ptr (b, _) -> Choice.return b
| _ ->
Log.err {|free: cannot fetch pointer base of "%a"|} Expr.pp v.symbolic

let abort () : unit Choice.t = Choice.abort
Log.debug2 {|free: cannot fetch pointer base of "%a"|} Expr.pp v.symbolic;
Choice.bind (abort ()) (fun () -> assert false)

let exit (p : Value.int32) : unit Choice.t =
ignore p;
abort ()

let alloc (base : Value.int32) (_size : Value.int32) : Value.int32 Choice.t =
let base : int32 = i32 base in
Choice.return
{ Concolic_value.concrete = base
; symbolic = Expr.make (Ptr (base, Symbolic_value.const_i32 0l))
}
Choice.bind (i32 base) (fun (base : int32) ->
Choice.return
{ Concolic_value.concrete = base
; symbolic = Expr.make (Ptr (base, Symbolic_value.const_i32 0l))
} )
(* WHAT ???? *)
(* Choice.with_thread (fun t : Value.int32 -> *)
(* let memories = t.shared.memories in *)
Expand Down

0 comments on commit 373e424

Please sign in to comment.