[PATCH] D55711: Don't trigger sanitizer initialization from `sysctlbyname` interceptor.
Dan Liew via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 10:05:08 PST 2018
delcypher created this revision.
delcypher added reviewers: kubamracek, george.karpenkov, devnexen, vitalybuka, krytarowski.
Herald added a subscriber: Sanitizers.
This fixes the `ThreadSanitizer-x86_64-iossim` testsuite which broke
when r348770 (https://reviews.llvm.org/D55473) landed.
The root cause of the problem is that early-on during the iOS simulator
init process a call to `sysctlbyname` is issued. If the TSan initializer
is triggered at this point it will eventually trigger a call to
`__cxa_at_exit(...)`. This call then aborts because the library
implementing this function is not yet had its initialization function
called.
rdar://problem/46696934
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D55711
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -7561,6 +7561,15 @@
INTERCEPTOR(int, sysctlbyname, char *sname, void *oldp, SIZE_T *oldlenp,
void *newp, SIZE_T newlen) {
void *ctx;
+ if (UNLIKELY(COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)) {
+ // On Darwin iOS simulators `sysctlbyname` gets called early
+ // during init. If we do TSan init now we'll trigger a
+ // call to `__cxa_atexit` which will crash due the implementing
+ // library not being properly initialized. To avoid this simply
+ // don't intercept this function until init has been triggered
+ // from elsewhere.
+ return REAL(sysctlbyname)(sname, oldp, oldlenp, newp, newlen);
+ }
COMMON_INTERCEPTOR_ENTER(ctx, sysctlbyname, sname, oldp, oldlenp, newp,
newlen);
if (sname)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55711.178245.patch
Type: text/x-patch
Size: 1018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181214/3d1f6775/attachment.bin>
More information about the llvm-commits
mailing list