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)