]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Skip signal-unsafe logging when we are about to exit, with TSAN 12587/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 24 Feb 2023 11:08:27 +0000 (12:08 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 24 Feb 2023 11:08:27 +0000 (12:08 +0100)
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
pdns/dnsdist.cc

index 43e1290b2fb5aa1291847508111a2241fe10d843..bf3d76c332c843229b2b9618e16e4614ca1eadfd 100644 (file)
@@ -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*)
index f2e5cd8c2ae691aa39d1f9ee8d51fd8eb9313624..1532226c26e93b572ffea9d9728dd582ad3bf8a8 100644 (file)
@@ -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"<<std::endl;
+#endif /* __SANITIZE_THREAD__ */
 
   _exit(EXIT_SUCCESS);
 }