[compiler-rt] TSAN: Report when thread is not live and referenced in pthread (PR #156921)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 4 12:54: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);
----------------
Katze719 wrote:
Per POSIX, pthread_detach returns an error if the thread isn’t joinable (EINVAL) or no such thread exists (ESRCH). Calling it twice just makes the second call fail. it doesn’t invoke undefined behavior.
https://www.man7.org/linux/man-pages/man3/pthread_detach.3.html
https://github.com/llvm/llvm-project/pull/156921
More information about the llvm-commits
mailing list