@@ -196,7 +196,10 @@ static int munmap_interceptor(Munmap real_munmap, void *addr, SIZE_T length) {
196196 __lsan::ScopedInterceptorDisabler disabler
197197#endif
198198
199- # define SIGNAL_INTERCEPTOR_ENTER () ENSURE_ASAN_INITED()
199+ # define SIGNAL_INTERCEPTOR_ENTER () \
200+ do { \
201+ AsanInitFromRtl (); \
202+ } while (false )
200203
201204# include " sanitizer_common/sanitizer_common_interceptors.inc"
202205# include " sanitizer_common/sanitizer_signal_interceptors.inc"
@@ -496,7 +499,7 @@ DEFINE_REAL(char*, index, const char *string, int c)
496499 INTERCEPTOR (char *, strcat, char *to, const char *from) {
497500 void *ctx;
498501 ASAN_INTERCEPTOR_ENTER (ctx, strcat);
499- ENSURE_ASAN_INITED ();
502+ AsanInitFromRtl ();
500503 if (flags ()->replace_str ) {
501504 uptr from_length = internal_strlen (from);
502505 ASAN_READ_RANGE (ctx, from, from_length + 1 );
@@ -517,7 +520,7 @@ DEFINE_REAL(char*, index, const char *string, int c)
517520INTERCEPTOR (char *, strncat, char *to, const char *from, uptr size) {
518521 void *ctx;
519522 ASAN_INTERCEPTOR_ENTER (ctx, strncat);
520- ENSURE_ASAN_INITED ();
523+ AsanInitFromRtl ();
521524 if (flags ()->replace_str ) {
522525 uptr from_length = MaybeRealStrnlen (from, size);
523526 uptr copy_length = Min (size, from_length + 1 );
@@ -594,7 +597,7 @@ INTERCEPTOR(char*, __strdup, const char *s) {
594597INTERCEPTOR (char *, strncpy, char *to, const char *from, uptr size) {
595598 void *ctx;
596599 ASAN_INTERCEPTOR_ENTER (ctx, strncpy);
597- ENSURE_ASAN_INITED ();
600+ AsanInitFromRtl ();
598601 if (flags ()->replace_str ) {
599602 uptr from_size = Min (size, MaybeRealStrnlen (from, size) + 1 );
600603 CHECK_RANGES_OVERLAP (" strncpy" , to, from_size, from, from_size);
@@ -620,7 +623,7 @@ static ALWAYS_INLINE auto StrtolImpl(void *ctx, Fn real, const char *nptr,
620623 INTERCEPTOR (ret_type, func, const char *nptr, char **endptr, int base) { \
621624 void *ctx; \
622625 ASAN_INTERCEPTOR_ENTER (ctx, func); \
623- ENSURE_ASAN_INITED (); \
626+ AsanInitFromRtl (); \
624627 return StrtolImpl (ctx, REAL (func), nptr, endptr, base); \
625628 }
626629
@@ -637,7 +640,7 @@ INTERCEPTOR(int, atoi, const char *nptr) {
637640 ASAN_INTERCEPTOR_ENTER (ctx, atoi);
638641 if (SANITIZER_APPLE && UNLIKELY (!AsanInited ()))
639642 return REAL (atoi)(nptr);
640- ENSURE_ASAN_INITED ();
643+ AsanInitFromRtl ();
641644 if (!flags ()->replace_str ) {
642645 return REAL (atoi)(nptr);
643646 }
@@ -657,7 +660,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
657660 ASAN_INTERCEPTOR_ENTER (ctx, atol);
658661 if (SANITIZER_APPLE && UNLIKELY (!AsanInited ()))
659662 return REAL (atol)(nptr);
660- ENSURE_ASAN_INITED ();
663+ AsanInitFromRtl ();
661664 if (!flags ()->replace_str ) {
662665 return REAL (atol)(nptr);
663666 }
@@ -671,7 +674,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
671674INTERCEPTOR (long long , atoll, const char *nptr) {
672675 void *ctx;
673676 ASAN_INTERCEPTOR_ENTER (ctx, atoll);
674- ENSURE_ASAN_INITED ();
677+ AsanInitFromRtl ();
675678 if (!flags ()->replace_str ) {
676679 return REAL (atoll)(nptr);
677680 }
@@ -694,8 +697,8 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
694697 void *dso_handle) {
695698 if (SANITIZER_APPLE && UNLIKELY (!AsanInited ()))
696699 return REAL (__cxa_atexit)(func, arg, dso_handle);
697- ENSURE_ASAN_INITED ();
698- #if CAN_SANITIZE_LEAKS
700+ AsanInitFromRtl ();
701+ # if CAN_SANITIZE_LEAKS
699702 __lsan::ScopedInterceptorDisabler disabler;
700703#endif
701704 int res = REAL (__cxa_atexit)(func, arg, dso_handle);
@@ -706,8 +709,8 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
706709
707710#if ASAN_INTERCEPT_ATEXIT
708711INTERCEPTOR (int , atexit, void (*func)()) {
709- ENSURE_ASAN_INITED ();
710- #if CAN_SANITIZE_LEAKS
712+ AsanInitFromRtl ();
713+ # if CAN_SANITIZE_LEAKS
711714 __lsan::ScopedInterceptorDisabler disabler;
712715#endif
713716 // Avoid calling real atexit as it is unreachable on at least on Linux.
0 commit comments