diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2021-02-01 23:06:33 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2021-02-01 23:06:33 +0900 |
commit | 138f0ba6da2a1ecf80729be3065310c5c0cfdb9a (patch) | |
tree | d865a342d21d4158fec0b208367bdc5cc8871aa1 /vm_method.c | |
parent | 74f90b46a9f21e8ef6e01bebad9dc00f420f8cec (diff) |
merge revision(s) 0ed71b37fa9af134fdd5a7fd1cebd171eba83541: [Backport #17536]
Don't try to clear cache on garbage objects
Method cache can be cleared during lazy sweeping. An object that will
be collected during lazy sweep *should not* have it's method cache
cleared. Soon-to-be-collected objects can be in an inconsistent state and
this can lead to a crash. This patch just leaves early if the object is
going to be collected.
Fixes [Bug #17536]
Co-Authored-By: John Hawthorn <john@hawthorn.email>
Co-Authored-By: Alan Wu <XrXr@users.noreply.github.com>
---
vm_method.c | 1 +
1 file changed, 1 insertion(+)
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/vm_method.c b/vm_method.c index 2177d00b73..e77f0a9678 100644 --- a/vm_method.c +++ b/vm_method.c @@ -136,6 +136,7 @@ static void clear_method_cache_by_id_in_class(VALUE klass, ID mid) { VM_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_ICLASS)); + if (rb_objspace_garbage_object_p(klass)) return; if (LIKELY(RCLASS_EXT(klass)->subclasses == NULL)) { // no subclasses |