Skip to content

Commit

Permalink
Add quick and dirty workaround attempt for working with
Browse files Browse the repository at this point in the history
SV-COMP's memory-safety category
  • Loading branch information
mrstanb committed Sep 6, 2023
1 parent 46ae6ee commit d4ef555
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/autoTune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ let focusOnSpecification () =
(* TODO: Finish these two below later *)
| ValidDeref
| ValidMemtrack -> ()
| MemorySafety -> () (* TODO: This is here for now just to complete the pattern match *)

(*Detect enumerations and enable the "ana.int.enums" option*)
exception EnumFound
Expand Down
1 change: 1 addition & 0 deletions src/witness/svcomp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct
| ValidFree -> "valid-free"
| ValidDeref -> "valid-deref"
| ValidMemtrack -> "valid-memtrack"
| MemorySafety -> "memory-safety" (* TODO: Currently here only to complete the pattern match *)
in
"false(" ^ result_spec ^ ")"
| Unknown -> "unknown"
Expand Down
14 changes: 10 additions & 4 deletions src/witness/svcompSpec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ type t =
| ValidFree
| ValidDeref
| ValidMemtrack
| MemorySafety (* Internal property for use in Goblint; serves as a summary for ValidFree, ValidDeref and ValidMemtrack *)

let of_string s =
let s = String.strip s in
let regexp = Str.regexp "CHECK( init(main()), LTL(G \\(.*\\)) )" in
let regexp = Str.regexp "CHECK( init(main()), LTL(G \\(.*\\)) )\nCHECK( init(main()), LTL(G \\(.*\\)) )\nCHECK( init(main()), LTL(G \\(.*\\)) )" in
let regexp_negated = Str.regexp "CHECK( init(main()), LTL(G ! \\(.*\\)) )" in
if Str.string_match regexp_negated s 0 then
let global_not = Str.matched_group 1 s in
Expand All @@ -28,13 +29,17 @@ let of_string s =
else
failwith "Svcomp.Specification.of_string: unknown global not expression"
else if Str.string_match regexp s 0 then
let global = Str.matched_group 1 s in
if global = "valid-free" then
let global1 = Str.matched_group 1 s in
let global2 = Str.matched_group 2 s in
let global3 = Str.matched_group 3 s in
if global1 = "valid-free" && global2 = "valid-deref" && global3 = "valid-memtrack" then
MemorySafety
(* if global = "valid-free" then
ValidFree
else if global = "valid-deref" then
ValidDeref
else if global = "valid-memtrack" then
ValidMemtrack
ValidMemtrack *)
else
failwith "Svcomp.Specification.of_string: unknown global expression"
else
Expand Down Expand Up @@ -65,5 +70,6 @@ let to_string spec =
| ValidFree -> "valid-free", false
| ValidDeref -> "valid-deref", false
| ValidMemtrack -> "valid-memtrack", false
| MemorySafety -> "memory-safety", false (* TODO: That's false, it's currently here just to complete the pattern match *)
in
print_output spec_str is_neg
46 changes: 38 additions & 8 deletions src/witness/witness.ml
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ struct
in
(module TaskResult:WitnessTaskResult)
)
| ValidFree ->
let module TrivialArg =
| ValidFree (*->*)
(* let module TrivialArg =
struct
include Arg
let next _ = []
Expand Down Expand Up @@ -534,9 +534,9 @@ struct
end
in
(module TaskResult:WitnessTaskResult)
)
| ValidDeref ->
let module TrivialArg =
) *)
| ValidDeref (*->*)
(* let module TrivialArg =
struct
include Arg
let next _ = []
Expand Down Expand Up @@ -564,9 +564,9 @@ struct
end
in
(module TaskResult:WitnessTaskResult)
)
| ValidMemtrack ->
let module TrivialArg =
) *)
| ValidMemtrack (*->*)
(* let module TrivialArg =
struct
include Arg
let next _ = []
Expand All @@ -583,6 +583,36 @@ struct
end
in
(module TaskResult:WitnessTaskResult)
) else (
let module TaskResult =
struct
module Arg = TrivialArg
let result = Result.Unknown
let invariant _ = Invariant.none
let is_violation _ = false
let is_sink _ = false
end
in
(module TaskResult:WitnessTaskResult)
) *)
| MemorySafety ->
let module TrivialArg =
struct
include Arg
let next _ = []
end
in
if not !AnalysisState.svcomp_may_invalid_free || not !AnalysisState.svcomp_may_invalid_deref || not !AnalysisState.svcomp_may_invalid_memtrack then (

This comment has been minimized.

Copy link
@michael-schwarz

michael-schwarz Sep 6, 2023

Member

Should this not be &&?

This comment has been minimized.

Copy link
@mrstanb

mrstanb Sep 6, 2023

Author Member

Yes, absolutely

let module TaskResult =
struct
module Arg = Arg
let result = Result.True
let invariant _ = Invariant.none
let is_violation _ = false
let is_sink _ = false
end
in
(module TaskResult:WitnessTaskResult)
) else (
let module TaskResult =
struct
Expand Down

0 comments on commit d4ef555

Please sign in to comment.