]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix one-definition-rule violation in the tests/ns
authorOndřej Surý <ondrej@isc.org>
Thu, 24 Jul 2025 06:41:38 +0000 (08:41 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 24 Jul 2025 06:46:11 +0000 (08:46 +0200)
Locally, clang reported odr-violation:

    =================================================================
    ==588371==ERROR: AddressSanitizer: odr-violation (0x55555556a060):
      [1] size=256 'client_addrs' ../tests/ns/netmgr_wrap.c:36:18 in /home/ondrej/Projects/bind9/build/tests/ns/query
      [2] size=256 'client_addrs' ../tests/ns/netmgr_wrap.c:36:18 in /home/ondrej/Projects/bind9/build/tests/ns/../libbindtest.so
    These globals were registered at these points:
      [1]:
#0 0x7ffff785306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
#1 0x7ffff6a2a303 in call_init ../csu/libc-start.c:145
#2 0x7ffff6a2a303 in __libc_start_main_impl ../csu/libc-start.c:347
#3 0x55555555a084 in _start (/home/ondrej/Projects/bind9/build/tests/ns/query+0x6084) (BuildId: fbe4a3fcf1a249c7d7da69ee8b255a1dbb610c7a)

      [2]:
#0 0x7ffff785306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
#1 0x7ffff7fca71e in call_init elf/dl-init.c:74
#2 0x7ffff7fca823 in call_init elf/dl-init.c:120
#3 0x7ffff7fca823 in _dl_init elf/dl-init.c:121
#4 0x7ffff7fe459f  (/lib64/ld-linux-x86-64.so.2+0x1f59f) (BuildId: 281ac1521b4102509b1c7ac7004db7c1efb81796)

    ==588371==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
    SUMMARY: AddressSanitizer: odr-violation: global 'client_addrs' at ../tests/ns/netmgr_wrap.c:36:18 in /home/ondrej/Projects/bind9/build/tests/ns/query
    ==588371==ABORTING

Move the client_addrs and client_refs to libtest to prevent this.

tests/libtest/ns.c
tests/ns/netmgr_wrap.c

index 8583f64060f7319480848428083d1e62a2988f9a..587f5be46b413ccbfc71802569ad7f5a9aba73b0 100644 (file)
@@ -55,6 +55,9 @@ dns_dispatchmgr_t *dispatchmgr = NULL;
 ns_interfacemgr_t *interfacemgr = NULL;
 ns_server_t *sctx = NULL;
 
+atomic_uint_fast32_t client_refs[32];
+atomic_uintptr_t client_addrs[32];
+
 static isc_result_t
 matchview(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr,
          dns_message_t *message, dns_aclenv_t *env, ns_server_t *lsctx,
index f32a6c9113da22257e31febb8bd68760f6d03ce4..f2b265c329f3daec3e536cb5ea1f3039693a6988 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <ns/client.h>
 
+#include <tests/ns.h>
+
 #if ISC_NETMGR_TRACE
 #define FLARG                                                                 \
        , const char *func ISC_ATTR_UNUSED, const char *file ISC_ATTR_UNUSED, \
@@ -32,8 +34,6 @@
 /*
  * We don't want to use netmgr-based client accounting, we need to emulate it.
  */
-atomic_uint_fast32_t client_refs[32];
-atomic_uintptr_t client_addrs[32];
 
 #if ISC_NETMGR_TRACE
 void