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

ruby-changes:71674

From: NAKAMURA <ko1@a...>
Date: Thu, 7 Apr 2022 22:52:54 +0900 (JST)
Subject: [ruby-changes:71674] 81f5453bd8 (ruby_2_7): merge revision(s) 5c7af72304d0ad33cd3f21b24a4bc44e8acd5b2c,d650b17686d49c2ce8e6a87039861154e93d4621: [Backport #18497]

https://git.ruby-lang.org/ruby.git/commit/?id=81f5453bd8

From 81f5453bd831e6f09e660fdf7e72d3d2da8753e7 Mon Sep 17 00:00:00 2001
From: NAKAMURA Usaku <usa@r...>
Date: Sat, 19 Mar 2022 22:23:08 +0900
Subject: merge revision(s)
 5c7af72304d0ad33cd3f21b24a4bc44e8acd5b2c,d650b17686d49c2ce8e6a87039861154e93d4621:
 [Backport #18497]

    Assuming EXIT_SUCCESS equals 0 is not portable

    ---
     test/ruby/test_fiber.rb | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)

    `rb_fiber_terminate` must not return [Bug #18497]

    In a forked process from a fiber, the fiber becomes the only
    fiber, `fiber_switch` does nothing as there is no other fibers,
    `rb_fiber_terminate` does not terminate the fiber.  In that case,
    reaches the end of `fiber_entry` finaly, which is declared as
    "COROUTINE" and should never return.
    ---
     cont.c                     |  3 ++-
     eval_intern.h              |  2 +-
     test/fiber/test_process.rb | 15 +++++++++++++++
     test/ruby/test_fiber.rb    |  5 +++++
     4 files changed, 23 insertions(+), 2 deletions(-)

    note that only backported a part of above patch because of incompatibility
    of ruby_2_7.
---
 cont.c                  | 3 ++-
 test/ruby/test_fiber.rb | 6 +++---
 version.h               | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/cont.c b/cont.c
index 7f971a9e9d..f1edd82bf0 100644
--- a/cont.c
+++ b/cont.c
@@ -1796,7 +1796,7 @@ rb_fiber_new(rb_block_call_func_t func, VALUE obj) https://github.com/ruby/ruby/blob/trunk/cont.c#L1796
     return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), &shared_fiber_pool);
 }
 
-static void rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt);
+NORETURN(static void rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt));
 
 #define PASS_KW_SPLAT (rb_empty_keyword_given_p() ? RB_PASS_EMPTY_KEYWORDS : rb_keyword_given_p())
 
@@ -2090,6 +2090,7 @@ rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt) https://github.com/ruby/ruby/blob/trunk/cont.c#L2090
     next_fiber = return_fiber();
     if (need_interrupt) RUBY_VM_SET_INTERRUPT(&next_fiber->cont.saved_ec);
     fiber_switch(next_fiber, 1, &value, 0, RB_NO_KEYWORDS);
+    ruby_stop(0);
 }
 
 VALUE
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index a7ed9ac7e0..20436eca69 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -318,7 +318,7 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L318
                 Fiber.new {}.transfer
                 Fiber.new { Fiber.yield }
               end
-              exit!(0)
+              exit!(true)
             end
           }.transfer
           _, status = Process.waitpid2(xpid)
@@ -327,8 +327,8 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L327
       end.resume
     end
     pid, status = Process.waitpid2(pid)
-    assert_equal(0, status.exitstatus, bug5700)
-    assert_equal(false, status.signaled?, bug5700)
+    assert_not_predicate(status, :signaled?, bug5700)
+    assert_predicate(status, :success?, bug5700)
   end
 
   def test_exit_in_fiber
diff --git a/version.h b/version.h
index f423165c28..73658c6ec7 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 6
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 212
+#define RUBY_PATCHLEVEL 213
 
 #define RUBY_RELEASE_YEAR 2022
 #define RUBY_RELEASE_MONTH 3
-- 
cgit v1.2.1


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

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