[ruby-dev:31819] rb_clear_cache_by_class

From: Tanaka Akira <akr@...>
Date: 2007-09-22 17:10:48 UTC
List: ruby-dev #31819
以下の表明は正しいでしょうか?

つまり、rb_clear_cache_by_class において ent->method が 0 で
ないとき、それは T_NONE ではないはずでしょうか。

Index: eval_method.ci
===================================================================
--- eval_method.ci	(revision 13485)
+++ eval_method.ci	(working copy)
@@ -72,6 +72,7 @@
     }
 }
 
+#include <assert.h>
 void
 rb_clear_cache_by_class(VALUE klass)
 {
@@ -84,6 +85,7 @@
     ent = cache;
     end = ent + CACHE_SIZE;
     while (ent < end) {
+        if (ent->method) assert(TYPE(ent->method) != T_NONE);
 	if ((ent->klass == klass) ||
 	    (ent->method && ent->method->nd_clss == klass)) {
 	    ent->mid = 0;

以下のようにすれば、その表明を失敗させることができます。

% ./ruby -ve '
3.times {
  o = Object.new
  def o.a() end
  o.a
  GC.start
}
'
ruby 1.9.0 (2007-09-22 patchlevel 0) [i686-linux]
ruby: eval_method.ci:88: rb_clear_cache_by_class: Assertion `rb_type((VALUE)(ent->method)) != RUBY_T_NONE' failed.
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next