Skip to content

Commit

Permalink
Merge branch 'svcomp24-conf' into svcomp24-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Nov 9, 2023
2 parents 6bad00c + 6aed24f commit c88a1fa
Show file tree
Hide file tree
Showing 66 changed files with 362 additions and 212 deletions.
1 change: 1 addition & 0 deletions conf/svcomp.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"uninit",
"expsplit",
"activeSetjmp",
"memLeak",
"threadflag"
],
"context": {
Expand Down
1 change: 1 addition & 0 deletions conf/svcomp24-validate.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"uninit",
"expsplit",
"activeSetjmp",
"memLeak",
"threadflag"
],
"context": {
Expand Down
1 change: 1 addition & 0 deletions conf/svcomp24.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"uninit",
"expsplit",
"activeSetjmp",
"memLeak",
"threadflag"
],
"context": {
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/abortUnless.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ struct
false

let startstate v = false
let threadenter ctx lval f args = [false]
let threadspawn ctx lval f args fctx = false
let threadenter ctx ~multiple lval f args = [false]
let threadspawn ctx ~multiple lval f args fctx = false
let exitstate v = false
end

Expand Down
4 changes: 2 additions & 2 deletions src/analyses/accessAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct

(** We just lift start state, global and dependency functions: *)
let startstate v = ()
let threadenter ctx lval f args = [()]
let threadenter ctx ~multiple lval f args = [()]
let exitstate v = ()
let context fd d = ()

Expand Down Expand Up @@ -121,7 +121,7 @@ struct
ctx.local


let threadspawn ctx lval f args fctx =
let threadspawn ctx ~multiple lval f args fctx =
(* must explicitly access thread ID lval because special to pthread_create doesn't if singlethreaded before *)
begin match lval with
| None -> ()
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/activeLongjmp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct

(* Initial values don't really matter: overwritten at longjmp call. *)
let startstate v = D.bot ()
let threadenter ctx lval f args = [D.bot ()]
let threadenter ctx ~multiple lval f args = [D.bot ()]
let exitstate v = D.top ()

let query ctx (type a) (q: a Queries.t): a Queries.result =
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/activeSetjmp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct
| _ -> ctx.local

let startstate v = D.bot ()
let threadenter ctx lval f args = [D.bot ()]
let threadenter ctx ~multiple lval f args = [D.bot ()]
let exitstate v = D.top ()

let query ctx (type a) (q: a Queries.t): a Queries.result =
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/apron/relationAnalysis.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ struct

(* Thread transfer functions. *)

let threadenter ctx lval f args =
let threadenter ctx ~multiple lval f args =
let st = ctx.local in
match Cilfacade.find_varinfo_fundec f with
| fd ->
Expand All @@ -665,7 +665,7 @@ struct
(* TODO: do something like base? *)
failwith "relation.threadenter: unknown function"

let threadspawn ctx lval f args fctx =
let threadspawn ctx ~multiple lval f args fctx =
ctx.local

let event ctx e octx =
Expand Down
18 changes: 9 additions & 9 deletions src/analyses/base.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ struct



let forkfun (ctx:(D.t, G.t, C.t, V.t) Analyses.ctx) (lv: lval option) (f: varinfo) (args: exp list) : (lval option * varinfo * exp list) list =
let forkfun (ctx:(D.t, G.t, C.t, V.t) Analyses.ctx) (lv: lval option) (f: varinfo) (args: exp list) : (lval option * varinfo * exp list) list * bool =
let create_thread lval arg v =
try
(* try to get function declaration *)
Expand Down Expand Up @@ -1985,7 +1985,7 @@ struct
else
start_funvars
in
List.filter_map (create_thread (Some (Mem id, NoOffset)) (Some ptc_arg)) start_funvars_with_unknown
List.filter_map (create_thread (Some (Mem id, NoOffset)) (Some ptc_arg)) start_funvars_with_unknown, false
end
| _, _ when get_bool "sem.unknown_function.spawn" ->
(* TODO: Remove sem.unknown_function.spawn check because it is (and should be) really done in LibraryFunctions.
Expand All @@ -1998,9 +1998,9 @@ struct
let deep_flist = collect_invalidate ~deep:true (Analyses.ask_of_ctx ctx) ctx.global ctx.local deep_args in
let flist = shallow_flist @ deep_flist in
let addrs = List.concat_map AD.to_var_may flist in
if addrs <> [] then M.debug ~category:Analyzer "Spawning functions from unknown function: %a" (d_list ", " CilType.Varinfo.pretty) addrs;
List.filter_map (create_thread None None) addrs
| _, _ -> []
if addrs <> [] then M.debug ~category:Analyzer "Spawning non-unique functions from unknown function: %a" (d_list ", " CilType.Varinfo.pretty) addrs;
List.filter_map (create_thread None None) addrs, true
| _, _ -> [], false

let assert_fn ctx e refine =
(* make the state meet the assertion in the rest of the code *)
Expand Down Expand Up @@ -2131,9 +2131,9 @@ struct
let addr = eval_lv (Analyses.ask_of_ctx ctx) ctx.global ctx.local lval in
(addr, AD.type_of addr)
in
let forks = forkfun ctx lv f args in
let forks, multiple = forkfun ctx lv f args in
if M.tracing then if not (List.is_empty forks) then M.tracel "spawn" "Base.special %s: spawning functions %a\n" f.vname (d_list "," CilType.Varinfo.pretty) (List.map BatTuple.Tuple3.second forks);
List.iter (BatTuple.Tuple3.uncurry ctx.spawn) forks;
List.iter (BatTuple.Tuple3.uncurry (ctx.spawn ~multiple)) forks;
let st: store = ctx.local in
let gs = ctx.global in
let desc = LF.find f in
Expand Down Expand Up @@ -2641,7 +2641,7 @@ struct
in
combine_one ctx.local after

let threadenter ctx (lval: lval option) (f: varinfo) (args: exp list): D.t list =
let threadenter ctx ~multiple (lval: lval option) (f: varinfo) (args: exp list): D.t list =
match Cilfacade.find_varinfo_fundec f with
| fd ->
[make_entry ~thread:true ctx fd args]
Expand All @@ -2651,7 +2651,7 @@ struct
let st = special_unknown_invalidate ctx (Analyses.ask_of_ctx ctx) ctx.global st f args in
[st]

let threadspawn ctx (lval: lval option) (f: varinfo) (args: exp list) fctx: D.t =
let threadspawn ctx ~multiple (lval: lval option) (f: varinfo) (args: exp list) fctx: D.t =
begin match lval with
| Some lval ->
begin match ThreadId.get_current (Analyses.ask_of_ctx fctx) with
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/basePriv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ end
module MinePrivBase =
struct
include NoFinalize
include ConfCheck.RequireMutexPathSensInit
include ConfCheck.RequireMutexPathSensOneMainInit
include MutexGlobals (* explicit not needed here because G is Prod anyway? *)

let thread_join ?(force=false) ask get e st = st
Expand Down
4 changes: 3 additions & 1 deletion src/analyses/commonPriv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ struct
if not mutex_active then failwith "Privatization (to be useful) requires the 'mutex' analysis to be enabled (it is currently disabled)"
end

module RequireMutexPathSensInit =
module RequireMutexPathSensOneMainInit =
struct
let init () =
RequireMutexActivatedInit.init ();
let mutex_path_sens = List.mem "mutex" (GobConfig.get_string_list "ana.path_sens") in
if not mutex_path_sens then failwith "The activated privatization requires the 'mutex' analysis to be enabled & path sensitive (it is currently enabled, but not path sensitive)";
let mainfuns = List.length @@ GobConfig.get_list "mainfun" in
if not (mainfuns = 1) then failwith "The activated privatization requires exactly one main function to be specified";
()
end

Expand Down
4 changes: 2 additions & 2 deletions src/analyses/condVars.ml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ struct
ctx.local

let startstate v = D.bot ()
let threadenter ctx lval f args = [D.bot ()]
let threadspawn ctx lval f args fctx = ctx.local
let threadenter ctx ~multiple lval f args = [D.bot ()]
let threadspawn ctx ~multiple lval f args fctx = ctx.local
let exitstate v = D.bot ()
end

Expand Down
4 changes: 2 additions & 2 deletions src/analyses/expsplit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ struct
in
emit_splits ctx d

let threadenter ctx lval f args = [ctx.local]
let threadenter ctx ~multiple lval f args = [ctx.local]

let threadspawn ctx lval f args fctx =
let threadspawn ctx ~multiple lval f args fctx =
emit_splits_ctx ctx

let event ctx (event: Events.t) octx =
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/extractPthread.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ module Spec : Analyses.MCPSpec = struct
(Ctx.top ())


let threadenter ctx lval f args =
let threadenter ctx ~multiple lval f args =
let d : D.t = ctx.local in
let tasks = ctx.global tasks_var in
(* TODO: optimize finding *)
Expand All @@ -1254,7 +1254,7 @@ module Spec : Analyses.MCPSpec = struct
[ { f_d with pred = d.pred } ]


let threadspawn ctx lval f args fctx = ctx.local
let threadspawn ctx ~multiple lval f args fctx = ctx.local

let exitstate v = D.top ()

Expand Down
4 changes: 2 additions & 2 deletions src/analyses/fileUse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ struct
| _ -> m

let startstate v = D.bot ()
let threadenter ctx lval f args = [D.bot ()]
let threadspawn ctx lval f args fctx = ctx.local
let threadenter ctx ~multiple lval f args = [D.bot ()]
let threadspawn ctx ~multiple lval f args fctx = ctx.local
let exitstate v = D.bot ()
end

Expand Down
11 changes: 10 additions & 1 deletion src/analyses/libraryFunctions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let c_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
("__builtin_strncat", special [__ "dest" [r; w]; __ "src" [r]; __ "n" []] @@ fun dest src n -> Strcat { dest; src; n = Some n; });
("__builtin___strncat_chk", special [__ "dest" [r; w]; __ "src" [r]; __ "n" []; drop "os" []] @@ fun dest src n -> Strcat { dest; src; n = Some n; });
("memcmp", unknown [drop "s1" [r]; drop "s2" [r]; drop "n" []]);
("__builtin_memcmp", unknown [drop "s1" [r]; drop "s2" [r]; drop "n" []]);
("memchr", unknown [drop "s" [r]; drop "c" []; drop "n" []]);
("asctime", unknown ~attrs:[ThreadUnsafe] [drop "time_ptr" [r_deep]]);
("fclose", unknown [drop "stream" [r_deep; w_deep; f_deep]]);
Expand Down Expand Up @@ -62,6 +63,7 @@ let c_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
("localeconv", unknown ~attrs:[ThreadUnsafe] []);
("localtime", unknown ~attrs:[ThreadUnsafe] [drop "time" [r]]);
("strlen", special [__ "s" [r]] @@ fun s -> Strlen s);
("__builtin_strlen", special [__ "s" [r]] @@ fun s -> Strlen s);
("strstr", special [__ "haystack" [r]; __ "needle" [r]] @@ fun haystack needle -> Strstr { haystack; needle; });
("strcmp", special [__ "s1" [r]; __ "s2" [r]] @@ fun s1 s2 -> Strcmp { s1; s2; n = None; });
("strtok", unknown ~attrs:[ThreadUnsafe] [drop "str" [r; w]; drop "delim" [r]]);
Expand Down Expand Up @@ -146,6 +148,7 @@ let c_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
("atomic_flag_test_and_set_explicit", unknown [drop "obj" [r; w]; drop "order" []]);
("atomic_load", unknown [drop "obj" [r]]);
("atomic_store", unknown [drop "obj" [w]; drop "desired" []]);
("_Exit", special [drop "status" []] @@ Abort);
]

(** C POSIX library functions.
Expand Down Expand Up @@ -335,7 +338,7 @@ let posix_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
("regexec", unknown [drop "preg" [r_deep]; drop "string" [r]; drop "nmatch" []; drop "pmatch" [w_deep]; drop "eflags" []]);
("regfree", unknown [drop "preg" [f_deep]]);
("ffs", unknown [drop "i" []]);
("_exit", special [drop "status" []] Abort);
("_exit", special [drop "status" []] @@ Abort);
("execvp", unknown [drop "file" [r]; drop "argv" [r_deep]]);
("execl", unknown (drop "path" [r] :: drop "arg" [r] :: VarArgs (drop' [r])));
("statvfs", unknown [drop "path" [r]; drop "buf" [w]]);
Expand Down Expand Up @@ -505,6 +508,7 @@ let gcc_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
("__builtin_unreachable", special' [] @@ fun () -> if get_bool "sem.builtin_unreachable.dead_code" then Abort else Unknown); (* https://github.com/sosy-lab/sv-benchmarks/issues/1296 *)
("__assert_rtn", special [drop "func" [r]; drop "file" [r]; drop "line" []; drop "exp" [r]] @@ Abort); (* MacOS's built-in assert *)
("__assert_fail", special [drop "assertion" [r]; drop "file" [r]; drop "line" []; drop "function" [r]] @@ Abort); (* gcc's built-in assert *)
("__assert", special [drop "assertion" [r]; drop "file" [r]; drop "line" []] @@ Abort); (* header says: The following is not at all used here but needed for standard compliance. *)
("__builtin_return_address", unknown [drop "level" []]);
("__builtin___sprintf_chk", unknown (drop "s" [w] :: drop "flag" [] :: drop "os" [] :: drop "fmt" [r] :: VarArgs (drop' [r])));
("__builtin_add_overflow", unknown [drop "a" []; drop "b" []; drop "c" [w]]);
Expand Down Expand Up @@ -576,6 +580,10 @@ let glibc_desc_list: (string * LibraryDesc.t) list = LibraryDsl.[
("__fgets_chk", unknown [drop "__s" [w]; drop "__size" []; drop "__n" []; drop "__stream" [r_deep; w_deep]]);
("__fread_alias", unknown [drop "__ptr" [w]; drop "__size" []; drop "__n" []; drop "__stream" [r_deep; w_deep]]);
("__fread_chk", unknown [drop "__ptr" [w]; drop "__ptrlen" []; drop "__size" []; drop "__n" []; drop "__stream" [r_deep; w_deep]]);
("fread_unlocked", unknown ~attrs:[ThreadUnsafe] [drop "buffer" [w]; drop "size" []; drop "count" []; drop "stream" [r_deep; w_deep]]);
("__fread_unlocked_alias", unknown ~attrs:[ThreadUnsafe] [drop "__ptr" [w]; drop "__size" []; drop "__n" []; drop "__stream" [r_deep; w_deep]]);
("__fread_unlocked_chk", unknown ~attrs:[ThreadUnsafe] [drop "__ptr" [w]; drop "__ptrlen" []; drop "__size" []; drop "__n" []; drop "__stream" [r_deep; w_deep]]);
("__fread_unlocked_chk_warn", unknown ~attrs:[ThreadUnsafe] [drop "__ptr" [w]; drop "__ptrlen" []; drop "__size" []; drop "__n" []; drop "__stream" [r_deep; w_deep]]);
("__read_chk", unknown [drop "__fd" []; drop "__buf" [w]; drop "__nbytes" []; drop "__buflen" []]);
("__read_alias", unknown [drop "__fd" []; drop "__buf" [w]; drop "__nbytes" []]);
("__readlink_chk", unknown [drop "path" [r]; drop "buf" [w]; drop "len" []; drop "buflen" []]);
Expand Down Expand Up @@ -972,6 +980,7 @@ let svcomp_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
("__VERIFIER_atomic_end", special [] @@ Unlock verifier_atomic);
("__VERIFIER_nondet_loff_t", unknown []); (* cannot give it in sv-comp.c without including stdlib or similar *)
("__VERIFIER_nondet_int", unknown []); (* declare invalidate actions to prevent invalidating globals when extern in regression tests *)
("__VERIFIER_nondet_size_t", unknown []); (* cannot give it in sv-comp.c without including stdlib or similar *)
]

let ncurses_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/locksetAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct
module C = D

let startstate v = D.empty ()
let threadenter ctx lval f args = [D.empty ()]
let threadenter ctx ~multiple lval f args = [D.empty ()]
let exitstate v = D.empty ()
end

Expand Down
16 changes: 8 additions & 8 deletions src/analyses/mCP.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ struct
f ((k,v::a')::a) b
in f [] xs

let do_spawns ctx (xs:(varinfo * (lval option * exp list)) list) =
let do_spawns ctx (xs:(varinfo * (lval option * exp list * bool)) list) =
let spawn_one v d =
List.iter (fun (lval, args) -> ctx.spawn lval v args) d
List.iter (fun (lval, args, multiple) -> ctx.spawn ~multiple lval v args) d
in
if get_bool "exp.single-threaded" then
M.msg_final Error ~category:Unsound "Thread not spawned"
Expand Down Expand Up @@ -324,8 +324,8 @@ struct

and outer_ctx tfname ?spawns ?sides ?emits ctx =
let spawn = match spawns with
| Some spawns -> (fun l v a -> spawns := (v,(l,a)) :: !spawns)
| None -> (fun v d -> failwith ("Cannot \"spawn\" in " ^ tfname ^ " context."))
| Some spawns -> (fun ?(multiple=false) l v a -> spawns := (v,(l,a,multiple)) :: !spawns)
| None -> (fun ?(multiple=false) v d -> failwith ("Cannot \"spawn\" in " ^ tfname ^ " context."))
in
let sideg = match sides with
| Some sides -> (fun v g -> sides := (v, (!WideningTokens.side_tokens, g)) :: !sides)
Expand Down Expand Up @@ -567,28 +567,28 @@ struct
let d = do_emits ctx !emits d q in
if q then raise Deadcode else d

let threadenter (ctx:(D.t, G.t, C.t, V.t) ctx) lval f a =
let threadenter (ctx:(D.t, G.t, C.t, V.t) ctx) ~multiple lval f a =
let sides = ref [] in
let emits = ref [] in
let ctx'' = outer_ctx "threadenter" ~sides ~emits ctx in
let f (n,(module S:MCPSpec),d) =
let ctx' : (S.D.t, S.G.t, S.C.t, S.V.t) ctx = inner_ctx "threadenter" ctx'' n d in
map (fun d -> (n, repr d)) @@ S.threadenter ctx' lval f a
map (fun d -> (n, repr d)) @@ (S.threadenter ~multiple) ctx' lval f a
in
let css = map f @@ spec_list ctx.local in
do_sideg ctx !sides;
(* TODO: this do_emits is now different from everything else *)
map (fun d -> do_emits ctx !emits d false) @@ map topo_sort_an @@ n_cartesian_product css

let threadspawn (ctx:(D.t, G.t, C.t, V.t) ctx) lval f a fctx =
let threadspawn (ctx:(D.t, G.t, C.t, V.t) ctx) ~multiple lval f a fctx =
let sides = ref [] in
let emits = ref [] in
let ctx'' = outer_ctx "threadspawn" ~sides ~emits ctx in
let fctx'' = outer_ctx "threadspawn" ~sides ~emits fctx in
let f post_all (n,(module S:MCPSpec),(d,fd)) =
let ctx' : (S.D.t, S.G.t, S.C.t, S.V.t) ctx = inner_ctx "threadspawn" ~post_all ctx'' n d in
let fctx' : (S.D.t, S.G.t, S.C.t, S.V.t) ctx = inner_ctx "threadspawn" ~post_all fctx'' n fd in
n, repr @@ S.threadspawn ctx' lval f a fctx'
n, repr @@ S.threadspawn ~multiple ctx' lval f a fctx'
in
let d, q = map_deadcode f @@ spec_list2 ctx.local fctx.local in
do_sideg ctx !sides;
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/mallocFresh.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ struct
| None -> ctx.local
| Some lval -> assign_lval (Analyses.ask_of_ctx ctx) lval ctx.local

let threadenter ctx lval f args =
let threadenter ctx ~multiple lval f args =
[D.empty ()]

let threadspawn ctx lval f args fctx =
let threadspawn ctx ~multiple lval f args fctx =
D.empty ()

module A =
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/malloc_null.ml
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ struct
let name () = "malloc_null"

let startstate v = D.empty ()
let threadenter ctx lval f args = [D.empty ()]
let threadspawn ctx lval f args fctx = ctx.local
let threadenter ctx ~multiple lval f args = [D.empty ()]
let threadspawn ctx ~multiple lval f args fctx = ctx.local
let exitstate v = D.empty ()

let init marshal =
Expand Down
7 changes: 4 additions & 3 deletions src/analyses/memLeak.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ struct
let name () = "memLeak"

module D = ToppedVarInfoSet
module C = Lattice.Unit
module C = D
module P = IdentityP (D)

let context _ _ = ()
let context _ d = d

(* HELPER FUNCTIONS *)
let warn_for_multi_threaded ctx =
Expand Down Expand Up @@ -95,4 +96,4 @@ struct
end

let _ =
MCP.register_analysis (module Spec : MCPSpec)
MCP.register_analysis (module Spec : MCPSpec)
Loading

0 comments on commit c88a1fa

Please sign in to comment.