https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112015-04-15T15:26:42ZRuby Issue Tracking SystemRuby master - Bug #11071: Stack consistency error while using RSpec and Timecophttps://redmine.ruby-lang.org/issues/11071?journal_id=521702015-04-15T15:26:42Zmyronmarston (Myron Marston)myron.marston@gmail.com
<ul></ul><p>There are two interesting things I've noticed about this:</p>
<ol>
<li>It does not happen on 2.1, so it appears to be a regression in 2.2.</li>
<li>It appears to be related to <code>to_proc</code>. If you change @jcoglan's example to use an around hook like this:</li>
</ol>
<pre><code> around do |example|
Timecop.travel(Time.parse('2015-01-01 06:30:00')) { example.run }
end
</code></pre>
<p>...the segfault does not happen. The <code>to_proc</code> definition is here, FWIW:</p>
<p><a href="https://github.com/rspec/rspec-core/blob/v3.2.3/lib/rspec/core/example.rb#L244-L255" class="external">https://github.com/rspec/rspec-core/blob/v3.2.3/lib/rspec/core/example.rb#L244-L255</a></p>
<p>If some ruby core folks want to work on this and would like a more isolated example (e.g. an example that triggers the same bug w/o loading RSpec itself), let me know and I can try to pare it down to something more minimal.</p> Ruby master - Bug #11071: Stack consistency error while using RSpec and Timecophttps://redmine.ruby-lang.org/issues/11071?journal_id=521752015-04-16T07:51:24Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/52175/diff?detail_id=37604">diff</a>)</li><li><strong>File</strong> <a href="/attachments/5170">bug-11071.log</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/5170/bug-11071.log">bug-11071.log</a> added</li><li><strong>Subject</strong> changed from <i>Segfault while using RSpec and Timecop</i> to <i>Stack consistency error while using RSpec and Timecop</i></li><li><strong>Backport</strong> changed from <i>2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN</i> to <i>2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED</i></li></ul><p>Reproduced with the trunk.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">E</span>
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="o">&</span><span class="nb">proc</span><span class="p">)</span>
<span class="vi">@proc</span> <span class="o">=</span> <span class="nb">proc</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="vi">@proc</span><span class="p">.</span><span class="nf">call</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">to_proc</span>
<span class="nb">method</span><span class="p">(</span><span class="ss">:run</span><span class="p">).</span><span class="nf">to_proc</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">T</span>
<span class="k">def</span> <span class="nf">doit</span>
<span class="k">yield</span> <span class="kp">nil</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">t</span> <span class="o">=</span> <span class="no">T</span><span class="p">.</span><span class="nf">new</span>
<span class="n">e</span> <span class="o">=</span> <span class="no">E</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span><span class="n">t</span><span class="p">.</span><span class="nf">doit</span> <span class="p">{}}</span>
<span class="n">t</span><span class="p">.</span><span class="nf">doit</span><span class="p">(</span><span class="o">&</span><span class="n">e</span><span class="p">)</span>
</code></pre> Ruby master - Bug #11071: Stack consistency error while using RSpec and Timecophttps://redmine.ruby-lang.org/issues/11071?journal_id=523572015-05-09T04:53:53Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Possibly shortest code.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">doit</span>
<span class="k">yield</span> <span class="kp">nil</span>
<span class="k">end</span>
<span class="n">doit</span><span class="p">(</span><span class="o">&</span><span class="nb">proc</span> <span class="p">{</span><span class="n">doit</span> <span class="p">{}}.</span><span class="nf">method</span><span class="p">(</span><span class="ss">:call</span><span class="p">))</span>
</code></pre>
<p>But it doesn't happen, if the inner block has a single argument or arbitrary number arguments <code>*</code>.<br>
Oppositely, it's similar but <code>sp</code> is less than <code>bp</code> when the arguments are more than one.<br>
And it seems the point to reenter the same method <code>doit</code>.</p> Ruby master - Bug #11071: Stack consistency error while using RSpec and Timecophttps://redmine.ruby-lang.org/issues/11071?journal_id=538392015-08-17T13:03:07Zalexdowad (Alex Dowad)alexinbeijing@gmail.com
<ul></ul><p>This is fixed by the patch I just posted for <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: MRI crashes with 'Stack inconsistency error' when a method which yields is called recursively in ... (Closed)" href="https://redmine.ruby-lang.org/issues/11451">#11451</a>.</p> Ruby master - Bug #11071: Stack consistency error while using RSpec and Timecophttps://redmine.ruby-lang.org/issues/11071?journal_id=538402015-08-17T13:07:33Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/11451">Bug #11451</a>: MRI crashes with 'Stack inconsistency error' when a method which yields is called recursively in a particular way</i> added</li></ul> Ruby master - Bug #11071: Stack consistency error while using RSpec and Timecophttps://redmine.ruby-lang.org/issues/11071?journal_id=798962019-07-23T17:17:06Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul>