Skip to content

Commit

Permalink
Marshal is calling functions that should pin things
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 28, 2019
1 parent 6e0b40a commit aec16b7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gc.c
Expand Up @@ -4710,7 +4710,7 @@ static int
mark_key(st_data_t key, st_data_t value, st_data_t data)
{
rb_objspace_t *objspace = (rb_objspace_t *)data;
gc_mark(objspace, (VALUE)key);
gc_mark_and_pin(objspace, (VALUE)key);
return ST_CONTINUE;
}

Expand Down Expand Up @@ -4744,6 +4744,16 @@ mark_keyvalue(st_data_t key, st_data_t value, st_data_t data)
return ST_CONTINUE;
}

static int
pin_key_pin_value(st_data_t key, st_data_t value, st_data_t data)
{
rb_objspace_t *objspace = (rb_objspace_t *)data;

gc_mark_and_pin(objspace, (VALUE)key);
gc_mark_and_pin(objspace, (VALUE)value);
return ST_CONTINUE;
}

static int
pin_key_mark_value(st_data_t key, st_data_t value, st_data_t data)
{
Expand Down Expand Up @@ -4779,7 +4789,7 @@ static void
mark_st(rb_objspace_t *objspace, st_table *tbl)
{
if (!tbl) return;
st_foreach(tbl, mark_keyvalue, (st_data_t)objspace);
st_foreach(tbl, pin_key_pin_value, (st_data_t)objspace);
}

void
Expand Down

0 comments on commit aec16b7

Please sign in to comment.