From 29707c1d73f35c15d118ea5ca2330e85ac475dd6 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 30 Jan 2013 04:17:59 +0000 Subject: [PATCH] cont.c: fiber local svar * cont.c (cont_restore_thread): svar should be separate per fibers. [ruby-core:51331] [Bug #7678] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ cont.c | 2 ++ test/ruby/test_fiber.rb | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8e2d720dbc..19c75d83aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jan 30 13:17:53 2013 Nobuyoshi Nakada + + * 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 * re.c (reg_operand): Simplify and reuse error handling [Bug #7539] diff --git a/cont.c b/cont.c index 9b43480dd3..2656cbeb2c 100644 --- a/cont.c +++ b/cont.c @@ -512,6 +512,8 @@ cont_restore_thread(rb_context_t *cont) 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 diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index dcf1fca50a..38050386c4 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -317,5 +317,29 @@ class TestFiber < Test::Unit::TestCase 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