From 0a30558921ee9a0da26697cc1896c0de9d340cca Mon Sep 17 00:00:00 2001 From: beer-1 Date: Fri, 1 Nov 2024 16:14:09 +0900 Subject: [PATCH] add debug assert to sure no case to call get_size recursively --- crates/storage/src/allocator.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/storage/src/allocator.rs b/crates/storage/src/allocator.rs index 230dd39b..385d67a7 100644 --- a/crates/storage/src/allocator.rs +++ b/crates/storage/src/allocator.rs @@ -31,12 +31,14 @@ static GLOBAL: SizeCounterAllocator = SizeCounterAllocator; #[inline] fn start_metering() { + debug_assert!(!METERING.with(|metering| metering.get())); SIZE.with(|size| size.set(0)); METERING.with(|metering| metering.set(true)); } #[inline] fn finish_metering() -> usize { + debug_assert!(METERING.with(|metering| metering.get())); METERING.with(|metering| metering.set(false)); SIZE.with(|size| size.get()) }