Skip to content

Commit c111734

Browse files
committed
fix the remaining __cxa_atexit(f, 0, 0) -> atexit(f) to avoid libc assertion.
1 parent 9a8f595 commit c111734

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ static void AtCxaAtexit(void *unused) {
706706
#endif
707707

708708
#if ASAN_INTERCEPT___CXA_ATEXIT
709+
#ifdef SANITIZER_NETBSD
710+
DECLARE_REAL(int, atexit, void (*func)());
711+
#endif
709712
INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
710713
void *dso_handle) {
711714
#if SANITIZER_APPLE
@@ -717,7 +720,11 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
717720
__lsan::ScopedInterceptorDisabler disabler;
718721
#endif
719722
int res = REAL(__cxa_atexit)(func, arg, dso_handle);
723+
#ifdef SANITIZER_NETBSD
724+
REAL(atexit)((void (*)())AtCxaAtexit);
725+
#else
720726
REAL(__cxa_atexit)(AtCxaAtexit, nullptr, nullptr);
727+
#endif
721728
return res;
722729
}
723730
#endif // ASAN_INTERCEPT___CXA_ATEXIT
@@ -728,9 +735,14 @@ INTERCEPTOR(int, atexit, void (*func)()) {
728735
#if CAN_SANITIZE_LEAKS
729736
__lsan::ScopedInterceptorDisabler disabler;
730737
#endif
738+
#ifdef SANITIZER_NETBSD
739+
int res = REAL(atexit)(func);
740+
REAL(atexit)((void (*)())AtCxaAtexit);
741+
#else
731742
// Avoid calling real atexit as it is unreachable on at least on Linux.
732743
int res = REAL(__cxa_atexit)((void (*)(void *a))func, nullptr, nullptr);
733744
REAL(__cxa_atexit)(AtCxaAtexit, nullptr, nullptr);
745+
#endif
734746
return res;
735747
}
736748
#endif

external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
378378
#if SANITIZER_INTERCEPT_ATEXIT
379379
INTERCEPTOR(int, atexit, void (*f)()) {
380380
__lsan::ScopedInterceptorDisabler disabler;
381+
#ifdef SANITIZER_NETBSD
382+
return REAL(atexit)(f);
383+
#else
381384
return REAL(__cxa_atexit)((void (*)(void *a))f, 0, 0);
385+
#endif
382386
}
383387
#define LSAN_MAYBE_INTERCEPT_ATEXIT INTERCEPT_FUNCTION(atexit)
384388
#else

0 commit comments

Comments
 (0)