Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
552d6bb
Reintroduce some ARG related code that was removed in 70e1be6
karoliineh Jun 28, 2025
f8f8915
Consider InlinedEdges correctly in BFS for violation path construction
karoliineh Jun 28, 2025
a16c8de
Add functionality to write violation yaml witnesses (with empty content)
karoliineh Jun 28, 2025
1756f67
Create assumption "1" waypoints and a target waypoint from violation …
karoliineh Jun 28, 2025
0396735
Differentiate function_enter, function_return and branching waypoints…
karoliineh Jun 28, 2025
87f5b8e
Use an efficient recursive function instead of map
karoliineh Jun 28, 2025
ae4679f
Find the right locations using WitnessInvariant.location_location
karoliineh Jun 29, 2025
1516a74
Disable function entry/return waypoints for now due to missing correc…
karoliineh Jun 29, 2025
a3fd139
Change violation path finding direction from bottom-up to top-down
karoliineh Jul 1, 2025
a0ff4fa
Add "mapping_start failed" to Yaml.to_string error handling
karoliineh Jul 2, 2025
d9cb04b
Temporarily disable conf immutability to bypass restriction on adding…
karoliineh Jul 2, 2025
745a4e8
Make `spec_module` a `ResettableLazy` to enable resetting hashcons li…
karoliineh Jul 2, 2025
0c1cea3
Add functionality to use witch for result refinement
karoliineh Jul 2, 2025
f73b8fa
Take into account that the verdicts can have suffixes (e.g. false(unr…
karoliineh Jul 2, 2025
c9eb38e
Bugfix: correctly account for InlinedEdges
karoliineh Jul 3, 2025
f40198a
Do not create waypoints of return edges (due to void fun-s not having…
karoliineh Jul 4, 2025
29efcde
Do uncilling only for witness waypoints (to keep the cilled path as a…
karoliineh Jul 4, 2025
a35192d
Add `--guide-only` flag for witch
karoliineh Jul 4, 2025
08a42eb
Trim path prefix up to the corresponding waypoint preceding the first…
karoliineh Jul 4, 2025
0d90cf9
Do not cut paths that contain the unreachable node within a loop
karoliineh Jul 6, 2025
da5b594
Log all of Witch'es output
karoliineh Jul 6, 2025
6cc99b7
Remove forgotten logging for debugging
karoliineh Jul 6, 2025
b47805c
Do not trim path when it includes setjump calls
karoliineh Jul 7, 2025
84bf053
Replace all `==` with `=`
karoliineh Jul 7, 2025
f6f8817
Bugfix: consider also Ret edges when removing function calls from cal…
karoliineh Jul 7, 2025
5ec6ae7
Bugfix: check that none of the function calls from the callstack are …
karoliineh Jul 7, 2025
798d41f
Move `collect_callstack` from `bfs` to `get_unreachable_path`
karoliineh Jul 7, 2025
b5600cf
Refactor: move `has_setjump_calls` check earlier
karoliineh Jul 7, 2025
4f1ec2a
Bugfix: include the step preceding the unreachable node (as identifie…
karoliineh Jul 8, 2025
4e6e78e
Bugfix: check loop containment for unreachable node itself, not just …
karoliineh Jul 8, 2025
842ef8d
Add branching waypoints at loop heads by considering loop locations f…
karoliineh Jul 9, 2025
7ca25fa
Count the number of times Witch runs
karoliineh Jul 9, 2025
3f3cbdc
Print number of Witch runs only once when SV-COMP result is printed
karoliineh Jul 10, 2025
c112d2d
Add branching "false" waypoints when the path skips the loop entirely
karoliineh Jul 10, 2025
99433a3
Do not add waypoints inside loops
karoliineh Jul 10, 2025
1e05007
Make the `uncil` option work again
karoliineh Jul 11, 2025
05feff9
Only print the nr of witch runs if Witch path is set
karoliineh Jul 11, 2025
8abcc15
Add tests where ARG uncilling crashes due to path sensitivity
sim642 Jul 11, 2025
063faa6
Hack ARG uncilling to remember and follow paths to avoid move_opt
sim642 Jul 11, 2025
67e4cef
Fix ARG uncilling hack duplicating edges
sim642 Jul 11, 2025
8883b72
Merge remote-tracking branch 'origin/arg-uncil-ambiguous' into violat…
karoliineh Jul 15, 2025
6333f93
Consider all possible paths in `next_opt`
karoliineh Sep 11, 2025
0604c03
Update configuration to the one used for server runs
karoliineh Oct 16, 2025
55acbb0
Merge branch 'master' into violation_witnesses
karoliineh Oct 16, 2025
98ecdf3
Merge branch 'master' into violation_witnesses
karoliineh Nov 27, 2025
9677dd4
Adapt Witch command to new witness-producing Witch
karoliineh Nov 4, 2025
86d696f
Use the cilled path prefix of the corresponding uncilling to determin…
karoliineh Nov 7, 2025
f037fa2
Refactor
karoliineh Nov 7, 2025
6ce9257
Remove branching waypoints with invalid locations using Witch
karoliineh Nov 8, 2025
cc6af51
Do not run Witch twice if result is already found during the location…
karoliineh Nov 10, 2025
afe27f5
Refactor
karoliineh Nov 10, 2025
78eaa50
Optimize
karoliineh Nov 10, 2025
275d60b
Fix indentation in `violation.ml`
karoliineh Nov 27, 2025
852f546
Address semgrep warnings
karoliineh Nov 27, 2025
19eb0bd
Rename violation.t -> violation-validation.t
karoliineh Nov 28, 2025
bb3d696
Add a cram test for violation witness generation
karoliineh Nov 28, 2025
01fd90c
Fix ambiguous ARG uncilling crash by remembering and following CFG paths
sim642 Jul 11, 2025
566813f
Comment ARG uncilling by following CFG paths
sim642 Nov 28, 2025
0cac26d
Merge branch 'master' into arg-uncil-ambiguous
sim642 Nov 28, 2025
b68f4e5
Remove now-unused ARG Node move_opt
sim642 Nov 28, 2025
60078ab
Remove unused ARG Node equal_node_context
sim642 Nov 28, 2025
ca40482
Change path printing log level to debug
karoliineh Nov 28, 2025
c2bbd89
Remove unused to_n argument in MyArg.Intra.follow
sim642 Nov 28, 2025
fdf1779
Add assert about to_n to MyARG.Intra.next
sim642 Nov 28, 2025
32c0acd
Remove ARG equivalent CFG chain detection
sim642 Nov 28, 2025
f85449f
Extract type MyARG.cfg_path
sim642 Nov 28, 2025
0f8b387
Disable violation cram tests on OSX
karoliineh Dec 1, 2025
4640382
Disable violation cram tests on OSX
karoliineh Dec 1, 2025
29d05cf
Add tests where MyARG.partition_if_next choosing arbitrary single pat…
sim642 Dec 1, 2025
1180f83
Return all possible paths MyARG.partition_if_next
karoliineh Sep 11, 2025
b8b6041
Simplify MyARG.partition_if_next by keeping triples paths with same e…
sim642 Dec 1, 2025
6d6c124
Revert to old partition_if_next but with path lists
sim642 Dec 1, 2025
0db8fea
Replace violation cram test
karoliineh Dec 1, 2025
bef86e2
Refactor old partition_if_next to check for more errors
sim642 Dec 1, 2025
eae4fb2
Remove Karoliine's partition_if_next
sim642 Dec 1, 2025
c630eae
Use List.concat_map in MyARG.cartesian_concat_paths
sim642 Dec 1, 2025
708edac
Fix MyARG.UnCilTernaryIntra returning duplicate edge and node
sim642 Dec 2, 2025
cc3768d
Merge branch 'arg-uncil-ambiguous' into violation_witnesses
sim642 Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf/svcomp25.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@
"pre": {
"enabled": false
}
}
}
25 changes: 9 additions & 16 deletions src/arg/argTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,6 @@ struct
| Statement stmt -> Printf.sprintf "s%d(%d)[%s]" stmt.sid c_tag i_str
| Function f -> Printf.sprintf "ret%d%s(%d)[%s]" f.svar.vid f.svar.vname c_tag i_str
| FunctionEntry f -> Printf.sprintf "fun%d%s(%d)[%s]" f.svar.vid f.svar.vname c_tag i_str

(* TODO: less hacky way (without ask_indices) to move node *)
let is_live (n, c, i) = not (Spec.D.is_bot (get (n, c)))
let move_opt (n, c, i) to_n =
match ask_indices (to_n, c) with
| [] -> None
| [to_i] ->
let to_node = (to_n, c, to_i) in
BatOption.filter is_live (Some to_node)
| _ :: _ :: _ ->
failwith "Node.move_opt: ambiguous moved index"
let equal_node_context (n1, c1, i1) (n2, c2, i2) =
EQSys.LVar.equal (n1, c1) (n2, c2)
end

module NHT = BatHashtbl.Make (Node)
Expand Down Expand Up @@ -211,11 +198,17 @@ struct
let next = witness_next
end
in
let module Arg =
(val if GobConfig.get_bool "exp.arg.uncil" then
let open MyARG in
(module Intra (UnCilTernaryIntra (UnCilLogicIntra (CfgIntra (FileCfg.Cfg)))) (Arg): MyARG.S with type Node.t = Arg.Node.t and type Edge.t = Arg.Edge.t)
else
(module Arg)
)
in
let module Arg =
struct
open MyARG
module ArgIntra = UnCilTernaryIntra (UnCilLogicIntra (CfgIntra (FileCfg.Cfg)))
include Intra (ArgIntra) (Arg)
include Arg

let prev = witness_prev

Expand Down
156 changes: 88 additions & 68 deletions src/arg/myARG.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ sig
val context_id: t -> int
val path_id: t -> int
val to_string: t -> string

val move_opt: t -> MyCFG.node -> t option
val equal_node_context: t -> t -> bool
end

module type Edge =
sig
type t
type t [@@deriving eq, ord]

val embed: MyCFG.edge -> t
val to_string: t -> string
end

module CFGEdge: Edge with type t = MyCFG.edge =
struct
type t = edge
type t = Edge.t [@@deriving eq, ord]

let embed e = e
let to_string e = GobPretty.sprint Edge.pretty_plain e
Expand Down Expand Up @@ -102,7 +99,7 @@ end

module InlineEdge: Edge with type t = inline_edge =
struct
type t = inline_edge
type t = inline_edge [@@deriving eq, ord]

let embed e = CFGEdge e
let to_string e = InlineEdgePrintable.show e
Expand Down Expand Up @@ -130,15 +127,6 @@ struct
nl
|> List.map Node.to_string
|> String.concat "@"

let move_opt nl to_node =
let open GobOption.Syntax in
match nl with
| [] -> None
| n :: stack ->
let+ to_n = Node.move_opt n to_node in
to_n :: stack
let equal_node_context _ _ = failwith "StackNode: equal_node_context"
end

module Stack (Arg: S with module Edge = InlineEdge):
Expand Down Expand Up @@ -265,16 +253,19 @@ struct
end
end

type cfg_path = (MyCFG.edge * MyCFG.node) list

module type SIntra =
sig
val next: MyCFG.node -> (MyCFG.edge * MyCFG.node) list
val next: MyCFG.node -> (MyCFG.edge * MyCFG.node * cfg_path list) list
(** @return Also the original CFG paths corresponding to the step. *)
end

module type SIntraOpt =
sig
include SIntra
val next_opt: MyCFG.node -> ((MyCFG.edge * MyCFG.node) list) option
val next_opt: MyCFG.node -> ((MyCFG.edge * MyCFG.node * cfg_path list) list) option
(** @return Also the original CFG paths corresponding to the step. *)
end

module CfgIntra (Cfg:CfgForward): SIntraOpt =
Expand All @@ -283,51 +274,38 @@ struct
let open GobList.Syntax in
let* (es, to_n) = Cfg.next node in
let+ (_, e) = es in
(e, to_n)
(e, to_n, [[(e, to_n)]])
let next_opt _ = None
end

let partition_if_next if_next_n =
(* TODO: refactor, check extra edges for error *)
let test_next b = List.find (function
| (Test (_, b'), _) when b = b' -> true
| (_, _) -> false
) if_next_n
let cartesian_concat_paths (ps : cfg_path list) (qs : cfg_path list) : cfg_path list = List.concat_map (fun p -> List.map (fun q -> p @ q) qs) ps

let partition_if_next if_next =
let (if_next_trues, if_next_falses) = List.partition (function
| (Test (_, b), _, _) -> b
| (_, _, _) -> failwith "partition_if_next: not Test edge"
) if_next
in
(* assert (List.length if_next <= 2); *)
match test_next true, test_next false with
| (Test (e_true, true), if_true_next_n), (Test (e_false, false), if_false_next_n) when Basetype.CilExp.equal e_true e_false ->
(e_true, if_true_next_n, if_false_next_n)
| _, _ -> failwith "partition_if_next: bad branches"
match if_next_trues, if_next_falses with
| [(Test (e_true, true), if_true_next_n, if_true_next_ps)], [(Test (e_false, false), if_false_next_n, if_false_next_ps)] when Basetype.CilExp.equal e_true e_false ->
(e_true, (if_true_next_n, if_true_next_ps), (if_false_next_n, if_false_next_ps))
| _, _ ->
(* This fails due to any of the following:
- Either true or false branch is missing.
- Either true or false branch has multiple different exps or nodes (same exp, branch and node should only occur once by construction/assumption).
- True and false branch have different exps. *)
failwith "partition_if_next: bad branches"

module UnCilLogicIntra (Arg: SIntraOpt): SIntraOpt =
struct
open Cil
(* TODO: questionable (=) and (==) use here *)

let is_equiv_stmtkind sk1 sk2 = match sk1, sk2 with
| Instr is1, Instr is2 -> GobList.equal (=) is1 is2
| Return _, Return _ -> sk1 = sk2
| _, _ -> false (* TODO: also consider others? not sure if they ever get duplicated *)
let is_equiv_stmt s1 s2 = is_equiv_stmtkind s1.skind s2.skind (* TODO: also consider labels *)
let is_equiv_node n1 n2 = match n1, n2 with
| Statement s1, Statement s2 -> is_equiv_stmt s1 s2
| _, _ -> false (* TODO: also consider FunctionEntry & Function? *)
let is_equiv_edge e1 e2 = match e1, e2 with
| Entry f1, Entry f2 -> f1 == f2 (* physical equality for fundec to avoid cycle *)
| Ret (exp1, f1), Ret (exp2, f2) -> exp1 = exp2 && f1 == f2 (* physical equality for fundec to avoid cycle *)
| _, _ -> e1 = e2
let rec is_equiv_chain n1 n2 =
Node.equal n1 n2 || (is_equiv_node n1 n2 && is_equiv_chain_next n1 n2)
and is_equiv_chain_next n1 n2 = match Arg.next n1, Arg.next n2 with
| [(e1, to_n1)], [(e2, to_n2)] ->
is_equiv_edge e1 e2 && is_equiv_chain to_n1 to_n2
| _, _-> false

let () =
assert (not !Cabs2cil.allowDuplication) (* duplication makes it more annoying to detect cilling *)

let rec next_opt' n = match n with
| Statement {sid; skind=If _; _} when GobConfig.get_bool "exp.arg.uncil" ->
let (e, if_true_next_n, if_false_next_n) = partition_if_next (Arg.next n) in
| Statement {sid; skind=If _; _} ->
let (e, (if_true_next_n, if_true_next_ps), (if_false_next_n, if_false_next_ps)) = partition_if_next (Arg.next n) in
(* avoid infinite recursion with sid <> sid2 in if_nondet_var *)
(* TODO: why physical comparison if_false_next_n != n doesn't work? *)
(* TODO: need to handle longer loops? *)
Expand All @@ -336,24 +314,24 @@ struct
(* && *)
| Statement {sid=sid2; skind=If _; _}, _ when sid <> sid2 && CilType.Location.equal loc (Node.location if_true_next_n) ->
(* get e2 from edge because recursive next returns it there *)
let (e2, if_true_next_true_next_n, if_true_next_false_next_n) = partition_if_next (next if_true_next_n) in
if is_equiv_chain if_false_next_n if_true_next_false_next_n then
let (e2, (if_true_next_true_next_n, if_true_next_true_next_ps), (if_true_next_false_next_n, if_true_next_false_next_ps)) = partition_if_next (next if_true_next_n) in
if Node.equal if_false_next_n if_true_next_false_next_n then
let exp = BinOp (LAnd, e, e2, intType) in
Some [
(Test (exp, true), if_true_next_true_next_n);
(Test (exp, false), if_false_next_n)
(Test (exp, true), if_true_next_true_next_n, cartesian_concat_paths if_true_next_ps if_true_next_true_next_ps);
(Test (exp, false), if_true_next_false_next_n, if_false_next_ps @ cartesian_concat_paths if_true_next_ps if_true_next_false_next_ps) (* concat two different path families to same false node *)
]
else
None
(* || *)
| _, Statement {sid=sid2; skind=If _; _} when sid <> sid2 && CilType.Location.equal loc (Node.location if_false_next_n) ->
(* get e2 from edge because recursive next returns it there *)
let (e2, if_false_next_true_next_n, if_false_next_false_next_n) = partition_if_next (next if_false_next_n) in
if is_equiv_chain if_true_next_n if_false_next_true_next_n then
let (e2, (if_false_next_true_next_n, if_false_next_true_next_ps), (if_false_next_false_next_n, if_false_next_false_next_ps)) = partition_if_next (next if_false_next_n) in
if Node.equal if_true_next_n if_false_next_true_next_n then
let exp = BinOp (LOr, e, e2, intType) in
Some [
(Test (exp, true), if_true_next_n);
(Test (exp, false), if_false_next_false_next_n)
(Test (exp, true), if_false_next_true_next_n, if_true_next_ps @ cartesian_concat_paths if_false_next_ps if_false_next_true_next_ps); (* concat two different path families to same true node *)
(Test (exp, false), if_false_next_false_next_n, cartesian_concat_paths if_false_next_ps if_false_next_false_next_ps)
]
else
None
Expand All @@ -380,15 +358,15 @@ struct
Question(e_cond, e_true, e_false, Cilfacade.typeOf e_false)

let next_opt' n = match n with
| Statement {skind=If _; _} when GobConfig.get_bool "exp.arg.uncil" ->
let (e_cond, if_true_next_n, if_false_next_n) = partition_if_next (Arg.next n) in
| Statement {skind=If _; _} ->
let (e_cond, (if_true_next_n, if_true_next_ps), (if_false_next_n, if_false_next_ps)) = partition_if_next (Arg.next n) in
let loc = Node.location n in
if CilType.Location.equal (Node.location if_true_next_n) loc && CilType.Location.equal (Node.location if_false_next_n) loc then
match Arg.next if_true_next_n, Arg.next if_false_next_n with
| [(Assign (v_true, e_true), if_true_next_next_n)], [(Assign (v_false, e_false), if_false_next_next_n)] when v_true = v_false && Node.equal if_true_next_next_n if_false_next_next_n ->
| [(Assign (v_true, e_true), if_true_next_next_n, if_true_next_next_ps)], [(Assign (v_false, e_false), if_false_next_next_n, if_false_next_next_ps)] when v_true = v_false && Node.equal if_true_next_next_n if_false_next_next_n ->
let exp = ternary e_cond e_true e_false in
Some [
(Assign (v_true, exp), if_true_next_next_n)
(Assign (v_true, exp), if_true_next_next_n, cartesian_concat_paths if_true_next_ps if_true_next_next_ps @ cartesian_concat_paths if_false_next_ps if_false_next_next_ps) (* concat two different path families with same variable to same node *)
]
| _, _ -> None
else
Expand All @@ -402,19 +380,61 @@ struct
| None -> Arg.next n
end

module Intra (ArgIntra: SIntraOpt) (Arg: S):
S with module Node = Arg.Node and module Edge = Arg.Edge =
module Intra (ArgIntra: SIntraOpt) (Arg: S) =
struct
include Arg

(** Starting from ARG node [node], follow CFG path [p] to the resulting ARG node.
Returns multiple ARG nodes if ARG contains path-sensitivity splits on the same CFG path. *)
let rec follow node p =
let open GobList.Syntax in
match p with
| [] -> [node]
| (e, to_n) :: p' ->
let* (_, node') = List.filter (fun (e', to_node) ->
Edge.equal (Edge.embed e) e' && Node0.equal to_n (Node.cfgnode to_node)
) (Arg.next node)
in
follow node' p'

let rec follow' (node : Node.t) p : (Node.t * (Edge.t * Node.t) list) list =
let open GobList.Syntax in
match p with
| [] -> [node, []]
| (e, to_n) :: p' ->
let* (_, node') = List.filter (fun (e', to_node) ->
Edge.equal (Edge.embed e) e' && Node0.equal to_n (Node.cfgnode to_node)
) (Arg.next node)
in
let+ (n, l) = follow' node' p' in
(n, (Edge.embed e, node') :: l)

let next node =
let open GobOption.Syntax in
let open GobList.Syntax in
match ArgIntra.next_opt (Node.cfgnode node) with
| None -> Arg.next node
| Some next ->
next
|> BatList.filter_map (fun (e, to_n) ->
let+ to_node = Node.move_opt node to_n in
|> BatList.concat_map (fun (e, to_n, p) ->
let* p in
let+ to_node = follow node p in
assert (Node0.equal to_n (Node.cfgnode to_node)); (* should always hold by follow filter above *)
(Edge.embed e, to_node)
)
|> BatList.unique_cmp ~cmp:[%ord: Edge.t * Node.t] (* after following paths, there may be duplicates because same ARG node can be reached via same ARG edge via multiple uncilled CFG paths *) (* TODO: avoid generating duplicates in the first place? *)

let next' node =
let open GobList.Syntax in
match ArgIntra.next_opt (Node.cfgnode node) with
| None ->
Arg.next node
|> List.map (fun (e,n) -> (e,n, [e, n]))
| Some next ->
next
|> BatList.concat_map (fun (e, to_n, p) ->
let* p in
let+ (to_node, path) = follow' node p in
assert (Node0.equal to_n (Node.cfgnode to_node)); (* should always hold by follow' filter above *)
(Edge.embed e, to_node, path)
)
end
Loading
Loading