[compiler-rt] TSAN: Report when thread is not live and referenced in pthread (PR #156921)

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 22:46:10 PDT 2025


================
@@ -0,0 +1,18 @@
+// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+
+#include <pthread.h>
+#include <stdio.h>
+
+void *fn(void *) { return NULL; }
+
+int main() {
+  pthread_t th;
+  int rc = pthread_create(&th, 0, fn, 0);
----------------
dvyukov wrote:

Right, just printing something in this case looks wrong. This is UB, and the actual implementation is not guaranteed to return EINVAL in these cases. Instead it can corrupt memory, etc.
If we print a proper report that will fail the process at the, or can be turned into a synchronous abort, that looks better than the CHECK failure. Also the report will contain a stack trace, otherwise the current printed line is competently unactionable. 


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


More information about the llvm-commits mailing list