Problems with thread safety and RAII patterns in C++
Problems with thread safety and RAII patterns in C++
Posted Mar 14, 2025 1:17 UTC (Fri) by irogers (subscriber, #121692)Parent article: Capability analysis for the kernel
Ironically C could be better than in C++ thread safety analysis as it doesn't apply to constructors and destructors. All constructors/destructors are implicitly made NO_THREAD_SAFETY_ANALYSIS:
https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#no-...
This can be pretty limiting as you may put logic in constructors/destructors that uses global locks, particularly common for RAII patterns. C cleanups for RAII are also considered in the thread.
https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#no-...
This can be pretty limiting as you may put logic in constructors/destructors that uses global locks, particularly common for RAII patterns. C cleanups for RAII are also considered in the thread.