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:
parent
d7c5a6d49b
commit
d6c98626da
Notes:
git
2022-07-07 22:39:49 +09:00
1 changed files with 5 additions and 0 deletions
5
gc.c
5
gc.c
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue