Skip to content
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
21 changes: 11 additions & 10 deletions src/solvers/td3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,17 @@ module Base =
(* delete from incremental postsolving/warning structures to remove spurious warnings *)
delete_marked superstable;
delete_marked var_messages;

if restart_write_only then (
(* restart write-only *)
(* before delete_marked because we also want to restart write-only side effects from deleted nodes *)
HM.iter (fun x w ->
HM.iter (fun y d ->
ignore (Pretty.printf "Restarting write-only to bot %a\n" S.Var.pretty_trace y);
HM.replace rho y (S.Dom.bot ());
) w
) rho_write
);
delete_marked rho_write;
HM.iter (fun x w -> delete_marked w) rho_write;

Expand Down Expand Up @@ -905,16 +916,6 @@ module Base =
HM.create 0 (* doesn't matter, not used *)
in

if restart_write_only then (
(* restart write-only *)
HM.iter (fun x w ->
HM.iter (fun y d ->
ignore (Pretty.printf "Restarting write-only to bot %a\n" S.Var.pretty_trace y);
HM.replace rho y (S.Dom.bot ());
) w
) rho_write
);

if incr_verify then (
HM.filteri_inplace (fun x _ -> HM.mem reachable_and_superstable x) var_messages;
HM.filteri_inplace (fun x _ -> HM.mem reachable_and_superstable x) rho_write
Expand Down
17 changes: 17 additions & 0 deletions tests/incremental/13-restart-write/09-mutex-self-fix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <pthread.h>

pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
int g;

void *t_fun(void *arg) {
g++; // RACE!
return NULL;
}

int main() {
pthread_t id;
while (1) {
pthread_create(&id, NULL, t_fun, NULL);
}
return 0;
}
10 changes: 10 additions & 0 deletions tests/incremental/13-restart-write/09-mutex-self-fix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"incremental": {
"restart": {
"sided": {
"enabled": false
},
"write-only": true
}
}
}
13 changes: 13 additions & 0 deletions tests/incremental/13-restart-write/09-mutex-self-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- tests/incremental/13-restart-write/09-mutex-self-fix.c
+++ tests/incremental/13-restart-write/09-mutex-self-fix.c
@@ -4,7 +4,9 @@ pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
int g;

void *t_fun(void *arg) {
- g++; // RACE!
+ pthread_mutex_lock(&A);
+ g++; // NORACE
+ pthread_mutex_unlock(&A);
return NULL;
}