Memory sanitizer workaround: unpoison fd_sets.
authorEmil Mikulic <emikulic@gmail.com>
Wed, 1 Jul 2020 09:18:13 +0000 (19:18 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Wed, 1 Jul 2020 09:18:13 +0000 (19:18 +1000)
This is necessary with clang-9, maybe earlier.

darkhttpd.c

index eb57105..b3e71df 100644 (file)
@@ -70,6 +70,12 @@ static const int debug = 1;
 #include <time.h>
 #include <unistd.h>
 
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+#  include <sanitizer/msan_interface.h>
+# endif
+#endif
+
 #ifdef __sun__
 # ifndef INADDR_NONE
 #  define INADDR_NONE -1
@@ -2372,6 +2378,13 @@ static void httpd_poll(void) {
     }
 #undef MAX_FD_SET
 
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+    __msan_unpoison(&recv_set, sizeof(recv_set));
+    __msan_unpoison(&send_set, sizeof(send_set));
+# endif
+#endif
+
     /* -select- */
     if (debug) {
         printf("select() with max_fd %d timeout %d\n",