STL
STL copied to clipboard
No thread-safe annotations for mutex and related classes
The clang compiler comes with some very useful warnings under the umbrella of -Wthread-safety. (See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html) Unfortunately, the MS STL does not provide annotations to the relevant classes, such that this warning cannot be used with the standard STL types.
How about other implementations?
- libc++ adds these annotations (https://github.com/llvm-mirror/libcxx/blob/master/include/mutex)
- libstdc++ does not add these annotations (https://gcc.gnu.org/onlinedocs/gcc-12.1.0/libstdc++/api/a00143_source.html#l00692)
Would it be possible to decorate the thread safety analysis such that this warning can be used and prevent a lot of debugging time for threading issues that are easily caught by the compiler?
This looks like duplicate of #3163.
It's a unfortunate that annotations in SAL for concurrency isn't designed for C++ lock types (https://github.com/microsoft/STL/pull/3536#issuecomment-1489352034).
But it seems possible to me to add annotations for Clang.
Looks indeed like a duplicate of #3163
Thanks! We'll use this newer issue as the primary since it talks only about Clang (and not SAL annotations which we've abandoned any attempt to use here).