Does TSA support recursive/re-entrant mutexes

Looking at the documentation at

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html

it seems that the TSA does not support recursive/re-entrant locks. Is that the case?

Technically it doesn’t support them, but in practice you might be fine.

If you acquire a lock twice in the same function (without releasing it in between), that’s a warning, and you can’t tell the analysis that this is Ok because the lock is recursive. But of course that rarely happens: recursive locks are usually reacquired in contexts where they’re not known to be held, and then the analysis won’t complain either.

You would run into issues with -Wthread-safety-negative, but that warning is of course pointless with recursive locks: after all, they can always be acquired, even when they’re already held.

Ultimately they wouldn’t be hard to support, but so far it didn’t seem necessary, and it seems like a nice thing to be warned about double acquisition even when that’s allowed.