Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC][sanitizer] Update DTLS_on_tls_get_addr failure comment #109546

Conversation

vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Sep 21, 2024

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

Created using spr 1.3.4
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 21, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

Changes

Also return nullptr on failure, as is all caller
handler nullptr and {tls_beg, 0} in the same
manner.


Full diff: https://github.com/llvm/llvm-project/pull/109546.diff

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp (+10-2)
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; }

@vitalybuka vitalybuka merged commit 6dcd0d4 into main Sep 21, 2024
8 of 10 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/nfcsanitizer-update-dtls_on_tls_get_addr-failure-comment branch September 21, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants