2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 10:10:06 +00:00

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.
This commit is contained in:
Ondřej Surý 2025-07-24 08:41:38 +02:00
parent bdf7a44442
commit 815c47f800
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41
2 changed files with 5 additions and 2 deletions

View File

@ -55,6 +55,9 @@ dns_dispatchmgr_t *dispatchmgr = NULL;
ns_interfacemgr_t *interfacemgr = NULL; ns_interfacemgr_t *interfacemgr = NULL;
ns_server_t *sctx = NULL; ns_server_t *sctx = NULL;
atomic_uint_fast32_t client_refs[32];
atomic_uintptr_t client_addrs[32];
static isc_result_t static isc_result_t
matchview(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr, matchview(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr,
dns_message_t *message, dns_aclenv_t *env, ns_server_t *lsctx, dns_message_t *message, dns_aclenv_t *env, ns_server_t *lsctx,

View File

@ -21,6 +21,8 @@
#include <ns/client.h> #include <ns/client.h>
#include <tests/ns.h>
#if ISC_NETMGR_TRACE #if ISC_NETMGR_TRACE
#define FLARG \ #define FLARG \
, const char *func ISC_ATTR_UNUSED, const char *file ISC_ATTR_UNUSED, \ , 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. * 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 #if ISC_NETMGR_TRACE
void void