NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/59982: named assertion failure when doing zone transfer
The following reply was made to PR bin/59982; it has been noted by GNATS.
From: Showta Ishizaki <zakinko%snowrabbit.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: zakinko%snowrabbit.org@localhost
Subject: Re: bin/59982: named assertion failure when doing zone transfer
Date: Sat, 14 Nov 2026 16:51:08 +0900 (JST)
A friend's NetBSD 11.1/i386 secondary hit this too, at the start of
the first zone transfer after named came up:
zone.c:18055: INSIST(((({ ... uint64_t x = (zone)->flags; ... x; })
& (DNS_ZONEFLG_REFRESH)) != 0)) failed
On _ILP32 the zone flags are kept in a plain uint64_t under
zone->atomic_lock, and ISC_ZONE_SET() and ISC_ZONE_CLR() compute the
new value but never store it back:
uint64_t x = ((z)->f | (o));
So DNS_ZONE_SETFLAG(), DNS_ZONE_SETOPTION() and the others do nothing
on 32-bit ports. zone_refresh() sets DNS_ZONEFLG_REFRESH, the flag is
still clear when the transfer finishes, and zone_xfrdone() trips the
INSIST. DNS_ZONEFLG_NEEDNOTIFY is never set either, which looks like
bin/60833. ISC_QP_ADD() in qp.c has the same shape, so the qp-trie
timing counters stay at zero.
The diff below stores the result and returns the old value, the same
as atomic_fetch_or()/atomic_fetch_and(). It applies to -current and to
netbsd-11.
I tested it under qemu on NetBSD 11.0/i386, 11.1/i386 and
11.1/evbarm-earmv7hf, with a primary and a secondary named on one
machine. On all three the stock named crashes on the first transfer
and its primary sends no NOTIFY, and the same libdns rebuilt from
source without the diff behaves the same way. With only libdns
replaced by a patched build, the transfer completes, NOTIFY from the
primary reaches the secondary, and the secondary fetches the new
serial. I have no m68k machine to try it on, but the code is not
machine dependent.
Index: external/mpl/bind/dist/lib/dns/qp.c
--- external/mpl/bind/dist/lib/dns/qp.c
+++ external/mpl/bind/dist/lib/dns/qp.c
@@ -77,7 +77,8 @@ static isc_mutex_t qp_mutex = PTHREAD_MUTEX_INITIALIZER;
#define ISC_QP_ADD(v, a) \
({ \
isc_mutex_lock(&qp_mutex); \
- uint64_t x = (v) + (a); \
+ uint64_t x = (v); \
+ (v) = x + (a); \
isc_mutex_unlock(&qp_mutex); \
x; \
})
Index: external/mpl/bind/dist/lib/dns/zone.c
--- external/mpl/bind/dist/lib/dns/zone.c
+++ external/mpl/bind/dist/lib/dns/zone.c
@@ -543,14 +543,16 @@ struct dns_zone {
#define ISC_ZONE_SET(z, f, o) \
({ \
isc_mutex_lock(&(z)->atomic_lock); \
- uint64_t x = ((z)->f | (o)); \
+ uint64_t x = (z)->f; \
+ (z)->f = x | (o); \
isc_mutex_unlock(&(z)->atomic_lock); \
x; \
})
#define ISC_ZONE_CLR(z, f, o) \
({ \
isc_mutex_lock(&(z)->atomic_lock); \
- uint64_t x = ((z)->f & ~(o)); \
+ uint64_t x = (z)->f; \
+ (z)->f = x & ~(o); \
isc_mutex_unlock(&(z)->atomic_lock); \
x; \
})
Home |
Main Index |
Thread Index |
Old Index