From 36fae898f6bf62c7b903a4274a01ff9caa5e49f1 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 24 Feb 2023 12:08:27 +0100 Subject: [PATCH] dnsdist: Skip signal-unsafe logging when we are about to exit, with TSAN TSAN is rightfully unhappy about this: ``` WARNING: ThreadSanitizer: signal-unsafe call inside of a signal ``` This is not a real problem for us, as the worst case is that we crash trying to exit, but let's try to avoid the warnings in our tests. --- pdns/dnsdist-idstate.hh | 9 --------- pdns/dnsdist.cc | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pdns/dnsdist-idstate.hh b/pdns/dnsdist-idstate.hh index 43e1290b2f..bf3d76c332 100644 --- a/pdns/dnsdist-idstate.hh +++ b/pdns/dnsdist-idstate.hh @@ -89,15 +89,6 @@ private: bool d_needRealTime; }; -/* 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 - struct InternalQueryState { static void DeleterPlaceHolder(DOHUnit*) diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index f2e5cd8c2a..1532226c26 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2384,12 +2384,30 @@ static void sigTermHandler(int) _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 + static void sigTermHandler(int) { +#if !defined(__SANITIZE_THREAD__) + /* TSAN is rightfully unhappy about this: + WARNING: ThreadSanitizer: signal-unsafe call inside of a signal + This is not a real problem for us, as the worst case is that + we crash trying to exit, but let's try to avoid the warnings + in our tests. + */ if (g_syslog) { syslog(LOG_INFO, "Exiting on user request"); } std::cout<<"Exiting on user request"<