1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Peter Zhu 2022-07-06 17:04:22 -04:00
parent d7c5a6d49b
commit d6c98626da
Notes: git 2022-07-07 22:39:49 +09:00

5
gc.c
View file

@ -8331,7 +8331,12 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, rb_size_pool_t *size_p
.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);