diff --git a/configure.ac b/configure.ac index 08866a0101..9138636ddd 100644 --- a/configure.ac +++ b/configure.ac @@ -148,7 +148,7 @@ AC_ARG_ENABLE([developer], AS_IF([test "$enable_developer" = "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_querytrace+set}" = set || enable_querytrace=yes test "${with_cmocka+set}" = set || with_cmocka=yes diff --git a/lib/isc/stats.c b/lib/isc/stats.c index 3e4676c2ac..756733ed51 100644 --- a/lib/isc/stats.c +++ b/lib/isc/stats.c @@ -114,7 +114,11 @@ void isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) { REQUIRE(ISC_STATS_VALID(stats)); 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); +#endif } void