Skip to content

Commit a592680

Browse files
authored
Merge pull request #1492 from goblint/issue_1489
Fix `mutex-meet` for malloc after thread creation
2 parents bc85d30 + 8f10b49 commit a592680

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

src/analyses/apron/relationPriv.apron.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ struct
503503
in
504504
let get_mutex_inits = getg V.mutex_inits in
505505
let get_mutex_inits' = RD.keep_vars get_mutex_inits [g_var] in
506-
if not (RD.mem_var get_mutex_inits' g_var) then (* TODO: is this just a workaround for an escape bug? https://github.com/goblint/analyzer/pull/1354/files#r1498882657 *)
506+
if RD.mem_var get_mutex_global_g g_var && not (RD.mem_var get_mutex_inits' g_var) then (* TODO: is this just a workaround for an escape bug? https://github.com/goblint/analyzer/pull/1354/files#r1498882657 *)
507507
(* This is an escaped variable whose value was never side-effected to get_mutex_inits' *)
508508
get_mutex_global_g
509509
else
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SKIP PARAM: --set ana.activated[+] apron --set ana.relation.privatization mutex-meet --set ana.apron.domain interval --set sem.int.signed_overflow assume_none
2+
// Checks that assinging to malloc'ed memory does not cause both branches to be dead
3+
#include <pthread.h>
4+
#include <goblint.h>
5+
void nop(void* arg) {
6+
}
7+
8+
void main() {
9+
pthread_t thread;
10+
pthread_create(&thread, 0, &nop, 0);
11+
12+
long *k = malloc(sizeof(long));
13+
*k = 5;
14+
if (1)
15+
;
16+
17+
__goblint_check(*k >= 5); // Reachable and true
18+
19+
*k = *k+1;
20+
__goblint_check(*k >= 5); // Reachable and true
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SKIP PARAM: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.relation.privatization mutex-meet-tid --set ana.apron.domain interval --set sem.int.signed_overflow assume_none
2+
// Checks that assinging to malloc'ed memory does not cause both branches to be dead
3+
#include <pthread.h>
4+
#include <goblint.h>
5+
void nop(void* arg) {
6+
}
7+
8+
void main() {
9+
pthread_t thread;
10+
pthread_create(&thread, 0, &nop, 0);
11+
12+
long *k = malloc(sizeof(long));
13+
*k = 5;
14+
if (1)
15+
;
16+
17+
__goblint_check(*k >= 5); // Reachable and true
18+
19+
*k = *k+1;
20+
__goblint_check(*k >= 5); // Reachable and true
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SKIP PARAM: --set ana.activated[+] apron --set ana.relation.privatization mutex-meet-atomic --set ana.apron.domain interval --set sem.int.signed_overflow assume_none
2+
// Checks that assinging to malloc'ed memory does not cause both branches to be dead
3+
#include <pthread.h>
4+
#include <goblint.h>
5+
void nop(void* arg) {
6+
}
7+
8+
void main() {
9+
pthread_t thread;
10+
pthread_create(&thread, 0, &nop, 0);
11+
12+
long *k = malloc(sizeof(long));
13+
*k = 5;
14+
if (1)
15+
;
16+
17+
__goblint_check(*k >= 5); // Reachable and true
18+
19+
*k = *k+1;
20+
__goblint_check(*k >= 5); // Reachable and true
21+
}

0 commit comments

Comments
 (0)