[compiler-rt] 6dcd0d4 - [NFC][sanitizer] Update `DTLS_on_tls_get_addr` failure comment (#109546)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 13:05:55 PDT 2024


Author: Vitaly Buka
Date: 2024-09-21T13:05:51-07:00
New Revision: 6dcd0d4b50ff3da15c316daad9b29633612664f6

URL: https://github.com/llvm/llvm-project/commit/6dcd0d4b50ff3da15c316daad9b29633612664f6
DIFF: https://github.com/llvm/llvm-project/commit/6dcd0d4b50ff3da15c316daad9b29633612664f6.diff

LOG: [NFC][sanitizer] Update `DTLS_on_tls_get_addr` failure comment (#109546)

Also return `nullptr` on failure. All callers
do nothing for `nullptr` or `{tls_beg, 0}`,
but with `nullptr` they continue earlier.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
index 6d5fad3e7b4a4b..e08bcb435ca841 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
@@ -158,10 +158,18 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
     return dtv;
   }
   VReport(2, "__tls_get_addr: Can't guess glibc version\n");
-  // This may happen inside the DTOR of main thread, so just ignore it.
+  // This may happen inside the DTOR a thread, or async signal handlers before
+  // thread initialization, so just ignore it.
+  //
+  // If the unknown block is dynamic TLS, unlikely we will be able to recognize
+  // it in future, mark it as done with '{tls_beg, 0}'.
+  //
+  // If the block is static TLS, possible reason of failed detection is nullptr
+  // in `static_tls_begin`. Regardless of reasons, the future handling of static
+  // TLS is still '{tls_beg, 0}'.
   dtv->beg = tls_beg;
   dtv->size = 0;
-  return dtv;
+  return nullptr;
 }
 
 DTLS *DTLS_Get() { return &dtls; }


        


More information about the llvm-commits mailing list