https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112018-11-30T20:36:58ZRuby Issue Tracking SystemRuby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753162018-11-30T20:36:58Zalanwu (Alan Wu)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/75316/diff?detail_id=50463">diff</a>)</li></ul> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753182018-11-30T22:47:30Zaselder (Andrew Selder)aselder@mac.com
<ul></ul><p>Alan,</p>
<p>You're amazing... We're completely blocked on upgrading by this bug. You're a savior</p>
<p>Thanks,</p>
<p>Andrew</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753212018-12-01T03:21:18Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul><li><strong>Assignee</strong> set to <i>ioquatix (Samuel Williams)</i></li><li><strong>Target version</strong> set to <i>2.6</i></li><li><strong>Backport</strong> changed from <i>2.4: UNKNOWN, 2.5: UNKNOWN</i> to <i>2.5: REQUIRED</i></li></ul><p>I will take look at it.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753222018-12-01T03:51:07Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>I looked at the patch it seemed okay.</p>
<p>I committed it to trunk r66111</p>
<p>Once we've confirmed it solves the issue, I will backport 2.5 branch, hopefully it can be included 2.5.4 or next patch release.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753232018-12-01T04:57:19Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>After I merged this patch, <a href="https://travis-ci.org/ruby/ruby/jobs/462071967" class="external">https://travis-ci.org/ruby/ruby/jobs/462071967</a> fails. I am testing locally in more detail.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753242018-12-01T05:01:14Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>Okay, it was random failure. That concerns me too. But, it passed now. I'll merge to ruby_2_5 too.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753252018-12-01T05:12:44Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p><a href="mailto:samuel@oriontransfer.net" class="email">samuel@oriontransfer.net</a> wrote:</p>
<blockquote>
<p>After I merged this patch,<br>
<a href="https://travis-ci.org/ruby/ruby/jobs/462071967" class="external">https://travis-ci.org/ruby/ruby/jobs/462071967</a> fails. I am<br>
testing locally in more detail.</p>
</blockquote>
<p>Alan + Sam: thanks for investigating this.</p>
<p>Perhaps an alternative fix would be to avoid calling<br>
rb_gc_mark_machine_stack() if the owner thread is dead.</p>
<p>I couldn't reproduce the original problem on FreeBSD 11.2<br>
with both FIBER_USE_NATIVE and FIBER_USE_COROUTINE disabled;<br>
so I can't verify my hypothesis<br>
(Didn't bother testing on Linux)</p>
<blockquote>
<p><a href="https://bugs.ruby-lang.org/issues/15362#change-75323" class="external">https://bugs.ruby-lang.org/issues/15362#change-75323</a></p>
</blockquote> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753262018-12-01T05:26:56Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/724">@normalperson (Eric Wong)</a> I am open to ideas. I don't know a lot about how thread and GC interact within Ruby, unfortunately it's not an area I spent much time on. So, if you have better proposal, I suggest you implement it. This change included a spec, so I was happy to merge it even thought I didn't fully understand what is going wrong. Confirmed green build matrix so I am happy to close. If you want to make a change, let me know, otherwise I will close this and it would be backported to 2.5.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753272018-12-01T06:05:30Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/724">@normalperson (Eric Wong)</a> I thought about it a bit more, perhaps both ideas should be implemented for maximum protection. We could add some notes in the source code too about the issue/invariants.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753282018-12-01T06:42:41Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p><a href="mailto:samuel@oriontransfer.net" class="email">samuel@oriontransfer.net</a> wrote:</p>
<blockquote>
<p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/724">@normalperson (Eric Wong)</a> I thought about it a bit more, perhaps both<br>
ideas should be implemented for maximum protection. We could<br>
add some notes in the source code too about the<br>
issue/invariants.</p>
</blockquote>
<p>NAK. I'm against belt-and-suspenders fixes because it favors<br>
lack-of-understanding and makes Ruby slower with more overhead.</p>
<p>Looking at Alan's original fix (which you committed), it seems<br>
to make sense. Anyways, my hypothesis is here:</p>
<p><a href="https://80x24.org/spew/20181201063852.30438-1-e@80x24.org/raw" class="external">https://80x24.org/spew/20181201063852.30438-1-e@80x24.org/raw</a></p>
<p>It may allow Alan's simple one-line fix to be reverted.<br>
However, I prefer Alan's one-liner fix since it's smaller<br>
with instructions with no extra branches.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753292018-12-01T06:50:58Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Okay, I think we are in agreement then.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=753382018-12-01T17:16:31Zalanwu (Alan Wu)
<ul></ul><p>A comment for future maintainers:<br>
Since <code>&fib->cont.saved_ec == ruby_current_execution_context_ptr</code> in the place my patch makes the change, if GC starts below where I set <code>stack_end</code> to NULL, the stack doesn't get marked.<br>
This is not a problem right now since there is no call to any function that could trigger GC (correct me if I'm wrong), but future changes should be careful to not introduce such calls.<br>
I wish there was some way to codify this constraint and have the compiler statically check this for us.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=756872018-12-14T21:32:45Zdazuma (Daniel Azuma)dazuma@gmail.com
<ul></ul><p>Did this get backported to ruby_2_5? I don't see a corresponding commit in the github mirror <a href="https://github.com/ruby/ruby/commits/ruby_2_5" class="external">https://github.com/ruby/ruby/commits/ruby_2_5</a></p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=760252018-12-31T19:30:11Zaselder (Andrew Selder)aselder@mac.com
<ul></ul><p>This still looks like it's waiting on a backport to Ruby 2.5. Also, does anyone know when the next release of the Ruby 2.5 branch will be done?</p>
<p>Thanks!</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=761862019-01-10T07:26:38Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Has duplicate</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/14561">Bug #14561</a>: Consistent 2.5.0 seg fault in GC, related to accessing an enumerator in a thread</i> added</li></ul> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=762182019-01-10T14:18:48Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.5: REQUIRED</i> to <i>2.5: DONE</i></li></ul><p>ruby_2_5 r66777 merged revision(s) 66111.</p> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=768002019-02-14T00:36:57Zwanabe (_ wanabe)s.wanabe@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/14714">Bug #14714</a>: Ruby 2.5.1 Segmentation Fault in GC</i> added</li></ul> Ruby master - Bug #15362: [PATCH] Avoid GCing dead stack after switching away from a fiberhttps://redmine.ruby-lang.org/issues/15362?journal_id=768022019-02-14T00:39:28Zwanabe (_ wanabe)s.wanabe@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/15375">Bug #15375</a>: Crash report for Ruby 2.5.3p105</i> added</li></ul>