Skip to content

Commit

Permalink
Fix crash when clearing method cache for builtin method
Browse files Browse the repository at this point in the history
Builtin methods do not always have their mandatory_only_cme created (it
is only created when called with only mandatory parameters), so it could
be null. If we try to clear the cme, it will crash because it is null.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
  • Loading branch information
peterzhu2118 and tenderlove committed Nov 17, 2021
1 parent b95d7d2 commit c400165
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vm_method.c
Expand Up @@ -209,7 +209,7 @@ clear_method_cache_by_id_in_class(VALUE klass, ID mid)
vm_cme_invalidate((rb_callable_method_entry_t *)cme);
RB_DEBUG_COUNTER_INC(cc_invalidate_tree_cme);

if (cme->def->iseq_overload) {
if (cme->def->iseq_overload && cme->def->body.iseq.mandatory_only_cme) {
vm_cme_invalidate((rb_callable_method_entry_t *)cme->def->body.iseq.mandatory_only_cme);
}
}
Expand Down

0 comments on commit c400165

Please sign in to comment.