Skip to content

Commit ea2a01d

Browse files
Handle non-racy MCPA for non-unique threads
1 parent b885ff7 commit ea2a01d

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

src/analyses/pthreadBarriers.ml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,27 @@ struct
108108
in
109109
let can_proceed = exists_k can_proceed_pred (min_cap - 1) relevant_waiters in
110110
if not can_proceed then raise Analyses.Deadcode;
111-
(* All TIDs are definite here, they may have other MCPA stuff but that is irrelevant. *)
112-
let tids = waiters |> List.map snd |> List.sort_uniq TID.compare in
113-
(* limit to this case to avoid having to construct all permutations above *)
114-
if BatList.compare_length_with tids (min_cap - 1) = 0 then
115-
List.fold_left (fun acc tid ->
116-
let curr = MustObserved.find tid acc in
117-
let must' = MustObserved.add tid (Barriers.add addr curr) acc in
118-
must'
119-
) must tids
120-
else
111+
let exists_non_unique = List.exists (function
112+
| _, `Lifted tid -> not @@ ThreadIdDomain.Thread.is_unique tid
113+
| _ -> true
114+
) waiters
115+
in
116+
if exists_non_unique then
117+
(* There can be non-unique threads that don't race with themselves because of mutexes etc *)
118+
(* We do nothing for those cases *)
121119
must
120+
else
121+
(* All TIDs are definite here, they may have other MCPA stuff but that is irrelevant. *)
122+
let tids = waiters |> List.map snd |> List.sort_uniq TID.compare in
123+
(* limit to this case to avoid having to construct all permutations above *)
124+
if BatList.compare_length_with tids (min_cap - 1) = 0 then
125+
List.fold_left (fun acc tid ->
126+
let curr = MustObserved.find tid acc in
127+
let must' = MustObserved.add tid (Barriers.add addr curr) acc in
128+
must'
129+
) must tids
130+
else
131+
must
122132
in
123133
(may, must)
124134
else

0 commit comments

Comments
 (0)