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

ruby-changes:26929

From: nobu <ko1@a...>
Date: Wed, 30 Jan 2013 13:18:09 +0900 (JST)
Subject: [ruby-changes:26929] nobu:r38981 (trunk): cont.c: fiber local svar

nobu	2013-01-30 13:17:59 +0900 (Wed, 30 Jan 2013)

  New Revision: 38981

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

  Log:
    cont.c: fiber local svar
    
    * cont.c (cont_restore_thread): svar should be separate per fibers.
      [ruby-core:51331] [Bug #7678]

  Modified files:
    trunk/ChangeLog
    trunk/cont.c
    trunk/test/ruby/test_fiber.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38980)
+++ ChangeLog	(revision 38981)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jan 30 13:17:53 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* cont.c (cont_restore_thread): svar should be separate per fibers.
+	  [ruby-core:51331] [Bug #7678]
+
 Wed Jan 30 07:15:04 2013  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* re.c (reg_operand): Simplify and reuse error handling [Bug #7539]
Index: cont.c
===================================================================
--- cont.c	(revision 38980)
+++ cont.c	(revision 38981)
@@ -512,6 +512,8 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L512
     th->protect_tag = sth->protect_tag;
     th->errinfo = sth->errinfo;
     th->first_proc = sth->first_proc;
+    th->root_lep = sth->root_lep;
+    th->root_svar = sth->root_svar;
 }
 
 #if FIBER_USE_NATIVE
Index: test/ruby/test_fiber.rb
===================================================================
--- test/ruby/test_fiber.rb	(revision 38980)
+++ test/ruby/test_fiber.rb	(revision 38981)
@@ -317,5 +317,29 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L317
     size_large = invoke_rec script, vm_stack_size, 1024 * 1024 * 10
     assert_operator(size_default, :<=, size_large)
   end
+
+  def test_separate_lastmatch
+    bug7678 = '[ruby-core:51331]'
+    /a/ =~ "a"
+    m1 = $~
+    m2 = nil
+    Fiber.new do
+      /b/ =~ "b"
+      m2 = $~
+    end.resume
+    assert_equal("b", m2[0])
+    assert_equal(m1, $~, bug7678)
+  end
+
+  def test_separate_lastline
+    bug7678 = '[ruby-core:51331]'
+    $_ = s1 = "outer"
+    s2 = nil
+    Fiber.new do
+      s2 = "inner"
+    end.resume
+    assert_equal("inner", s2)
+    assert_equal(s1, $_, bug7678)
+  end
 end
 

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

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