Merge pull request #2667 from lightpanda-io/arena_pool_debug_cleanup

Improve ArenaPool release debug reporting
This commit is contained in:
Karl Seguin authored and GitHub committed 2026-06-08 17:32:52 +08:00
commit 4fc0ba7dcb
1 file changed
+7 -6
+7 -6
View File
@@ -171,13 +171,9 @@ pub fn release(self: *ArenaPool, allocator: Allocator) void {
const entry: *Entry = @fieldParentPtr("arena", arena);
const bucket = entry.bucket;
// Reset the arena before acquiring the lock to minimize lock hold time
_ = arena.reset(.{ .retain_with_limit = bucket.retain_bytes });
self.mutex.lock();
defer self.mutex.unlock();
if (IS_DEBUG) {
self.mutex.lock();
defer self.mutex.unlock();
if (self._leak_track.getPtr(entry.debug)) |count| {
count.* -= 1;
if (count.* < 0) {
@@ -190,6 +186,11 @@ pub fn release(self: *ArenaPool, allocator: Allocator) void {
}
}
_ = arena.reset(.{ .retain_with_limit = bucket.retain_bytes });
self.mutex.lock();
defer self.mutex.unlock();
if ((comptime SAFETY) or bucket.free_list_len >= bucket.free_list_max) {
// In Debug, we never pool. It can mask UAF bugs.
arena.deinit();