Skip to content

Commit

Permalink
Merge pull request #1265 from goblint/mutex-meet-tid-memsafety
Browse files Browse the repository at this point in the history
Test for `mutex-meet-tid` for ValidDeref & Move `Afterconfig.run` to ensure privatizations can potentially be auto-tuned
  • Loading branch information
michael-schwarz authored Nov 27, 2023
2 parents 778d883 + 209a560 commit 24943a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/autoTune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ 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;
| 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.path_sens[+] threadflag --set ana.activated[+] memOutOfBounds --set ana.base.privatization mutex-meet-tid
#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; //NOWARN
pthread_mutex_unlock(&mutex);
return 0;
}

0 comments on commit 24943a1

Please sign in to comment.