https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-02-08T05:53:11ZRuby Issue Tracking SystemBackport193 - Backport #5700: fork {} segfaults during VM cleanup when run inside Fiberhttps://redmine.ruby-lang.org/issues/5700?journal_id=236102012-02-08T05:53:11Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Eric Wong <a href="mailto:normalperson@yhbt.net" class="email">normalperson@yhbt.net</a> wrote:</p>
<blockquote>
<p><a href="http://redmine.ruby-lang.org/issues/5700" class="external">http://redmine.ruby-lang.org/issues/5700</a></p>
</blockquote>
<p>Hello, I would like to see this fixed for the next 1.9.3 release.</p>
<p>I'm pretty sure this is an easy fix for somebody already familiar with<br>
the Fiber/continuation code (unfortunately I am not familiar with it).</p> Backport193 - Backport #5700: fork {} segfaults during VM cleanup when run inside Fiberhttps://redmine.ruby-lang.org/issues/5700?journal_id=236752012-02-10T12:30:14Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>File</strong> <a href="/attachments/2446">bug5700.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/2446/bug5700.patch">bug5700.patch</a> added</li></ul><p>Hmm, it don't seems easy problem for me... Apparently I'm not so familiar with fiber.</p>
<p>Anyway I've written a patch for this issue. I know it's somewhat ad-hoc, but it works.<br>
ko1 and nobu how do you think?</p> Backport193 - Backport #5700: fork {} segfaults during VM cleanup when run inside Fiberhttps://redmine.ruby-lang.org/issues/5700?journal_id=237252012-02-11T12:23:13Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Tomoyuki Chikanaga <a href="mailto:nagachika00@gmail.com" class="email">nagachika00@gmail.com</a> wrote:</p>
<blockquote>
<p>Anyway I've written a patch for this issue. I know it's somewhat ad-hoc, but it works.<br>
ko1 and nobu how do you think?</p>
</blockquote>
<p>Thanks for looking into this. This fix works for me, too :></p> Backport193 - Backport #5700: fork {} segfaults during VM cleanup when run inside Fiberhttps://redmine.ruby-lang.org/issues/5700?journal_id=237262012-02-11T12:59:41Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>One particular case is OK, two cases would be still OK, but three cases are not exceptional already.<br>
We'll need some standard way to tell if a given object can be discarded immediately or not, I guess.</p>
<p>Anyway, it would be enough for the time being.</p> Backport193 - Backport #5700: fork {} segfaults during VM cleanup when run inside Fiberhttps://redmine.ruby-lang.org/issues/5700?journal_id=238172012-02-14T12:44:13Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul></ul><p>I agree. In fact we don't have to protect all Fibers but only a root Fiber of main Thread.</p>
<p>But can I check-in previous patch for a temporary workaround? The next release of 1.9.3 is almost coming.</p> Backport193 - Backport #5700: fork {} segfaults during VM cleanup when run inside Fiberhttps://redmine.ruby-lang.org/issues/5700?journal_id=238942012-02-15T23:05:35Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Backport</i></li><li><strong>Project</strong> changed from <i>Ruby master</i> to <i>Backport193</i></li><li><strong>Category</strong> deleted (<del><i>core</i></del>)</li><li><strong>Target version</strong> deleted (<del><i>2.0.0</i></del>)</li></ul><p>I've committed at r34629, r34630. Please backport them.</p> Backport193 - Backport #5700: fork {} segfaults during VM cleanup when run inside Fiberhttps://redmine.ruby-lang.org/issues/5700?journal_id=239062012-02-16T07:34:51Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r34637.<br>
Eric, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>merge revision(s) 34629,34630:</p>
<pre><code>* cont.c (rb_fiber_reset_root_local_storage): add a new function to
restore rb_thread_t::local_storage.
* cont.c (rb_obj_is_fiber): add a new function to tell finalizer to
prevent fibers from destroy.
* gc.c (rb_objspace_call_finalizer): don't sweep fibers at finalizing
objspace.
* internal.h (rb_fiber_reset_root_local_storage, rb_obj_is_fiber):
add prototypes.
* vm.c (ruby_vm_destruct): reset main thread's local_storage before
free main thread. rb_thread_t::local_storage is replaced by fiber's
local storage when forked from fiber, and it should be already freed
when the fiber was destroyed.
* test/ruby/test_fiber.rb (test_fork_from_fiber): add test for fork
from fiber.
when the fiber was destroyed. <a href="/issues/5700">[ruby-core:41456]</a> [Bug #5700]
</code></pre>