Skip to content

Commit

Permalink
check liveness of cc->klass and cc->cme_
Browse files Browse the repository at this point in the history
`cc->klass` and `cc->cme_` can be free'ed while last marking
so that it should be checked bofore updating the pointers.
  • Loading branch information
ko1 committed Jul 29, 2023
1 parent b0f44cf commit b09dabe
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10128,17 +10128,14 @@ gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
case imemo_callcache:
{
const struct rb_callcache *cc = (const struct rb_callcache *)obj;
if (cc->klass) {

if (!is_live_object(objspace, cc->klass) ||
!is_live_object(objspace, (VALUE)cc->cme_)) {
vm_cc_invalidate(cc);
}
else {
UPDATE_IF_MOVED(objspace, cc->klass);
if (!is_live_object(objspace, cc->klass)) {
vm_cc_invalidate(cc);
}
else if (cc->cme_) { // cc->cme_ is available if cc->klass is given
TYPED_UPDATE_IF_MOVED(objspace, struct rb_callable_method_entry_struct *, cc->cme_);
if (!is_live_object(objspace, (VALUE)cc->cme_)) {
vm_cc_invalidate(cc);
}
}
TYPED_UPDATE_IF_MOVED(objspace, struct rb_callable_method_entry_struct *, cc->cme_);
}
}
break;
Expand Down

0 comments on commit b09dabe

Please sign in to comment.