Skip to content

Commit 52817d6

Browse files
authored
Merge pull request #1512 from goblint/yaml-witness-violation-reject
Add primitive verdict-based YAML violation witness rejection
2 parents 46f2fbd + fccc91e commit 52817d6

File tree

13 files changed

+603
-52
lines changed

13 files changed

+603
-52
lines changed

conf/svcomp-validate.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"ana": {
3+
"sv-comp": {
4+
"enabled": true,
5+
"functions": true
6+
},
7+
"int": {
8+
"def_exc": true,
9+
"enums": false,
10+
"interval": true
11+
},
12+
"float": {
13+
"interval": true
14+
},
15+
"activated": [
16+
"base",
17+
"threadid",
18+
"threadflag",
19+
"threadreturn",
20+
"mallocWrapper",
21+
"mutexEvents",
22+
"mutex",
23+
"access",
24+
"race",
25+
"escape",
26+
"expRelation",
27+
"mhp",
28+
"assert",
29+
"var_eq",
30+
"symb_locks",
31+
"region",
32+
"thread",
33+
"threadJoins",
34+
"abortUnless",
35+
"unassume"
36+
],
37+
"path_sens": [
38+
"mutex",
39+
"malloc_null",
40+
"uninit",
41+
"expsplit",
42+
"activeSetjmp",
43+
"memLeak",
44+
"threadflag"
45+
],
46+
"context": {
47+
"widen": false
48+
},
49+
"malloc": {
50+
"wrappers": [
51+
"kmalloc",
52+
"__kmalloc",
53+
"usb_alloc_urb",
54+
"__builtin_alloca",
55+
"kzalloc",
56+
57+
"ldv_malloc",
58+
59+
"kzalloc_node",
60+
"ldv_zalloc",
61+
"kmalloc_array",
62+
"kcalloc",
63+
64+
"ldv_xmalloc",
65+
"ldv_xzalloc",
66+
"ldv_calloc",
67+
"ldv_kzalloc"
68+
]
69+
},
70+
"base": {
71+
"arrays": {
72+
"domain": "partitioned"
73+
}
74+
},
75+
"race": {
76+
"free": false,
77+
"call": false
78+
},
79+
"autotune": {
80+
"enabled": true,
81+
"activated": [
82+
"singleThreaded",
83+
"mallocWrappers",
84+
"noRecursiveIntervals",
85+
"enums",
86+
"congruence",
87+
"octagon",
88+
"wideningThresholds",
89+
"loopUnrollHeuristic",
90+
"memsafetySpecification",
91+
"termination",
92+
"tmpSpecialAnalysis"
93+
]
94+
},
95+
"widen": {
96+
"tokens": true
97+
}
98+
},
99+
"exp": {
100+
"region-offsets": true
101+
},
102+
"solver": "td3",
103+
"sem": {
104+
"unknown_function": {
105+
"spawn": false
106+
},
107+
"int": {
108+
"signed_overflow": "assume_none"
109+
},
110+
"null-pointer": {
111+
"dereference": "assume_none"
112+
}
113+
},
114+
"witness": {
115+
"graphml": {
116+
"enabled": false
117+
},
118+
"yaml": {
119+
"enabled": false,
120+
"strict": true,
121+
"format-version": "2.0",
122+
"entry-types": [
123+
"location_invariant",
124+
"loop_invariant",
125+
"invariant_set",
126+
"violation_sequence"
127+
],
128+
"invariant-types": [
129+
"location_invariant",
130+
"loop_invariant"
131+
]
132+
},
133+
"invariant": {
134+
"loop-head": true,
135+
"after-lock": true,
136+
"other": true
137+
}
138+
},
139+
"pre": {
140+
"enabled": false
141+
}
142+
}

src/analyses/unassumeAnalysis.ml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ struct
7171
| _ -> ()
7272
);
7373

74-
let loc_of_location (location: YamlWitnessType.Location.t): Cil.location = {
75-
file = location.file_name;
76-
line = location.line;
77-
column = location.column;
78-
byte = -1;
79-
endLine = -1;
80-
endColumn = -1;
81-
endByte = -1;
82-
synthetic = false;
83-
}
84-
in
85-
8674
let yaml = match Yaml_unix.of_file (Fpath.v (GobConfig.get_string "witness.yaml.unassume")) with
8775
| Ok yaml -> yaml
8876
| Error (`Msg m) ->
@@ -125,7 +113,7 @@ struct
125113
in
126114

127115
let unassume_location_invariant (location_invariant: YamlWitnessType.LocationInvariant.t) =
128-
let loc = loc_of_location location_invariant.location in
116+
let loc = YamlWitness.loc_of_location location_invariant.location in
129117
let inv = location_invariant.location_invariant.string in
130118
let msgLoc: M.Location.t = CilLocation loc in
131119

@@ -137,7 +125,7 @@ struct
137125
in
138126

139127
let unassume_loop_invariant (loop_invariant: YamlWitnessType.LoopInvariant.t) =
140-
let loc = loc_of_location loop_invariant.location in
128+
let loc = YamlWitness.loc_of_location loop_invariant.location in
141129
let inv = loop_invariant.loop_invariant.string in
142130
let msgLoc: M.Location.t = CilLocation loc in
143131

@@ -187,7 +175,7 @@ struct
187175
in
188176

189177
let unassume_precondition_loop_invariant (precondition_loop_invariant: YamlWitnessType.PreconditionLoopInvariant.t) =
190-
let loc = loc_of_location precondition_loop_invariant.location in
178+
let loc = YamlWitness.loc_of_location precondition_loop_invariant.location in
191179
let pre = precondition_loop_invariant.precondition.string in
192180
let inv = precondition_loop_invariant.loop_invariant.string in
193181
let msgLoc: M.Location.t = CilLocation loc in
@@ -202,7 +190,7 @@ struct
202190
let unassume_invariant_set (invariant_set: YamlWitnessType.InvariantSet.t) =
203191

204192
let unassume_location_invariant (location_invariant: YamlWitnessType.InvariantSet.LocationInvariant.t) =
205-
let loc = loc_of_location location_invariant.location in
193+
let loc = YamlWitness.loc_of_location location_invariant.location in
206194
let inv = location_invariant.value in
207195
let msgLoc: M.Location.t = CilLocation loc in
208196

@@ -214,7 +202,7 @@ struct
214202
in
215203

216204
let unassume_loop_invariant (loop_invariant: YamlWitnessType.InvariantSet.LoopInvariant.t) =
217-
let loc = loc_of_location loop_invariant.location in
205+
let loc = YamlWitness.loc_of_location loop_invariant.location in
218206
let inv = loop_invariant.value in
219207
let msgLoc: M.Location.t = CilLocation loc in
220208

src/config/options.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,8 @@
26082608
"precondition_loop_invariant",
26092609
"loop_invariant_certificate",
26102610
"precondition_loop_invariant_certificate",
2611-
"invariant_set"
2611+
"invariant_set",
2612+
"violation_sequence"
26122613
]
26132614
},
26142615
"default": [

src/witness/yamlWitness.ml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,20 @@ struct
4343
specification
4444
}
4545

46-
let location ~location:(loc: Cil.location) ~(location_function): Location.t = {
47-
file_name = loc.file;
48-
file_hash = sha256_file loc.file;
49-
line = loc.line;
50-
column = loc.column;
51-
function_ = location_function;
52-
}
46+
let location ~location:(loc: Cil.location) ~(location_function): Location.t =
47+
let file_hash =
48+
match GobConfig.get_string "witness.yaml.format-version" with
49+
| "0.1" -> Some (sha256_file loc.file)
50+
| "2.0" -> None
51+
| _ -> assert false
52+
in
53+
{
54+
file_name = loc.file;
55+
file_hash;
56+
line = loc.line;
57+
column = Some loc.column;
58+
function_ = Some location_function;
59+
}
5360

5461
let invariant invariant: Invariant.t = {
5562
string = invariant;
@@ -524,6 +531,17 @@ let init () =
524531
Svcomp.errorwith "witness missing"
525532
)
526533

534+
let loc_of_location (location: YamlWitnessType.Location.t): Cil.location = {
535+
file = location.file_name;
536+
line = location.line;
537+
column = Option.value location.column ~default:1;
538+
byte = -1;
539+
endLine = -1;
540+
endColumn = -1;
541+
endByte = -1;
542+
synthetic = false;
543+
}
544+
527545
module ValidationResult =
528546
struct
529547
(* constructor order is important for the chain lattice *)
@@ -562,17 +580,6 @@ struct
562580
module InvariantParser = WitnessUtil.InvariantParser
563581
module VR = ValidationResult
564582

565-
let loc_of_location (location: YamlWitnessType.Location.t): Cil.location = {
566-
file = location.file_name;
567-
line = location.line;
568-
column = location.column;
569-
byte = -1;
570-
endLine = -1;
571-
endColumn = -1;
572-
endByte = -1;
573-
synthetic = false;
574-
}
575-
576583
let validate () =
577584
let location_locator = Locator.create () in
578585
let loop_locator = Locator.create () in
@@ -806,6 +813,15 @@ struct
806813
None
807814
in
808815

816+
let validate_violation_sequence (violation_sequence: YamlWitnessType.ViolationSequence.t) =
817+
(* TODO: update cnt-s appropriately (needs access to SV-COMP result pre-witness validation) *)
818+
(* Nothing needs to be checked here!
819+
If program is correct and we can prove it, we output true, which counts as refutation of violation witness.
820+
If program is correct and we cannot prove it, we output unknown.
821+
If program is incorrect, we output unknown. *)
822+
None
823+
in
824+
809825
match entry_type_enabled target_type, entry.entry_type with
810826
| true, LocationInvariant x ->
811827
validate_location_invariant x
@@ -815,7 +831,9 @@ struct
815831
validate_precondition_loop_invariant x
816832
| true, InvariantSet x ->
817833
validate_invariant_set x
818-
| false, (LocationInvariant _ | LoopInvariant _ | PreconditionLoopInvariant _ | InvariantSet _) ->
834+
| true, ViolationSequence x ->
835+
validate_violation_sequence x
836+
| false, (LocationInvariant _ | LoopInvariant _ | PreconditionLoopInvariant _ | InvariantSet _ | ViolationSequence _) ->
819837
incr cnt_disabled;
820838
M.info_noloc ~category:Witness "disabled entry of type %s" target_type;
821839
None

0 commit comments

Comments
 (0)