Skip to content

Commit db84ba3

Browse files
authored
Merge pull request #709 from goblint/interactive-reluctant-warn
Fix incremental warnings with reluctant destabilization
2 parents 964f974 + aca39c3 commit db84ba3

10 files changed

+176
-4
lines changed

src/solvers/td3.ml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ module WP =
540540

541541
start_event ();
542542

543+
(* reluctantly unchanged return nodes to additionally query for postsolving to get warnings, etc. *)
544+
let reluctant_vs: S.Var.t list ref = ref [] in
545+
543546
if GobConfig.get_bool "incremental.load" then (
544547
let c = S.increment.changes in
545548
List.(Printf.printf "change_info = { unchanged = %d; changed = %d; added = %d; removed = %d }\n" (length c.unchanged) (length c.changed) (length c.added) (length c.removed));
@@ -737,7 +740,7 @@ module WP =
737740
print_endline "Removing data for changed and removed functions...";
738741
let delete_marked s = HM.iter (fun k _ -> HM.remove s k) marked_for_deletion in
739742
delete_marked rho;
740-
delete_marked infl;
743+
delete_marked infl; (* TODO: delete from inner sets? *)
741744
delete_marked wpoint;
742745

743746
(* destabilize_with_side doesn't have all infl to follow anymore, so should somewhat work with reluctant *)
@@ -826,8 +829,15 @@ module WP =
826829
);
827830

828831
delete_marked stable;
829-
delete_marked side_dep;
830-
delete_marked side_infl;
832+
delete_marked side_dep; (* TODO: delete from inner sets? *)
833+
delete_marked side_infl; (* TODO: delete from inner sets? *)
834+
835+
(* delete from incremental postsolving/warning structures to remove spurious warnings *)
836+
delete_marked superstable;
837+
delete_marked var_messages;
838+
delete_marked rho_write;
839+
HM.iter (fun x w -> delete_marked w) rho_write;
840+
831841
print_data data "Data after clean-up";
832842

833843
(* TODO: reluctant doesn't call destabilize on removed functions or old copies of modified functions (e.g. after removing write), so those globals don't get restarted *)
@@ -845,6 +855,10 @@ module WP =
845855
destabilize x;
846856
HM.replace stable x ()
847857
)
858+
else (
859+
print_endline "Destabilization not required...";
860+
reluctant_vs := x :: !reluctant_vs
861+
)
848862
) old_ret;
849863

850864
print_endline "Final solve..."
@@ -1101,7 +1115,7 @@ module WP =
11011115

11021116
let module Post = PostSolver.MakeIncrList (MakeIncrListArg) in
11031117

1104-
Post.post st vs rho;
1118+
Post.post st (!reluctant_vs @ vs) rho;
11051119

11061120
print_data data "Data after postsolve";
11071121

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <pthread.h>
2+
#include <stdio.h>
3+
4+
int myglobal;
5+
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
6+
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
7+
8+
void *t_fun(void *arg) {
9+
pthread_mutex_lock(&mutex1);
10+
myglobal=myglobal+1; // RACE!
11+
pthread_mutex_unlock(&mutex1);
12+
return NULL;
13+
}
14+
15+
int main(void) {
16+
pthread_t id;
17+
pthread_create(&id, NULL, t_fun, NULL);
18+
pthread_mutex_lock(&mutex2);
19+
myglobal=myglobal+1; // RACE!
20+
pthread_mutex_unlock(&mutex2);
21+
pthread_join (id, NULL);
22+
return 0;
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"incremental": {
3+
"restart": {
4+
"sided": {
5+
"enabled": false
6+
}
7+
},
8+
"reluctant": {
9+
"on": true
10+
}
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--- tests/incremental/13-restart-write/06-mutex-simple-reluctant.c
2+
+++ tests/incremental/13-restart-write/06-mutex-simple-reluctant.c
3+
@@ -7,7 +7,7 @@ pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
4+
5+
void *t_fun(void *arg) {
6+
pthread_mutex_lock(&mutex1);
7+
- myglobal=myglobal+1; // RACE!
8+
+ myglobal=myglobal+1; // NORACE
9+
pthread_mutex_unlock(&mutex1);
10+
return NULL;
11+
}
12+
@@ -15,9 +15,9 @@ void *t_fun(void *arg) {
13+
int main(void) {
14+
pthread_t id;
15+
pthread_create(&id, NULL, t_fun, NULL);
16+
- pthread_mutex_lock(&mutex2);
17+
- myglobal=myglobal+1; // RACE!
18+
- pthread_mutex_unlock(&mutex2);
19+
+ pthread_mutex_lock(&mutex1);
20+
+ myglobal=myglobal+1; // NORACE
21+
+ pthread_mutex_unlock(&mutex1);
22+
pthread_join (id, NULL);
23+
return 0;
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <pthread.h>
2+
#include <stdio.h>
3+
4+
int myglobal;
5+
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
6+
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
7+
8+
void *t_fun(void *arg) {
9+
pthread_mutex_lock(&mutex1);
10+
myglobal=myglobal+1; // RACE!
11+
pthread_mutex_unlock(&mutex1);
12+
return NULL;
13+
}
14+
15+
int main(void) {
16+
pthread_t id;
17+
pthread_create(&id, NULL, t_fun, NULL);
18+
pthread_mutex_lock(&mutex2);
19+
myglobal=myglobal+1; // RACE!
20+
pthread_mutex_unlock(&mutex2);
21+
pthread_join (id, NULL);
22+
return 0;
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"incremental": {
3+
"restart": {
4+
"sided": {
5+
"enabled": false
6+
}
7+
},
8+
"reluctant": {
9+
"on": true
10+
}
11+
}
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- tests/incremental/13-restart-write/07-mutex-simple-reluctant2.c
2+
+++ tests/incremental/13-restart-write/07-mutex-simple-reluctant2.c
3+
@@ -7,7 +7,7 @@ pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
4+
5+
void *t_fun(void *arg) {
6+
pthread_mutex_lock(&mutex1);
7+
- myglobal=myglobal+1; // RACE!
8+
+ myglobal=myglobal+2; // RACE!
9+
pthread_mutex_unlock(&mutex1);
10+
return NULL;
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <pthread.h>
2+
#include <stdio.h>
3+
4+
int myglobal;
5+
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
6+
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
7+
8+
void *t_fun(void *arg) {
9+
pthread_mutex_lock(&mutex1);
10+
pthread_mutex_unlock(&mutex1);
11+
return NULL;
12+
}
13+
14+
int main(void) {
15+
pthread_t id;
16+
pthread_create(&id, NULL, t_fun, NULL);
17+
pthread_mutex_lock(&mutex2);
18+
myglobal=myglobal+1; // NORACE
19+
pthread_mutex_unlock(&mutex2);
20+
pthread_join (id, NULL);
21+
return 0;
22+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"incremental": {
3+
"restart": {
4+
"sided": {
5+
"enabled": false
6+
}
7+
},
8+
"reluctant": {
9+
"on": true
10+
}
11+
}
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- tests/incremental/13-restart-write/08-mutex-simple-reluctant3.c
2+
+++ tests/incremental/13-restart-write/08-mutex-simple-reluctant3.c
3+
@@ -7,6 +7,7 @@ pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
4+
5+
void *t_fun(void *arg) {
6+
pthread_mutex_lock(&mutex1);
7+
+ myglobal=myglobal+1; // RACE!
8+
pthread_mutex_unlock(&mutex1);
9+
return NULL;
10+
}
11+
@@ -15,7 +16,7 @@ int main(void) {
12+
pthread_t id;
13+
pthread_create(&id, NULL, t_fun, NULL);
14+
pthread_mutex_lock(&mutex2);
15+
- myglobal=myglobal+1; // NORACE
16+
+ myglobal=myglobal+1; // RACE!
17+
pthread_mutex_unlock(&mutex2);
18+
pthread_join (id, NULL);
19+
return 0;

0 commit comments

Comments
 (0)