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

Check semantic indices of unlocked mutex #1409

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
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
Next Next commit
Check semantic indices of unlocked mutex
sim642 committed Apr 4, 2024
commit 06fc425f9002db72f5e90735638f3fb05c2af405
8 changes: 3 additions & 5 deletions src/cdomains/lockDomain.ml
Original file line number Diff line number Diff line change
@@ -39,11 +39,9 @@ struct
include SetDomain.Reverse(SetDomain.ToppedSet (Lock) (struct let topname = "All mutexes" end))
let name () = "lockset"

let may_be_same_offset of1 of2 =
let may_be_same_offset mv1 mv2 =
(* Only reached with definite of2 and indefinite of1. *)
(* TODO: Currently useless, because MayPointTo query doesn't return index offset ranges, so not enough information to ever return false. *)
(* TODO: Use Addr.Offs.semantic_equal. *)
true
Addr.Mval.semantic_equal mv1 mv2 <> Some false

let add (addr,rw) set =
match (Addr.to_mval addr) with
@@ -53,7 +51,7 @@ struct
let remove (addr,rw) set =
let collect_diff_varinfo_with (vi,os) (addr,rw) =
match (Addr.to_mval addr) with
| Some (v,o) when CilType.Varinfo.equal vi v -> not (may_be_same_offset o os)
| Some (v,o) when CilType.Varinfo.equal vi v -> not (may_be_same_offset (v,o) (vi,os))
| Some (v,o) -> true
| None -> false
in
7 changes: 3 additions & 4 deletions tests/regression/05-lval_ls/19-idxunknown_unlock_precise.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// PARAM: --enable ana.int.interval
// TODO because queries don't pass lvalue index intervals
// PARAM: --enable ana.int.interval --enable ana.sv-comp.functions
extern int __VERIFIER_nondet_int();
extern void abort(void);
void assume_abort_if_not(int cond) {
@@ -15,7 +14,7 @@ pthread_mutex_t m[10];

void *t_fun(void *arg) {
pthread_mutex_lock(&m[4]);
data++; // TODO NORACE
data++; // NORACE
pthread_mutex_unlock(&m[4]);
return NULL;
}
@@ -33,7 +32,7 @@ int main() {
pthread_create(&id, NULL, t_fun, NULL);
pthread_mutex_lock(&m[4]);
pthread_mutex_unlock(&m[i]); // no UB because ERRORCHECK
data++; // TODO NORACE
data++; // NORACE
pthread_mutex_unlock(&m[4]);
return 0;
}