https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112015-11-16T13:46:23ZRuby Issue Tracking SystemRuby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=548782015-11-16T13:46:23Zgazay (Alex Gaziev)alex.gaziev@gmail.com
<ul></ul><p>This issue is related: <a href="https://bugs.ruby-lang.org/issues/11593" class="external">https://bugs.ruby-lang.org/issues/11593</a></p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549052015-11-17T19:52:08Zebeigarts (Edgars Beigarts)edgars.beigarts@makit.lv
<ul></ul><p>I'm having similar issue when running tests with capybara that starts additional server in a new thread.<br>
If I have some problems in my rails app that raises SystemStackError in the server thread then I am left without a GC and memory just keeps growing and growing, I have tried manually calling GC.start after that, but it doesn't help, GC.stat dislays the same number for major/minor.</p>
<p>I was trying to create a simple example, but I run into other issues too.<br>
Here is the example: <a href="https://gist.github.com/ebeigarts/933f1601332609ed33a8" class="external">https://gist.github.com/ebeigarts/933f1601332609ed33a8</a></p>
<p>Do I need to open a new issue for this?</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549062015-11-17T19:53:50Zebeigarts (Edgars Beigarts)edgars.beigarts@makit.lv
<ul><li><strong>File</strong> <a href="/attachments/5585">gc_threads_issue.rb</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/5585/gc_threads_issue.rb">gc_threads_issue.rb</a> added</li></ul> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549172015-11-18T01:52:53Zgazay (Alex Gaziev)alex.gaziev@gmail.com
<ul></ul><p>Edgars Beigarts wrote:</p>
<blockquote>
<p>Do I need to open a new issue for this?</p>
</blockquote>
<p>I think it is the same problem. I wrote small explanation what is happening: <a href="https://gist.github.com/gazay/54da61919b85eb2e0d42" class="external">https://gist.github.com/gazay/54da61919b85eb2e0d42</a></p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549522015-11-19T06:54:55Zko1 (Koichi Sasada)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset r52668.</p>
<hr>
<ul>
<li>signal.c: should also clear ruby_disable_gc.<br>
[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: [PATCH] Re-enable GC if stack overflow was caught from signal handler (Closed)" href="https://bugs.ruby-lang.org/issues/11692">#11692</a>]</li>
</ul> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549532015-11-19T06:55:18Zko1 (Koichi Sasada)
<ul><li><strong>Assignee</strong> set to <i>ko1 (Koichi Sasada)</i></li></ul><p>Thank you for your great survey!</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549602015-11-19T08:55:17Zebeigarts (Edgars Beigarts)edgars.beigarts@makit.lv
<ul></ul><p>Tried with ruby head, this solves the GC problems now, but it doesn't solve the other problem that is visible if you run my example -<br>
<a href="https://gist.github.com/ebeigarts/44648eb7b2773e102335" class="external">https://gist.github.com/ebeigarts/44648eb7b2773e102335</a></p>
<p><del>In ruby 2.2 it looks like if a stack overflow is raised in a thread, the thread just dies.</del> I was running with 2.2.0 and not 2.2.3.</p>
<p>In ruby trunk (and also 2.2.3) it looks like if a stack overflow is raised in a thread 2 times then on the 2nd time the whole process just hangs and the only way to stop is kill -9.</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549712015-11-19T13:47:32Zko1 (Koichi Sasada)
<ul></ul><p>Unfortunately, it is known problem (2nd time machine stack overflow we can not capture correctly).</p>
<ul>
<li>1st machine stack overflow
<ul>
<li>SEGV</li>
<li>check machine stack overflow</li>
<li>raise an error from signal handler (*1) by longjmp.</li>
</ul>
</li>
<li>2nd machine stack overflow
<ul>
<li>SEGV</li>
<li>signal status is signaling. So OS can not deliver signal correctly...</li>
</ul>
</li>
</ul>
<p>The correct way is restoring signal status using sigsetjmp/siglongjmp at (*1).<br>
However, on Linux 2.x, siglongjmp is too slow than longjmp, so that we continue to use longjmp, at least the last time we had discussed this issue. We can't slow down Ruby interpreter for such a corner case.</p>
<p>However, Linux 2.x is older OS. So that we can change.<br>
(BTW, I'm using Linux 2.6 on several machines)</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=549872015-11-20T06:55:03Zgazay (Alex Gaziev)alex.gaziev@gmail.com
<ul></ul><p>Koichi, do you plan to do backport to 2.2 version of this patch?</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=556532015-12-18T10:09:32Zgazay (Alex Gaziev)alex.gaziev@gmail.com
<ul><li><strong>File</strong> <a href="/attachments/5656">re-enable-GC-if-stack-overflow-was-caught-from.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/5656/re-enable-GC-if-stack-overflow-was-caught-from.patch">re-enable-GC-if-stack-overflow-was-caught-from.patch</a> added</li></ul><p>As I see, problem wasn't fixed in Ruby 2.2.4. Patch for it in attachment</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=556542015-12-18T10:15:17Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<ul><li><strong>Backport</strong> changed from <i>2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN</i> to <i>2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: REQUIRED</i></li></ul><p>Backport should be probably requested</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=556552015-12-18T10:16:26Zgazay (Alex Gaziev)alex.gaziev@gmail.com
<ul></ul><p>Thank you, didn't know that</p> Ruby master - Bug #11692: [PATCH] Re-enable GC if stack overflow was caught from signal handlerhttps://bugs.ruby-lang.org/issues/11692?journal_id=577692016-03-28T17:21:44Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: REQUIRED</i> to <i>2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: DONE</i></li></ul><p>Backported into <code>ruby_2_2</code> branch at r54340.</p>