[compiler-rt] [compiler-rt][TSan] fix crash caused by intercpting pthread_detach on Android (PR #161596)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 6 08:01:13 PDT 2025


================
@@ -1130,6 +1130,20 @@ TSAN_INTERCEPTOR(int, pthread_create,
 
 TSAN_INTERCEPTOR(int, pthread_join, void *th, void **ret) {
   SCOPED_INTERCEPTOR_RAW(pthread_join, th, ret);
+#if SANITIZER_ANDROID
+  {
+    // In Bionic, pthread_detach calls pthread_join, so the thread has already
+    // been consumed by the pthread_detach interceptor.
+    Tid tid = ctx->thread_registry.FindThread(
+        [](ThreadContextBase* tctx, void* arg) {
+          return tctx->user_id == (uptr)arg;
+        },
+        th);
+    if (tid == kInvalidTid) {
----------------
enh-google wrote:

the new comment sounds right to me...

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


More information about the llvm-commits mailing list