Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112014-02-06T07:52:06ZRuby Issue Tracking System
Redmine Ruby master - Bug #9494 (Closed): Race condition in autoload of Digest::SHA256, etc.https://redmine.ruby-lang.org/issues/94942014-02-06T07:52:06ZConrad.Irwin (Conrad Irwin)conrad.irwin@gmail.com
<p>At the moment the digest extension uses const_missing to implement autoload. Unfortunately there's a race condition: another thread can run after the constant is defined, but before it is initialized. (<a href="http://git.io/YW3bbA" class="external">http://git.io/YW3bbA</a>)</p>
<p>There's a minimal test case here: <a href="http://git.io/5umBqQ" class="external">http://git.io/5umBqQ</a> — this was happening to us regularly in production because each sidekiq worker would race to create a hash.</p>
<p>The work around we have deployed is to require digest/sha2.so pre-emptively. And the attached patch does that.</p>
<p>An alternative solution would be to use <code>autoload</code>, but that is deprecated; or to change the way meta-data is stored for Digest classes so that it can be accessed immediately. There's no way to use a mutex inside const_missing to fix this, because the bug is that the constant becomes not-missing before it is fully defined.</p> Ruby master - Bug #7772 (Closed): Consider bumping stack size in ruby_qsorthttps://redmine.ruby-lang.org/issues/77722013-02-03T16:06:59ZConrad.Irwin (Conrad Irwin)conrad.irwin@gmail.com
<p>At the moment the maximum size of the stack is 32. The comment implies this should be enough for arrays with up to 2**32 elements, but it's possible to create larger arrays on some big systems.</p>
<p>I was not able to trigger a bug with: ([0, 1] * (2**32 + 10000)).sort! so it may actually never be a problem in practice, but it seems unsafe.</p> Ruby master - Bug #7536 (Closed): local variables added to TOPLEVEL_BINDING in -r are broken https://redmine.ruby-lang.org/issues/75362012-12-09T09:41:51ZConrad.Irwin (Conrad Irwin)conrad.irwin@gmail.com
<p>If a library that you require in the -r flag of ruby evals things in TOPLEVEL_BINDING (e.g. RUBY_OPT=-rbundler/setup), then the local variables will show up in TOPLEVEL_BINDING.eval("local_variables"), but they raise a NameError if you try to use them.</p>
<p>A minimal test case is:</p>
<p>$ cat b.rb<br>
TOPLEVEL_BINDING.eval("lib = 2")</p>
<p>$ cat a.rb<br>
puts TOPLEVEL_BINDING.eval("local_variables").inspect<br>
puts TOPLEVEL_BINDING.eval("lib").inspect</p>
<p>$ ruby -r./b.rb a.rb<br>
[:lib]</p>
:in `': undefined local variable or method `lib' for main:Object (NameError)
from a.rb:2:in `eval'
from a.rb:2:in `'
<p>This affects ruby 1.9.3 and ruby 2.0.0, I tested with:<br>
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]<br>
ruby 2.0.0dev (2012-12-09 trunk 38278) [x86_64-linux]</p>
<p>Ruby 1.8.7 works fine:<br>
$ ruby -v<br>
ruby 1.8.7 (2012-06-29 patchlevel 370) [x86_64-linux]<br>
$ ruby -r./b.rb a.rb<br>
["lib"]<br>
2</p>
<p>This breaks debugging tools like pry or <a href="https://github.com/charliesome/better_errors" class="external">https://github.com/charliesome/better_errors</a>, which rightly assume that it's safe to do:</p>
<pre><code>any_binding.eval("local_variables").map{ |x| any_binding.eval("#{x}") }
</code></pre>
<p>There are two possible solutions; either remove the variable names from the list of "local_variables", make sure they don't raise a NameError.</p> Ruby master - Feature #3575 (Closed): String#split is inconsistent with empty string and negative...https://redmine.ruby-lang.org/issues/35752010-07-15T15:51:02ZConrad.Irwin (Conrad Irwin)conrad.irwin@gmail.com
<p>Currently works like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="s2">""</span><span class="p">.</span><span class="nf">split</span><span class="p">(</span><span class="s2">","</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># => []</span>
</code></pre>
<p>According to the documentation, blank fields should not be stripped when a negative offset is provided. I expect:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="s2">""</span><span class="p">.</span><span class="nf">split</span><span class="p">(</span><span class="s2">","</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># => [""]</span>
</code></pre>