Skip to content

Commit

Permalink
Merge branch 'master' into thesis-weakly-relational-pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schwarz authored Sep 22, 2024
2 parents cb9dc2f + 52817d6 commit f787e67
Show file tree
Hide file tree
Showing 43 changed files with 677 additions and 157 deletions.
142 changes: 142 additions & 0 deletions conf/svcomp-validate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"ana": {
"sv-comp": {
"enabled": true,
"functions": true
},
"int": {
"def_exc": true,
"enums": false,
"interval": true
},
"float": {
"interval": true
},
"activated": [
"base",
"threadid",
"threadflag",
"threadreturn",
"mallocWrapper",
"mutexEvents",
"mutex",
"access",
"race",
"escape",
"expRelation",
"mhp",
"assert",
"var_eq",
"symb_locks",
"region",
"thread",
"threadJoins",
"abortUnless",
"unassume"
],
"path_sens": [
"mutex",
"malloc_null",
"uninit",
"expsplit",
"activeSetjmp",
"memLeak",
"threadflag"
],
"context": {
"widen": false
},
"malloc": {
"wrappers": [
"kmalloc",
"__kmalloc",
"usb_alloc_urb",
"__builtin_alloca",
"kzalloc",

"ldv_malloc",

"kzalloc_node",
"ldv_zalloc",
"kmalloc_array",
"kcalloc",

"ldv_xmalloc",
"ldv_xzalloc",
"ldv_calloc",
"ldv_kzalloc"
]
},
"base": {
"arrays": {
"domain": "partitioned"
}
},
"race": {
"free": false,
"call": false
},
"autotune": {
"enabled": true,
"activated": [
"singleThreaded",
"mallocWrappers",
"noRecursiveIntervals",
"enums",
"congruence",
"octagon",
"wideningThresholds",
"loopUnrollHeuristic",
"memsafetySpecification",
"termination",
"tmpSpecialAnalysis"
]
},
"widen": {
"tokens": true
}
},
"exp": {
"region-offsets": true
},
"solver": "td3",
"sem": {
"unknown_function": {
"spawn": false
},
"int": {
"signed_overflow": "assume_none"
},
"null-pointer": {
"dereference": "assume_none"
}
},
"witness": {
"graphml": {
"enabled": false
},
"yaml": {
"enabled": false,
"strict": true,
"format-version": "2.0",
"entry-types": [
"location_invariant",
"loop_invariant",
"invariant_set",
"violation_sequence"
],
"invariant-types": [
"location_invariant",
"loop_invariant"
]
},
"invariant": {
"loop-head": true,
"after-lock": true,
"other": true
}
},
"pre": {
"enabled": false
}
}
1 change: 1 addition & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Goblint includes analyses for assertions, overflows, deadlocks, etc and can be e
(ppx_deriving (>= 6.0.2))
(ppx_deriving_hash (>= 0.1.2))
(ppx_deriving_yojson (>= 3.7.0))
(ppx_blob (>= 0.8.0))
(ppxlib (>= 0.30.0)) ; ppx_easy_deriving
(ounit2 :with-test)
(qcheck-ounit :with-test)
Expand Down
3 changes: 2 additions & 1 deletion goblint.opam
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ depends: [
"ppx_deriving" {>= "6.0.2"}
"ppx_deriving_hash" {>= "0.1.2"}
"ppx_deriving_yojson" {>= "3.7.0"}
"ppx_blob" {>= "0.8.0"}
"ppxlib" {>= "0.30.0"}
"ounit2" {with-test}
"qcheck-ounit" {with-test}
Expand Down Expand Up @@ -96,7 +97,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
# also remember to generate/adjust goblint.opam.locked!
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
pin-depends: [
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#317e26d48b06d5cdc4acff3df1a6824587052b53" ]
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b" ]
]
depexts: [
["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}
Expand Down
3 changes: 2 additions & 1 deletion goblint.opam.locked
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ depends: [
"ordering" {= "3.16.0"}
"ounit2" {= "2.2.7" & with-test}
"pp" {= "1.2.0"}
"ppx_blob" {= "0.9.0"}
"ppx_derivers" {= "1.2.1"}
"ppx_deriving" {= "6.0.2"}
"ppx_deriving_hash" {= "0.1.2"}
Expand Down Expand Up @@ -139,7 +140,7 @@ post-messages: [
pin-depends: [
[
"goblint-cil.2.0.4"
"git+https://github.com/goblint/cil.git#317e26d48b06d5cdc4acff3df1a6824587052b53"
"git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b"
]
]
depexts: ["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}
Expand Down
2 changes: 1 addition & 1 deletion goblint.opam.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# also remember to generate/adjust goblint.opam.locked!
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
pin-depends: [
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#317e26d48b06d5cdc4acff3df1a6824587052b53" ]
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b" ]
]
depexts: [
["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}
Expand Down
24 changes: 16 additions & 8 deletions src/analyses/base.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ struct
List.map mpt exps
)

let invalidate ?(deep=true) ~ctx (st:store) (exps: exp list): store =
let invalidate ~(must: bool) ?(deep=true) ~ctx (st:store) (exps: exp list): store =
if M.tracing && exps <> [] then M.tracel "invalidate" "Will invalidate expressions [%a]" (d_list ", " d_plainexp) exps;
if exps <> [] then M.info ~category:Imprecise "Invalidating expressions: %a" (d_list ", " d_exp) exps;
(* To invalidate a single address, we create a pair with its corresponding
Expand All @@ -2072,7 +2072,15 @@ struct
let vs = List.map (Tuple3.third) invalids' in
M.tracel "invalidate" "Setting addresses [%a] to values [%a]" (d_list ", " AD.pretty) addrs (d_list ", " VD.pretty) vs
);
set_many ~ctx st invalids'
(* copied from set_many *)
let f (acc: store) ((lval:AD.t),(typ:Cil.typ),(value:value)): store =
let acc' = set ~ctx acc lval typ value in
if must then
acc'
else
D.join acc acc'
in
List.fold_left f st invalids'


let make_entry ?(thread=false) (ctx:(D.t, G.t, C.t, V.t) Analyses.ctx) fundec args: D.t =
Expand Down Expand Up @@ -2211,8 +2219,8 @@ struct
in
(* TODO: what about escaped local variables? *)
(* invalidate arguments and non-static globals for unknown functions *)
let st' = invalidate ~deep:false ~ctx ctx.local shallow_addrs in
invalidate ~deep:true ~ctx st' deep_addrs
let st' = invalidate ~must:false ~deep:false ~ctx ctx.local shallow_addrs in
invalidate ~must:false ~deep:true ~ctx st' deep_addrs

let check_invalid_mem_dealloc ctx special_fn ptr =
let has_non_heap_var = AD.exists (function
Expand Down Expand Up @@ -2302,7 +2310,7 @@ struct
let invalidate_ret_lv st = match lv with
| Some lv ->
if M.tracing then M.tracel "invalidate" "Invalidating lhs %a for function call %s" d_plainlval lv f.vname;
invalidate ~deep:false ~ctx st [Cil.mkAddrOrStartOf lv]
invalidate ~must:true ~deep:false ~ctx st [Cil.mkAddrOrStartOf lv]
| None -> st
in
let addr_type_of_exp exp =
Expand Down Expand Up @@ -2636,14 +2644,14 @@ struct
| Int n when GobOption.exists (Z.equal Z.zero) (ID.to_int n) -> st
| Address ret_a ->
begin match eval_rv ~ctx st id with
| Thread a when ValueDomain.Threads.is_top a -> invalidate ~ctx st [ret_var]
| Thread a when ValueDomain.Threads.is_top a -> invalidate ~must:true ~ctx st [ret_var]
| Thread a ->
let v = List.fold VD.join (VD.bot ()) (List.map (fun x -> G.thread (ctx.global (V.thread x))) (ValueDomain.Threads.elements a)) in
(* TODO: is this type right? *)
set ~ctx st ret_a (Cilfacade.typeOf ret_var) v
| _ -> invalidate ~ctx st [ret_var]
| _ -> invalidate ~must:true ~ctx st [ret_var]
end
| _ -> invalidate ~ctx st [ret_var]
| _ -> invalidate ~must:true ~ctx st [ret_var]
in
let st' = invalidate_ret_lv st' in
Priv.thread_join (Analyses.ask_of_ctx ctx) (priv_getg ctx.global) id st'
Expand Down
5 changes: 2 additions & 3 deletions src/analyses/mutexEventsAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
module M = Messages
module Addr = ValueDomain.Addr
module LF = LibraryFunctions
open Batteries
open GoblintCil
open Analyses
open GobConfig
Expand Down Expand Up @@ -52,12 +51,12 @@ struct

let return ctx exp fundec : D.t =
(* deprecated but still valid SV-COMP convention for atomic block *)
if get_bool "ana.sv-comp.functions" && String.starts_with fundec.svar.vname "__VERIFIER_atomic_" then
if get_bool "ana.sv-comp.functions" && String.starts_with fundec.svar.vname ~prefix:"__VERIFIER_atomic_" then
ctx.emit (Events.Unlock (LockDomain.Addr.of_var LF.verifier_atomic_var))

let body ctx f : D.t =
(* deprecated but still valid SV-COMP convention for atomic block *)
if get_bool "ana.sv-comp.functions" && String.starts_with f.svar.vname "__VERIFIER_atomic_" then
if get_bool "ana.sv-comp.functions" && String.starts_with f.svar.vname ~prefix:"__VERIFIER_atomic_" then
ctx.emit (Events.Lock (LockDomain.Addr.of_var LF.verifier_atomic_var, true))

let special (ctx: (unit, _, _, _) ctx) lv f arglist : D.t =
Expand Down
22 changes: 5 additions & 17 deletions src/analyses/unassumeAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ struct
| _ -> ()
);

let loc_of_location (location: YamlWitnessType.Location.t): Cil.location = {
file = location.file_name;
line = location.line;
column = location.column;
byte = -1;
endLine = -1;
endColumn = -1;
endByte = -1;
synthetic = false;
}
in

let yaml = match Yaml_unix.of_file (Fpath.v (GobConfig.get_string "witness.yaml.unassume")) with
| Ok yaml -> yaml
| Error (`Msg m) ->
Expand Down Expand Up @@ -125,7 +113,7 @@ struct
in

let unassume_location_invariant (location_invariant: YamlWitnessType.LocationInvariant.t) =
let loc = loc_of_location location_invariant.location in
let loc = YamlWitness.loc_of_location location_invariant.location in
let inv = location_invariant.location_invariant.string in
let msgLoc: M.Location.t = CilLocation loc in

Expand All @@ -137,7 +125,7 @@ struct
in

let unassume_loop_invariant (loop_invariant: YamlWitnessType.LoopInvariant.t) =
let loc = loc_of_location loop_invariant.location in
let loc = YamlWitness.loc_of_location loop_invariant.location in
let inv = loop_invariant.loop_invariant.string in
let msgLoc: M.Location.t = CilLocation loc in

Expand Down Expand Up @@ -187,7 +175,7 @@ struct
in

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

let unassume_location_invariant (location_invariant: YamlWitnessType.InvariantSet.LocationInvariant.t) =
let loc = loc_of_location location_invariant.location in
let loc = YamlWitness.loc_of_location location_invariant.location in
let inv = location_invariant.value in
let msgLoc: M.Location.t = CilLocation loc in

Expand All @@ -214,7 +202,7 @@ struct
in

let unassume_loop_invariant (loop_invariant: YamlWitnessType.InvariantSet.LoopInvariant.t) =
let loc = loc_of_location loop_invariant.location in
let loc = YamlWitness.loc_of_location loop_invariant.location in
let inv = loop_invariant.value in
let msgLoc: M.Location.t = CilLocation loc in

Expand Down
5 changes: 4 additions & 1 deletion src/autoTune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ let functionArgs fd = (ResettableLazy.force functionCallMaps).argLists |> Functi

let findMallocWrappers () =
let isMalloc f =
Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo f) @@ fun () ->
if LibraryFunctions.is_special f then (
let desc = LibraryFunctions.find f in
match functionArgs f with
Expand Down Expand Up @@ -104,7 +105,7 @@ let rec setCongruenceRecursive fd depth neigbourFunction =
| exception Not_found -> () (* Happens for __goblint_bounded *)
)
(FunctionSet.filter (*for extern and builtin functions there is no function definition in CIL*)
(fun x -> not (isExtern x.vstorage || BatString.starts_with x.vname "__builtin"))
(fun x -> not (isExtern x.vstorage || String.starts_with x.vname ~prefix:"__builtin"))
(neigbourFunction fd.svar)
)
;
Expand Down Expand Up @@ -153,13 +154,15 @@ let disableIntervalContextsInRecursiveFunctions () =

let hasFunction pred =
let relevant_static var =
Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo var) @@ fun () ->
if LibraryFunctions.is_special var then
let desc = LibraryFunctions.find var in
GobOption.exists (fun args -> pred (desc.special args)) (functionArgs var)
else
false
in
let relevant_dynamic var =
Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo var) @@ fun () ->
if LibraryFunctions.is_special var then
let desc = LibraryFunctions.find var in
(* We don't really have arguments at hand, so we cheat and just feed it a list of MyCFG.unknown_exp of appropriate length *)
Expand Down
1 change: 0 additions & 1 deletion src/build-info/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
(library
(name goblint_build_info)
(public_name goblint.build-info)
(libraries batteries.unthreaded)
(virtual_modules dune_build_info))

(rule
Expand Down
2 changes: 1 addition & 1 deletion src/build-info/goblint_build_info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let release_commit = "%%VCS_COMMIT_ID%%"
(** Goblint version. *)
let version =
let commit = ConfigVersion.version in
if BatString.starts_with release_version "%" then
if String.starts_with release_version ~prefix:"%" then
commit
else (
let commit =
Expand Down
Loading

0 comments on commit f787e67

Please sign in to comment.