Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zapashcanon committed Feb 10, 2025
1 parent 9c98ea0 commit 2fc41c8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/cmd/cmd_conc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ let find_node_to_run tree =
loop tree []

let pc_model solver pc =
let pc = Concolic_choice.pc_to_exprs pc |> Symbolic_path_condition.to_set in
let pc = Concolic_choice.pc_to_exprs pc in
match Solver.check solver pc with
| `Unsat | `Unknown -> None
| `Sat ->
Expand Down
4 changes: 1 addition & 3 deletions src/concolic/concolic_choice.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ let pc_elt_to_expr = function
| Assume c -> Some c
| Assert _ -> None

let pc_to_exprs pc =
List.filter_map pc_elt_to_expr pc
|> List.fold_left Symbolic_path_condition.add Symbolic_path_condition.empty
let pc_to_exprs pc = List.filter_map pc_elt_to_expr pc |> Smtml.Expr.Set.of_list

type shared_thread_info =
{ memories : Symbolic_memory.collection
Expand Down
3 changes: 2 additions & 1 deletion src/symbolic/symbolic_choice.ml
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ module Make (Thread : Thread_intf.S) = struct
true
in
let false_branch =
let* () = add_pc (Symbolic_value.Bool.not v) in
let v = Symbolic_value.Bool.not v in
let* () = add_pc v in
let* () = add_breadcrumb 0l in
let+ () = check_reachability v in
false
Expand Down
16 changes: 10 additions & 6 deletions src/symbolic/symbolic_path_condition.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ let add (pc : t) (c : Symbolic_value.vbool) : t =
let c = Smtml.Expr.Set.singleton c in
union_on_all_syms c pc symbols

(* Turns all constraints into a set *)
let to_set pc =
Union_find.merge_all_values ~empty:Smtml.Expr.Set.empty
~merge:Smtml.Expr.Set.union pc

(* Return the set of constraints from [pc] that are relevant for [c]. *)
let slice (pc : t) (c : Symbolic_value.vbool) : Smtml.Expr.Set.t =
match Smtml.Expr.get_symbols [ c ] with
| [] -> (* TODO: not sure what to do here *) Smtml.Expr.Set.empty
| [] -> Smtml.Expr.Set.add c (to_set pc)
| sym0 :: _tl -> (
(* we need only the first symbol as all the other one should have been merged with it *)
match Union_find.find_opt sym0 pc with
| None -> Smtml.Expr.Set.empty
| None ->
(* if there is a symbol, it should have been added to the union-find structure before *)
assert false
| Some s -> s )

let to_set pc =
Union_find.merge_all_values ~empty:Smtml.Expr.Set.empty
~merge:Smtml.Expr.Set.union pc
2 changes: 1 addition & 1 deletion test/c/malloc_aligned.t
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
$ owi c ./malloc_aligned.c
$ owi c ./malloc_aligned.c -w1
All OK

0 comments on commit 2fc41c8

Please sign in to comment.