From: Ondřej Surý Date: Thu, 24 Jul 2025 06:41:38 +0000 (+0200) Subject: Fix one-definition-rule violation in the tests/ns X-Git-Tag: v9.21.11~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=815c47f80034cdf692ed7679a1c3a4abd8f87a31;p=thirdparty%2Fbind9.git Fix one-definition-rule violation in the tests/ns 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. --- diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index 8583f64060f..587f5be46b4 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -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, diff --git a/tests/ns/netmgr_wrap.c b/tests/ns/netmgr_wrap.c index f32a6c9113d..f2b265c329f 100644 --- a/tests/ns/netmgr_wrap.c +++ b/tests/ns/netmgr_wrap.c @@ -21,6 +21,8 @@ #include +#include + #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