Skip to content

Commit 90fc5aa

Browse files
committed
Refine MustBeProtectedBy and MayBePublicWithout query mutex type
1 parent 500b452 commit 90fc5aa

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/analyses/commonPriv.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ struct
7474

7575
let is_unprotected_without ask ?(write=true) ?(protection=Strong) x m: bool =
7676
(if protection = Weak then ThreadFlag.is_currently_multi ask else ThreadFlag.has_ever_been_multi ask) &&
77-
ask.f (Q.MayBePublicWithout {global=x; write; without_mutex=Addr (LockDomain.MustLock.to_mval m); protection}) (* TODO: no mutex conversion? *)
77+
ask.f (Q.MayBePublicWithout {global=x; write; without_mutex=m; protection})
7878

7979
let is_protected_by ask ?(protection=Strong) m x: bool =
8080
is_global ask x &&
8181
not (VD.is_immediate_type x.vtype) &&
82-
ask.f (Q.MustBeProtectedBy {mutex=Addr (LockDomain.MustLock.to_mval m); global=x; write=true; protection}) (* TODO: no mutex conversion? *)
82+
ask.f (Q.MustBeProtectedBy {mutex=m; global=x; write=true; protection})
8383

8484
let protected_vars (ask: Q.ask): varinfo list =
8585
LockDomain.MustLockset.fold (fun ml acc ->

src/analyses/mutexAnalysis.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,14 @@ struct
209209
MustLockset.disjoint held_locks protecting
210210
| Queries.MayBePublicWithout _ when MustLocksetRW.is_all ls -> false
211211
| Queries.MayBePublicWithout {global=v; write; without_mutex; protection} ->
212-
let held_locks = MustLocksetRW.to_must_lockset @@ fst @@ Arg.remove' ctx ~warn:false without_mutex in
212+
let held_locks = MustLockset.remove without_mutex (MustLocksetRW.to_must_lockset ls) in
213213
let protecting = protecting ~write protection v in
214214
(* TODO: unsound in 29/24, why did we do this before? *)
215215
(* if Mutexes.mem verifier_atomic (Lockset.export_locks (Lockset.remove (without_mutex, true) ctx.local)) then
216216
false
217217
else *)
218218
MustLockset.disjoint held_locks protecting
219-
| Queries.MustBeProtectedBy {mutex = Addr mutex_mv; global=v; write; protection} when Mval.is_definite mutex_mv -> (* only definite Addrs can be in must-locksets to begin with, anything else cannot protect anything *)
220-
let ml = LockDomain.MustLock.of_mval mutex_mv in
219+
| Queries.MustBeProtectedBy {mutex = ml; global=v; write; protection} ->
221220
let protecting = protecting ~write protection v in
222221
(* TODO: unsound in 29/24, why did we do this before? *)
223222
(* if LockDomain.Addr.equal mutex (LockDomain.Addr.of_var LF.verifier_atomic_var) then

src/domains/queries.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ end
4949

5050
(* Helper definitions for deriving complex parts of Any.compare below. *)
5151
type maybepublic = {global: CilType.Varinfo.t; write: bool; protection: Protection.t} [@@deriving ord, hash]
52-
type maybepublicwithout = {global: CilType.Varinfo.t; write: bool; without_mutex: PreValueDomain.Addr.t; protection: Protection.t} [@@deriving ord, hash]
53-
type mustbeprotectedby = {mutex: PreValueDomain.Addr.t; global: CilType.Varinfo.t; write: bool; protection: Protection.t} [@@deriving ord, hash]
52+
type maybepublicwithout = {global: CilType.Varinfo.t; write: bool; without_mutex: LockDomain.MustLock.t; protection: Protection.t} [@@deriving ord, hash]
53+
type mustbeprotectedby = {mutex: LockDomain.MustLock.t; global: CilType.Varinfo.t; write: bool; protection: Protection.t} [@@deriving ord, hash]
5454
type mustprotectedvars = {mutex: LockDomain.MustLock.t; write: bool} [@@deriving ord, hash]
5555
type access =
5656
| Memory of {exp: CilType.Exp.t; var_opt: CilType.Varinfo.t option; kind: AccessKind.t} (** Memory location access (race). *)

0 commit comments

Comments
 (0)