Commit 2a4081e
committed
sync: use proper TSA attributes
Use the proper attribute from Clang's thread safety analysis for
`AssertLockHeld()`:
* if `DEBUG_LOCKORDER` is defined then `AssertLockHeld()` will check if
the caller owns the given mutex and will `abort()` if not. Clang has
an attribute exactly for that - `ASSERT_EXCLUSIVE_LOCK()`, documented
as: "These are attributes on a function or method that does a run-time
test to see whether the calling thread holds the given capability. The
function is assumed to fail (no return) if the capability is not
held." [1]
* if `DEBUG_LOCKORDER` is not defined, then `AssertLockHeld()` does
nothing, thus don't tag it with any attributes (don't fool the
compiler that we do something which we don't).
Replace `LockAssertion` with `AssertLockHeld` and remove the former.
On the places where Clang cannot deduce that a mutex is held, use
`NO_THREAD_SAFETY_ANALYSIS`, intended to be used when a code is
"too complicated for the analysis to understand" [2].
[1] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#requires-requires-shared
[2] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#no-thread-safety-analysis1 parent 564e1ab commit 2a4081e
2 files changed
+15
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
665 | | - | |
666 | | - | |
| 665 | + | |
| 666 | + | |
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
| |||
1354 | 1354 | | |
1355 | 1355 | | |
1356 | 1356 | | |
1357 | | - | |
1358 | | - | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1359 | 1360 | | |
1360 | 1361 | | |
1361 | 1362 | | |
| |||
1488 | 1489 | | |
1489 | 1490 | | |
1490 | 1491 | | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
| 1492 | + | |
| 1493 | + | |
1494 | 1494 | | |
1495 | 1495 | | |
1496 | 1496 | | |
| |||
3979 | 3979 | | |
3980 | 3980 | | |
3981 | 3981 | | |
3982 | | - | |
3983 | | - | |
| 3982 | + | |
| 3983 | + | |
3984 | 3984 | | |
3985 | 3985 | | |
3986 | 3986 | | |
| |||
3996 | 3996 | | |
3997 | 3997 | | |
3998 | 3998 | | |
3999 | | - | |
4000 | | - | |
| 3999 | + | |
| 4000 | + | |
4001 | 4001 | | |
4002 | 4002 | | |
4003 | 4003 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | 355 | | |
0 commit comments