Check absence of locks at compile-time (using LOCKS_EXCLUDED annotation) in addition to the current run-time checking (using AssertLockNotHeld(…)).
In line with the developer notes:
Generally; compile-time checking is preferred over run-time checking.
For people who are not compiling with clang -Werror=thread-safety-analysis -- this is the type of checking these annotations enable:
[…]: error: cannot call function 'LimitValidationInterfaceQueue' while mutex 'cs_main' is
held [-Werror,-Wthread-safety-analysis]
LimitValidationInterfaceQueue();
^