Skip to content

Commit e8b09f1

Browse files
Category for Double Locking
1 parent 6236e48 commit e8b09f1

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/analyses/mayLocks.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ struct
99
module G = DefaultSpec.G
1010
module V = DefaultSpec.V
1111

12-
let add ctx (l,_) =
12+
let add ctx (l,r) =
1313
if D.mem l ctx.local then
1414
match D.Addr.to_var_must l with
1515
| Some v when ctx.ask (Queries.IsRecursiveMutex v)->
1616
ctx.local
1717
| _ ->
18-
(M.warn "double locking"; ctx.local)
18+
(M.warn ~category:M.Category.Behavior.Undefined.double_locking "Acquiring a (possibly non-recursive) mutex that may be already held"; ctx.local)
1919
else
2020
D.add l ctx.local
2121

src/util/messageCategory.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type undefined_behavior =
1212
| NullPointerDereference
1313
| UseAfterFree
1414
| Uninitialized
15+
| DoubleLocking
1516
[@@deriving eq, ord, hash]
1617

1718
type behavior =
@@ -61,6 +62,7 @@ struct
6162
let nullpointer_dereference: category = create @@ NullPointerDereference
6263
let use_after_free: category = create @@ UseAfterFree
6364
let uninitialized: category = create @@ Uninitialized
65+
let double_locking: category = create @@ DoubleLocking
6466

6567
module ArrayOutOfBounds =
6668
struct
@@ -95,6 +97,7 @@ struct
9597
| "nullpointer_dereference" -> nullpointer_dereference
9698
| "use_after_free" -> use_after_free
9799
| "uninitialized" -> uninitialized
100+
| "double_locking" -> double_locking
98101
| _ -> Unknown
99102

100103
let path_show (e: t) =
@@ -103,6 +106,7 @@ struct
103106
| NullPointerDereference -> ["NullPointerDereference"]
104107
| UseAfterFree -> ["UseAfterFree"]
105108
| Uninitialized -> ["Uninitialized"]
109+
| DoubleLocking -> ["DoubleLocking"]
106110
end
107111

108112
let from_string_list (s: string list): category =
@@ -208,6 +212,7 @@ let behaviorName = function
208212
|NullPointerDereference -> "NullPointerDereference"
209213
|UseAfterFree -> "UseAfterFree"
210214
|Uninitialized -> "Uninitialized"
215+
|DoubleLocking -> "DoubleLocking"
211216
| ArrayOutOfBounds aob -> match aob with
212217
| PastEnd -> "PastEnd"
213218
| BeforeStart -> "BeforeStart"

tests/regression/60-doublelocking/05-rec.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,4 @@ int main(int argc, char const *argv[])
4646

4747
return 0;
4848
}
49-
}
5049
#endif

0 commit comments

Comments
 (0)