ruby-changes:72451
From: Peter <ko1@a...>
Date: Thu, 7 Jul 2022 22:39:43 +0900 (JST)
Subject: [ruby-changes:72451] d6c98626da (master): Fix crash in compaction due to unlocked page
https://git.ruby-lang.org/ruby.git/commit/?id=d6c98626da From d6c98626da706fe5399a2a13f4a934c27c8f4c7b Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Wed, 6 Jul 2022 17:04:22 -0400 Subject: Fix crash in compaction due to unlocked page The page of src could be partially compacted, so it may contain T_MOVED. Sweeping a page may read objects on this page, so we need to lock the page. --- gc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gc.c b/gc.c index 29131a8f3a..1ef9cab171 100644 --- a/gc.c +++ b/gc.c @@ -8331,7 +8331,12 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, rb_size_pool_t *size_p https://github.com/ruby/ruby/blob/trunk/gc.c#L8331 .empty_slots = 0, }; + /* The page of src could be partially compacted, so it may contain + * T_MOVED. Sweeping a page may read objects on this page, so we + * need to lock the page. */ + lock_page_body(objspace, GET_PAGE_BODY(src)); gc_sweep_page(objspace, dheap, &ctx); + unlock_page_body(objspace, GET_PAGE_BODY(src)); if (dheap->sweeping_page->free_slots > 0) { heap_add_freepage(dheap, dheap->sweeping_page); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/