From 007d88790a99fabcca951b58fec3e7f47ebb3182 Mon Sep 17 00:00:00 2001 From: Michael Constant Date: Thu, 7 Nov 2024 22:47:34 -0800 Subject: [PATCH] Don't count the region tracker page when checking for leaks We never shrink the region tracker page, so it'll show up as a leak any time it grows larger than its initial size. This isn't a useful leak to report, so just ignore it --- fuzz/fuzz_targets/fuzz_redb.rs | 4 ++-- src/transactions.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_redb.rs b/fuzz/fuzz_targets/fuzz_redb.rs index 2beff1ec..599784d0 100644 --- a/fuzz/fuzz_targets/fuzz_redb.rs +++ b/fuzz/fuzz_targets/fuzz_redb.rs @@ -527,7 +527,7 @@ fn exec_table_crash_support(config: &FuzzConfig, apply: fn(WriteTransa txn.commit().unwrap(); db.begin_write().unwrap().commit().unwrap(); let txn = db.begin_write().unwrap(); - let baseline_allocated_pages = txn.stats().unwrap().allocated_pages(); + let baseline_allocated_pages = txn.stats().unwrap().allocated_pages() - txn.num_region_tracker_pages(); txn.abort().unwrap(); countdown.store(old_countdown, Ordering::SeqCst); @@ -686,7 +686,7 @@ fn exec_table_crash_support(config: &FuzzConfig, apply: fn(WriteTransa } let txn = db.begin_write().unwrap(); - let allocated_pages = txn.stats().unwrap().allocated_pages(); + let allocated_pages = txn.stats().unwrap().allocated_pages() - txn.num_region_tracker_pages(); txn.abort().unwrap(); assert_eq!(allocated_pages, baseline_allocated_pages, "Found {} allocated pages at shutdown, expected {}", allocated_pages, baseline_allocated_pages); diff --git a/src/transactions.rs b/src/transactions.rs index e290ef18..732cbfc1 100644 --- a/src/transactions.rs +++ b/src/transactions.rs @@ -1320,6 +1320,11 @@ impl WriteTransaction { }) } + #[cfg(any(test, fuzzing))] + pub fn num_region_tracker_pages(&self) -> u64 { + 1 << self.mem.tracker_page().page_order + } + #[allow(dead_code)] pub(crate) fn print_debug(&self) -> Result { // Flush any pending updates to make sure we get the latest root