https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112017-02-20T17:20:00ZRuby Issue Tracking SystemRuby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=630522017-02-20T17:20:00ZGondolin (Damien Robert)Damien.Olivier.Robert+ruby@gmail.com
<ul></ul><p>Damien Robert wrote:</p>
<blockquote>
<p>The code is in <a href="https://github.com/DamienRobert/drain" class="external">https://github.com/DamienRobert/drain</a><br>
You can run 'rake test' to (sometime, not often) get the core dump.</p>
</blockquote>
<p>PS: I apologize that I was not able to get a minimal working example. I tried to do so in 'test_graph_segfault.rb' but it does not segfault. However removing test_graph.rb <em>or</em> test_converter.rb seems to prevent the segfault, but it is hard to tell because I am not able to get the segfault all the time. That's why I sent the coredump, I have several others (one where the message I get is an error due to a 'double free') if you need.</p> Ruby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=630532017-02-20T19:00:46Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>Some bugs are just like that - they exist somewhere out there but they are hard<br>
to find or reproduce. Almost real heisenbugs. :)</p> Ruby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=630612017-02-21T12:09:20Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/63061/diff?detail_id=43995">diff</a>)</li><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Could you enable debugging?</p> Ruby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=637882017-03-24T23:38:29ZGondolin (Damien Robert)Damien.Olivier.Robert+ruby@gmail.com
<ul></ul><p>nobu (Nobuyoshi Nakada) wrote:</p>
<blockquote>
<p>Could you enable debugging?</p>
</blockquote>
<p>So I <em>think</em> I have managed to bisect the segfault. When I comment a specific test I never see the segfault, but when I uncomment it I get (sometimes) the segfault. The test itself in isolation does not segfault, it is only when I run a fairly large amount of other tests that I can get the segfault. Contrary to what I was thinking at first, the tests about graphs with loops are not the ones responsible for the segfault. I can provide the debugging information if you still need but they only concern the other tests, not the one that causes the segfault.</p>
<p>Here is the tested code and the test:</p>
<pre><code class="ruby syntaxhl" data-language="ruby">
<span class="k">module</span> <span class="nn">Meta</span>
<span class="kp">extend</span> <span class="nb">self</span>
<span class="c1">#convert a class into a module using refinements</span>
<span class="c1">#ex: (Class.new { include Meta.refined_module(String) { def length; super+5; end } }).new("foo").length #=> 8</span>
<span class="c1">#This uses the fact that a refining module of klass behaves as if it had</span>
<span class="c1">#klass has his direct ancestor</span>
<span class="k">def</span> <span class="nf">refined_module</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span><span class="o">&</span><span class="n">b</span><span class="p">)</span>
<span class="n">klass</span><span class="o">=</span><span class="n">klass</span><span class="p">.</span><span class="nf">singleton_class</span> <span class="k">unless</span> <span class="no">Module</span><span class="o">===</span><span class="n">klass</span>
<span class="no">Module</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="c1">#including the module rather than just returning it allow us to</span>
<span class="c1">#still be able to use 'using' ('using' does not work directly on</span>
<span class="c1">#refining modules, only the enclosing ones)</span>
<span class="kp">include</span> <span class="n">refine</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span> <span class="p">{</span>
<span class="nb">module_eval</span><span class="p">(</span><span class="o">&</span><span class="n">b</span><span class="p">)</span> <span class="k">if</span> <span class="nb">block_given?</span>
<span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">describe</span> <span class="no">Meta</span> <span class="k">do</span>
<span class="n">it</span> <span class="s2">"Can convert a class to module"</span> <span class="k">do</span>
<span class="p">(</span><span class="no">Class</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span> <span class="kp">include</span> <span class="no">DR</span><span class="o">::</span><span class="no">Meta</span><span class="p">.</span><span class="nf">refined_module</span><span class="p">(</span><span class="no">String</span><span class="p">)</span> <span class="p">{</span> <span class="k">def</span> <span class="nf">length</span><span class="p">;</span> <span class="k">super</span><span class="o">+</span><span class="mi">5</span><span class="p">;</span> <span class="k">end</span> <span class="p">}</span> <span class="p">}).</span><span class="nf">new</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">).</span><span class="nf">length</span><span class="p">.</span><span class="nf">must_equal</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre> Ruby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=637892017-03-25T02:11:18Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>shugo (Shugo Maeda)</i></li><li><strong>Backport</strong> changed from <i>2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN</i> to <i>2.2: DONTNEED, 2.3: REQUIRED, 2.4: REQUIRED</i></li></ul><p>Thank you, reduced code with <code>GC.stress</code> could reproduce it.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">module</span> <span class="nn">M</span>
<span class="kp">include</span> <span class="n">refine</span><span class="p">(</span><span class="no">String</span><span class="p">)</span> <span class="p">{</span><span class="k">def</span> <span class="nf">test</span><span class="p">;</span><span class="ss">:ok</span> <span class="k">end</span><span class="p">}</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">C</span>
<span class="kp">include</span> <span class="no">M</span>
<span class="k">end</span>
<span class="no">GC</span><span class="p">.</span><span class="nf">stress</span> <span class="o">=</span> <span class="kp">true</span>
<span class="no">C</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">).</span><span class="nf">test</span>
</code></pre>
<p>But I wonder if it is possible to "convert a class to module".</p> Ruby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=637902017-03-25T03:23:49Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset trunk|r58083.</p>
<hr>
<p>class.c: prohibit refinement module</p>
<ul>
<li>class.c (ensure_includable): cannot include refinement<br>
module, or the type and the class do not match.<br>
<a href="/issues/13236">[ruby-core:79632]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Ruby segfault (Closed)" href="https://bugs.ruby-lang.org/issues/13236">#13236</a>]</li>
</ul> Ruby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=646002017-04-30T14:05:18Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Backport</strong> changed from <i>2.2: DONTNEED, 2.3: REQUIRED, 2.4: REQUIRED</i> to <i>2.2: DONTNEED, 2.3: DONE, 2.4: REQUIRED</i></li></ul><p>ruby_2_3 r58519 merged revision(s) 58082,58083.</p> Ruby master - Bug #13236: Ruby segfaulthttps://bugs.ruby-lang.org/issues/13236?journal_id=647202017-05-09T15:06:04Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.2: DONTNEED, 2.3: DONE, 2.4: REQUIRED</i> to <i>2.2: DONTNEED, 2.3: DONE, 2.4: DONE</i></li></ul><p>ruby_2_4 r58632 merged revision(s) 58082,58083.</p>