Skip to content

Commit 6dcd0d4

Browse files
authored
[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.
1 parent 37bb9ad commit 6dcd0d4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,18 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
158158
return dtv;
159159
}
160160
VReport(2, "__tls_get_addr: Can't guess glibc version\n");
161-
// This may happen inside the DTOR of main thread, so just ignore it.
161+
// This may happen inside the DTOR a thread, or async signal handlers before
162+
// thread initialization, so just ignore it.
163+
//
164+
// If the unknown block is dynamic TLS, unlikely we will be able to recognize
165+
// it in future, mark it as done with '{tls_beg, 0}'.
166+
//
167+
// If the block is static TLS, possible reason of failed detection is nullptr
168+
// in `static_tls_begin`. Regardless of reasons, the future handling of static
169+
// TLS is still '{tls_beg, 0}'.
162170
dtv->beg = tls_beg;
163171
dtv->size = 0;
164-
return dtv;
172+
return nullptr;
165173
}
166174

167175
DTLS *DTLS_Get() { return &dtls; }

0 commit comments

Comments
 (0)