Skip to content

Commit cb92439

Browse files
Merge branch 'master' into affineeq-refine
2 parents f7666fd + 3068dcb commit cb92439

File tree

4 files changed

+65
-7
lines changed

4 files changed

+65
-7
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 =

src/cdomains/apron/sharedFunctions.apron.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,12 @@ struct
170170
| exception Invalid_argument _ -> raise (Unsupported_CilExp Exp_not_supported)
171171
| true -> texpr1 e
172172
| false -> (* Cast is not injective - we now try to establish suitable ranges manually *)
173-
(* try to evaluate e by EvalInt Query *)
174-
let res = try (query e @@ Cilfacade.get_ikind_exp e) with Invalid_argument _ -> raise (Unsupported_CilExp Exp_not_supported) in
175-
(* convert response to a constant *)
176-
let const = IntDomain.IntDomTuple.to_int @@ IntDomain.IntDomTuple.cast_to t_ik res in
173+
(* retrieving a valuerange for a non-injective cast works by a query to the value-domain with subsequent value extraction from domtuple - which should be speculative, since it is not program code *)
174+
let const,res = GobRef.wrap AnalysisState.executing_speculative_computations true @@ fun () ->
175+
(* try to evaluate e by EvalInt Query *)
176+
let res = try (query e @@ Cilfacade.get_ikind_exp e) with Invalid_argument _ -> raise (Unsupported_CilExp Exp_not_supported) in
177+
(* convert response to a constant *)
178+
IntDomain.IntDomTuple.to_int @@ IntDomain.IntDomTuple.cast_to t_ik res, res in
177179
match const with
178180
| Some c -> Cst (Coeff.s_of_z c) (* Got a constant value -> use it straight away *)
179181
(* I gotten top, we can not guarantee injectivity *)
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+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//SKIP PARAM: --enable ana.int.interval --set sem.int.signed_overflow assume_none --set ana.activated[+] lin2vareq
2+
3+
#include <goblint.h>
4+
5+
int nondet() {
6+
int x;
7+
return x;
8+
}
9+
int SIZE = 1;
10+
int rand;
11+
12+
int main() {
13+
unsigned int n=2,i=8;
14+
n = i%(SIZE+2); //NOWARN
15+
16+
rand=nondet();
17+
18+
if (rand>5 && rand<10) {
19+
n= i%(rand+2); //NOWARN
20+
}
21+
22+
return 0;
23+
}
24+

0 commit comments

Comments
 (0)