From fa1f6abe784f37fcd10524abfe88b6ff95b59a91 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Wed, 9 Apr 2025 16:18:23 -0400 Subject: [PATCH] Don't atomically subtract zero from `remote_free_count` --- base/runtime/heap_allocator_implementation.odin | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/runtime/heap_allocator_implementation.odin b/base/runtime/heap_allocator_implementation.odin index 0c6ea2d26..76013ba4f 100644 --- a/base/runtime/heap_allocator_implementation.odin +++ b/base/runtime/heap_allocator_implementation.odin @@ -1502,7 +1502,9 @@ heap_alloc :: proc "contextless" (size: int, zero_memory: bool = true) -> (ptr: assert_contextless(cache.next_cache_block != nil) cache = cache.next_cache_block } - intrinsics.atomic_sub_explicit(&local_heap_cache.remote_free_count, removed, .Release) + if removed > 0 { + intrinsics.atomic_sub_explicit(&local_heap_cache.remote_free_count, removed, .Release) + } heap_debug_cover(.Alloc_Collected_Remote_Frees) }