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

ruby-changes:27227

From: ktsj <ko1@a...>
Date: Sat, 16 Feb 2013 20:45:39 +0900 (JST)
Subject: [ruby-changes:27227] ktsj:r39279 (ruby_2_0_0): * backport r39276 from trunk. [Bug #7825]

ktsj	2013-02-16 20:45:27 +0900 (Sat, 16 Feb 2013)

  New Revision: 39279

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39279

  Log:
    * backport r39276 from trunk. [ruby-dev:46997] [Bug #7825]
    
    * vm.c (rb_thread_mark): mark a working Proc of bmethod
      (a method defined by define_method) even if the method was removed.
      We could not trace working Proc object which represents the body
      of bmethod if the method was removed (alias/undef/overridden).
      Simply, it was mark miss.
      This patch by Kazuki Tsujimoto. [Bug #7825]
    
      NOTE: We can brush up this marking because we do not need to mark
      `me' on each living control frame. We need to mark `me's
      only if `me' was free'ed. This is future work after Ruby 2.0.0.
    
    * test/ruby/test_method.rb: add a test.

  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/test/ruby/test_method.rb
    branches/ruby_2_0_0/vm.c

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 39278)
+++ ruby_2_0_0/ChangeLog	(revision 39279)
@@ -1,3 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Feb 16 20:43:43 2013  Koichi Sasada  <ko1@a...>
+
+	* backport r39276 from trunk. [ruby-dev:46997] [Bug #7825]
+
+	* vm.c (rb_thread_mark): mark a working Proc of bmethod
+	  (a method defined by define_method) even if the method was removed.
+	  We could not trace working Proc object which represents the body
+	  of bmethod if the method was removed (alias/undef/overridden).
+	  Simply, it was mark miss.
+	  This patch by Kazuki Tsujimoto. [Bug #7825]
+
+	  NOTE: We can brush up this marking because we do not need to mark
+	  `me' on each living control frame. We need to mark `me's
+	  only if `me' was free'ed. This is future work after Ruby 2.0.0.
+
+	* test/ruby/test_method.rb: add a test.
+
 Fri Feb 15 00:49:32 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/net/http.rb:  Removed OpenSSL dependency from Net::HTTP.
Index: ruby_2_0_0/vm.c
===================================================================
--- ruby_2_0_0/vm.c	(revision 39278)
+++ ruby_2_0_0/vm.c	(revision 39279)
@@ -1782,7 +1782,11 @@ rb_thread_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm.c#L1782
 		if (iseq) {
 		    rb_gc_mark(RUBY_VM_NORMAL_ISEQ_P(iseq) ? iseq->self : (VALUE)iseq);
 		}
-		if (cfp->me) ((rb_method_entry_t *)cfp->me)->mark = 1;
+		if (cfp->me) {
+		    /* TODO: marking `me' can be more sophisticated way */
+		    ((rb_method_entry_t *)cfp->me)->mark = 1;
+		    rb_mark_method_entry(cfp->me);
+		}
 		cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
 	    }
 	}
Index: ruby_2_0_0/test/ruby/test_method.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_method.rb	(revision 39278)
+++ ruby_2_0_0/test/ruby/test_method.rb	(revision 39279)
@@ -522,4 +522,18 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_method.rb#L522
     assert_equal(x.singleton_class, x.method(:bar).owner)
     assert(x.method(:foo) != x.method(:bar), bug7613)
   end
+
+  def test_gced_bmethod
+    assert_normal_exit %q{
+      require 'irb'
+      IRB::Irb.module_eval do
+        define_method(:eval_input) do
+          IRB::Irb.module_eval { alias_method :eval_input, :to_s }
+          GC.start
+          Kernel
+        end
+      end
+      IRB.start
+    }, '[Bug #7825]'
+  end
 end

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

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