Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for mutex-meet-tid for ValidDeref & Move Afterconfig.run to ensure privatizations can potentially be auto-tuned #1265

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
8 changes: 7 additions & 1 deletion src/analyses/base.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,13 @@ struct
);
(* Warn if any of the addresses contains a non-local and non-global variable *)
if AD.exists (function
| AD.Addr.Addr (v, _) -> not (CPA.mem v st.cpa) && not (is_global a v)
| AD.Addr.Addr (v, _) ->
(M.tracel "wtf" "checking for %a\n" CilType.Varinfo.pretty v;
michael-schwarz marked this conversation as resolved.
Show resolved Hide resolved
if v.vglob then
(* this is OK *)
false
else
(not (CPA.mem v st.cpa)) || WeakUpdates.mem v st.weak)
| _ -> false
) adr then (
AnalysisStateUtil.set_mem_safety_flag InvalidDeref;
Expand Down
6 changes: 5 additions & 1 deletion src/autoTune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ let focusOnMemSafetySpecification (spec: Svcomp.Specification.t) =
print_endline "Setting \"cil.addNestedScopeAttr\" to true";
set_bool "cil.addNestedScopeAttr" true;
print_endline @@ "Specification: ValidDeref -> enabling memOutOfBounds analysis \"" ^ (String.concat ", " memOobAna) ^ "\"";
enableAnalyses memOobAna
enableAnalyses memOobAna;
(* Set privatization to mutex-meet-tid *)
set_string "ana.base.privatization" "mutex-meet-tid";
(* Required for mutex-meet-tid privatization *)
GobConfig.set_auto "ana.path_sens[+]" "threadflag";
| ValidMemtrack
| ValidMemcleanup -> (* Enable the memLeak analysis *)
let memLeakAna = ["memLeak"] in
Expand Down
2 changes: 1 addition & 1 deletion src/maingoblint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ let handle_flags () =

let handle_options () =
check_arguments ();
AfterConfig.run ();
Sys.set_signal (GobSys.signal_of_string (get_string "dbg.solver-signal")) Signal_ignore; (* Ignore solver-signal before solving (e.g. MyCFG), otherwise exceptions self-signal the default, which crashes instead of printing backtrace. *)
if AutoTune.isActivated "memsafetySpecification" && get_string "ana.specification" <> "" then
AutoTune.focusOnMemSafetySpecification ();
AfterConfig.run ();
Cilfacade.init_options ();
handle_flags ()

Expand Down
21 changes: 21 additions & 0 deletions tests/regression/74-invalid_deref/31-multithreaded.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//PARAM: --set ana.activated[+] useAfterFree --set ana.activated[+] threadJoins --set ana.path_sens[+] threadflag --set ana.activated[+] memOutOfBounds --enable ana.int.interval --set ana.base.arrays.domain partitioned --set ana.base.privatization mutex-meet-tid
michael-schwarz marked this conversation as resolved.
Show resolved Hide resolved
#include <pthread.h>

int data;
int *p = &data, *q;
pthread_mutex_t mutex;
void *t_fun(void *arg) {
pthread_mutex_lock(&mutex);
*p = 8;
pthread_mutex_unlock(&mutex);
return ((void *)0);
}
int main() {
pthread_t id;
pthread_create(&id, ((void *)0), t_fun, ((void *)0));
q = p;
pthread_mutex_lock(&mutex);
*q = 8;
pthread_mutex_unlock(&mutex);
return 0;
}