Skip to content

Commit

Permalink
Trim explored paths and enable collections-c for owi conc
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Aug 10, 2024
1 parent 22e4151 commit 18e6fc2
Show file tree
Hide file tree
Showing 30 changed files with 1,434 additions and 571 deletions.
402 changes: 204 additions & 198 deletions src/cmd/cmd_conc.ml

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/cmd/cmd_sym.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ let cmd profiling debug unsafe optimize workers no_stop_at_failure no_values
let result = List.fold_left (run_file ~unsafe ~optimize) pc files in
let thread = Thread_with_memory.init () in
let res_queue = Wq.init () in
let path_count = ref 0 in
let callback v =
let open Symbolic_choice_intf in
incr path_count;
match (fail_mode, v) with
| _, (EVal (Ok ()), _) -> ()
| _, (EVal (Error e), thread) -> Wq.push (`Error e, thread) res_queue
Expand Down Expand Up @@ -115,8 +117,9 @@ let cmd profiling debug unsafe optimize workers no_stop_at_failure no_values
else results
in
let* count = print_and_count_failures 0 results in
Fmt.pr "Completed paths: %d@." !path_count;
if count > 0 then Error (`Found_bug count)
else begin
Fmt.pr "All OK";
Fmt.pr "All OK@.";
Ok ()
end
4 changes: 2 additions & 2 deletions src/concolic/concolic_choice.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let ( let+ ) = map
let abort =
M
(fun st ->
(Ok (), { st with pc = Assert (Symbolic_value.Bool.const false) :: st.pc })
(Ok (), { st with pc = Assume (Symbolic_value.Bool.const false) :: st.pc })
)

let add_pc (c : Concolic_value.V.vbool) =
Expand All @@ -94,7 +94,7 @@ let add_pc_to_thread (st : thread) c = { st with pc = c :: st.pc }

let no_choice e =
let v = Smtml.Expr.simplify e in
match Smtml.Expr.view v with Val _ -> true | _ -> false
not (Smtml.Expr.is_symbolic v)

let select (vb : Concolic_value.V.vbool) =
let r = vb.concrete in
Expand Down
4 changes: 1 addition & 3 deletions src/concolic/concolic_value.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ module T_pair (C : Value_intf.T) (S : Value_intf.T) = struct
match (C.Ref.get_func ref.concrete, S.Ref.get_func ref.symbolic) with
| Null, Null -> Null
| Type_mismatch, Type_mismatch -> Type_mismatch
| Ref_value c, Ref_value s ->
assert (equal_func_intf c s);
Ref_value c
| Ref_value c, Ref_value _s -> Ref_value c
| _ -> assert false

let get_externref ref ty_id : _ Value_intf.get_ref =
Expand Down
6 changes: 4 additions & 2 deletions src/concolic/concolic_wasm_ffi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,16 @@ module M :
| Val (Num (I32 v)) -> Choice.return v
| _ ->
Log.debug2 {|alloc: cannot allocate base pointer "%a"|} Expr.pp v.symbolic;
Choice.bind (abort ()) (fun () -> assert false)
assert false
(* Choice.bind (abort ()) (fun () -> assert false) *)

let ptr (v : Value.int32) : int32 Choice.t =
match view v.symbolic with
| Ptr { base; _ } -> Choice.return base
| _ ->
Log.debug2 {|free: cannot fetch pointer base of "%a"|} Expr.pp v.symbolic;
Choice.bind (abort ()) (fun () -> assert false)
assert false
(* Choice.bind (abort ()) (fun () -> assert false) *)

let exit (_p : Value.int32) : unit Choice.t = abort ()

Expand Down
7 changes: 4 additions & 3 deletions src/symbolic/symbolic_memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ let extract v pos =
| Val (Num (I64 i)) ->
let i' = Int64.(to_int @@ logand 0xffL @@ shr_s i @@ of_int (pos * 8)) in
value (Num (I8 i'))
| Cvtop (_, Zero_extend 24, ({ node = Symbol _; _ } as sym))
| Cvtop (_, Sign_extend 24, ({ node = Symbol _; _ } as sym))
when Smtml.Ty.equal (Ty_bitv 8) (ty sym) ->
| Cvtop
( _
, (Zero_extend 24 | Sign_extend 24)
, ({ node = Symbol { ty = Ty_bitv 8; _ }; _ } as sym) ) ->
sym
| _ -> make (Extract (v, pos + 1, pos))

Expand Down
1 change: 1 addition & 0 deletions src/symbolic/symbolic_value.ml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ module I32 = struct
let to_bool (e : vbool) =
match view e with
| Val (Num (I32 i)) -> Bool.const @@ Int32.ne i 0l
| Ptr _ -> Bool.const true
| Cvtop (_, OfBool, cond) -> cond
| _ -> make (Cvtop (ty, ToBool, e))

Expand Down
51 changes: 0 additions & 51 deletions test/c/collections-c/array_tests.t

This file was deleted.

69 changes: 0 additions & 69 deletions test/c/collections-c/deque_tests.t

This file was deleted.

3 changes: 2 additions & 1 deletion test/c/collections-c/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
(deps
%{bin:owi}
(package owi)
(source_tree files)))
(source_tree files)
run-subdir.sh))
75 changes: 0 additions & 75 deletions test/c/collections-c/list_tests.t

This file was deleted.

28 changes: 0 additions & 28 deletions test/c/collections-c/pqueue_tests.t

This file was deleted.

Loading

0 comments on commit 18e6fc2

Please sign in to comment.