summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-07-18 15:23:09 +0900
committernagachika <nagachika@ruby-lang.org>2021-07-22 11:47:00 +0900
commita215c6d0448764131cbbb48b476dc698b51c2273 (patch)
tree93492686fdf93e14d7694f543bb872cb37543dbf /internal
parentc4b602e80fdc1824c68602302a4ed82a0e90d5b7 (diff)
partially merge revision(s) 119697f61e2b2b157816a8aa33aada5863959900,4a627dbdfd1165022fa9e716ba845e937b03773d: [Backport #18014]
[Bug #18014] Fix rb_gc_force_recycle unmark before sweep If we force recycle an object before the page is swept, we should clear it in the mark bitmap. If we don't clear it in the bitmap, then during sweeping we won't account for this free slot so the `free_slots` count of the page will be incorrect. --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) [Bug #18014] Fix memory leak in GC when using Ractors When a Ractor is removed, the freelist in the Ractor cache is not returned to the GC, leaving the freelist permanently lost. This commit recycles the freelist when the Ractor is destroyed, preventing a memory leak from occurring. --- gc.c | 116 +++++++++++++++++++++++++++------------------------------- internal/gc.h | 6 +++ ractor.c | 3 ++ ractor_core.h | 5 +-- 4 files changed, 64 insertions(+), 66 deletions(-) Co-authored-by: Peter Zhu <peter@peterzhu.ca>
Diffstat (limited to 'internal')
-rw-r--r--internal/gc.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/gc.h b/internal/gc.h
index a602f0c9b3..d439f6d8f6 100644
--- a/internal/gc.h
+++ b/internal/gc.h
@@ -61,6 +61,11 @@ struct rb_objspace; /* in vm_core.h */
rb_obj_write((VALUE)(a), UNALIGNED_MEMBER_ACCESS((VALUE *)(slot)), \
(VALUE)(b), __FILE__, __LINE__)
+typedef struct ractor_newobj_cache {
+ struct RVALUE *freelist;
+ struct heap_page *using_page;
+} rb_ractor_newobj_cache_t;
+
/* gc.c */
extern VALUE *ruby_initial_gc_stress_ptr;
extern int ruby_disable_gc;
@@ -100,6 +105,7 @@ void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
void ruby_sized_xfree(void *x, size_t size);
+void rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache);
RUBY_SYMBOL_EXPORT_END
MJIT_SYMBOL_EXPORT_BEGIN