UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1:suppressions=${{ env.REPO_HOME }}/build-scripts/UBSan.supp"
# Disabling (intercept_send=0) the custom send wrappers for ASAN and TSAN because they cause the tools to report a race that doesn't exist on actual implementations of send(), see https://github.com/google/sanitizers/issues/1498
ASAN_OPTIONS: intercept_send=0
+ LSAN_OPTIONS: "suppressions=${{ env.REPO_HOME }}/pdns/dnsdistdist/dnsdist-lsan.supp"
TSAN_OPTIONS: "halt_on_error=1:intercept_send=0:suppressions=${{ env.REPO_HOME }}/pdns/dnsdistdist/dnsdist-tsan.supp"
# IncludeDir tests are disabled because of a weird interaction between TSAN and these tests which ever only happens on GH actions
SKIP_INCLUDEDIR_TESTS: yes
[#include <sanitizer/common_interface_defs.h>]
)]
)
+ AC_CHECK_HEADERS([sanitizer/lsan_interface.h],
+ AC_DEFINE([HAVE_LEAK_SANITIZER_INTERFACE], [1], [Define if LSAN interface is available.]),
+ []
+ )
],
[AC_MSG_ERROR([Cannot enable AddressSanitizer])]
)
[SANITIZER_FLAGS="-fsanitize=leak $SANITIZER_FLAGS"],
[AC_MSG_ERROR([Cannot enable LeakSanitizer])]
)
+ AC_CHECK_HEADERS([sanitizer/lsan_interface.h],
+ AC_DEFINE([HAVE_LEAK_SANITIZER_INTERFACE], [1], [Define if LSAN interface is available.]),
+ []
+ )
])
AC_SUBST([SANITIZER_FLAGS])
])
])
AC_SUBST([SANITIZER_FLAGS])
])
-
cout << "-V,--version Show dnsdist version information and exit\n";
}
-#ifdef COVERAGE
+/* g++ defines __SANITIZE_THREAD__
+ clang++ supports the nice __has_feature(thread_sanitizer),
+ let's merge them */
+#if defined(__has_feature)
+#if __has_feature(thread_sanitizer)
+#define __SANITIZE_THREAD__ 1
+#endif
+#if __has_feature(address_sanitizer)
+#define __SANITIZE_ADDRESS__ 1
+#if defined(__SANITIZE_ADDRESS__) && defined(HAVE_LEAK_SANITIZER_INTERFACE)
+#include <sanitizer/lsan_interface.h>
+#endif
+#endif
+#endif
+
+#if defined(COVERAGE) || (defined(__SANITIZE_ADDRESS__) && defined(HAVE_LEAK_SANITIZER_INTERFACE))
static void cleanupLuaObjects()
{
/* when our coverage mode is enabled, we need to make sure
clearWebHandlers();
dnsdist::lua::hooks::clearMaintenanceHooks();
}
+#endif /* defined(COVERAGE) || (defined(__SANITIZE_ADDRESS__) && defined(HAVE_LEAK_SANITIZER_INTERFACE)) */
+#if defined(COVERAGE)
static void sigTermHandler(int)
{
cleanupLuaObjects();
pdns::coverage::dumpCoverageData();
_exit(EXIT_SUCCESS);
}
-#else /* COVERAGE */
-
-/* g++ defines __SANITIZE_THREAD__
- clang++ supports the nice __has_feature(thread_sanitizer),
- let's merge them */
-#if defined(__has_feature)
-#if __has_feature(thread_sanitizer)
-#define __SANITIZE_THREAD__ 1
-#endif
-#endif
-
+#else
static void sigTermHandler([[maybe_unused]] int sig)
{
#if !defined(__SANITIZE_THREAD__)
}
std::cout << "Exiting on user request" << std::endl;
#endif /* __SANITIZE_THREAD__ */
-
+#if defined(__SANITIZE_ADDRESS__) && defined(HAVE_LEAK_SANITIZER_INTERFACE)
+ auto lock = g_lua.lock();
+ cleanupLuaObjects();
+ *lock = LuaContext();
+ __lsan_do_leak_check();
+#endif /* __SANITIZE_ADDRESS__ && HAVE_LEAK_SANITIZER_INTERFACE */
_exit(EXIT_SUCCESS);
}
#endif /* COVERAGE */