Skip to content

Commit 984bae9

Browse files
Merge branch 'master' into fix-apron-overflows
2 parents 7410da7 + e36e738 commit 984bae9

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/analyses/basePriv.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,11 +1255,11 @@ struct
12551255
else
12561256
st
12571257

1258-
let threadenter =
1258+
let threadenter ask st =
12591259
if Param.side_effect_global_init then
1260-
startstate_threadenter startstate
1260+
startstate_threadenter startstate ask st
12611261
else
1262-
old_threadenter
1262+
{(old_threadenter ask st) with priv = W.empty ()}
12631263
end
12641264

12651265
module LockCenteredD =
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// PARAM: --set ana.base.privatization mine-W-noinit --enable ana.int.enums
2+
#include <pthread.h>
3+
#include <goblint.h>
4+
5+
int g;
6+
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
7+
8+
void *t_fun(void *arg) {
9+
return NULL;
10+
}
11+
12+
void *t_fun2(void *arg) {
13+
pthread_mutex_lock(&A);
14+
pthread_mutex_unlock(&A); // used to spuriously publish g = 8
15+
return NULL;
16+
}
17+
18+
int main() {
19+
pthread_t id, id2;
20+
pthread_create(&id, NULL, t_fun, NULL); // enter multithreaded
21+
22+
pthread_mutex_lock(&A);
23+
g = 8;
24+
pthread_create(&id2, NULL, t_fun2, NULL); // used to pass g = 8 and W: A -> {g} to t_fun2
25+
g = 0;
26+
pthread_mutex_unlock(&A);
27+
28+
pthread_mutex_lock(&A);
29+
__goblint_check(g == 0);
30+
pthread_mutex_unlock(&A);
31+
return 0;
32+
}

0 commit comments

Comments
 (0)