]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Disable stringop-overread with gcc-11+ Address Sanitizer
authorOndřej Surý <ondrej@isc.org>
Thu, 8 Sep 2022 05:33:31 +0000 (07:33 +0200)
committerOndřej Surý <ondrej@isc.org>
Mon, 19 Sep 2022 13:50:29 +0000 (15:50 +0200)
When Address Sanitizer is enabled in gcc-11+, number of false positives
might appear like this:

    netmgr/udp.c: In function 'isc__nm_udp_send':
    netmgr/udp.c:729:13: warning: 'uv_udp_send' reading 16 bytes from a region of size 8 [-Wstringop-overread]
      729 |         r = uv_udp_send(&uvreq->uv_req.udp_send, &sock->uv_handle.udp,
  |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      730 |                         &uvreq->uvbuf, 1, sa, udp_send_cb);
          |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    netmgr/udp.c:729:13: note: referencing argument 3 of type 'const uv_buf_t[0]'
    In file included from ./include/isc/uv.h:17,
                     from ./include/isc/barrier.h:31,
                     from netmgr/udp.c:17:
    /usr/include/uv.h:711:15: note: in a call to function 'uv_udp_send'
      711 | UV_EXTERN int uv_udp_send(uv_udp_send_t* req,
          |               ^~~~~~~~~~~

Disable the warning globally in the autoconf, instead of just locally in
a single CI job, as it might affect people outside our GitLab CI.

.gitlab-ci.yml
configure.ac

index bdabe4715e2eef4e99708844f5ec46d379782b49..9874ff4ed04e053c5a7f2b0a7ce494720fe25258 100644 (file)
@@ -968,7 +968,7 @@ unit:gcc:jammy:amd64:
 gcc:asan:
   variables:
     CC: gcc
-    CFLAGS: "${CFLAGS_COMMON} -fsanitize=address,undefined -Wno-error=stringop-overread"
+    CFLAGS: "${CFLAGS_COMMON} -fsanitize=address,undefined"
     LDFLAGS: "-fsanitize=address,undefined"
     EXTRA_CONFIGURE: "--with-libidn2 --without-jemalloc"
   <<: *fedora_35_amd64_image
index 786f228c4295dade9e62ed68bb1d37a648ea9a28..903287748b3aa28b208c7dfed8fa2f0af74b3ade 100644 (file)
@@ -119,6 +119,16 @@ STD_CFLAGS="-Wall -Wextra -Wwrite-strings -Wpointer-arith -Wno-missing-field-ini
 # These should be always errors
 STD_CFLAGS="$STD_CFLAGS -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=format-security -Werror=parentheses -Werror=implicit -Werror=strict-prototypes -Werror=vla"
 
+# Disable false positives generated by GCC 11+ and ASAN
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM([[]],
+                  [[#if __GNUC__ >= 11 && defined(__SANITIZE_ADDRESS__)
+                    #error Address Sanitizer enabled
+                    #endif
+                   ]])],
+  [],
+  [STD_CFLAGS="$STD_CFLAGS -Wno-stringop-overread"])
+
 STD_LDFLAGS=""
 
 # ... except in test code