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

Fix unsoundness from relation analysis reading special mutexes as integer variables #1441

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion src/analyses/apron/relationPriv.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,10 @@ struct
)
in
(* Unprotected invariant is one big relation. *)
sideg (V.mutex atomic_mutex) rel_side;
(* If no globals are contained here, none need to be published *)
(* https://github.com/goblint/analyzer/pull/1354 *)
if RD.vars rel_side <> [] then
sideg (V.mutex atomic_mutex) rel_side;
let rel_local =
let newly_unprot var = match AV.find_metadata var with
| Some (Global g) -> is_unprotected_without ask g atomic_mutex
Expand Down
8 changes: 4 additions & 4 deletions src/util/library/libraryFunctions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,8 @@ let linux_userspace_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
]
[@@coverage off]

let big_kernel_lock = AddrOf (Cil.var (Cilfacade.create_var (makeGlobalVar "[big kernel lock]" intType)))
let console_sem = AddrOf (Cil.var (Cilfacade.create_var (makeGlobalVar "[console semaphore]" intType)))
let big_kernel_lock = AddrOf (Cil.var (Cilfacade.create_var (makeGlobalVar "[big kernel lock]" voidType)))
let console_sem = AddrOf (Cil.var (Cilfacade.create_var (makeGlobalVar "[console semaphore]" voidType)))

(** Linux kernel functions. *)
let linux_kernel_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
Expand Down Expand Up @@ -1017,7 +1017,7 @@ let math_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
]
[@@coverage off]

let verifier_atomic_var = Cilfacade.create_var (makeGlobalVar "[__VERIFIER_atomic]" intType)
let verifier_atomic_var = Cilfacade.create_var (makeGlobalVar "[__VERIFIER_atomic]" voidType)
let verifier_atomic = AddrOf (Cil.var (Cilfacade.create_var verifier_atomic_var))

(** SV-COMP functions.
Expand All @@ -1032,7 +1032,7 @@ let svcomp_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
]
[@@coverage off]

let rtnl_lock = AddrOf (Cil.var (Cilfacade.create_var (makeGlobalVar "[rtnl_lock]" intType)))
let rtnl_lock = AddrOf (Cil.var (Cilfacade.create_var (makeGlobalVar "[rtnl_lock]" voidType)))

(** LDV Klever functions. *)
let klever_descs_list: (string * LibraryDesc.t) list = LibraryDsl.[
Expand Down
26 changes: 26 additions & 0 deletions tests/regression/46-apron2/69-atomic-live.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SKIP PARAM: --set ana.activated[+] apron --enable ana.sv-comp.functions --set ana.relation.privatization mutex-meet
#include <pthread.h>
#include <stdlib.h>
#include <goblint.h>

pthread_mutex_t mutex;

void *fun(void* args)
{
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);

__goblint_assert(1); //Reachable

__VERIFIER_atomic_begin();
__goblint_assert(1); //Reachable
__VERIFIER_atomic_end();

__goblint_assert(1); //Reachable
}

int main(void)
{
pthread_t t;
pthread_create(&t, ((void *)0), fun, ((void *)0));
}
Loading