[compiler-rt] [NFC][sanitizer] Update `DTLS_on_tls_get_addr` failure comment (PR #109546)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 21 13:02:02 PDT 2024
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/109546
Also return `nullptr` on failure, as is all caller
handler `nullptr` and `{tls_beg, 0}` in the same
manner.
>From 5ad995d1b10c52d2c2d2dc6b4e20dbade53c0abd Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 21 Sep 2024 13:01:44 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
.../lib/sanitizer_common/sanitizer_tls_get_addr.cpp | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
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