diff options
author | Peter Zhu <[email protected]> | 2024-08-26 10:59:57 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-08-26 13:25:12 -0400 |
commit | 8c01dec8275739f247eedc505723c6585da13c4b (patch) | |
tree | 4cbf6897a2fed494397c125ec975c84d61e2149d /gc/default.c | |
parent | 1cafc9d51d3be36ab34e77b5c8f034b2daba231f (diff) |
Skip assertion in gc/default.c when multi-Ractor
The counter for total allocated objects may not be accurate when there are
multiple Ractors since it is not atomic so there could be race conditions
when it is incremented.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11462
Diffstat (limited to 'gc/default.c')
-rw-r--r-- | gc/default.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gc/default.c b/gc/default.c index 9038df3810..9d0d05c3a1 100644 --- a/gc/default.c +++ b/gc/default.c @@ -2637,8 +2637,9 @@ newobj_alloc(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t si rb_size_pool_t *size_pool = &size_pools[size_pool_idx]; size_pool->total_allocated_objects++; - GC_ASSERT(SIZE_POOL_EDEN_HEAP(size_pool)->total_slots + SIZE_POOL_TOMB_HEAP(size_pool)->total_slots >= - (size_pool->total_allocated_objects - size_pool->total_freed_objects - size_pool->final_slots_count)); + GC_ASSERT(rb_gc_multi_ractor_p() || + SIZE_POOL_EDEN_HEAP(size_pool)->total_slots + SIZE_POOL_TOMB_HEAP(size_pool)->total_slots >= + (size_pool->total_allocated_objects - size_pool->total_freed_objects - size_pool->final_slots_count)); return obj; } |