ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "nobu (Nobuyoshi Nakada)" <noreply@ruby-lang.org>
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:51147] [Ruby master Bug#18497] Fiber内でProcess.daemonをするとSegmentation faultが起こる
Date: Wed, 19 Jan 2022 14:34:25 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-96055.20220119143424.51941@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-18497.20220119081105.51941@ruby-lang.org>

Issue #18497 has been updated by nobu (Nobuyoshi Nakada).


In 2.7 or earlier, commit:bf3b2a43741e or the following patch is also needed.
```diff
diff --git a/cont.c b/cont.c
index 7f971a9e9d5..50403b8258d 100644
--- a/cont.c
+++ b/cont.c
@@ -1930,7 +1930,7 @@ fiber_current(void)
 }
 
 static inline rb_fiber_t*
-return_fiber(void)
+return_fiber(bool terminate)
 {
     rb_fiber_t *fiber = fiber_current();
     rb_fiber_t *prev = fiber->prev;
@@ -1941,7 +1941,7 @@ return_fiber(void)
 
         VM_ASSERT(root_fiber != NULL);
 
-        if (root_fiber == fiber) {
+        if (!terminate && root_fiber == fiber) {
             rb_raise(rb_eFiberError, "can't yield from root fiber");
         }
         return root_fiber;
@@ -2087,7 +2087,7 @@ rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt)
     fiber->cont.machine.stack = NULL;
     fiber->cont.machine.stack_size = 0;
 
-    next_fiber = return_fiber();
+    next_fiber = return_fiber(true);
     if (need_interrupt) RUBY_VM_SET_INTERRUPT(&next_fiber->cont.saved_ec);
     fiber_switch(next_fiber, 1, &value, 0, RB_NO_KEYWORDS);
 }
@@ -2121,13 +2121,13 @@ rb_fiber_resume(VALUE fiber_value, int argc, const VALUE *argv)
 VALUE
 rb_fiber_yield_kw(int argc, const VALUE *argv, int kw_splat)
 {
-    return fiber_switch(return_fiber(), argc, argv, 0, kw_splat);
+    return fiber_switch(return_fiber(false), argc, argv, 0, kw_splat);
 }
 
 VALUE
 rb_fiber_yield(int argc, const VALUE *argv)
 {
-    return fiber_switch(return_fiber(), argc, argv, 0, RB_NO_KEYWORDS);
+    return fiber_switch(return_fiber(false), argc, argv, 0, RB_NO_KEYWORDS);
 }
 
 void
```

----------------------------------------
Bug #18497: Fiber内でProcess.daemonをするとSegmentation faultが起こる
https://bugs.ruby-lang.org/issues/18497#change-96055

* Author: sevenc-nanashi (Nanashi. @sevenc-nanashi)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [aarch64-linux]
* Backport: 2.6: REQUIRED, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED
----------------------------------------
```
ruby -e 'Fiber.new { Process.daemon true, true }.resume'
```

OCIのUbuntu(`ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [aarch64-linux]`)で確認出来ましたが、WSL(`ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]`)では確認出来ませんでした。


---Files--------------------------------
sf.log (17 KB)


-- 
https://bugs.ruby-lang.org/

  reply	other threads:[~2022-01-19 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-19  8:11 [ruby-dev:51146] " sevenc-nanashi (Nanashi. @sevenc-nanashi)
2022-01-19 14:34 ` nobu (Nobuyoshi Nakada) [this message]
2022-01-31 10:22 ` [ruby-dev:51153] " naruse (Yui NARUSE)
2022-03-13  3:12 ` [ruby-dev:51172] " nagachika (Tomoyuki Chikanaga)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-96055.20220119143424.51941@ruby-lang.org \
    --to=noreply@ruby-lang.org \
    --cc=ruby-dev@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).