Skip to content

Commit

Permalink
Error on must-relocking of non-recursive mutex
Browse files Browse the repository at this point in the history
mayLocks analysis can warn on it, but mutex analysis can be definite about it.
  • Loading branch information
sim642 committed Nov 14, 2024
1 parent 065f990 commit f2f0c12
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/analyses/mutexAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ struct

let add ctx ((addr, rw): AddrRW.t): D.t =
match addr with
| Addr mv ->
| Addr ((v, o) as mv) ->
let (s, m) = ctx.local in
let s' = MustLocksetRW.add_mval_rw (mv, rw) s in
let m' =
if MutexTypeAnalysis.must_be_recursive ctx mv then
MustMultiplicity.increment mv m
else
match ctx.ask (Queries.MutexType (v, Offset.Unit.of_offs o)) with
| `Lifted Recursive -> MustMultiplicity.increment mv m
| `Lifted NonRec ->
if MustLocksetRW.mem_mval mv s then
M.error ~category:M.Category.Behavior.Undefined.double_locking "Acquiring a non-recursive mutex that is already held";
m
| `Bot | `Top -> m
in
(s', m')
| NullPtr ->
Expand Down

0 comments on commit f2f0c12

Please sign in to comment.