2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Assert if statistics counter underflows in the developer mode

There are reported occurences where the statitic counters underflows and
starts reporting non-sense.

Add a check for the underflow, when ``named`` is compiled in the
developer mode.
This commit is contained in:
Ondřej Surý 2022-01-17 12:39:56 +01:00 committed by Petr Špaček
parent 89935864e9
commit 0893b5fb79
No known key found for this signature in database
GPG Key ID: ABD587CDF06581AE
2 changed files with 5 additions and 1 deletions

View File

@ -148,7 +148,7 @@ AC_ARG_ENABLE([developer],
AS_IF([test "$enable_developer" = "yes"], AS_IF([test "$enable_developer" = "yes"],
[DEVELOPER_MODE=yes [DEVELOPER_MODE=yes
STD_CPPFLAGS="$STD_CPPFLAGS -DISC_MEM_DEFAULTFILL=1 -DISC_MEM_TRACKLINES=1 -DISC_LIST_CHECKINIT=1" STD_CPPFLAGS="$STD_CPPFLAGS -DISC_MEM_DEFAULTFILL=1 -DISC_MEM_TRACKLINES=1 -DISC_LIST_CHECKINIT=1 -DISC_STATS_CHECKUNDERFLOW=1"
test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
test "${enable_querytrace+set}" = set || enable_querytrace=yes test "${enable_querytrace+set}" = set || enable_querytrace=yes
test "${with_cmocka+set}" = set || with_cmocka=yes test "${with_cmocka+set}" = set || with_cmocka=yes

View File

@ -114,7 +114,11 @@ void
isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) { isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) {
REQUIRE(ISC_STATS_VALID(stats)); REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters); REQUIRE(counter < stats->ncounters);
#if ISC_STATS_CHECKUNDERFLOW
REQUIRE(atomic_fetch_sub_release(&stats->counters[counter], 1) > 0);
#else
atomic_fetch_sub_release(&stats->counters[counter], 1); atomic_fetch_sub_release(&stats->counters[counter], 1);
#endif
} }
void void