[前][次][番号順一覧][スレッド一覧]

ruby-changes:64903

From: Aaron <ko1@a...>
Date: Sat, 16 Jan 2021 08:23:34 +0900 (JST)
Subject: [ruby-changes:64903] 0ed71b37fa (master): Don't try to clear cache on garbage objects

https://git.ruby-lang.org/ruby.git/commit/?id=0ed71b37fa

From 0ed71b37fa9af134fdd5a7fd1cebd171eba83541 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Fri, 15 Jan 2021 14:14:43 -0800
Subject: 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@h...>
Co-Authored-By: Alan Wu <XrXr@u...>

diff --git a/vm_method.c b/vm_method.c
index 287d4ae..81920bb 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -151,6 +151,7 @@ static void https://github.com/ruby/ruby/blob/trunk/vm_method.c#L151
 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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]