Skip to content

Commit

Permalink
need more lock in finalize_list()
Browse files Browse the repository at this point in the history
Some data should be accessed in parallel so they should be protected
by the lock.
  • Loading branch information
ko1 committed Dec 7, 2020
1 parent 556a728 commit 1ba05f5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2735,6 +2735,7 @@ make_io_zombie(rb_objspace_t *objspace, VALUE obj)
static void
obj_free_object_id(rb_objspace_t *objspace, VALUE obj)
{
ASSERT_vm_locking();
st_data_t o = (st_data_t)obj, id;

GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID));
Expand Down Expand Up @@ -3672,17 +3673,17 @@ finalize_list(rb_objspace_t *objspace, VALUE zombie)

run_final(objspace, zombie);

GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE);
if (FL_TEST(zombie, FL_SEEN_OBJ_ID)) {
obj_free_object_id(objspace, zombie);
}

RZOMBIE(zombie)->basic.flags = 0;
GC_ASSERT(heap_pages_final_slots > 0);
GC_ASSERT(page->final_slots > 0);

RB_VM_LOCK_ENTER();
{
GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE);
if (FL_TEST(zombie, FL_SEEN_OBJ_ID)) {
obj_free_object_id(objspace, zombie);
}

RZOMBIE(zombie)->basic.flags = 0;
GC_ASSERT(heap_pages_final_slots > 0);
GC_ASSERT(page->final_slots > 0);

heap_pages_final_slots--;
page->final_slots--;
page->free_slots++;
Expand Down

0 comments on commit 1ba05f5

Please sign in to comment.