[compiler-rt] [rtsan] Support legacy pthread_cond variables (PR #152947)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 19:54:37 PDT 2025


================
@@ -46,12 +46,52 @@
 
 using namespace __sanitizer;
 
+#if defined(__x86_64__) || defined(__mips__) || SANITIZER_PPC64V1 ||           \
+    defined(__s390x__)
+#define PTHREAD_ABI_BASE "GLIBC_2.3.2"
+#elif defined(__aarch64__) || SANITIZER_PPC64V2
+#define PTHREAD_ABI_BASE "GLIBC_2.17"
+#elif SANITIZER_LOONGARCH64
+#define PTHREAD_ABI_BASE "GLIBC_2.36"
+#elif SANITIZER_RISCV64
+#define PTHREAD_ABI_BASE "GLIBC_2.27"
+#endif
+
+DECLARE_REAL_AND_INTERCEPTOR(void *, malloc, usize size)
+DECLARE_REAL_AND_INTERCEPTOR(void, free, void *ptr)
+
 namespace {
 struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
   static bool UseImpl() { return !__rtsan_is_initialized(); }
 };
 } // namespace
 
+// See note in tsan as to why this is necessary
+static pthread_cond_t *init_cond(pthread_cond_t *c, bool force = false) {
+  if (!common_flags()->legacy_pthread_cond)
----------------
MaskRay wrote:

The option is for DSO built against glibc 2.2.5 (released in 2002). For rtsan we can reasonably assume newer shared objects and don't allow this at all.

So, just delete this code path?

https://github.com/llvm/llvm-project/pull/152947


More information about the llvm-commits mailing list