Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112024-03-28T18:13:35ZRuby Issue Tracking System
Redmine Ruby master - Bug #20400 (Open): Nested BEGIN{} execution orderhttps://bugs.ruby-lang.org/issues/204002024-03-28T18:13:35Zkddnewton (Kevin Newton)kddnewton@gmail.com
<p>Right now there are specs for the order in which <code>BEGIN{}</code> should be executed, which is the order they appear in the file. For example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"1"</span> <span class="p">}</span>
<span class="nb">print</span> <span class="s2">"4"</span>
<span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"2"</span> <span class="p">}</span>
<span class="nb">print</span> <span class="s2">"5"</span>
<span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"3"</span> <span class="p">}</span>
</code></pre>
<p>should output "12345". However, I couldn't find any tests/specs on what happens when <code>BEGIN{}</code> is nested. The order appears to be somewhat confusing, so I wanted to clarify if it was intentional or a bug. For example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">BEGIN</span> <span class="p">{</span>
<span class="nb">print</span> <span class="s2">"1"</span>
<span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"2"</span> <span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>prints "21", and:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">BEGIN</span> <span class="p">{</span>
<span class="nb">print</span> <span class="s2">"1"</span>
<span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"2"</span> <span class="p">}</span>
<span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"3"</span> <span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>prints "231", and finally:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">BEGIN</span> <span class="p">{</span>
<span class="nb">print</span> <span class="s2">"1"</span>
<span class="k">BEGIN</span> <span class="p">{</span>
<span class="nb">print</span> <span class="s2">"2"</span>
<span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"3"</span> <span class="p">}</span>
<span class="p">}</span>
<span class="k">BEGIN</span> <span class="p">{</span> <span class="nb">print</span> <span class="s2">"4"</span> <span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>prints "3241". Is this intentional?</p> Ruby master - Bug #20399 (Open): Ripper doesn't respect implicit -xhttps://bugs.ruby-lang.org/issues/203992024-03-28T14:27:26Zkddnewton (Kevin Newton)kddnewton@gmail.com
<p>For the given script:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1">#!/bin/sh</span>
<span class="c1"># -*- ruby -*-</span>
<span class="nb">exec</span> <span class="s2">"${RUBY-ruby}"</span> <span class="s2">"-x"</span> <span class="s2">"$0"</span> <span class="s2">"$@"</span> <span class="o">&&</span> <span class="p">[</span> <span class="p">]</span> <span class="k">if</span> <span class="kp">false</span>
<span class="c1">#!ruby</span>
<span class="c1"># This needs ruby 2.0, Subversion and Git.</span>
<span class="c1"># As a Ruby committer, run this in an SVN repository</span>
<span class="c1"># to commit a change.</span>
<span class="nb">require</span> <span class="s1">'tempfile'</span>
<span class="nb">require</span> <span class="s1">'net/http'</span>
</code></pre>
<p>I would expect all of the various Ripper APIs (<code>lex</code>, <code>sexp</code>, <code>sexp_raw</code>, <code>new.parse</code>, etc.) to start parsing on line 4, because that's what the parser does. Instead, it starts parsing on line 1.</p> Ruby master - Bug #20397 (Open): The nkf license in LEGAL file seems to be obsoletehttps://bugs.ruby-lang.org/issues/203972024-03-27T17:22:36Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<p>The LEGAL file seems to contain <a href="https://github.com/ruby/ruby/blob/a69f0047cb489c136001937442c1d2ffd8ea1dd7/LEGAL?plain=1#L730-L746" class="external">obsolete information</a> about nkf license.</p>
<p>It seems that nkf indeed use such license, but in upstream, it was first changed to <a href="https://github.com/nurse/nkf/commit/c12280757bfb275d6f9e6b0bf6293a28b060e77b" class="external">MIT</a> and then immediately to <a href="https://github.com/nurse/nkf/commit/2ed3e1c270f1deb9487f7bc7d7586030fe7dabc5" class="external">zlib</a> license.</p>
<p>Ruby has picked up that change with <a class="changeset" title="* ext/nkf/nkf-utf8/nkf.c: Update nkf to 2.0.9. revert -s meaning as Shift_JIS, etc. git-svn-id..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/13313688b243882aff7815598ddd9fcbae69bc17">git|13313688b243882aff7815598ddd9fcbae69bc17</a></p>
<p>Maybe <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/5">@naruse (Yui NARUSE)</a> can comment about this.</p> Ruby master - Bug #20395 (Open): Invalid license note in vsnprintf.chttps://bugs.ruby-lang.org/issues/203952024-03-26T11:19:39Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<p>I am looking into Ruby licenses and I stumble upon vsnprintf.c, namely about these lines:</p>
<pre><code>/*
* IMPORTANT NOTE:
* --------------
* From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
* paragraph 3 above is now null and void.
*/
</code></pre>
<p>I doubt the note is valid since <a class="changeset" title="* missing/crypt.c: replaced with 4.4BSD version. * missing/erf.c: ditto. * missing/vsnprintf.c:..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/626f1ee196fe06514d66771ff0e3f82d7686af25">git|626f1ee196fe06514d66771ff0e3f82d7686af25</a>, which actually removes the 3rd clause, while the (broken) URL refers to "4bsd". Can somebody please review? The note from the URL can be likely viewed e.g. <a href="https://www.freebsd.org/copyright/license/" class="external">here</a></p> Ruby master - Bug #20346 (Open): FiberScheduler.unblock not called by Thread#join when Thread bod...https://bugs.ruby-lang.org/issues/203462024-03-18T19:06:21Zforthoney (Seong-Heon Jung)castlehoneyjung@gmail.com
<p>When using a <code>Ractor.take</code> inside a different thread, <code>Thread#join</code> on the thread running <code>Ractor.take</code> fails to call <code>FiberScheduler.unblock</code>. The below code can replicate this behavior</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s2">"async"</span>
<span class="k">class</span> <span class="nc">RactorWrapper</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="vi">@ractor</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">recv</span> <span class="c1"># Ractor doesn't start until explicitly told to</span>
<span class="c1"># Do some calculations</span>
<span class="n">fib</span> <span class="o">=</span> <span class="o">-></span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span> <span class="n">x</span> <span class="o"><</span> <span class="mi">2</span> <span class="p">?</span> <span class="mi">1</span> <span class="p">:</span> <span class="n">fib</span><span class="p">.</span><span class="nf">call</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="n">fib</span><span class="p">.</span><span class="nf">call</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="p">}</span>
<span class="n">fib</span><span class="p">.</span><span class="nf">call</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">take_async</span>
<span class="vi">@ractor</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="kp">nil</span><span class="p">)</span>
<span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span> <span class="vi">@ractor</span><span class="p">.</span><span class="nf">take</span> <span class="p">}.</span><span class="nf">join</span><span class="p">.</span><span class="nf">value</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="no">Async</span> <span class="k">do</span> <span class="o">|</span><span class="n">task</span><span class="o">|</span>
<span class="mi">10000</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span>
<span class="n">task</span><span class="p">.</span><span class="nf">async</span> <span class="k">do</span>
<span class="no">RactorWrapper</span><span class="p">.</span><span class="nf">new</span><span class="p">.</span><span class="nf">take_async</span>
<span class="nb">puts</span> <span class="n">i</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>The above code deadlocks, and when we leave a debugging print statement inside of <code>Async</code>'s scheduler's <code>block</code> and <code>unblock</code> method, we can confirm that we only call <code>Scheduler.block</code>, and never <code>Scheduler.unblock</code></p> Ruby master - Bug #20344 (Open): argument stack underflow (-1)https://bugs.ruby-lang.org/issues/203442024-03-18T15:37:22Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<p>This file produces argument stack underflow, since ruby 2.5.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">proc</span> <span class="k">do</span>
<span class="k">next</span> <span class="k">if</span> <span class="kp">true</span>
<span class="k">case</span> <span class="kp">nil</span>
<span class="k">when</span> <span class="s2">"a"</span>
<span class="k">next</span>
<span class="k">when</span> <span class="s2">"b"</span>
<span class="k">when</span> <span class="s2">"c"</span>
<span class="nb">proc</span> <span class="p">{}</span>
<span class="k">end</span>
<span class="k">next</span> <span class="k">unless</span> <span class="kp">true</span>
<span class="k">end</span>
</code></pre>
<pre><code>-- raw disasm--------
trace: 100
0000 nop ( 1)
<L000> [sp: 0, unremovable: 1, refcnt: 5]
trace: 1
<L004> [sp: 0, unremovable: 0, refcnt: 1]
adjust: [label: 0]
0001 putnil ( 2)
0002 leave ( 13)
<L008> [sp: 1, unremovable: 0, refcnt: 1]
adjust: [label: 0]
0003 putnil ( 6)
0004 leave ( 13)
adjust: [label: 8]
0005 jump <L005> ( 5)
0007 pop ( 7)
0008 jump <L005> ( 7)
* 0010 pop ( 8)
trace: 1
<L011> [sp: -1, unremovable: 1, refcnt: 1]
0011 putself ( 9)
0012 send <calldata:proc, 0>, nil ( 9)
<L012> [sp: -1, unremovable: 0, refcnt: 2]
0015 pop ( 9)
<L005> [sp: 1, unremovable: 0, refcnt: 2]
trace: 1
0016 putnil ( 12)
<L001> [sp: -1, unremovable: 0, refcnt: 3]
trace: 200
0017 leave ( 13)
---------------------
</code></pre> Ruby master - Bug #20342 (Open): Top level `public`, `private` and `ruby2_keywords` do not work i...https://bugs.ruby-lang.org/issues/203422024-03-16T10:21:57Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<p>With this file:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># load.rb</span>
<span class="kp">public</span> <span class="k">def</span> <span class="nf">f</span> <span class="o">=</span> <span class="ss">:ok</span>
</code></pre>
<p>It is OK when <code>require</code>d.</p>
<pre><code data-language="sh-session">$ ruby -r ./load.rb -e 'p f'
:ok
</code></pre>
<p>Simple <code>load</code> is OK too.</p>
<pre><code data-language="sh-session">$ ruby -e 'load ARGV[0]; p f' load.rb
:ok
</code></pre>
<p>Wrapped <code>load</code> fails.</p>
<pre><code data-language="sh-session">$ ruby -e 'load ARGV[0], true' load.rb
load.rb:1:in 'public': undefined method 'f' for class 'Object' (NameError)
public def f = :ok
^^^^^^
from load.rb:1:in '<top (required)>'
from -e:1:in 'Kernel#load'
from -e:1:in '<main>'
</code></pre> Ruby master - Bug #20340 (Open): Ractor comments not applying to constant targetshttps://bugs.ruby-lang.org/issues/203402024-03-14T19:39:40Zkddnewton (Kevin Newton)kddnewton@gmail.com
<p>In this example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">C</span><span class="p">,</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">foo: </span><span class="n">bar</span> <span class="p">}</span>
</code></pre>
<p>You get:</p>
<pre><code>== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(1,17)>
0000 putobject :foo ( 1)[Li]
0002 putself
0003 opt_send_without_block <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0005 newhash 2
0007 dup
0008 expandarray 1, 0
0011 putspecialobject 3
0013 setconstant :C
0015 leave
</code></pre>
<p>But there's no difference from:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># shareable_constant_value: literal</span>
<span class="no">C</span><span class="p">,</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">foo: </span><span class="n">bar</span> <span class="p">}</span>
</code></pre>
<p>I would have expected:</p>
<pre><code>== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(2,16)>
0000 putobject RubyVM::FrozenCore ( 2)[Li]
0002 putobject :foo
0004 putobject RubyVM::FrozenCore
0006 putself
0007 opt_send_without_block <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0009 putobject "C"
0011 opt_send_without_block <calldata!mid:ensure_shareable, argc:2, ARGS_SIMPLE>
0013 newhash 2
0015 opt_send_without_block <calldata!mid:make_shareable, argc:1, ARGS_SIMPLE>
0017 dup
0018 expandarray 1, 0
0021 putspecialobject 3
0023 setconstant :C
0025 leave
</code></pre>
<p>Is this omission intentional? For context, I'm building this in prism and I need to know if I should explicitly disable this behavior.</p> Ruby master - Bug #20337 (Open): Complex#inspect mutates the string returned by `real.inspect`https://bugs.ruby-lang.org/issues/203372024-03-14T11:23:54ZEregon (Benoit Daloze)
<pre><code>irb(main):001:0> n = Numeric.new
=> #<Numeric:0x00007f81b2308578>
irb(main):004:0> class Numeric; def inspect = super.freeze; end
=> :inspect
irb(main):006:0> Complex(n, 1).inspect
(irb):6:in `inspect': can't modify frozen String: "#<Numeric:0x00007f81b2308578>" (FrozenError)
from (irb):6:in `<main>'
from /home/eregon/.rubies/ruby-3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
from /home/eregon/.rubies/ruby-3.2.2/bin/irb:25:in `load'
from /home/eregon/.rubies/ruby-3.2.2/bin/irb:25:in `<main>'
</code></pre>
<p>It feels wrong to mutate the result of inspect at least in general, for instance <code>true.inspect</code> is frozen.</p>
<p>Discovered by <a href="https://github.com/ruby/spec/pull/1142" class="external">https://github.com/ruby/spec/pull/1142</a></p> Ruby master - Bug #20332 (Open): After upgrading to ruby v 3.2.3 rb_scan_args() skips argument va...https://bugs.ruby-lang.org/issues/203322024-03-12T18:06:04Zpraveenrocket (Praveen N)
<p>Hi,</p>
<p>Note: I am not an expert at ruby.</p>
<p>I am working on ibm_db gem, its an adapter developed using ruby C extension, which helps ruby & rails applications to connect to DB2 database.<br>
Here is a github link for its source <a href="https://github.com/ibmdb/ruby-ibmdb/tree/master" class="external">https://github.com/ibmdb/ruby-ibmdb/tree/master</a></p>
<p>As of now ibm_db gem is compatible with ruby v 3.1.<br>
Now I am trying to make ibm_db gem compatible with ruby v 3.2.3.</p>
<p>All my test cases were working for ruby v 3.1, but post upgrading to ruby v 3.2.3, most of my test cases are failing.</p>
<p>After debugging using gdb what I see is, my ruby test cases calls ruby C extension API passing required arguments, but inside C extension code arguments are not parsed, indeed nothing is read. Because of this most of test cases are failing.</p>
<p>Below is a sample ruby script which when run calls ibm_db extension,</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="err">$</span> <span class="n">irb</span>
<span class="n">irb</span><span class="p">(</span><span class="n">main</span><span class="p">):</span><span class="mo">001</span><span class="p">:</span><span class="mi">0</span><span class="o">></span> <span class="nb">require</span> <span class="s1">'ibm_db'</span>
<span class="o">=></span> <span class="kp">true</span>
<span class="n">irb</span><span class="p">(</span><span class="n">main</span><span class="p">):</span><span class="mo">002</span><span class="p">:</span><span class="mi">0</span><span class="o">></span> <span class="n">conn</span> <span class="o">=</span> <span class="no">IBM_DB</span><span class="p">.</span><span class="nf">connect</span><span class="p">(</span><span class="s2">"DATABASE=sample;HOSTNAME=waldevdbclnxtst06.dev.rocketsoftware.com;PORT=60000;PROTOCOL=TCPIP;UID=zurbie;PWD=A2m8test;"</span><span class="p">,</span><span class="s1">''</span><span class="p">,</span><span class="s1">''</span><span class="p">)</span>
<span class="p">(</span><span class="n">irb</span><span class="p">):</span><span class="mi">2</span><span class="p">:</span> <span class="ss">warning: </span><span class="n">undefining</span> <span class="n">the</span> <span class="n">allocator</span> <span class="n">of</span> <span class="no">T_DATA</span> <span class="k">class</span> <span class="nc">IBM_DB::Connection</span>
<span class="o">=></span> <span class="c1">#<IBM_DB::Connection:0x00007ff60314ce58></span>
<span class="n">irb</span><span class="p">(</span><span class="n">main</span><span class="p">):</span><span class="mo">003</span><span class="p">:</span><span class="mi">0</span><span class="o">></span> <span class="n">stmt</span> <span class="o">=</span> <span class="no">IBM_DB</span><span class="p">.</span><span class="nf">exec</span> <span class="n">conn</span><span class="p">,</span><span class="s1">'create table abc(C1 int)'</span>
<span class="o">=></span> <span class="kp">false</span>
<span class="n">irb</span><span class="p">(</span><span class="n">main</span><span class="p">):</span><span class="mo">004</span><span class="p">:</span><span class="mi">0</span><span class="o">></span>
<span class="n">irb</span><span class="p">(</span><span class="n">main</span><span class="p">):</span><span class="mo">005</span><span class="p">:</span><span class="mi">0</span><span class="o">></span> <span class="no">IBM_DB</span><span class="p">.</span><span class="nf">close</span><span class="p">(</span><span class="n">conn</span><span class="p">)</span>
<span class="o">=></span> <span class="kp">true</span>
<span class="n">irb</span><span class="p">(</span><span class="n">main</span><span class="p">):</span><span class="mo">006</span><span class="p">:</span><span class="mi">0</span><span class="o">></span> <span class="nb">exit</span>
</code></pre>
<p>Above, If you observe IBM_DB.exec is called passing two arguments conn & string with create table query.<br>
In extension code <a href="https://github.com/ibmdb/ruby-ibmdb/blob/master/IBM_DB_Driver/ibm_db.c" class="external">https://github.com/ibmdb/ruby-ibmdb/blob/master/IBM_DB_Driver/ibm_db.c</a>,<br>
below function will be called</p>
<pre><code class="c syntaxhl" data-language="c"><span class="n">VALUE</span> <span class="nf">ibm_db_exec</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="n">VALUE</span> <span class="o">*</span><span class="n">argv</span><span class="p">,</span> <span class="n">VALUE</span> <span class="n">self</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">....</span>
<span class="n">rb_scan_args</span><span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="s">"21"</span><span class="p">,</span> <span class="o">&</span><span class="n">connection</span><span class="p">,</span> <span class="o">&</span><span class="n">stmt</span><span class="p">,</span> <span class="o">&</span><span class="n">options</span><span class="p">);</span>
<span class="p">......</span>
<span class="p">}</span>
</code></pre>
<p>Note: Please refer <a href="https://github.com/ibmdb/ruby-ibmdb/blob/master/IBM_DB_Driver/ibm_db.c" class="external">https://github.com/ibmdb/ruby-ibmdb/blob/master/IBM_DB_Driver/ibm_db.c</a> for complete code.</p>
<p>rb_scan_args used to parse arguments very well in ruby v 3.1, but now its failing to do so. I see stmt parameter doesnt hold anything.</p>
<p>I just want to know whats issue here, Am I passing arguments in wrong way (in ruby script), or am I not using rb_scan_args properly ?</p>
<p>To reproduce,<br>
Install ruby v 3.2.3,<br>
Install ibm_db gem version 5.4.1 (latest)<br>
Run above sample ruby script using IRB.</p>
<p>Response at earliest is much appreciated.</p>
<p>Thanks<br>
Praveen</p> Ruby master - Bug #20330 (Open): [BUG] Segmentation fault at 0xffffffffffffffffhttps://bugs.ruby-lang.org/issues/203302024-03-09T10:33:11Zl33tname (Sir l33tname)sirl33tname@gmail.com
<p>I get a segfault from ruby on fly.io (a platform to run full stack apps).<br>
As you can see from the stacktracke im using a jemalloc version but im getting the same crash with the<br>
ruby:3.3.0-slim docker image. (Thats the docker file: <a href="https://github.com/Binaergewitter/serious-bg/blob/be890bf6af110b02f22f359d395bedb0659f4243/Dockerfile.fly" class="external">https://github.com/Binaergewitter/serious-bg/blob/be890bf6af110b02f22f359d395bedb0659f4243/Dockerfile.fly</a> based on quay.io/evl.ms/fullstaq-ruby:3.3.0-jemalloc-slim)</p>
<p>Reverting back to ruby 3.2.3 solved the issue for now: <a href="https://github.com/Binaergewitter/serious-bg/commit/4eed4119706303383ce5994c796bc5a8a1813afc" class="external">https://github.com/Binaergewitter/serious-bg/commit/4eed4119706303383ce5994c796bc5a8a1813afc</a></p>
<p>I was not able to reproduce it locally.<br>
But the application is open source -> <a href="https://github.com/Binaergewitter/serious-bg" class="external">https://github.com/Binaergewitter/serious-bg</a></p>
<pre><code>2024-03-09T09:31:07Z app[3d8d7d99f40128] iad [info][ 0.037737] Spectre V2 : WARNING: Unprivileged eBPF is enabled with eIBRS on, data leaks possible via Spectre v2 BHB attacks!
2024-03-09T09:31:07Z app[3d8d7d99f40128] iad [info][ 0.041193] PCI: Fatal: No config space access function found
2024-03-09T09:31:07Z app[3d8d7d99f40128] iad [info] INFO Starting init (commit: 913ad9c)...
2024-03-09T09:31:07Z app[3d8d7d99f40128] iad [info] INFO Preparing to run: `bundle exec puma -e production -b tcp://0.0.0.0:8080 -t 0:5` as root
2024-03-09T09:31:07Z app[3d8d7d99f40128] iad [info] INFO [fly api proxy] listening at /.fly/api
2024-03-09T09:31:07Z app[3d8d7d99f40128] iad [info]2024/03/09 09:31:07 listening on [fdaa:0:182f:a7b:22c:a04d:ac4:2]:22 (DNS: [fdaa::3]:53)
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems.rb:165: [BUG] Segmentation fault at 0xffffffffffffffff
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +jemalloc [x86_64-linux]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]-- Control frame information -----------------------------------------------
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]c:0005 p:0074 s:0023 e:000021 CLASS /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems.rb:165
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]c:0004 p:0045 s:0019 e:000018 TOP /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems.rb:115 [FINISH]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]c:0003 p:---- s:0012 e:000011 CFUNC :require
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]c:0002 p:0012 s:0007 e:000006 TOP <internal:gem_prelude>:2 [FINISH]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]c:0001 p:0000 s:0003 E:0001c0 DUMMY [FINISH]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]-- Ruby level backtrace information ----------------------------------------
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]<internal:gem_prelude>:2:in `<internal:gem_prelude>'
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]<internal:gem_prelude>:2:in `require'
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems.rb:115:in `<top (required)>'
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems.rb:165:in `<module:Gem>'
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]-- Threading information ---------------------------------------------------
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]Total ractor count: 1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]Ruby thread count for this ractor: 1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]-- Machine register context ------------------------------------------------
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] RIP: 0x00007fc80e6c51b4 RBP: 0x00007fc80c400050 RSP: 0x00007ffee5a36a98
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] RAX: 0xffffffffffffffff RBX: 0x00007fc80c4003e8 RCX: 0x00007fc80c4003e9
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] RDX: 0xffffffffffffffff RDI: 0x00007fc80d8170d0 RSI: 0x000000000000c2d3
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] R8: 0x0000000000000000 R9: 0x00007fc80da36340 R10: 0x0000000000000001
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] R11: 0x00007fc80e026880 R12: 0x00007fc80ea4b860 R13: 0x0000000000000001
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] R14: 0x00007fc80c400550 R15: 0x00007fc80e026880 EFL: 0x0000000000010202
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]-- C level backtrace information -------------------------------------------
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_vm_bugreport+0x96b) [0x7fc80e77adab]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_bug_for_fatal_signal+0x100) [0x7fc80e576720]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(sigsegv+0x4b) [0x7fc80e6c74db]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/lib/x86_64-linux-gnu/libc.so.6(0x7fc80e13a050) [0x7fc80e13a050]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(redblack_insert_aux+0x364) [0x7fc80e6c51b4]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(redblack_cache_ancestors+0x8f) [0x7fc80e6c552f]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(redblack_cache_ancestors+0x6d) [0x7fc80e6c550d]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(redblack_cache_ancestors+0x6d) [0x7fc80e6c550d]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(redblack_cache_ancestors+0x6d) [0x7fc80e6c550d]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(redblack_cache_ancestors+0x6d) [0x7fc80e6c550d]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(redblack_cache_ancestors+0x6d) [0x7fc80e6c550d]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_shape_get_next+0x2a8) [0x7fc80e6c6458]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_class_ivar_set+0xb0) [0x7fc80e742560]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_ivar_set+0x83) [0x7fc80e742743]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(vm_exec_core+0x8ca) [0x7fc80e75ea1a]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_vm_exec+0x179) [0x7fc80e7640f9]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(require_internal+0xd2f) [0x7fc80e5e84bf]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_require_string+0x66) [0x7fc80e5e9156]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(vm_call_cfunc_other+0x169) [0x7fc80e74cf29]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(vm_exec_core+0x129) [0x7fc80e75e279]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_vm_exec+0x179) [0x7fc80e7640f9]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(ruby_opt_init.part.0+0xbf) [0x7fc80e6c185f]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(load_file_internal+0x47e) [0x7fc80e6c1e7e]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(rb_ensure+0x110) [0x7fc80e580190]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(process_options+0x15fb) [0x7fc80e6c38ab]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(ruby_process_options+0x145) [0x7fc80e6c3ff5]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3(ruby_options+0xc9) [0x7fc80e581249]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby(0x56225c24510a) [0x56225c24510a]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/lib/x86_64-linux-gnu/libc.so.6(0x7fc80e12524a) [0x7fc80e12524a]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x7fc80e125305]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]/usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby(_start+0x21) [0x56225c245151]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]-- Other runtime information -----------------------------------------------
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]* Loaded script: /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]* Loaded features:
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 0 enumerator.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 1 thread.rb
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 2 fiber.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 3 rational.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 4 complex.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 5 ruby2_keywords.rb
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 6 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/encdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 7 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/trans/transdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 8 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/rbconfig.rb
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 9 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems/compatibility.rb
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 10 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems/defaults.rb
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 11 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems/deprecate.rb
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info] 12 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/rubygems/errors.rb
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]* Process memory map:
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]56225c244000-56225c245000 r--p 00000000 fe:00 134645 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]56225c245000-56225c246000 r-xp 00001000 fe:00 134645 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]56225c246000-56225c247000 r--p 00002000 fe:00 134645 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]56225c247000-56225c248000 r--p 00002000 fe:00 134645 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]56225c248000-56225c249000 rw-p 00003000 fe:00 134645 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80994f000-7fc80a000000 r--s 00000000 fe:00 134864 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a000000-7fc80a400000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a54a000-7fc80a720000 r--s 00000000 fe:00 131782 /usr/lib/x86_64-linux-gnu/libc.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a720000-7fc80a7b0000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a7bf000-7fc80a7c0000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a7c0000-7fc80a861000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a861000-7fc80a862000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a862000-7fc80a903000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a903000-7fc80a904000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a904000-7fc80a9a5000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a9a5000-7fc80a9a6000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80a9a6000-7fc80aa47000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80aa47000-7fc80aa48000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80aa48000-7fc80aae9000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80aae9000-7fc80aaea000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80aaea000-7fc80ab8b000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ab8b000-7fc80ab8c000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ab8c000-7fc80ac2d000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ac2d000-7fc80ac2e000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ac2e000-7fc80accf000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80accf000-7fc80acd0000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80acd0000-7fc80ad71000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ad71000-7fc80ad72000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ad72000-7fc80ae13000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ae13000-7fc80ae14000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ae14000-7fc80aeb5000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80aeb5000-7fc80aeb6000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80aeb6000-7fc80af57000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80af57000-7fc80af58000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80af58000-7fc80aff9000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80aff9000-7fc80affa000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80affa000-7fc80b09b000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b09b000-7fc80b09c000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b09c000-7fc80b13d000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b13d000-7fc80b13e000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b13e000-7fc80b1df000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b1df000-7fc80b1e0000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b1e0000-7fc80b281000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b281000-7fc80b282000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b282000-7fc80b323000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b323000-7fc80b324000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b324000-7fc80b3c5000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b3c5000-7fc80b3c6000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b3c6000-7fc80b467000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b467000-7fc80b468000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b468000-7fc80b509000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b509000-7fc80b50a000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b50a000-7fc80b5ab000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b5ab000-7fc80b5ac000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b5ac000-7fc80b64d000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b64d000-7fc80b64e000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b64e000-7fc80b6ef000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b6ef000-7fc80b6f0000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b6f0000-7fc80b791000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b791000-7fc80b792000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b792000-7fc80b833000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b833000-7fc80b834000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b834000-7fc80b8d5000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b8d5000-7fc80b8d6000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b8d6000-7fc80b977000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b977000-7fc80b978000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80b978000-7fc80ba19000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ba19000-7fc80ba1a000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ba1a000-7fc80babb000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80babb000-7fc80babc000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80babc000-7fc80bb5d000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80bb5d000-7fc80bb5e000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80bb5e000-7fc80bbff000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80bbff000-7fc80bc00000 ---p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80bc00000-7fc80e000000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e010000-7fc80e020000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e020000-7fc80e070000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e074000-7fc80e075000 r--p 00000000 fe:00 136223 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/trans/transdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e075000-7fc80e076000 r-xp 00001000 fe:00 136223 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/trans/transdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e076000-7fc80e077000 r--p 00002000 fe:00 136223 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/trans/transdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e077000-7fc80e078000 r--p 00002000 fe:00 136223 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/trans/transdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e078000-7fc80e079000 rw-p 00003000 fe:00 136223 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/trans/transdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e079000-7fc80e07a000 r--p 00000000 fe:00 136179 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/encdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e07a000-7fc80e07b000 r-xp 00001000 fe:00 136179 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/encdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e07b000-7fc80e07c000 r--p 00002000 fe:00 136179 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/encdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e07c000-7fc80e07d000 r--p 00002000 fe:00 136179 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/encdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e07d000-7fc80e07e000 rw-p 00003000 fe:00 136179 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/ruby/3.3.0/x86_64-linux/enc/encdb.so
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e07e000-7fc80e085000 r--s 00000000 fe:00 131755 /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e085000-7fc80e0dc000 r--p 00000000 fe:00 131399 /usr/lib/locale/C.utf8/LC_CTYPE
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e0dc000-7fc80e0de000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e0de000-7fc80e0e1000 r--p 00000000 fe:00 131804 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e0e1000-7fc80e0f8000 r-xp 00003000 fe:00 131804 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e0f8000-7fc80e0fc000 r--p 0001a000 fe:00 131804 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e0fc000-7fc80e0fd000 r--p 0001d000 fe:00 131804 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e0fd000-7fc80e0fe000 rw-p 0001e000 fe:00 131804 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e0fe000-7fc80e124000 r--p 00000000 fe:00 131782 /usr/lib/x86_64-linux-gnu/libc.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e124000-7fc80e279000 r-xp 00026000 fe:00 131782 /usr/lib/x86_64-linux-gnu/libc.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e279000-7fc80e2cc000 r--p 0017b000 fe:00 131782 /usr/lib/x86_64-linux-gnu/libc.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e2cc000-7fc80e2d0000 r--p 001ce000 fe:00 131782 /usr/lib/x86_64-linux-gnu/libc.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e2d0000-7fc80e2d2000 rw-p 001d2000 fe:00 131782 /usr/lib/x86_64-linux-gnu/libc.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e2d2000-7fc80e2e1000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e2e1000-7fc80e2f1000 r--p 00000000 fe:00 131821 /usr/lib/x86_64-linux-gnu/libm.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e2f1000-7fc80e364000 r-xp 00010000 fe:00 131821 /usr/lib/x86_64-linux-gnu/libm.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e364000-7fc80e3be000 r--p 00083000 fe:00 131821 /usr/lib/x86_64-linux-gnu/libm.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3be000-7fc80e3bf000 r--p 000dc000 fe:00 131821 /usr/lib/x86_64-linux-gnu/libm.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3bf000-7fc80e3c0000 rw-p 000dd000 fe:00 131821 /usr/lib/x86_64-linux-gnu/libm.so.6
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3c0000-7fc80e3c2000 r--p 00000000 fe:00 131791 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3c2000-7fc80e3d8000 r-xp 00002000 fe:00 131791 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3d8000-7fc80e3f2000 r--p 00018000 fe:00 131791 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3f2000-7fc80e3f3000 r--p 00031000 fe:00 131791 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3f3000-7fc80e3f4000 rw-p 00032000 fe:00 131791 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3f4000-7fc80e3fc000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3fc000-7fc80e3ff000 r--p 00000000 fe:00 134861 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libjemalloc.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e3ff000-7fc80e436000 r-xp 00003000 fe:00 134861 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libjemalloc.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e436000-7fc80e43e000 r--p 0003a000 fe:00 134861 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libjemalloc.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e43e000-7fc80e440000 r--p 00042000 fe:00 134861 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libjemalloc.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e440000-7fc80e441000 rw-p 00044000 fe:00 134861 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libjemalloc.so.1
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e441000-7fc80e442000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e442000-7fc80e445000 r--p 00000000 fe:00 131881 /usr/lib/x86_64-linux-gnu/libz.so.1.2.13
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e445000-7fc80e458000 r-xp 00003000 fe:00 131881 /usr/lib/x86_64-linux-gnu/libz.so.1.2.13
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e458000-7fc80e45f000 r--p 00016000 fe:00 131881 /usr/lib/x86_64-linux-gnu/libz.so.1.2.13
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e45f000-7fc80e460000 r--p 0001c000 fe:00 131881 /usr/lib/x86_64-linux-gnu/libz.so.1.2.13
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e460000-7fc80e461000 rw-p 0001d000 fe:00 131881 /usr/lib/x86_64-linux-gnu/libz.so.1.2.13
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e461000-7fc80e465000 r--s 00000000 fe:00 134645 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/bin/ruby
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e465000-7fc80e4b0000 r--p 00000000 fe:00 134864 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e4b0000-7fc80e89a000 r-xp 0004b000 fe:00 134864 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80e89a000-7fc80ea21000 r--p 00435000 fe:00 134864 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea21000-7fc80ea38000 r--p 005bb000 fe:00 134864 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea38000-7fc80ea3c000 rw-p 005d2000 fe:00 134864 /usr/lib/fullstaq-ruby/versions/3.3.0-jemalloc/lib/libruby.so.3.3.0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea3c000-7fc80ea53000 rw-p 00000000 00:00 0
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea53000-7fc80ea54000 r--p 00000000 fe:00 131764 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea54000-7fc80ea79000 r-xp 00001000 fe:00 131764 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea79000-7fc80ea83000 r--p 00026000 fe:00 131764 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea83000-7fc80ea85000 r--p 00030000 fe:00 131764 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7fc80ea85000-7fc80ea87000 rw-p 00032000 fe:00 131764 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7ffee523b000-7ffee5a3a000 rw-p 00000000 00:00 0 [stack]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7ffee5ba8000-7ffee5bac000 r--p 00000000 00:00 0 [vvar]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]7ffee5bac000-7ffee5bae000 r-xp 00000000 00:00 0 [vdso]
2024-03-09T09:31:08Z app[3d8d7d99f40128] iad [info]ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
</code></pre> Ruby master - Bug #20328 (Open): optparse omits the option's description in the --help output if ...https://bugs.ruby-lang.org/issues/203282024-03-07T22:03:25Zpostmodern (Hal Brodigan)postmodern.mod3@gmail.com
<p>If you define an option using <code>OptionParser#on</code>, but give the option's description as a multi-line Array, then the option's description is omitted from the <code>--help</code> output.</p>
<a name="Steps-To-Reproduce"></a>
<h2 >Steps To Reproduce<a href="#Steps-To-Reproduce" class="wiki-anchor">¶</a></h2>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1">#!/usr/bin/env ruby</span>
<span class="nb">require</span> <span class="s1">'optparse'</span>
<span class="n">optparser</span> <span class="o">=</span> <span class="no">OptionParser</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span> <span class="o">|</span><span class="n">opts</span><span class="o">|</span>
<span class="n">opts</span><span class="p">.</span><span class="nf">banner</span> <span class="o">=</span> <span class="s1">'usage: test.rb [options]'</span>
<span class="n">opts</span><span class="p">.</span><span class="nf">on</span><span class="p">(</span><span class="s1">'-o'</span><span class="p">,</span> <span class="s1">'--opt [OPT]'</span><span class="p">,</span> <span class="s1">'Line one'</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">opt</span><span class="o">|</span>
<span class="k">end</span>
<span class="n">opts</span><span class="p">.</span><span class="nf">on</span><span class="p">(</span><span class="s1">'-m'</span><span class="p">,</span> <span class="s1">'--multiline-opt'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'Line one'</span><span class="p">,</span> <span class="s1">'Line two'</span><span class="p">])</span> <span class="k">do</span> <span class="o">|</span><span class="nb">test</span><span class="o">|</span>
<span class="k">end</span>
<span class="n">opts</span><span class="p">.</span><span class="nf">on</span><span class="p">(</span><span class="s1">'-h'</span><span class="p">,</span> <span class="s1">'--help'</span><span class="p">,</span> <span class="s1">'Prints this help'</span><span class="p">)</span> <span class="k">do</span>
<span class="nb">puts</span> <span class="n">opts</span>
<span class="nb">exit</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">optparser</span><span class="p">.</span><span class="nf">parse</span><span class="p">([</span><span class="s1">'--help'</span><span class="p">])</span>
</code></pre>
<a name="Expected-result"></a>
<h3 >Expected result<a href="#Expected-result" class="wiki-anchor">¶</a></h3>
<pre><code>usage: test.rb [options]
-o, --opt [OPT] Line one
-m, --multiline-opt Line one
Line two
-h, --help Prints this help
</code></pre>
<a name="Actual-Result"></a>
<h3 >Actual Result<a href="#Actual-Result" class="wiki-anchor">¶</a></h3>
<pre><code>usage: test.rb [options]
-o, --opt [OPT] Line one
-m, --multiline-opt
-h, --help Prints this help
</code></pre>
<p>or an <code>ArgumentError</code> should be raised if Array descriptions are not allowed/supported.</p>
<a name="Version-Info"></a>
<h2 >Version Info<a href="#Version-Info" class="wiki-anchor">¶</a></h2>
<p>Tested against optparse 0.1.0, 0.2.0, 0.3.1, and the master branch.</p> Ruby master - Bug #20325 (Open): Enumerator.product.size bug with zero * infinite enumeratorshttps://bugs.ruby-lang.org/issues/203252024-03-05T15:21:08Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Enumerator</span><span class="p">.</span><span class="nf">product</span><span class="p">([],</span> <span class="mi">1</span><span class="o">..</span><span class="p">).</span><span class="nf">to_a</span> <span class="c1"># => [] (OK)</span>
<span class="no">Enumerator</span><span class="p">.</span><span class="nf">product</span><span class="p">([],</span> <span class="mi">1</span><span class="o">..</span><span class="p">).</span><span class="nf">size</span> <span class="c1"># => Infinity (Should be 0)</span>
</code></pre> Ruby master - Bug #20319 (Open): Singleton class is being frozen lazily in some caseshttps://bugs.ruby-lang.org/issues/203192024-03-01T11:52:12Zandrykonchin (Andrew Konchin)
<p>I've noticed suspicious behaviour (it doesn't affect anything in practice for me though) when an object becomes frozen only its own singleton class becomes frozen immediately.</p>
<p>A singleton class of the object immediate singleton class becomes frozen lazily after <code>#singleton_class</code> method call:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">o</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="n">klass</span> <span class="o">=</span> <span class="n">o</span><span class="p">.</span><span class="nf">singleton_class</span><span class="p">.</span><span class="nf">singleton_class</span>
<span class="n">o</span><span class="p">.</span><span class="nf">freeze</span>
<span class="nb">puts</span> <span class="n">klass</span><span class="p">.</span><span class="nf">frozen?</span> <span class="c1"># false <== here we expect true</span>
<span class="nb">puts</span> <span class="n">o</span><span class="p">.</span><span class="nf">singleton_class</span><span class="p">.</span><span class="nf">singleton_class</span><span class="p">.</span><span class="nf">frozen?</span> <span class="c1"># true</span>
<span class="nb">puts</span> <span class="n">klass</span><span class="p">.</span><span class="nf">frozen?</span> <span class="c1"># true</span>
</code></pre>
<p>I would expect all created (and visible to user) singleton classes in an object singleton classes chain to become frozen immediately when the object gets frozen.</p> Ruby master - Bug #20316 (Open): Regexp quantifier behavior changes in different syntactic context.https://bugs.ruby-lang.org/issues/203162024-02-29T17:21:18Zjirkamarsik (Jirka Marsik)
<p>In the example below, adding a vertical bar to the end of a regular expression changes what is being matched by the preceding regular expression.</p>
<pre><code>irb(main):001:0> /(|a){3}b/.match("aab")
=> #<MatchData "aab" 1:"">
irb(main):002:0> /(|a){3}b|/.match("aab")
=> #<MatchData "aab" 1:"a">
</code></pre>
<p>This is because the <code>{3}</code> quantifier is compiled into a <code>repeat</code> loop which uses the <code>OP_NULL_CHECK_END_MEMST</code> operation to perform a capture-group sensitive null-check after every loop iteration. The logic behind the <code>OP_NULL_CHECK_END_MEMST</code> operation is implemented using the <code>STACK_NULL_CHECK_MEMST</code> macro in <code>regexec.c</code>. The <code>STACK_NULL_CHECK_MEMST</code> macro checks whether any capture groups have been updated inside the last loop iteration and it does so by searching the stack for <code>STK_MEM_START</code> entries. However, such entries are not used for all capture groups. They are only used by capture groups which are listed in <code>bt_mem_start</code>. A capture group is marked as needing such bookkeeping only when it is either referenced by a back-reference or it appears in certain syntactic contexts (see e.g. around line 4096 of <code>regcomp.c</code>). This looks like an optimization that tries to avoid polluting the stack with <code>STK_MEM_START</code> entries in cases in which they are not needed. However, in this case, not putting <code>STK_MEM_START</code> entries on the stack leads to a different match result.</p>
<p>In the example above, by adding a vertical bar to the end of the regexp, we have placed the group <code>(|a)</code> inside an alternation. This means that a different operation for tracking the state of the capture group is emitted in the compiled bytecode and this leads to a different result. Incidentally, this result should be the correct result, as the null-check ends up respecting the state of capture groups, as it tries to do in Ruby.</p>
<p>This is the compilation and execution of <code>/(|a){3}b/.match("aab")</code> with ONIG_DEBUG_PARSE_TREE, ONIG_DEBUG_COMPILE and ONIG_DEBUG_MATCH. Note that <code>mem-start:1</code> is used for tracking the state of capture group 1.</p>
<pre><code>PATTERN: /(|a){3}b/ (US-ASCII)
<list:55db929991f0>
<quantifier:55db92999230>{3,3}
<enclose:55db92999330> memory:1
<alt:55db929991b0>
<string:55db929992f0>
<string:55db929992b0>a
<string:55db929993b0>b
optimize: EXACT
anchor: []
sub anchor: []
exact: [b]: length: 1
code length: 37
0:[repeat:0:27] 7:[null-check-start:0] 10:[mem-start:1] 13:[push:(+5)] 18:[jump:(+2)]
23:[exact1:a] 25:[mem-end:1] 28:[null-check-end-memst:0] 31:[repeat-inc:0] 34:[exact1:b]
36:[end]
match_at: str: 139809364021904 (0x7f27e77a9290), end: 139809364021906 (0x7f27e77a9292), start: 139809364021904 (0x7f27e77a9290), sprev: 0 ((nil))
size: 2, start offset: 0
ofs> str stk:type addr:opcode
0> "ab" 0:Alt 0:[repeat:0:27]
0> "ab" 1:Rep 7:[null-check-start:0]
0> "ab" 2:NulChS 10:[mem-start:1]
0> "ab" 2:NulChS 13:[push:(+5)]
0> "ab" 3:Alt 18:[jump:(+2)]
0> "ab" 3:Alt 25:[mem-end:1]
0> "ab" 3:Alt 28:[null-check-end-memst:0]
NULL_CHECK_END_MEMST: skip id:0, s:139809364021904 (0x7f27e77a9290)
0> "ab" 3:Alt 34:[exact1:b]
0> "ab" 2:NulChS 23:[exact1:a]
1> "b" 2:NulChS 25:[mem-end:1]
1> "b" 2:NulChS 28:[null-check-end-memst:0]
1> "b" 2:NulChS 31:[repeat-inc:0]
1> "b" 3:RepInc 7:[null-check-start:0]
1> "b" 4:NulChS 10:[mem-start:1]
1> "b" 4:NulChS 13:[push:(+5)]
1> "b" 5:Alt 18:[jump:(+2)]
1> "b" 5:Alt 25:[mem-end:1]
1> "b" 5:Alt 28:[null-check-end-memst:0]
NULL_CHECK_END_MEMST: skip id:0, s:139809364021905 (0x7f27e77a9291)
1> "b" 5:Alt 34:[exact1:b]
2> "" 5:Alt 36:[end]
</code></pre>
<p>This is the compilation and execution of <code>/(|a){3}b|/.match("aab")</code> (where the group <code>(|a)</code> appears inside an alternation) with ONIG_DEBUG_PARSE_TREE, ONIG_DEBUG_COMPILE and ONIG_DEBUG_MATCH. Note that <code>mem-start-push:1</code> is used for tracking the state of capture group 1, not <code>mem-start:1</code>.</p>
<pre><code>PATTERN: /(|a){3}b|/ (US-ASCII)
<alt:55d9a91cc3c0>
<list:55d9a91cc200>
<quantifier:55d9a91cc240>{3,3}
<enclose:55d9a91cc340> memory:1
<alt:55d9a91cc1c0>
<string:55d9a91cc300>
<string:55d9a91cc2c0>a
<string:55d9a91cc480>b
<string:55d9a91cc400>
optimize: NONE
anchor: []
code length: 47
0:[push:(+41)] 5:[repeat:0:27] 12:[null-check-start:0] 15:[mem-start-push:1] 18:[push:(+5)]
23:[jump:(+2)] 28:[exact1:a] 30:[mem-end:1] 33:[null-check-end-memst:0] 36:[repeat-inc:0]
39:[exact1:b] 41:[jump:(+0)] 46:[end]
match_at: str: 140072854131304 (0x7f6540b69268), end: 140072854131306 (0x7f6540b6926a), start: 140072854131304 (0x7f6540b69268), sprev: 0 ((nil))
size: 2, start offset: 0
ofs> str stk:type addr:opcode
0> "ab" 0:Alt 0:[push:(+41)]
0> "ab" 1:Alt 5:[repeat:0:27]
0> "ab" 2:Rep 12:[null-check-start:0]
0> "ab" 3:NulChS 15:[mem-start-push:1]
0> "ab" 4:MemS 18:[push:(+5)]
0> "ab" 5:Alt 23:[jump:(+2)]
0> "ab" 5:Alt 30:[mem-end:1]
0> "ab" 5:Alt 33:[null-check-end-memst:0]
0> "ab" 5:Alt 36:[repeat-inc:0]
0> "ab" 6:RepInc 12:[null-check-start:0]
0> "ab" 7:NulChS 15:[mem-start-push:1]
0> "ab" 8:MemS 18:[push:(+5)]
0> "ab" 9:Alt 23:[jump:(+2)]
0> "ab" 9:Alt 30:[mem-end:1]
0> "ab" 9:Alt 33:[null-check-end-memst:0]
NULL_CHECK_END_MEMST: skip id:0, s:140072854131304 (0x7f6540b69268)
0> "ab" 9:Alt 39:[exact1:b]
0> "ab" 8:MemS 28:[exact1:a]
1> "b" 8:MemS 30:[mem-end:1]
1> "b" 8:MemS 33:[null-check-end-memst:0]
1> "b" 8:MemS 36:[repeat-inc:0]
1> "b" 9:RepInc 12:[null-check-start:0]
1> "b" 10:NulChS 15:[mem-start-push:1]
1> "b" 11:MemS 18:[push:(+5)]
1> "b" 12:Alt 23:[jump:(+2)]
1> "b" 12:Alt 30:[mem-end:1]
1> "b" 12:Alt 33:[null-check-end-memst:0]
1> "b" 12:Alt 36:[repeat-inc:0]
1> "b" 13:RepInc 39:[exact1:b]
2> "" 13:RepInc 41:[jump:(+0)]
2> "" 13:RepInc 46:[end]
</code></pre> Ruby master - Bug #20315 (Open): Quantifier expansion leads to different results in Regexp.https://bugs.ruby-lang.org/issues/203152024-02-29T16:59:34Zjirkamarsik (Jirka Marsik)
<p>Consider the following series of regular expression matches:</p>
<pre><code>irb(main):001:0> /(|a)(|a)(|a)(|a)(|a)b/.match("aaaab")
=> #<MatchData "aaaab" 1:"" 2:"a" 3:"a" 4:"a" 5:"a">
irb(main):002:0> /(|a)(|a)(|a)(|a)b/.match("aaab")
=> #<MatchData "aaab" 1:"" 2:"a" 3:"a" 4:"a">
irb(main):003:0> /(|a)(|a)(|a)b/.match("aab")
=> #<MatchData "aab" 1:"" 2:"a" 3:"a">
irb(main):004:0> /(|a)(|a)b/.match("ab")
=> #<MatchData "ab" 1:"" 2:"a">
</code></pre>
<p>Let <code>X^{N}</code> mean <code>N</code> concatenated repetitions of <code>X</code>. When matching the pattern <code>/(|a)^{N}b/</code> against <code>a^{N-1}b</code>, the first group will match the empty string and the last <code>N-1</code> groups will match <code>a</code>.</p>
<p>Now, let's look at this series of similar expressions, in which <code>(|a)^{N}</code> is replaced with <code>(|a){N}</code>, i.e. a counted quantifier.</p>
<pre><code>irb(main):001:0> /(|a){5}b/.match("aaaab")
=> #<MatchData "aaaab" 1:"">
irb(main):002:0> /(|a){4}b/.match("aaab")
=> #<MatchData "aaab" 1:"">
irb(main):003:0> /(|a){3}b/.match("aab")
=> #<MatchData "aab" 1:"">
irb(main):004:0> /(|a){2}b/.match("ab")
=> #<MatchData "ab" 1:"a">
</code></pre>
<p>When matching the pattern <code>/(|a){N}b/</code> against <code>a^{N-1}b</code>, the first <code>N-1</code> iterations will match <code>a</code> and the <code>N</code>-th iteration will match the empty string (compare this with the behavior of the first series of expressions). However, something strange happens when <code>N</code> is 2. We end up getting a result which is not consistent with this series, but looks like a result that belongs to the first series discussed above.</p>
<p>This is due to quantifier expansion done by the regexp compiler (see usages of <code>QUANTIFIER_EXPAND_LIMIT_SIZE</code> in <code>regcomp.c</code>). This is an optimization that tries to remove the overhead of managing a counted repetition during regex execution at the cost of increasing the size of the compiled regex bytecode. The source of the inconsistency is caused by the fact that this optimization can actually change the semantics of the regular expression, because as we have seen above, <code>X^{N}</code> (<code>X</code> repeated <code>N</code> times) can have different semantics from <code>X{N}</code> (a single <code>X</code> with an <code>{N}</code> quantifier).</p>
<p>Compilation and execution of <code>/(|a){3}b/.match("aab")</code> with <code>ONIG_DEBUG_PARSE_TREE</code>, <code>ONIG_DEBUG_COMPILE</code> and <code>ONIG_DEBUG_MATCH</code>:</p>
<pre><code>PATTERN: /(|a){3}b/ (US-ASCII)
<list:556161bb11f0>
<quantifier:556161bb1230>{3,3}
<enclose:556161bb1330> memory:1
<alt:556161bb11b0>
<string:556161bb12f0>
<string:556161bb12b0>a
<string:556161bb13b0>b
optimize: EXACT
anchor: []
sub anchor: []
exact: [b]: length: 1
code length: 37
0:[repeat:0:27] 7:[null-check-start:0] 10:[mem-start:1] 13:[push:(+5)] 18:[jump:(+2)]
23:[exact1:a] 25:[mem-end:1] 28:[null-check-end-memst:0] 31:[repeat-inc:0] 34:[exact1:b]
36:[end]
match_at: str: 140607416406704 (0x7fe1b71b92b0), end: 140607416406706 (0x7fe1b71b92b2), start: 140607416406704 (0x7fe1b71b92b0), sprev: 0 ((nil))
size: 2, start offset: 0
ofs> str stk:type addr:opcode
0> "ab" 0:Alt 0:[repeat:0:27]
0> "ab" 1:Rep 7:[null-check-start:0]
0> "ab" 2:NulChS 10:[mem-start:1]
0> "ab" 2:NulChS 13:[push:(+5)]
0> "ab" 3:Alt 18:[jump:(+2)]
0> "ab" 3:Alt 25:[mem-end:1]
0> "ab" 3:Alt 28:[null-check-end-memst:0]
NULL_CHECK_END_MEMST: skip id:0, s:140607416406704 (0x7fe1b71b92b0)
0> "ab" 3:Alt 34:[exact1:b]
0> "ab" 2:NulChS 23:[exact1:a]
1> "b" 2:NulChS 25:[mem-end:1]
1> "b" 2:NulChS 28:[null-check-end-memst:0]
1> "b" 2:NulChS 31:[repeat-inc:0]
1> "b" 3:RepInc 7:[null-check-start:0]
1> "b" 4:NulChS 10:[mem-start:1]
1> "b" 4:NulChS 13:[push:(+5)]
1> "b" 5:Alt 18:[jump:(+2)]
1> "b" 5:Alt 25:[mem-end:1]
1> "b" 5:Alt 28:[null-check-end-memst:0]
NULL_CHECK_END_MEMST: skip id:0, s:140607416406705 (0x7fe1b71b92b1)
1> "b" 5:Alt 34:[exact1:b]
2> "" 5:Alt 36:[end]
</code></pre>
<p>Compilation and execution of <code>/(|a){2}b/.match("ab")</code> with <code>ONIG_DEBUG_PARSE_TREE</code>, <code>ONIG_DEBUG_COMPILE</code> and <code>ONIG_DEBUG_MATCH</code>:</p>
<pre><code>PATTERN: /(|a){2}b/ (US-ASCII)
<list:55bbc826c1f0>
<quantifier:55bbc826c230>{2,2}
<enclose:55bbc826c330> memory:1
<alt:55bbc826c1b0>
<string:55bbc826c2f0>
<string:55bbc826c2b0>a
<string:55bbc826c3b0>b
optimize: EXACT
anchor: []
sub anchor: []
exact: [b]: length: 1
code length: 39
0:[mem-start:1] 3:[push:(+5)] 8:[jump:(+2)] 13:[exact1:a] 15:[mem-end:1]
18:[mem-start:1] 21:[push:(+5)] 26:[jump:(+2)] 31:[exact1:a] 33:[mem-end:1]
36:[exact1:b] 38:[end]
match_at: str: 140139875963504 (0x7f74db869270), end: 140139875963506 (0x7f74db869272), start: 140139875963504 (0x7f74db869270), sprev: 0 ((nil))
size: 2, start offset: 0
ofs> str stk:type addr:opcode
0> "ab" 0:Alt 0:[mem-start:1]
0> "ab" 0:Alt 3:[push:(+5)]
0> "ab" 1:Alt 8:[jump:(+2)]
0> "ab" 1:Alt 15:[mem-end:1]
0> "ab" 1:Alt 18:[mem-start:1]
0> "ab" 1:Alt 21:[push:(+5)]
0> "ab" 2:Alt 26:[jump:(+2)]
0> "ab" 2:Alt 33:[mem-end:1]
0> "ab" 2:Alt 36:[exact1:b]
0> "ab" 1:Alt 31:[exact1:a]
1> "b" 1:Alt 33:[mem-end:1]
1> "b" 1:Alt 36:[exact1:b]
2> "" 1:Alt 38:[end]
</code></pre> Ruby master - Bug #20314 (Open): Simultaneous Timeout expires may raise an exception after the blockhttps://bugs.ruby-lang.org/issues/203142024-02-29T06:25:26Zmame (Yusuke Endoh)mame@ruby-lang.org
<p>Launchable reports <code>TestTimeout#test_nested_timeout</code> as a flaky test, and I reproduced it as follows.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s2">"timeout"</span>
<span class="k">class</span> <span class="nc">A</span> <span class="o"><</span> <span class="no">Exception</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">B</span> <span class="o"><</span> <span class="no">Exception</span>
<span class="k">end</span>
<span class="k">begin</span>
<span class="no">Timeout</span><span class="p">.</span><span class="nf">timeout</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="no">A</span><span class="p">)</span> <span class="k">do</span>
<span class="no">Timeout</span><span class="p">.</span><span class="nf">timeout</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="no">B</span><span class="p">)</span> <span class="k">do</span>
<span class="kp">nil</span> <span class="k">while</span> <span class="kp">true</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">rescue</span> <span class="no">A</span><span class="p">,</span> <span class="no">B</span>
<span class="nb">p</span> <span class="vg">$!</span> <span class="c1">#=> #<A: execution expired></span>
<span class="c1"># Exception B is raised after the above call returns</span>
<span class="c1">#=> test.rb:16:in `p': execution expired (B)</span>
<span class="nb">p</span> <span class="ss">:end</span> <span class="c1"># not reach</span>
<span class="k">end</span>
</code></pre>
<p>This is because the timer thread performs two consecutive <code>Thread#raise</code> to the target thread.</p>
<p>I have discussed this with <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/17">@ko1 (Koichi Sasada)</a> and have come up with three solutions.</p>
<a name="Solution-1"></a>
<h3 >Solution 1<a href="#Solution-1" class="wiki-anchor">¶</a></h3>
<p>When multiple nested Timeouts expire simultaneously, raise an exception for the outer-most Timeout and let the inner Timeouts expire without throwing an exception. In the above example, it would only raise A.</p>
<p>The problem with this approach is that if you are rescuing A in the inner block, it may never ends:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Timeout</span><span class="p">.</span><span class="nf">timeout</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="no">A</span><span class="p">)</span> <span class="k">do</span>
<span class="no">Timeout</span><span class="p">.</span><span class="nf">timeout</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="no">B</span><span class="p">)</span> <span class="k">do</span>
<span class="k">begin</span>
<span class="nb">sleep</span>
<span class="k">rescue</span> <span class="no">A</span>
<span class="nb">sleep</span> <span class="c1"># The exception A is caught. The inner Timeout is already expired, so the code (may) never end.</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>Note that, if A and B did not occur at the same time, it would raise B. This is a race condition.</p>
<a name="Solution-2"></a>
<h3 >Solution 2<a href="#Solution-2" class="wiki-anchor">¶</a></h3>
<p>When multiple nested Timeouts expire simultaneously, raise an exception for the inner-most Timeout and let the outer Timeouts wait until the inner-most Timeout returns. In the above example, it would raise either A or B, not both.</p>
<p>The problem with this approach is that if you are rescuing B in the inner block, it never ends:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Timeout</span><span class="p">.</span><span class="nf">timeout</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="no">A</span><span class="p">)</span> <span class="k">do</span>
<span class="no">Timeout</span><span class="p">.</span><span class="nf">timeout</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="no">B</span><span class="p">)</span> <span class="k">do</span>
<span class="k">begin</span>
<span class="nb">sleep</span>
<span class="k">rescue</span> <span class="no">B</span>
<span class="nb">sleep</span> <span class="c1"># The outer Timeout waits for the inner timeout, and the inner Timeout never return. So this code never ends.</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<a name="Solution-3"></a>
<h3 >Solution 3<a href="#Solution-3" class="wiki-anchor">¶</a></h3>
<p>Make thread interrupt queue one length. If the target thread has already been <code>Thread#raise(A)</code>, the new <code>Thread#raise(B)</code> blocks until the target thread processes A.</p>
<p>Since there will be no more simultaneous Thread#raise, there will be no more exceptions after the end of the block. The timeout timer thread should be changed in consideration that <code>Thread#raise</code> may block.</p> Ruby master - Bug #20301 (Open): `Set#add?` does two hash look-upshttps://bugs.ruby-lang.org/issues/203012024-02-26T02:42:35ZAMomchilov (Alexander Momchilov)
<p>A common usage of <code>Set</code>s is to keep track of seen objects, and do something different whenever an object is seen for the first time, e.g.:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">SEEN_VALUES</span> <span class="o">=</span> <span class="no">Set</span><span class="p">.</span><span class="nf">new</span>
<span class="k">def</span> <span class="nf">receive_value</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">if</span> <span class="no">SEEN_VALUES</span><span class="p">.</span><span class="nf">add?</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="nb">puts</span> <span class="s2">"Saw </span><span class="si">#{</span><span class="n">value</span><span class="si">}</span><span class="s2"> for the first time."</span>
<span class="k">else</span>
<span class="nb">puts</span> <span class="s2">"Already seen </span><span class="si">#{</span><span class="n">value</span><span class="si">}</span><span class="s2">, ignoring."</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">receive_value</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># Saw 1 for the first time.</span>
<span class="n">receive_value</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="c1"># Saw 2 for the first time.</span>
<span class="n">receive_value</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="c1"># Saw 3 for the first time.</span>
<span class="n">receive_value</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># Already seen 1, ignoring.</span>
</code></pre>
<p>Readers might reasonably assume that <code>add?</code> is only looking up into the set a single time, but it's actually doing two separate look-ups! (<a href="https://github.com/ruby/ruby/blob/c976cb5/lib/set.rb#L517-L525" class="external">source</a>)</p>
<pre><code class="rb syntaxhl" data-language="rb"><span class="k">class</span> <span class="nc">Set</span>
<span class="k">def</span> <span class="nf">add?</span><span class="p">(</span><span class="n">o</span>
<span class="c1"># 1. `include?(o)` looks up into `@hash`</span>
<span class="c1"># 2. if the value isn't there, `add(o)` does a second look-up into `@hash`</span>
<span class="n">add</span><span class="p">(</span><span class="n">o</span><span class="p">)</span> <span class="k">unless</span> <span class="kp">include</span><span class="p">?(</span><span class="n">o</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>This gets especially expensive if the values are large hash/arrays/objects, whose <code>#hash</code> is expensive to compute.</p>
<p>We can optimize this if it was possible to set a value in hash, <em>and</em> retrieve the value that was already there, in a single go. I propose adding <code>Hash#exchange_value</code> to do exactly that. If that existed, we can re-implement <code>#add?</code> as:</p>
<pre><code class="rb syntaxhl" data-language="rb"><span class="k">class</span> <span class="nc">Set</span>
<span class="k">def</span> <span class="nf">add?</span><span class="p">(</span><span class="n">o</span><span class="p">)</span>
<span class="c1"># Only requires a single look-up into `@hash`!</span>
<span class="nb">self</span> <span class="k">unless</span> <span class="vi">@hash</span><span class="p">.</span><span class="nf">exchange_value</span><span class="p">(</span><span class="n">o</span><span class="p">,</span> <span class="kp">true</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<p>Here's a proof-of-concept implementation: <a href="https://github.com/ruby/ruby/pull/10093" class="external">https://github.com/ruby/ruby/pull/10093</a></p>
<a name="Theory"></a>
<h1 >Theory<a href="#Theory" class="wiki-anchor">¶</a></h1>
<p>How much of a benefit this has depends on 2 factors:</p>
<ol>
<li>How much <code>#hash</code> is called, which depends on how many <strong>new</strong> objects are added to the set.
<ul>
<li>If every object is new, then <code>#hash</code> used to be called twice on every <code>#add?</code>.
<ul>
<li>This is where this improvement makes the biggest (2x!) change.</li>
</ul>
</li>
<li>If every object has already been seen, then <code>#hash</code> was never being called twice before anyway, so there would be no improvement.
<ul>
<li>It's important to not regress in this case, because many use cases of sets don't deal with many distinct objects, but just need to do quick checks against an existing set.</li>
</ul>
</li>
<li>Every other case lies somewhere in between those two, depending on the % of objects which are new.</li>
</ul>
</li>
<li>How slow <code>#hash</code> is to compute for the key
<ul>
<li>If the hash is slow to compute, this change will make a bigger improvement</li>
<li>If the hash value is fast to compute, then it won't matter as much. Even if we called it half as much, it's a minority of the total time, so it won't have much net impact.</li>
</ul>
</li>
</ol>
<a name="Benchmark-summary"></a>
<h1 >Benchmark summary<a href="#Benchmark-summary" class="wiki-anchor">¶</a></h1>
<table>
<thead>
<tr>
<th></th>
<th align="right">All objects are new</th>
<th align="right">All objects are preexisting</th>
</tr>
</thead>
<tbody>
<tr>
<td>objects with slow <code>#hash</code>
</td>
<td align="right">100.0%</td>
<td align="right">~0.0%</td>
</tr>
<tr>
<td>objects with fast <code>#hash</code>
</td>
<td align="right">24.5%</td>
<td align="right">4.6%</td>
</tr>
</tbody>
</table>
<p>As we see, this change makes a huge improvement the cases where it helps, and crucially, doesn't slow down the cases where it can't.</p>
<p>For the complete benchmark source code and results, see the PR: <a href="https://github.com/ruby/ruby/pull/10093" class="external">https://github.com/ruby/ruby/pull/10093</a></p> Ruby master - Bug #20299 (Open): Tracepoint staying enable after a disablehttps://bugs.ruby-lang.org/issues/202992024-02-26T01:06:28ZMaxLap (Maxime Lapointe)hunter_spawn@hotmail.com
<p>Problem is present in Ruby 3.2.2, 3.2.3, 3.3.0. Didn't check before.</p>
<p>It seems that TracePoint can sometime be "stuck" enabled after using disabled once on it.</p>
<p>Here is a reproduction step using a "check speed" method that just does some work and print out how long it takes. This makes it pretty clear when TracePoint was on.</p>
<p>Put this in a Ruby file:</p>
<pre><code>def check_speed(msg)
t1 = Time.now.to_f
a = 0
1000000.times { |i|
a += 10
}
t2 = Time.now.to_f
puts "#{t2-t1} - #{msg}"
end
check_speed("before") # fast
trace = TracePoint.new(:line) {}
trace.enable
check_speed("after enable") # slow
trace.enable {
check_speed("in block enable") # slow
}
check_speed("after block enable") # slow
trace.disable
check_speed("after disable") # slow !!!!
trace.disable
check_speed("after disable again") # fast !!!!
# And yet, using enable multiple time doesn't have a "counter" or similar
trace.enable
trace.enable
trace.enable
check_speed("after triple enable") # slow
trace.disable
check_speed("after single disable") # fast
</code></pre>
<p>Running the file, we get this:</p>
<pre><code>$ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
$ ruby local.rb
0.03473854064941406 - before
0.18935227394104004 - after enable
0.17757630348205566 - in block enable
0.18320131301879883 - after block enable
0.1818866729736328 - after disable
0.03412747383117676 - after disable again
0.18405628204345703 - after triple enable
0.033496856689453125 - after single disable
</code></pre>
<p>The first "after disable" should probably have been fast. If it's possible to have multiple nested enable/disable, then one would instead assume that after the last "single disable", things would still be slow.</p>
<p>Note: This code patterns comes directly for a ruby/spec: ctrl+f for "enables trace object on calling with a block if it was already enabled"</p>
<p>I note that in Ruby 3.2, the timing are a lot less similar. I don't know why. It would seem like TracePoint got slower in Ruby 3.3.0. Is that worth checking out / making a distincct bug for?</p>
<pre><code>$ rvm use 3.2.3
Using /home/max/.rvm/gems/ruby-3.2.3
$ ruby local.rb
0.03246927261352539 - before
0.07910513877868652 - after enable
0.10309600830078125 - in block enable
0.12397646903991699 - after block enable
0.07114601135253906 - after disable
0.028218746185302734 - after disable again
0.12534689903259277 - after triple enable
0.02810525894165039 - after single disable
</code></pre> Ruby master - Bug #20294 (Open): Parser no longer warns on some duplicated keyshttps://bugs.ruby-lang.org/issues/202942024-02-22T14:09:39Zkddnewton (Kevin Newton)kddnewton@gmail.com
<p>Previously, the parser would warn on all duplicated keys. Now some cases are not handled:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">{</span> <span class="mf">100.0</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> <span class="mf">1e2</span> <span class="o">=></span> <span class="mi">1</span> <span class="p">}</span>
<span class="p">{</span> <span class="mf">100.0</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> <span class="mf">1E2</span> <span class="o">=></span> <span class="mi">1</span> <span class="p">}</span>
<span class="p">{</span> <span class="mf">100.0</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> <span class="mf">100.00</span> <span class="o">=></span> <span class="mi">1</span> <span class="p">}</span>
<span class="p">{</span> <span class="mf">100.0</span><span class="n">r</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> <span class="mf">100.00</span><span class="n">r</span> <span class="o">=></span> <span class="mi">1</span> <span class="p">}</span>
<span class="p">{</span> <span class="mf">100.0</span><span class="n">i</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> <span class="mf">100.00</span><span class="n">i</span> <span class="o">=></span> <span class="mi">1</span> <span class="p">}</span>
</code></pre> Ruby master - Bug #20285 (Assigned): Stale inline method caches when refinement modules are reopenedhttps://bugs.ruby-lang.org/issues/202852024-02-21T02:44:55Zjhawthorn (John Hawthorn)
<p>This is essentially the same issue as <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: refinement (Closed)" href="https://bugs.ruby-lang.org/issues/11672">#11672</a>, but for inline method caches rather than class caches.</p>
<p>In Ruby 3.3 we started using inline caches for refinements. However, we weren't clearing inline caches when defined on a reopened refinement module.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">C</span>
<span class="k">end</span>
<span class="k">module</span> <span class="nn">R</span>
<span class="n">refine</span> <span class="no">C</span> <span class="k">do</span>
<span class="k">def</span> <span class="nf">m</span>
<span class="ss">:foo</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">using</span> <span class="no">R</span>
<span class="k">def</span> <span class="nf">m</span>
<span class="no">C</span><span class="p">.</span><span class="nf">new</span><span class="p">.</span><span class="nf">m</span>
<span class="k">end</span>
<span class="k">raise</span> <span class="k">unless</span> <span class="ss">:foo</span> <span class="o">==</span> <span class="n">m</span><span class="p">()</span>
<span class="k">module</span> <span class="nn">R</span>
<span class="n">refine</span> <span class="no">C</span> <span class="k">do</span>
<span class="k">alias</span> <span class="n">m</span> <span class="n">m</span>
<span class="k">def</span> <span class="nf">m</span>
<span class="ss">:bar</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">v</span> <span class="o">=</span> <span class="n">m</span><span class="p">()</span>
<span class="k">raise</span> <span class="s2">"expected :bar, got </span><span class="si">#{</span><span class="n">v</span><span class="p">.</span><span class="nf">inspect</span><span class="si">}</span><span class="s2">"</span> <span class="k">unless</span> <span class="ss">:bar</span> <span class="o">==</span> <span class="n">v</span>
</code></pre>
<p>This will raise in Ruby 3.3 as the inline cache finds a stale refinement, but passes in previous versions.</p> Ruby master - Bug #20283 (Open): Build failed since Ruby 3.2.3 if Xcode.app was renamed to space ...https://bugs.ruby-lang.org/issues/202832024-02-20T06:41:28Zwatson1978 (Shizuo Fujita)watson1978@gmail.com
<p>When I renamed Xcode.app to space contained name (like <code>Xcode 15.2.0.app</code>), then I met build error with Ruby 3.2.3 and Ruby 3.3.0.<br>
(Ruby 3.2.2 can be built with successfully.)</p>
<a name="How-to-reproduce"></a>
<h2 >How to reproduce<a href="#How-to-reproduce" class="wiki-anchor">¶</a></h2>
<pre><code>$ sudo mv /Applications/Xcode.app '/Applications/Xcode 15.2.app'
$ sudo xcode-select --switch '/Applications/Xcode 15.2.app'
$ tar xzf ruby-3.2.3.tar.xz
$ cd ruby-3.2.3
$ ./configure
$ make V=1
:
clang -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE -I. -I.ext/include/arm64-darwin23 -I./include -I. -I./enc/unicode/15.0.0 -I/opt/homebrew/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -o dmyenc.o -c dmyenc.c
rustc --crate-name=yjit --crate-type=staticlib --edition=2021 -g -C opt-level=3 -C overflow-checks=on '--out-dir=/Users/watson/prj/ruby-3.2.3/yjit/target/release/' ./yjit/src/lib.rs
touch yjit/target/release/libyjit.a
clang -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef -pipe -L. -L/opt/homebrew/lib -fstack-protector-strong -fstack-protector-strong -Wl,-pie -framework CoreFoundation main.o dmydln.o miniinit.o dmyext.o array.o ast.o bignum.o class.o compar.o compile.o complex.o cont.o debug.o debug_counter.o dir.o dln_find.o encoding.o enum.o enumerator.o error.o eval.o file.o gc.o hash.o inits.o io.o io_buffer.o iseq.o load.o marshal.o math.o memory_view.o mjit.o mjit_c.o node.o numeric.o object.o pack.o parse.o proc.o process.o ractor.o random.o range.o rational.o re.o regcomp.o regenc.o regerror.o regexec.o regparse.o regsyntax.o ruby.o scheduler.o shape.o signal.o sprintf.o st.o strftime.o string.o struct.o symbol.o thread.o time.o transcode.o transient_heap.o util.o variable.o version.o vm.o vm_backtrace.o vm_dump.o vm_sync.o vm_trace.o yjit.o coroutine/arm64/Context.o enc/ascii.o enc/us_ascii.o enc/unicode.o enc/utf_8.o enc/trans/newline.o explicit_bzero.o setproctitle.o addr2line.o yjit/target/release/libyjit.a -lgmp -ldl -lobjc -lpthread -lpthread -o miniruby
ld: warning: ignoring duplicate libraries: '-lpthread'
ld: Undefined symbols:
_coroutine_transfer, referenced from:
_fiber_setcontext in cont.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre>
<a name="Environment"></a>
<h2 >Environment<a href="#Environment" class="wiki-anchor">¶</a></h2>
<ul>
<li>Apple M1 Max</li>
<li>macOS 14.3.1</li>
<li>clang 15.0.0 (clang-1500.1.0.2.5)</li>
<li>rustc 1.75.0</li>
</ul>
<a name="Note"></a>
<h2 >Note<a href="#Note" class="wiki-anchor">¶</a></h2>
<p>This problem occurs on Intel Mac and Apple M1 Mac both.</p> Ruby master - Bug #20271 (Open): Issue with moving embedded string across ractorshttps://bugs.ruby-lang.org/issues/202712024-02-16T16:29:35Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>When embedded strings are moved, not all the embedded bytes are copied over to the new embedded string. This shows itself when<br>
an embedded string has more than 16 characters.</p>
<p>For example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span>
<span class="n">foo</span> <span class="o">=</span> <span class="n">receive</span>
<span class="nb">puts</span> <span class="n">foo</span>
<span class="n">foo</span>
<span class="p">}</span>
<span class="n">obj</span> <span class="o">=</span> <span class="s2">"12345678"</span> <span class="o">*</span> <span class="mi">3</span>
<span class="nb">puts</span> <span class="n">obj</span>
<span class="n">r</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="ss">move: </span><span class="kp">true</span><span class="p">)</span>
<span class="n">r</span><span class="p">.</span><span class="nf">take</span>
</code></pre>
<pre><code>123456781234567812345678
1234567812345678
</code></pre> Ruby master - Bug #20269 (Open): bignum too big to convert into `long' when running String#bytesl...https://bugs.ruby-lang.org/issues/202692024-02-15T16:22:39Zsimpliandy (Andy Pfister)andy.pfister@simplificator.com
<p>Running <code>String#byteslice</code> on Ruby 3.3 on Windows results in an error when using any number bigger than 32 bits:</p>
<pre><code>"".byteslice(0, 2547483647)
(irb):1:in `byteslice': bignum too big to convert into `long' (RangeError)
from (irb):1:in `<main>'
from <internal:kernel>:187:in `loop'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/irb-1.11.0/exe/irb:9:in `<top (required)>'
from C:/Ruby33-x64/bin/irb:33:in `load'
from C:/Ruby33-x64/bin/irb:33:in `<main>'
</code></pre>
<p>It works fine on MacOS:</p>
<pre><code>irb(main):001> "".byteslice(0, 2547483647)
=> ""
irb(main):002> exit
Andys-MBP:project apf$ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]
</code></pre> Ruby master - Bug #20267 (Open): Hashes that use ar_table aren't moved properly across ractorshttps://bugs.ruby-lang.org/issues/202672024-02-15T15:56:49Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>This crashes in debug build and gives weird results in non debug build, because the ar_table values aren't copied over to the new "embedded" hash during a move across ractors.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span>
<span class="nb">hash</span> <span class="o">=</span> <span class="n">receive</span>
<span class="nb">puts</span> <span class="nb">hash</span>
<span class="p">}</span>
<span class="n">obj</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">"1"</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span>
<span class="s2">"2"</span> <span class="o">=></span> <span class="mi">2</span><span class="p">,</span>
<span class="s2">"3"</span> <span class="o">=></span> <span class="mi">3</span><span class="p">,</span>
<span class="p">}</span>
<span class="nb">puts</span> <span class="n">obj</span>
<span class="n">r</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="ss">move: </span><span class="kp">true</span><span class="p">)</span>
<span class="n">r</span><span class="p">.</span><span class="nf">take</span>
</code></pre>
<p>Crash log:</p>
<pre><code>/home/lukeg/workspace/ruby-build/miniruby(sigsegv+0x4d) [0x5641e67d105d] ../ruby/signal.c:926
/lib/x86_64-linux-gnu/libc.so.6(0x7fb4baa42520) [0x7fb4baa42520]
/home/lukeg/workspace/ruby-build/miniruby(RB_BUILTIN_TYPE+0x0) [0x5641e6778db0] ../ruby/ractor.c:3128
/home/lukeg/workspace/ruby-build/miniruby(rbimpl_RB_TYPE_P_fastpath) ../ruby/include/ruby/internal/value_type.h:351
/home/lukeg/workspace/ruby-build/miniruby(RB_TYPE_P) ../ruby/include/ruby/internal/value_type.h:378
/home/lukeg/workspace/ruby-build/miniruby(RB_FL_ABLE) ../ruby/include/ruby/internal/fl_type.h:449
/home/lukeg/workspace/ruby-build/miniruby(RB_FL_TEST_RAW) ../ruby/include/ruby/internal/fl_type.h:471
/home/lukeg/workspace/ruby-build/miniruby(rb_ractor_shareable_p) ../ruby/include/ruby/ractor.h:256
/home/lukeg/workspace/ruby-build/miniruby(reset_belonging_enter) ../ruby/ractor.c:3121
</code></pre> Ruby master - Bug #20262 (Open): Regex mismatch between Ruby 3.2.2 and 3.3.0https://bugs.ruby-lang.org/issues/202622024-02-13T06:28:11Zweilandia (Nick Weiland)
<p>This might be a duplicate of <a href="https://bugs.ruby-lang.org/issues/20098" class="external">https://bugs.ruby-lang.org/issues/20098</a>, but I cannot make it match with the backref so maybe not.</p>
<p>Below example matches in 3.2.2 but not in 3.3.0</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">str</span> <span class="o">=</span> <span class="s2">"------------abcdefg------------#3895912"</span>
<span class="n">re</span> <span class="o">=</span> <span class="sr">/()\1\b\w*[a-zA-Z-]*\d+[\w-]{3,}\w+\b/</span>
<span class="n">re</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="n">str</span><span class="p">)</span>
</code></pre> Ruby master - Bug #20255 (Open): Embedded arrays aren't moved correctly across ractorshttps://bugs.ruby-lang.org/issues/202552024-02-10T17:31:30Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p><code>ractor.send(ary, move: true)</code> works incorrectly because if <code>ary</code> is embedded, the new moved object doesn't populate its own embedded space, it uses the MovedObject's embedded space.</p>
<p>example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span>
<span class="n">inner_ary</span> <span class="o">=</span> <span class="n">receive</span>
<span class="n">values</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">values</span><span class="p">[</span><span class="ss">:equal</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">inner_ary</span> <span class="o">==</span> <span class="p">[</span><span class="s2">""</span><span class="p">,{},</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">])</span>
<span class="n">values</span><span class="p">[</span><span class="ss">:string</span><span class="p">]</span> <span class="o">=</span> <span class="n">inner_ary</span><span class="p">.</span><span class="nf">to_s</span>
<span class="n">values</span>
<span class="p">}</span>
<span class="n">ary</span> <span class="o">=</span> <span class="p">[</span><span class="no">String</span><span class="p">.</span><span class="nf">new</span><span class="p">,</span><span class="no">Hash</span><span class="p">.</span><span class="nf">new</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">]</span>
<span class="n">r</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="n">ary</span><span class="p">,</span> <span class="ss">move: </span><span class="kp">true</span><span class="p">)</span>
<span class="n">r_values</span> <span class="o">=</span> <span class="n">r</span><span class="p">.</span><span class="nf">take</span>
<span class="nb">p</span> <span class="n">r_values</span><span class="p">[</span><span class="ss">:equal</span><span class="p">]</span>
<span class="nb">p</span> <span class="n">r_values</span><span class="p">[</span><span class="ss">:string</span><span class="p">]</span>
<span class="c1"># => false</span>
<span class="c1"># => "[\"\", {}, 2, 2.0, 21747991570, String, 3]"</span>
</code></pre> Ruby master - Bug #20243 (Open): M:N threading VM_ASSERT failure in rb_current_execution_context ...https://bugs.ruby-lang.org/issues/202432024-02-07T09:18:09Zkjtsanaktsidis (KJ Tsanaktsidis)kjtsanaktsidis@gmail.com
<p>When building with Clang 17 and <code>-DVM_CHECK_MODE=1</code> (with the following configure)</p>
<pre><code>optflags="-ggdb3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -O3" cflags="-DVM_CHECK_MODE=1" CC=clang ../configure --prefix=/home/kj/ruby/installed --enable-yjit=dev --disable-install-doc
</code></pre>
<p>And then running the following script with the built <code>./miniruby</code> (which is actually from <code>bootstraptest/test_ractor.rb</code>):</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">counts</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">counts</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">count</span>
<span class="n">ractors</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">3</span><span class="p">).</span><span class="nf">map</span> <span class="p">{</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">receive</span> <span class="p">}</span> <span class="p">}</span>
<span class="n">counts</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">count</span>
<span class="n">ractors</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nf">send</span><span class="p">(</span><span class="s1">'End 0'</span><span class="p">).</span><span class="nf">take</span>
<span class="nb">sleep</span> <span class="mf">0.1</span> <span class="k">until</span> <span class="n">ractors</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nf">inspect</span> <span class="o">=~</span> <span class="sr">/terminated/</span>
<span class="n">counts</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">count</span>
<span class="n">ractors</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nf">send</span><span class="p">(</span><span class="s1">'End 1'</span><span class="p">).</span><span class="nf">take</span>
<span class="nb">sleep</span> <span class="mf">0.1</span> <span class="k">until</span> <span class="n">ractors</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nf">inspect</span> <span class="o">=~</span> <span class="sr">/terminated/</span>
<span class="n">counts</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">count</span>
<span class="n">ractors</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="nf">send</span><span class="p">(</span><span class="s1">'End 2'</span><span class="p">).</span><span class="nf">take</span>
<span class="nb">sleep</span> <span class="mf">0.1</span> <span class="k">until</span> <span class="n">ractors</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="nf">inspect</span> <span class="o">=~</span> <span class="sr">/terminated/</span>
<span class="n">counts</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">count</span>
<span class="n">counts</span><span class="p">.</span><span class="nf">inspect</span>
</code></pre>
<p>I get the following crash:</p>
<pre><code>Assertion Failed: ../vm_core.h:1957:rb_current_execution_context:ec == rb_current_ec_noinline()
ruby 3.4.0dev (2024-02-07T07:52:06Z ktsanaktsidis/igno.. 5cc6d944c2) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0003 p:0003 s:0010 e:000009 METHOD <internal:ractor>:431
c:0002 p:0004 s:0006 e:000005 BLOCK ractor_crash.rb:3 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
ractor_crash.rb:3:in `block (2 levels) in <main>'
<internal:ractor>:431:in `receive'
-- Threading information ---------------------------------------------------
Total ractor count: 2
Ruby thread count for this ractor: 1
-- C level backtrace information -------------------------------------------
/home/kj/ruby/build/miniruby(rb_print_backtrace+0x14) [0x55faa97a4ebd] ../vm_dump.c:820
/home/kj/ruby/build/miniruby(rb_vm_bugreport) ../vm_dump.c:1151
/home/kj/ruby/build/miniruby(rb_assert_failure+0x81) [0x55faa94d2719] ../error.c:1131
./miniruby(thread_sched_wait_running_turn+0x2e9) [0x55faa9726f59]
/home/kj/ruby/build/miniruby(rb_ractor_sched_sleep+0x10b) [0x55faa972687b] ../thread_pthread.c:1348
/home/kj/ruby/build/miniruby(ractor_check_ints+0x0) [0x55faa968b328] ../ractor.c:683
/home/kj/ruby/build/miniruby(ractor_sleep_with_cleanup) ../ractor.c:684
/home/kj/ruby/build/miniruby(ractor_sleep+0x15) [0x55faa968adf4] ../ractor.c:701
/home/kj/ruby/build/miniruby(ractor_wait_receive) ../ractor.c:748
/home/kj/ruby/build/miniruby(ractor_receive+0x1f) [0x55faa968768e] ../ractor.c:762
/home/kj/ruby/build/miniruby(builtin_inline_class_431) ../ractor.rb:432
/home/kj/ruby/build/miniruby(builtin_invoker0+0x6) [0x55faa978fc66] ../vm_insnhelper.c:6746
/home/kj/ruby/build/miniruby(invoke_bf+0x39) [0x55faa979816e] ../vm_insnhelper.c:6886
/home/kj/ruby/build/miniruby(vm_invoke_builtin_delegate) ../vm_insnhelper.c:6909
/home/kj/ruby/build/miniruby(rb_vm_check_ints+0x0) [0x55faa9771fac] ../insns.def:1533
/home/kj/ruby/build/miniruby(vm_pop_frame) ../vm_insnhelper.c:419
/home/kj/ruby/build/miniruby(vm_exec_core) ../insns.def:1537
/home/kj/ruby/build/miniruby(vm_exec_loop+0x0) [0x55faa9767f02] ../vm.c:2489
/home/kj/ruby/build/miniruby(rb_vm_exec) ../vm.c:2492
/home/kj/ruby/build/miniruby(invoke_block+0x6f) [0x55faa9781a58] ../vm.c:1512
/home/kj/ruby/build/miniruby(invoke_iseq_block_from_c) ../vm.c:1582
/home/kj/ruby/build/miniruby(invoke_block_from_c_proc) ../vm.c:1680
/home/kj/ruby/build/miniruby(vm_invoke_proc) ../vm.c:1710
/home/kj/ruby/build/miniruby(rb_vm_invoke_proc_with_self+0x5a) [0x55faa9781eaa] ../vm.c:1745
/home/kj/ruby/build/miniruby(thread_do_start_proc+0x199) [0x55faa9739e19] ../thread.c:574
/home/kj/ruby/build/miniruby(thread_do_start+0x6c) [0x55faa973933f] ../thread.c:618
/home/kj/ruby/build/miniruby(thread_start_func_2) ../thread.c:668
/home/kj/ruby/build/miniruby(rb_native_mutex_lock+0x0) [0x55faa973a141] ../thread_pthread.c:2234
/home/kj/ruby/build/miniruby(thread_sched_lock_) ../thread_pthread.c:387
/home/kj/ruby/build/miniruby(call_thread_start_func_2) ../thread_pthread_mn.c:436
/home/kj/ruby/build/miniruby(co_start) ../thread_pthread_mn.c:434
</code></pre>
<p>The failing assertion is this one in vm_core.h: <a href="https://github.com/ruby/ruby/blob/42c36269403baac67b0d5dc1d6d6e31168cf6a1f/vm_core.h#L1957" class="external">https://github.com/ruby/ruby/blob/42c36269403baac67b0d5dc1d6d6e31168cf6a1f/vm_core.h#L1957</a>. It actually has a very helpful comment.</p>
<pre><code> /* On the shared objects, `__tls_get_addr()` is used to access the TLS
* and the address of the `ruby_current_ec` can be stored on a function
* frame. However, this address can be mis-used after native thread
* migration of a coroutine.
* 1) Get `ptr =&ruby_current_ec` op NT1 and store it on the frame.
* 2) Context switch and resume it on the NT2.
* 3) `ptr` is used on NT2 but it accesses to the TLS on NT1.
* This assertion checks such misusage.
*
* To avoid accidents, `GET_EC()` should be called once on the frame.
* Note that inlining can produce the problem.
*/
VM_ASSERT(ec == rb_current_ec_noinline());
</code></pre>
<p>What seems to be happening is exactly that. This is a disassembly of the relevant bits of <code>thread_sched_wait_running_turn</code>:</p>
<pre><code>........
# This is the only bits of the entire function which access the TLS base register %fs.
# It seems to have spilled the value of ruby_current_ec into %r13.
0x000055603d2e1cf8 <+136>: mov $0xffffffffffffff90,%rax
0x000055603d2e1cff <+143>: mov %fs:0x0,%r12
0x000055603d2e1d08 <+152>: add %rax,%r12
0x000055603d2e1d0b <+155>: mov %fs:(%rax),%r13
........
# There's a call to coroutine_transfer, so after this point we're returned to on a
# different thread
0x000055603d2e1e90 <+544>: call 0x55603d7fce84 <coroutine_transfer>
# But nothing ever loads the address of ruby_current_ec from %fs again (i didn't trace
# exactly the data flow from %r13 at 0x000055603d2e1d0b to here, but i assume it spilled
# somewhere and now got loaded back into %r15 here). In any case, that means %r15 here
# contains the value of ruby_current_ec from the _old_ thread, not the current one.
0x000055603d2e1e95 <+549>: mov %rbx,0x28(%r14)
0x000055603d2e1e99 <+553>: mov (%r12),%r15
0x000055603d2e1e9d <+557>: call 0x55603d33a010 <rb_current_ec_noinline>
0x000055603d2e1ea2 <+562>: cmp %rax,%r15
=> 0x000055603d2e1ea5 <+565>: jne 0x55603d2e1f3a <thread_sched_wait_running_turn+714>
........
# assertion failure code path.
0x000055603d2e1f3a <+714>: lea 0x542c0c(%rip),%rdi # 0x55603d824b4d
0x000055603d2e1f41 <+721>: lea 0x542c12(%rip),%rdx # 0x55603d824b5a
0x000055603d2e1f48 <+728>: lea 0x542c28(%rip),%rcx # 0x55603d824b77
0x000055603d2e1f4f <+735>: mov $0x7a5,%esi
0x000055603d2e1f54 <+740>: call 0x55603d08d698 <rb_assert_failure>
</code></pre>
<p>if we look at the register values from <code>0x000055603d2e1ea2</code>:</p>
<pre><code>(rr) print/x $rax
$2 = 0x55603e159ad0
(rr) print/x $r15
$3 = 0x0
</code></pre>
<p>So the value from <code>%rax</code> which came from <code>ruby_current_ec_noinline</code> is correctly the value of <code>ruby_current_ec</code> for this thread, and <code>%r15</code> contains a stale value from a previous thread.</p>
<ul>
<li>
</ul>
<p>Now, what can we <em>do</em> about this, is a different question :/ There's a really good stackoverflow answer about it here: <a href="https://stackoverflow.com/questions/75592038/how-to-disable-clang-expression-elimination-for-thread-local-variable" class="external">https://stackoverflow.com/questions/75592038/how-to-disable-clang-expression-elimination-for-thread-local-variable</a>, but to summarise</p>
<ul>
<li>longstanding GCC and Clang bugs for this exist and have been marked as WONTFIX (<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26461" class="external">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26461</a>, <a href="https://github.com/llvm/llvm-project/issues/19551" class="external">https://github.com/llvm/llvm-project/issues/19551</a>)</li>
<li>It's even worse than this EC problem - things like <code>errno</code> also might be incorrectly persisted across coroutine switches (so e.g. an inlined C library function could in theory set <code>errno</code> in another thread, for example)</li>
<li>C++ actually has coroutines now, so this <em>must</em> work for those. Clang at least has fixed some TLS problems in their C++ coroutine implementation (<a href="https://github.com/llvm/llvm-project/issues/47179" class="external">https://github.com/llvm/llvm-project/issues/47179</a>)</li>
</ul>
<p>Other than reimplementing all of our coroutine stuff on top of C++ coroutines, I'm not sure what else we can do. AFAICT there's no way to tell the compiler that we clobbered the <code>%fs</code> register because that's just not a thing in its model (<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66631" class="external">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66631</a>, but i assume clang is similar).</p>
<p>Thoughts? For now I think my workaround is to disable M:N at build time when building with ASAN (or turn optimizations down). At least this isn't a problem with <code>Fiber</code> because we never move them across threads (probably for this reason in part).</p> Ruby master - Bug #20237 (Assigned): Unable to unshare(CLONE_NEWUSER) in Linux because of timer t...https://bugs.ruby-lang.org/issues/202372024-02-05T04:59:20Zhanazuki (Kasumi Hanazuki)
<a name="Backgrounds"></a>
<h2 >Backgrounds<a href="#Backgrounds" class="wiki-anchor">¶</a></h2>
<p><a href="https://man7.org/linux/man-pages/man2/unshare.2.html" class="external">unshare(2)</a> is a syscall in Linux to move the calling process into a fresh execution context. With <code>unshare(CLONE_NEWUSER)</code> you can move a process into a new <a href="https://man7.org/linux/man-pages/man7/user_namespaces.7.html" class="external">user_namespace(7)</a>, where the process gains the full capability on the resources within the namespace. This is fundamental for Linux containers to achieve privilege separation. <code>unshare(CLONE_NEWUSER)</code> requires the calling process to be single-threaded (or no background threads are running). So, it is often invoked after <code>fork(2)</code> as forking propagates only the calling thread to the child process.</p>
<a name="Problem"></a>
<h2 >Problem<a href="#Problem" class="wiki-anchor">¶</a></h2>
<p>It becomes a problem that Ruby 3.3 on Linux uses timer threads even for a single-<code>Thread</code>ed application. Because <code>Kernel#fork</code> spawns a thread in the child process before the control returns to the user code, there is no chance to call <code>unshare(CLONE_NEWUSER)</code> in Ruby.</p>
<p>The following snippet is a reproducer of this problem. This program first forks and then shows the user namespace to which the process belongs before and after calling unshare(2). It also shows the threads of the child process after forking.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">p</span><span class="p">(</span><span class="no">RUBY_DESCRIPTION</span><span class="p">:)</span>
<span class="nb">require</span> <span class="s1">'fiddle/import'</span>
<span class="k">module</span> <span class="nn">C</span>
<span class="kp">extend</span> <span class="no">Fiddle</span><span class="o">::</span><span class="no">Importer</span>
<span class="n">dlload</span> <span class="s1">'libc.so.6'</span>
<span class="n">extern</span> <span class="s1">'int unshare(int flags)'</span>
<span class="no">CLONE_NEWUSER</span> <span class="o">=</span> <span class="mh">0x10000000</span>
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">raise_system_call_error</span>
<span class="k">raise</span> <span class="no">SystemCallError</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Fiddle</span><span class="p">.</span><span class="nf">last_error</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">pid</span> <span class="o">=</span> <span class="nb">fork</span> <span class="k">do</span>
<span class="nb">system</span><span class="p">(</span><span class="s2">"ps -O tid -T -p #$$"</span><span class="p">)</span>
<span class="nb">system</span><span class="p">(</span><span class="s2">"ls -l /proc/self/ns/user"</span><span class="p">)</span>
<span class="k">if</span> <span class="no">C</span><span class="p">.</span><span class="nf">unshare</span><span class="p">(</span><span class="no">C</span><span class="o">::</span><span class="no">CLONE_NEWUSER</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">0</span>
<span class="no">C</span><span class="p">.</span><span class="nf">raise_system_call_error</span> <span class="c1"># => EINVAL with Ruby 3.3</span>
<span class="k">end</span>
<span class="nb">system</span><span class="p">(</span><span class="s2">"ls -l /proc/self/ns/user"</span><span class="p">)</span>
<span class="k">end</span>
<span class="nb">p</span> <span class="no">Process</span><span class="p">.</span><span class="nf">wait2</span><span class="p">(</span><span class="n">pid</span><span class="p">)</span>
</code></pre>
<p>The program successfully changes the user namespace with Ruby 3.2, but it raises EINVAL with Ruby 3.3. You can see Ruby 3.3 has two threads running after forking.</p>
<pre><code>% rbenv shell 3.2 && ruby ./test.rb
{:RUBY_DESCRIPTION=>"ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux]"}
PID TID S TTY TIME COMMAND
1585787 1585787 S pts/12 00:00:00 ruby ./test.rb
lrwxrwxrwx 1 kasumi kasumi 0 Feb 5 02:25 /proc/self/ns/user -> 'user:[4026531837]'
lrwxrwxrwx 1 nobody nogroup 0 Feb 5 02:25 /proc/self/ns/user -> 'user:[4026532675]'
[1585787, #<Process::Status: pid 1585787 exit 0>]
% rbenv shell 3.3 && ruby ./test.rb
{:RUBY_DESCRIPTION=>"ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]"}
PID TID S TTY TIME COMMAND
1585849 1585849 S pts/12 00:00:00 ruby ./test.rb
1585849 1585851 S pts/12 00:00:00 ruby ./test.rb
lrwxrwxrwx 1 kasumi kasumi 0 Feb 5 02:25 /proc/self/ns/user -> 'user:[4026531837]'
./test.rb:10:in `raise_system_call_error': Invalid argument (Errno::EINVAL)
from ./test.rb:24:in `block in <main>'
from ./test.rb:19:in `fork'
from ./test.rb:19:in `<main>'
[1585849, #<Process::Status: pid 1585849 exit 1>]
% rbenv shell master && ruby ./test.rb
{:RUBY_DESCRIPTION=>"ruby 3.4.0dev (2024-02-04T16:05:02Z master 8bc6fff322) [x86_64-linux]"}
PID TID S TTY TIME COMMAND
1585965 1585965 S pts/12 00:00:00 ruby ./test.rb
1585965 1585967 S pts/12 00:00:00 ruby ./test.rb
lrwxrwxrwx 1 kasumi kasumi 0 Feb 5 02:25 /proc/self/ns/user -> 'user:[4026531837]'
./test.rb:10:in `raise_system_call_error': Invalid argument (Errno::EINVAL)
from ./test.rb:24:in `block in <main>'
from ./test.rb:19:in `fork'
from ./test.rb:19:in `<main>'
[1585965, #<Process::Status: pid 1585965 exit 1>]
</code></pre>
<a name="Workaround"></a>
<h2 >Workaround<a href="#Workaround" class="wiki-anchor">¶</a></h2>
<p>My workaround is to rebuild ruby with <code>rb_thread_stop_timer_thread</code> and <code>rb_thread_start_timer_thread</code> exported, and use a C-ext that stops the timer thread before calling <code>unshare</code>. This seems not robust because the process cannot know when the terminated thread is reclaimed by the kernel, after which the process is considered single-threaded.</p>
<pre><code class="c syntaxhl" data-language="c"><span class="cp">#define _GNU_SOURCE 1
#include</span> <span class="cpf"><sched.h></span><span class="cp">
#include</span> <span class="cpf"><ruby/ruby.h></span><span class="cp">
</span>
<span class="k">static</span> <span class="n">VALUE</span> <span class="nf">Unshare_s_unshare</span><span class="p">(</span><span class="n">VALUE</span> <span class="n">_self</span><span class="p">,</span> <span class="n">VALUE</span> <span class="n">rflags</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">int</span> <span class="k">const</span> <span class="n">flags</span> <span class="o">=</span> <span class="n">NUM2INT</span><span class="p">(</span><span class="n">rflags</span><span class="p">);</span>
<span class="n">rb_thread_stop_timer_thread</span><span class="p">();</span>
<span class="n">usleep</span><span class="p">(</span><span class="mi">1000</span><span class="p">);</span> <span class="c1">// FIXME: It takes some time for the kernel to remove the stopped thread?</span>
<span class="kt">int</span> <span class="k">const</span> <span class="n">ret</span> <span class="o">=</span> <span class="n">unshare</span><span class="p">(</span><span class="n">flags</span><span class="p">);</span>
<span class="n">rb_thread_start_timer_thread</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="n">ret</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="n">rb_sys_fail_str</span><span class="p">(</span><span class="n">rb_sprintf</span><span class="p">(</span><span class="s">"unshare(%#x)"</span><span class="p">,</span> <span class="n">flags</span><span class="p">));</span>
<span class="k">return</span> <span class="n">Qnil</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">RUBY_FUNC_EXPORTED</span> <span class="kt">void</span>
<span class="nf">Init_unshare</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span>
<span class="n">VALUE</span> <span class="n">rb_mUnshare</span> <span class="o">=</span> <span class="n">rb_define_module</span><span class="p">(</span><span class="s">"Unshare"</span><span class="p">);</span>
<span class="n">rb_define_singleton_method</span><span class="p">(</span><span class="n">rb_mUnshare</span><span class="p">,</span> <span class="s">"unshare"</span><span class="p">,</span> <span class="n">Unshare_s_unshare</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="n">rb_define_const</span><span class="p">(</span><span class="n">rb_mUnshare</span><span class="p">,</span> <span class="s">"CLONE_NEWUSER"</span><span class="p">,</span> <span class="n">INT2FIX</span><span class="p">(</span><span class="n">CLONE_NEWUSER</span><span class="p">));</span>
<span class="p">}</span>
</code></pre>
<a name="Questions"></a>
<h2 >Questions<a href="#Questions" class="wiki-anchor">¶</a></h2>
<ul>
<li>Is this a limitation of Ruby?</li>
<li>Is it safe (or even possible) to stop the timer thread during execution?
<ul>
<li>If so, can we export it as the public API?</li>
<li>But it may not so useful for this problem as explained in the workaround.</li>
</ul>
</li>
<li>Is it guaranteed that no other threads are running after forks?</li>
<li>Are there any better ways to solve this issue?
<ul>
<li>Can we somehow delay the start of the timer thread after forking, or hook into <code>fork</code> to run some code in the child process immediately after it spawns.</li>
<li>Can they be Ruby API instead of C API?</li>
</ul>
</li>
</ul> Ruby master - Bug #20225 (Open): Inconsistent behavior of regex matching for a regex has a null loophttps://bugs.ruby-lang.org/issues/202252024-01-30T02:53:03Zmake_now_just (Hiroya Fujinami)make.just.on@gmail.com
<p>Usually, in Ruby (Onigmo), when a null loop (a loop consuming no characters) occurs on regex matching, this loop is terminated. But, if a loop has a capture and some complex condition is satisfied, this causes backtracking. This behavior invokes unexpected results, for example,</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">p</span> <span class="sr">/(?:.B.(?<a>(?:[C-Z]|.)*)+){2}/</span> <span class="o">=~</span> <span class="s2">"ABCABC"</span> <span class="c1"># => nil</span>
<span class="nb">p</span> <span class="sr">/(?:.B.(?:(?:[C-Z]|.)*)+){2}/</span> <span class="o">=~</span> <span class="s2">"ABCABC"</span> <span class="c1"># => 0</span>
</code></pre>
<p>Because the above regex has a capture and the below does not, different matching results are returned. It is not very intuitive that the presence of a capture changes the matching result.</p>
<p>The detailed condition for changing the null-loop behavior is 1) a previous capture in this loop holds the empty string, and 2) this capture's position is different from the current matching position. This condition is checked in <code>STACK_NULL_CHECK_MEMST</code> (<a href="https://github.com/ruby/ruby/blob/bbb7ab906ec64b963bd4b5d37e47b14796d64371/regexec.c#L1766-L1778" class="external">https://github.com/ruby/ruby/blob/bbb7ab906ec64b963bd4b5d37e47b14796d64371/regexec.c#L1766-L1778</a>).</p>
<p>Perhaps, you cannot understand what this condition means. Don't worry, I also cannot understand. This condition has been introduced for at least 20 years, and no one may remember the reason for this necessity. (If you know, please tell me!) Even if there is a reason, I believe that there is no reasonable authority for allowing counter-intuitive behavior, such as the above example.</p>
<p>This behavior can also cause memoization to be buggy. Memoization relies on the fact that backtracking only depends on positions and states (byte-code offsets of a regex). However, this condition additionally refers to captures, and the memoization is broken.</p>
<p>My proposal is to <strong>correct this inconsistent behavior</strong>. Specifically, a null loop should be determined solely on the basis of whether the matching position has changed, without referring to captures.</p>
<p>This fix changes the behavior of regex matching, but I believe that the probability that this will actually cause backward compatibility problems is remarkably low. This is because I have never seen any mention of this puzzling behavior before.</p> Ruby master - Bug #20216 (Open): Circular parameter reference not checked for assignmenthttps://bugs.ruby-lang.org/issues/202162024-01-26T18:25:53Zkddnewton (Kevin Newton)kddnewton@gmail.com
<p>I wanted to check if this was a bug or desired.</p>
<p>Usually when you reference a parameter within its own default value (optional positional or optional keyword) it raises a syntax error. This is unless you use it in an assignment, in which case it is not checked. Is this desired? Here's an example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">bar</span> <span class="o">=</span> <span class="n">bar</span> <span class="o">=</span> <span class="mi">1</span><span class="p">);</span> <span class="k">end</span>
<span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="ss">bar: </span><span class="n">bar</span> <span class="o">=</span> <span class="mi">1</span><span class="p">);</span> <span class="k">end</span>
</code></pre>
<p>I'm not sure what this code is supposed to be doing. I expected it to raise a syntax error.</p> Ruby master - Bug #20203 (Open): `TestEnumerable` test failures with GCC 14https://bugs.ruby-lang.org/issues/202032024-01-22T17:10:42Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<p>There is ongoing mass rebuild in Fedora and that is first time GCC 14 is used and we observe test failures in <code>TestEnumerable</code>. Here are a few examples:</p>
<pre><code>[ 3000/26419] TestEnumerable#test_transient_heap_sort_bymalloc_consolidate(): unaligned fastbin chunk detected
</code></pre>
<pre><code>[ 2455/26535] TestEnumerable#test_transient_heap_sort_bycorrupted size vs. prev_size in fastbins
</code></pre>
<pre><code>[ 9716/26532] TestEnumerable#test_any_with_unused_blockdouble free or corruption (fasttop)
</code></pre>
<p>The full logs are accessible <a href="https://koji.fedoraproject.org/koji/taskinfo?taskID=112176941" class="external">here</a>. Please drill through <code>Descendants</code> and <code>build.log</code></p> Ruby master - Bug #20189 (Open): `rb_str_resize` does not clear coderange when expandinghttps://bugs.ruby-lang.org/issues/201892024-01-16T12:56:47Ztompng (tomoya ishida)tomoyapenguin@gmail.com
<p>Expanding string in some encoding (utf16 utf32) can change coderange to either valid or broken, but rb_str_resize does not clear coderange.</p>
<p>This will cause a bug in c-extension libraries that use rb_str_resize.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># Example for stringio</span>
<span class="n">s</span> <span class="o">=</span> <span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s2">"</span><span class="se">\0</span><span class="s2">"</span><span class="p">.</span><span class="nf">encode</span><span class="p">(</span><span class="s1">'UTF-16LE'</span><span class="p">))</span>
<span class="n">s</span><span class="p">.</span><span class="nf">truncate</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> <span class="n">s</span><span class="p">.</span><span class="nf">truncate</span><span class="p">(</span><span class="mi">2</span><span class="p">);</span> <span class="n">s</span><span class="p">.</span><span class="nf">string</span><span class="p">.</span><span class="nf">valid_encoding?</span>
<span class="c1">#=> true</span>
<span class="n">s</span><span class="p">.</span><span class="nf">truncate</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> <span class="n">s</span><span class="p">.</span><span class="nf">string</span><span class="p">.</span><span class="nf">valid_encoding?</span><span class="p">;</span> <span class="n">s</span><span class="p">.</span><span class="nf">truncate</span><span class="p">(</span><span class="mi">2</span><span class="p">);</span> <span class="n">s</span><span class="p">.</span><span class="nf">string</span><span class="p">.</span><span class="nf">valid_encoding?</span>
<span class="c1">#=> false (expect to be true)</span>
</code></pre> Ruby master - Bug #20186 (Open): Ripper does not generate AST for some keywords in Ruby 3.3https://bugs.ruby-lang.org/issues/201862024-01-16T06:39:52Zkzkn (Kazuki Nishikawa)
<p>Ripper does not generate AST for the below keyword:</p>
<ul>
<li>break</li>
<li>next</li>
<li>redo</li>
<li>retry</li>
<li>yield</li>
</ul>
<p>Ruby 3.2</p>
<pre><code>$ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
$ ruby -rripper -e "p Ripper.sexp('break')"
[:program, [[:break, []]]]
$ ruby -rripper -e "p Ripper.sexp('next')"
[:program, [[:next, []]]]
$ ruby -rripper -e "p Ripper.sexp('redo')"
[:program, [[:redo]]]
$ ruby -rripper -e "p Ripper.sexp('retry')"
[:program, [[:retry]]]
$ ruby -rripper -e "p Ripper.sexp('yield')"
[:program, [[:yield0]]]
</code></pre>
<p>Ruby 3.3</p>
<pre><code>$ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
$ ruby -rripper -e "p Ripper.sexp('break')"
nil
$ ruby -rripper -e "p Ripper.sexp('next')"
nil
$ ruby -rripper -e "p Ripper.sexp('redo')"
nil
$ ruby -rripper -e "p Ripper.sexp('retry')"
nil
$ ruby -rripper -e "p Ripper.sexp('yield')"
nil
</code></pre>
<p>EDIT)<br>
Here is a case of real-world problem: <a href="https://github.com/ruby-formatter/rufo/issues/319" class="external">https://github.com/ruby-formatter/rufo/issues/319</a></p> Ruby master - Bug #20179 (Open): `--with-ruby-version` configure option is not correctly applied ...https://bugs.ruby-lang.org/issues/201792024-01-12T13:18:55Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<p>I am trying to configure ruby using <code>--with-ruby-version=ruby3.3</code>. Here is the configure output:</p>
<pre><code>$ /builddir/build/BUILD/ruby-3.3.0/configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --runstatedir=/run --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-compress-debug-sections=no --disable-rpath --enable-mkmf-verbose --enable-shared --with-ruby-version=ruby3.3 --enable-yjit
... snip ...
---
Configuration summary for ruby version 3.3.0
* Installation prefix: /usr
* exec prefix: /usr
* arch: x86_64-linux
* site arch: ${arch}
* RUBY_BASE_NAME: ruby
* enable shared: yes
* ruby lib prefix: ${libdir}/${RUBY_BASE_NAME}
* site libraries path: ${rubylibprefix}/${sitearch}
* vendor path: ${rubylibprefix}/vendor_ruby
* target OS: linux
* compiler: gcc
* with thread: pthread
* with coroutine: amd64
* enable shared libs: yes
* dynamic library ext: so
* CFLAGS: ${optflags} ${debugflags} ${warnflags}
* LDFLAGS: -L. -Wl,-z,relro -Wl,--as-needed \
-Wl,-z,pack-relative-relocs -Wl,-z,now \
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld \
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 \
-Wl,--build-id=sha1 -fstack-protector-strong \
-rdynamic -Wl,-export-dynamic -Wl,--no-as-needed
* DLDFLAGS: -Wl,-z,relro -Wl,--as-needed \
-Wl,-z,pack-relative-relocs -Wl,-z,now \
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld \
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 \
-Wl,--build-id=sha1
* optflags: -O3 -fno-fast-math
* debugflags: -ggdb3
* warnflags: -Wall -Wextra -Wdeprecated-declarations \
-Wdiv-by-zero -Wduplicated-cond \
-Wimplicit-function-declaration -Wimplicit-int \
-Wpointer-arith -Wwrite-strings \
-Wold-style-definition -Wimplicit-fallthrough=0 \
-Wmissing-noreturn -Wno-cast-function-type \
-Wno-constant-logical-operand -Wno-long-long \
-Wno-missing-field-initializers \
-Wno-overlength-strings \
-Wno-packed-bitfield-compat \
-Wno-parentheses-equality -Wno-self-assign \
-Wno-tautological-compare -Wno-unused-parameter \
-Wno-unused-value -Wsuggest-attribute=format \
-Wsuggest-attribute=noreturn -Wunused-variable \
-Wmisleading-indentation -Wundef
* strip command: strip -S -x
* install doc: rdoc
* YJIT support: yes
* RJIT support: yes
* man page type: doc
---
</code></pre>
<p>However, the option is not applied consistently, especially the <code>rubyhdrdir</code> stands out:</p>
<pre><code>$ find . -name \*ruby3.3\*
./usr/lib64/ruby/ruby3.3
./usr/lib64/ruby/site_ruby/ruby3.3
./usr/lib64/ruby/vendor_ruby/ruby3.3
./usr/lib64/ruby/gems/ruby3.3
./usr/lib64/ruby/gems/ruby3.3/extensions/x86_64-linux/ruby3.3
./usr/include/ruby-ruby3.3
./usr/share/ri/ruby3.3
</code></pre>
<p>The correct path should be IMHO <code>./usr/include/ruby3.3</code>. I can likely workaround it by <code>--with-rubyhdrdir</code>, but I think this should behave consistently.</p> Ruby master - Bug #20171 (Open): ri -i ruby interactive pressing tab does not autocompletehttps://bugs.ruby-lang.org/issues/201712024-01-09T17:45:34ZMystorium (Josh Goldfarb)
<p>When typing a Object or Object with a method, the tab button does not pull up autocomplete options.</p>
<p>This issue is not present in ruby 3.2.2</p>
<p>Ex</p>
<p>Type</p>
<ul>
<li>
<p>ri - i</p>
</li>
<li>
<p>String.cap</p>
</li>
</ul>
<p>Press.</p>
<ul>
<li>"Tab"</li>
</ul>
<p>What is expected</p>
<ul>
<li>autocomplete options to populate</li>
</ul>
<p>What is happening</p>
<ul>
<li>Nothing Happens when pressing tab.</li>
</ul> Ruby master - Bug #20168 (Open): Process won't exit when Ractor.select waiting a Ractorhttps://bugs.ruby-lang.org/issues/201682024-01-09T09:29:43Zshia (Sangyong Sim)
<a name="Reproduction-code"></a>
<h2 >Reproduction code<a href="#Reproduction-code" class="wiki-anchor">¶</a></h2>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">trap</span><span class="p">(</span><span class="ss">:INT</span><span class="p">)</span> <span class="k">do</span>
<span class="nb">puts</span> <span class="s2">"SIGINT"</span>
<span class="nb">exit</span>
<span class="k">end</span>
<span class="nb">trap</span><span class="p">(</span><span class="ss">:TERM</span><span class="p">)</span> <span class="k">do</span>
<span class="nb">puts</span> <span class="s2">"SIGTERM"</span>
<span class="nb">exit</span>
<span class="k">end</span>
<span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="kp">loop</span> <span class="k">do</span>
<span class="nb">sleep</span> <span class="mi">1</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">select</span><span class="p">(</span><span class="n">r</span><span class="p">)</span> <span class="c1"># stucked.</span>
<span class="c1"># SIGINT/SIGTERM sent to Ruby process(confirmed by trap),</span>
<span class="c1"># but process won't exit.</span>
</code></pre>
<a name="Expected-behavior"></a>
<h2 >Expected behavior<a href="#Expected-behavior" class="wiki-anchor">¶</a></h2>
<p>Process killed successfully with exit code 0.</p>
<a name="Affected-Ruby-version"></a>
<h2 >Affected Ruby version<a href="#Affected-Ruby-version" class="wiki-anchor">¶</a></h2>
<p>3.3.0<br>
3.2.x works as expected.</p> Ruby master - Bug #20167 (Open): Code execution isn't recorded in Ractorhttps://bugs.ruby-lang.org/issues/201672024-01-09T09:08:58Zshia (Sangyong Sim)
<a name="reproduction-code"></a>
<h2 >reproduction code<a href="#reproduction-code" class="wiki-anchor">¶</a></h2>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># frozen-string-literal: true</span>
<span class="nb">require</span> <span class="s2">"coverage"</span>
<span class="no">Coverage</span><span class="p">.</span><span class="nf">start</span>
<span class="nb">require_relative</span> <span class="s2">"./some_lib"</span>
<span class="c1"># # some_lib.rb</span>
<span class="c1"># class C</span>
<span class="c1"># def hoge(i)</span>
<span class="c1"># i</span>
<span class="c1"># end</span>
<span class="c1"># end</span>
<span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="kp">loop</span> <span class="k">do</span>
<span class="n">v</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">receive</span>
<span class="n">ret_v</span> <span class="o">=</span> <span class="no">C</span><span class="p">.</span><span class="nf">new</span><span class="p">.</span><span class="nf">hoge</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">yield</span> <span class="n">ret_v</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="mi">2</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span>
<span class="n">r</span> <span class="o"><<</span> <span class="n">i</span>
<span class="n">r</span><span class="p">.</span><span class="nf">take</span>
<span class="k">end</span>
<span class="no">Coverage</span><span class="p">.</span><span class="nf">result</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">file</span><span class="p">,</span> <span class="n">lines</span><span class="o">|</span>
<span class="k">if</span> <span class="n">file</span><span class="p">.</span><span class="nf">include?</span><span class="p">(</span><span class="s2">"some_ractor_lib"</span><span class="p">)</span>
<span class="k">if</span> <span class="n">lines</span> <span class="o">==</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="kp">nil</span><span class="p">,</span> <span class="kp">nil</span><span class="p">]</span>
<span class="nb">puts</span> <span class="s2">"OK"</span>
<span class="k">else</span>
<span class="nb">puts</span> <span class="s2">"expected: [1, 1, 2, nil, nil]"</span>
<span class="nb">puts</span> <span class="s2">"actual: </span><span class="si">#{</span><span class="n">lines</span><span class="p">.</span><span class="nf">inspect</span><span class="si">}</span><span class="s2">"</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<a name="Target-ruby-version"></a>
<h2 >Target ruby version<a href="#Target-ruby-version" class="wiki-anchor">¶</a></h2>
<p>3.2.0+ affected</p> Ruby master - Bug #20165 (Open): Ractors moving a Struct breaks beyond the first 3 fieldshttps://bugs.ruby-lang.org/issues/201652024-01-08T21:02:19Zcodekitchen (Brian Palmer)
<p>Experimenting with Ractors on ruby 3.3.0, and I'm seeing a bug where if you move a struct between ractors, all but the first 3 fields are set to nil.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Foo</span> <span class="o">=</span> <span class="no">Struct</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">:a</span><span class="p">,</span><span class="ss">:b</span><span class="p">,</span><span class="ss">:c</span><span class="p">,</span><span class="ss">:d</span><span class="p">,</span><span class="ss">:e</span><span class="p">,</span><span class="ss">:f</span><span class="p">)</span>
<span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span>
<span class="n">foo</span> <span class="o">=</span> <span class="no">Foo</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
<span class="nb">p</span> <span class="n">foo</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">yield</span><span class="p">(</span><span class="n">foo</span><span class="p">,</span> <span class="ss">move: </span><span class="kp">true</span><span class="p">)</span>
<span class="p">}</span>
<span class="nb">p</span> <span class="n">r</span><span class="p">.</span><span class="nf">take</span>
</code></pre>
<pre><code>❯ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
❯ ruby rbug.rb
rbug.rb:3: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
#<struct Foo a=0, b=0, c=0, d=0, e=0, f=0>
#<struct Foo a=0, b=0, c=0, d=nil, e=nil, f=nil>
</code></pre>
<p>This seems specific to moving, if I set <code>move: false</code> the struct makes it across OK.</p> Ruby master - Bug #20158 (Assigned): Ractor affects Coverage resultshttps://bugs.ruby-lang.org/issues/201582024-01-07T15:12:34Zjanosch-x (Janosch Müller)
<p>I have a large rspec test suite. I found that if I call a Ractor, the Coverage results are strongly affected, i.e. almost all files appear to be uncovered. This happens even if I only ever call a Ractor before the library or rspec are required.</p>
<p>Unfortunately, I was not able to build a simple repro yet.</p>
<p>I assume it is a timing thing and only affects larger suites, or it only happens if there are multiple files, and maybe if the library lazily requires its sub-modules?</p>
<p>However, I guess this should produce the same results when added to the spec_helper.rb of other large suites:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># Ractor.new { nil } # uncomment this to affect coverage results</span>
<span class="nb">require</span> <span class="s1">'coverage'</span>
<span class="no">Coverage</span><span class="p">.</span><span class="nf">start</span>
<span class="c1"># require library, set up rspec etc. </span>
<span class="no">RSpec</span><span class="p">.</span><span class="nf">configuration</span><span class="p">.</span><span class="nf">after</span><span class="p">(</span><span class="ss">:suite</span><span class="p">)</span> <span class="k">do</span>
<span class="c1"># this number is greatly reduced and unstable when calling Ractor above</span>
<span class="nb">p</span> <span class="no">Coverage</span><span class="p">.</span><span class="nf">result</span><span class="p">.</span><span class="nf">values</span><span class="p">.</span><span class="nf">sum</span> <span class="p">{</span> <span class="o">|</span><span class="n">arr</span><span class="o">|</span> <span class="n">arr</span><span class="p">.</span><span class="nf">sum</span><span class="p">(</span><span class="o">&</span><span class="ss">:to_i</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
</code></pre>
<p>I had this problem in <a href="https://github.com/jaynetics/character_set/" class="external">this library</a>. The problem affects simplecov users as well, as described <a href="https://github.com/simplecov-ruby/simplecov/issues/1058" class="external">here</a>.</p> Ruby master - Bug #20155 (Assigned): Using value of rb_fiber_scheduler_current() crashes Rubyhttps://bugs.ruby-lang.org/issues/201552024-01-05T22:14:24Zpaddor (Patrik Wenger)paddor@gmail.com
<p>While trying to manually block/unblock fibers from an extension using the Fiber Scheduler,<br>
I noticed that using the return value of <code>rb_fiber_scheduler_current()</code> crashes Ruby.</p>
<p>I've created a minimal extension gem called "fiber_blocker". Its test suite shows the behavior. See <a href="https://github.com/paddor/fiber_blocker" class="external">https://github.com/paddor/fiber_blocker</a>, especially the lines containing <code>FIXME</code>.</p>
<p>Passing <code>Fiber.scheduler</code> to the extension functions works. But letting it get the current scheduler itself does not seem to work.</p>
<p>Is <code>rb_fiber_scheduler_current()</code>(within a non-blocking Fiber) not the equivalent to <code>Fiber.scheduler</code>?<br>
Even just printing the its return value with <code>#p</code> will crash Ruby.</p>
<p>Ruby either crashes like this:</p>
<pre><code># Running:
T1 BEGIN
T2 BEGIN
T1 END
..T1 BEGIN
ext: blocking fiber
passed scheduler = #<Scheduler:0x00007fc5f22d39e8 @readable={}, @writable={}, @waiting={}, @closed=false, @lock=#<Thread::Mutex:0x00007fc5f22ec8d0>, @blocking={}, @ready=[], @urgent=[#<IO:fd 5>, #<IO:fd 6>]>
T2 BEGIN
ext: unblocking fiber
T1 END
.E
Finished in 1.007014s, 3.9721 runs/s, 2.9791 assertions/s.
1) Error:
TestFiberBlocker#test_fiber_blocker_current_fiber:
fatal: machine stack overflow in critical region
No backtrace
</code></pre>
<p>Or with a segfault:</p>
<pre><code># Running:
FiberBlocker.test works.
.T1 BEGIN
T2 BEGIN
T1 END
.T1 BEGIN
ext: blocking fiber
/home/user/dev/oss/async_ruby_test/rbnng/fiber_blocker/test/test_fiber_blocker.rb:40: [BUG] Segmentation fault at 0x00000000390d8f98
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0003 p:---- s:0012 e:000011 CFUNC :block_fiber
c:0002 p:0014 s:0006 e:000005 BLOCK /home/user/dev/oss/async_ruby_test/rbnng/fiber_blocker/test/test_fiber_blocker.rb:40 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
/home/user/dev/oss/async_ruby_test/rbnng/fiber_blocker/test/test_fiber_blocker.rb:40:in `block in test_fiber_blocking_in_ext'
/home/user/dev/oss/async_ruby_test/rbnng/fiber_blocker/test/test_fiber_blocker.rb:40:in `block_fiber'
-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 4
-- Machine register context ------------------------------------------------
RIP: 0x00007f1554f17ad8 RBP: 0x00000000390d8f90 RSP: 0x00007f153a79e280
RAX: 0x00007f1554addba8 RBX: 0x00007f153a79eab0 RCX: 0x0000000000000000
RDX: 0x00007f1554ade600 RDI: 0x00007f15551e8788 RSI: 0x0000000000000ae1
R8: 0x000000000000002b R9: 0x00007f153a79f038 R10: 0x00007f1554c0b9b0
R11: 0x00007f153a79e490 R12: 0x0000000000000ae1 R13: 0x0000000000000000
R14: 0x0000000000000000 R15: 0x000055ab732d7df0 EFL: 0x0000000000010206
-- C level backtrace information -------------------------------------------
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_print_backtrace+0x14) [0x7f1554f24961] /home/user/src/ruby-3.3.0/vm_dump.c:820
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_vm_bugreport) /home/user/src/ruby-3.3.0/vm_dump.c:1151
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_bug_for_fatal_signal+0x104) [0x7f1554d1c214] /home/user/src/ruby-3.3.0/error.c:1065
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(sigsegv+0x4f) [0x7f1554e700df] /home/user/src/ruby-3.3.0/signal.c:926
/lib/x86_64-linux-gnu/libc.so.6(0x7f1554842520) [0x7f1554842520]
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(RBASIC_CLASS+0x0) [0x7f1554f17ad8] ./include/ruby/internal/globals.h:178
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(gccct_method_search) /home/user/src/ruby-3.3.0/vm_eval.c:475
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_funcallv_scope) /home/user/src/ruby-3.3.0/vm_eval.c:1063
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_funcallv) /home/user/src/ruby-3.3.0/vm_eval.c:1084
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_inspect+0x19) [0x7f1554dc1569] /home/user/src/ruby-3.3.0/object.c:697
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(ruby__sfvextra+0x11a) [0x7f1554e7223a] /home/user/src/ruby-3.3.0/sprintf.c:1119
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(BSD_vfprintf+0xa69) [0x7f1554e73059] /home/user/src/ruby-3.3.0/vsnprintf.c:830
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(RBASIC_SET_CLASS_RAW+0x0) [0x7f1554e75b56] /home/user/src/ruby-3.3.0/sprintf.c:1168
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(ruby_vsprintf0) /home/user/src/ruby-3.3.0/sprintf.c:1169
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_enc_vsprintf+0x5d) [0x7f1554e75ecd] /home/user/src/ruby-3.3.0/sprintf.c:1195
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_sprintf+0x9d) [0x7f1554e7607d] /home/user/src/ruby-3.3.0/sprintf.c:1225
/home/user/dev/oss/async_ruby_test/rbnng/fiber_blocker/lib/fiber_blocker/fiber_blocker.so(block_fiber+0x4a) [0x7f1554ad430a] ../../../../ext/fiber_blocker/fiber_blocker.c:29
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(vm_cfp_consistent_p+0x0) [0x7f1554ef64b4] /home/user/src/ruby-3.3.0/vm_insnhelper.c:3490
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(vm_call_cfunc_with_frame_) /home/user/src/ruby-3.3.0/vm_insnhelper.c:3492
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(vm_call_cfunc_with_frame) /home/user/src/ruby-3.3.0/vm_insnhelper.c:3518
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(vm_call_cfunc_other) /home/user/src/ruby-3.3.0/vm_insnhelper.c:3544
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(vm_sendish+0x9e) [0x7f1554f06f87] /home/user/src/ruby-3.3.0/vm_insnhelper.c:5581
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(vm_exec_core) /home/user/src/ruby-3.3.0/insns.def:834
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_vm_exec+0x19a) [0x7f1554f0d1fa] /home/user/src/ruby-3.3.0/vm.c:2486
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_vm_invoke_proc+0x5f) [0x7f1554f12e0f] /home/user/src/ruby-3.3.0/vm.c:1728
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_fiber_start+0x1ba) [0x7f1554cf098a] /home/user/src/ruby-3.3.0/cont.c:2536
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(fiber_entry+0x20) [0x7f1554cf0d00] /home/user/src/ruby-3.3.0/cont.c:847
/home/user/.rubies/ruby-3.3.0/lib/libruby.so.3.3(rb_threadptr_root_fiber_setup) (null):0
</code></pre>
<p>This happens with the Async scheduler as well as with Ruby’s test scheduler. My minimal extension uses Ruby’s.</p>
<p>I hope I'm not missing something obvious. My C isn't very good.</p> Ruby master - Bug #20154 (Open): aarch64: configure overrides `-mbranch-protection` if it was set...https://bugs.ruby-lang.org/issues/201542024-01-05T21:25:03Zjprokop (Jarek Prokop)
<p>Recently a GH PR was merged <a href="https://github.com/ruby/ruby/pull/9306" class="external">https://github.com/ruby/ruby/pull/9306</a> For PAC/BTI support on ARM CPUs for Coroutine.S.</p>
<p>Without proper compilation support in configure.ac it segfaults Ruby with fibers on CPUs where PAC is supported: <a href="https://bugs.ruby-lang.org/issues/20085" class="external">https://bugs.ruby-lang.org/issues/20085</a></p>
<p>At the time of writing, configure.ac appends the first option from a list for flag <code>-mbranch-protection</code> that successfully compiles a program <a href="https://github.com/ruby/ruby/blob/master/configure.ac#L829" class="external">https://github.com/ruby/ruby/blob/master/configure.ac#L829</a>,<br>
to XCFLAGS and now also ASFLAGS to fix issue 20085 for Ruby master.</p>
<p>This is suboptimal for Fedora as we set -mbranch-protection=standard by default in C{,XX}FLAGS:</p>
<pre><code>CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '
export CFLAGS
CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer'
export CXXFLAGS
</code></pre>
<p>And the appended flag overrides distribution's compilation configuration, which in this case ends up omitting BTI instructions and only using PAC.</p>
<p>Would it make sense to check if such flags exist and not overwrite them if they do?</p>
<p>Serious proposals:</p>
<ol>
<li>Simplest fix that does not overwrite what is set in the distribution and results in higher security is simply prepending the list of options with <code>-mbranch-protection=standard</code>, it should cause no problems on ARMv8 CPUs and forward, BTI similarly to PAC instructions result into NOP, it is only extending the capability.</li>
</ol>
<p>See attached 0001-aarch64-Check-mbranch-protection-standard-first-to-u.patch</p>
<ol start="2">
<li>Other fix that sounds more sane IMO and dodges this kind of guessing where are all the correct places for the flag is what another Fedora contributor Florian Weimer suggested: <a href="https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/CVTNF2OQCL3XZHUUFNYMDK6ZEF2SWUEN/" class="external">https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/CVTNF2OQCL3XZHUUFNYMDK6ZEF2SWUEN/</a>
</li>
</ol>
<p>"The reliable way to do this would be to compile a C file and check<br>
whether that enables __ARM_FEATURE_PAC_DEFAULT, and if that's the case,<br>
define a <em>different</em> macro for use in the assembler implementation.<br>
This way, you don't need to care about the exact name of the option."</p>
<p>IOW instead of using _<em>ARM_FEATURE</em>* directly in that code, define a macro in the style of "USE_PAC" with value of the feature if it is defined, I think that way we shouldn't need to append ASFLAGS anymore.</p>
<p>However it's also important to catch the value of those macros as their values have meaning, I have an idea how to do that but I'd get on that monday earliest.</p> Ruby master - Bug #20151 (Open): Can't build Ruby 3.1 on FreeBSD 14.0https://bugs.ruby-lang.org/issues/201512024-01-05T03:14:58Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<p>I couldn't install Ruby 3.1.3 on FreeBSD 14.0.</p>
<pre><code>compiling util.c
util.c:255:1: error: expected identifier or '('
ruby_qsort(void* base, const size_t nel, const size_t size, cmpfunc_t *cmp, void *d)
^
./include/ruby/util.h:124:21: note: expanded from macro 'ruby_qsort'
# define ruby_qsort qsort_r
^
/usr/include/stdlib.h:356:5: note: expanded from macro 'qsort_r'
__generic(arg5, int (*)(void *, const void *, const void *), \
^
/usr/include/sys/cdefs.h:322:2: note: expanded from macro '__generic'
_Generic(expr, t: yes, default: no)
^
1 error generated.
*** Error code 1
Stop.
</code></pre>
<p>Compiler version is here:</p>
<pre><code>FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
</code></pre>
<p>I could install Ruby 3.2.2.</p> Ruby master - Bug #20147 (Open): FreeBSD libyamlhttps://bugs.ruby-lang.org/issues/201472024-01-04T13:09:45Zkaiquekandykoga (Kaíque Koga)
<p>I use ruby-install to manage multiple Ruby versions. Some time ago I had issues installing Ruby 3.2.2 <a href="https://github.com/postmodern/ruby-install/issues/463" class="external">https://github.com/postmodern/ruby-install/issues/463</a>, and the same issue was open for ruby-build in <a href="https://github.com/rbenv/ruby-build/issues/2184" class="external">https://github.com/rbenv/ruby-build/issues/2184</a>. I am trying to install Ruby 3.3.0 using ruby-install, and the same behaviour is occurring. Please, take a look in the links I have provided for detailed information.</p>
<pre><code class="shell syntaxhl" data-language="shell">/usr/home/kandy/src/ruby-3.3.0/lib/yaml.rb:3: warning: It seems your ruby installation is missing psych <span class="o">(</span><span class="k">for </span>YAML output<span class="o">)</span><span class="nb">.</span>
To eliminate this warning, please <span class="nb">install </span>libyaml and reinstall your ruby.
uh-oh! RDoc had a problem:
cannot load such file <span class="nt">--</span> psych
run with <span class="nt">--debug</span> <span class="k">for </span>full backtrace
<span class="k">***</span> Error code 1
Stop.
make: stopped <span class="k">in</span> /usr/home/kandy/src/ruby-3.3.0
<span class="o">!!!</span> Compiling ruby 3.3.0 failed!
</code></pre>
<p>Thank you.</p> Ruby master - Bug #20146 (Assigned): Code using Ractor with env `RUBY_MAX_CPU=1` ends with unreac...https://bugs.ruby-lang.org/issues/201462024-01-04T02:17:54Zshia (Sangyong Sim)
<a name="Reproducible-code"></a>
<h2 >Reproducible code<a href="#Reproducible-code" class="wiki-anchor">¶</a></h2>
<pre><code class="rb syntaxhl" data-language="rb"><span class="c1"># sample-code.rb</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span> <span class="mi">1</span> <span class="p">}</span>
</code></pre>
<pre><code class="bash syntaxhl" data-language="bash"><span class="nv">RUBY_MAX_CPU</span><span class="o">=</span>1 ruby sample-code.rb <span class="c"># This will not end with exit code 0</span>
<span class="nv">RUBY_MAX_CPU</span><span class="o">=</span>2 ruby sample-code.rb <span class="c"># This ends with exit code 0 as expected</span>
</code></pre>
<a name="Expected"></a>
<h2 >Expected<a href="#Expected" class="wiki-anchor">¶</a></h2>
<p>process with RUBY_MAX_CPU=1 exits successfully as same as RUBY_MAX_CPU more than 1.</p> Ruby master - Bug #20112 (Assigned): Ractors not working properly in ruby 3.3.0https://bugs.ruby-lang.org/issues/201122024-01-03T15:51:14Zariasdiniz (Aria Diniz)
<p>I recently installed Ruby 3.3.0, and noticed that some of my scripts that use Ractors started to struggle with performance. After doing some benchmarks, I noticed that, while Ractors seem to be working well on Ruby 3.2.2, they're not working properly on 3.3.0.</p>
<p>I'm using Ubuntu 22.04.3 LTS</p>
<p>Here is the benchmark code:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># frozen_string_literal: true</span>
<span class="nb">require</span> <span class="s1">'benchmark'</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span> <span class="ss">:warmup</span> <span class="p">}</span> <span class="k">if</span> <span class="k">defined?</span><span class="p">(</span><span class="no">Ractor</span><span class="p">)</span>
<span class="no">Benchmark</span><span class="p">.</span><span class="nf">bmbm</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
<span class="n">x</span><span class="p">.</span><span class="nf">report</span><span class="p">(</span><span class="s2">"Thread: "</span><span class="p">)</span> <span class="k">do</span>
<span class="n">threads</span> <span class="o">=</span> <span class="p">[]</span>
<span class="mi">8</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span>
<span class="n">threads</span> <span class="o"><<</span> <span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="mi">20000000</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">j</span><span class="o">|</span>
<span class="p">((</span><span class="n">i</span> <span class="o">*</span> <span class="mi">20000000</span><span class="p">)</span> <span class="o">+</span> <span class="n">j</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">threads</span><span class="p">.</span><span class="nf">each</span><span class="p">(</span><span class="o">&</span><span class="ss">:join</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">x</span><span class="p">.</span><span class="nf">report</span><span class="p">(</span><span class="s2">"Ractor: "</span><span class="p">)</span> <span class="k">do</span>
<span class="n">ractors</span> <span class="o">=</span> <span class="p">[]</span>
<span class="mi">0</span><span class="o">..</span><span class="mi">8</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span>
<span class="n">ractors</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">k</span><span class="o">|</span>
<span class="mi">20000000</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">j</span><span class="o">|</span>
<span class="p">((</span><span class="n">k</span> <span class="o">*</span> <span class="mi">20000000</span><span class="p">)</span> <span class="o">+</span> <span class="n">j</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">ractors</span><span class="p">.</span><span class="nf">map</span><span class="p">(</span><span class="o">&</span><span class="ss">:take</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>Here is the results for Ruby 3.2.2:</p>
<p>Rehearsal --------------------------------------------<br>
Thread: 7.666909 0.001091 7.668000 ( 7.675266)<br>
Ractor: 19.318528 0.012017 19.330545 ( 2.505888)<br>
---------------------------------- total: 26.998545sec</p>
<pre><code> user system total real
</code></pre>
<p>Thread: 7.918141 0.004011 7.922152 ( 7.928772)<br>
Ractor: 19.366414 0.003954 19.370368 ( 2.517993)</p>
<p>Here is the results for Ruby 3.3.0:</p>
<p>Rehearsal --------------------------------------------<br>
Thread: 8.634152 0.010895 8.645047 ( 8.645104)<br>
Ractor: 100.172179 0.035985 100.208164 ( 15.213245)<br>
--------------------------------- total: 108.853211sec</p>
<pre><code> user system total real
</code></pre>
<p>Thread: 9.451236 0.004002 9.455238 ( 9.460132)<br>
Ractor: 118.463294 0.119942 118.583236 ( 18.462157)</p> Ruby master - Bug #20103 (Open): rb_internal_thread_remove_event_hook() hangs when called from wi...https://bugs.ruby-lang.org/issues/201032023-12-28T15:46:51Zosyoyu (Daisuke Aritomo)
<a name="Problem"></a>
<h2 >Problem<a href="#Problem" class="wiki-anchor">¶</a></h2>
<p>The Ruby process hangs when <code>rb_internal_thread_remove_event_hook()</code> is called from within a Thread hook registered by <code>rb_internal_thread_add_event_hook()</code>.<br>
The thread is waiting for the thread event execution lock (<code>pthread_rwlock_wrlock(&rb_internal_thread_event_hooks_rw_lock))</code>), which is acquired by its caller, <code>rb_thread_execute_hooks()</code>.<br>
<a href="https://github.com/ruby/ruby/blob/e81a5453e3c76c4348da042d86debde7689254fe/thread_pthread.c#L3323" class="external">https://github.com/ruby/ruby/blob/e81a5453e3c76c4348da042d86debde7689254fe/thread_pthread.c#L3323</a></p>
<p>This situation would occur when one wants to register a <em>oneshot</em> hook that performs something on a Thread for only a single time. The hook would remove itself after its main procedure.<br>
In my case, I'm doing a timer_create(3) on each pthread for profiling purposes.</p>
<a name="Expected-behavior"></a>
<h2 >Expected behavior<a href="#Expected-behavior" class="wiki-anchor">¶</a></h2>
<p>The process won't hang, or at least print some kind of warning.</p>
<p>I think there some options here:</p>
<ol>
<li>Discourage this kind of definition. Thread hooks should not add/remove other Thread hooks, or otherwise do so through other async methods, such as postponed jobs.</li>
<li>Find a way to make this work. Maybe inner calls to add/remove_event_hook() can share locks with the outer call, but I'm not sure if that's possible as I'm not familiar with pthread_rwlocks.</li>
</ol>
<a name="Repro"></a>
<h2 >Repro<a href="#Repro" class="wiki-anchor">¶</a></h2>
<pre><code class="c syntaxhl" data-language="c"><span class="cp">#include</span> <span class="cpf">"ruby.h"</span><span class="cp">
#include</span> <span class="cpf">"ruby/thread.h"</span><span class="cp">
</span>
<span class="n">rb_internal_thread_event_hook_t</span> <span class="o">*</span><span class="n">hook</span><span class="p">;</span>
<span class="kt">void</span>
<span class="nf">event_hook_callback</span><span class="p">(</span><span class="n">rb_event_flag_t</span> <span class="n">flag</span><span class="p">,</span> <span class="k">const</span> <span class="n">rb_internal_thread_event_data_t</span> <span class="o">*</span><span class="n">data</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">custom_data</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">rb_internal_thread_remove_event_hook</span><span class="p">(</span><span class="n">hook</span><span class="p">);</span> <span class="c1">// hangs</span>
<span class="p">}</span>
<span class="n">RUBY_FUNC_EXPORTED</span> <span class="kt">void</span>
<span class="nf">Init_mycext</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">hook</span> <span class="o">=</span> <span class="n">rb_internal_thread_add_event_hook</span><span class="p">(</span>
<span class="n">event_hook_callback</span><span class="p">,</span>
<span class="n">RUBY_INTERNAL_THREAD_EVENT_RESUMED</span><span class="p">,</span>
<span class="nb">NULL</span>
<span class="p">);</span>
<span class="p">}</span>
</code></pre>
<pre><code>ruby -rmycext -e 'Thread.new { loop { 1 + 1 } }'
</code></pre> Ruby master - Bug #20097 (Open): Regexp#match? with empty capture group repeat is inconsistenthttps://bugs.ruby-lang.org/issues/200972023-12-27T10:56:46Ztompng (tomoya ishida)tomoyapenguin@gmail.com
<p>It sometimes matches and sometimes does not, depend on repeat quantifier number.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># empty capture group repeat</span>
<span class="nb">p</span> <span class="sr">/(a(){1,4}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> true</span>
<span class="nb">p</span> <span class="sr">/(a(){1,5}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> false</span>
<span class="c1"># repeat of capture group that match to empty string</span>
<span class="nb">p</span> <span class="sr">/(a(|){1,2}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> true</span>
<span class="nb">p</span> <span class="sr">/(a(|){1,3}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> false</span>
<span class="nb">p</span> <span class="sr">/(a(x?y?|z){1,2}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> false</span>
</code></pre>
<p>non-capturing group seems ok.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">p</span> <span class="sr">/(a(?:){1,4}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> true</span>
<span class="nb">p</span> <span class="sr">/(a(?:){1,5}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> true</span>
<span class="nb">p</span> <span class="sr">/(a(?:|){1,2}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> true</span>
<span class="nb">p</span> <span class="sr">/(a(?:|){1,3}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> true</span>
<span class="nb">p</span> <span class="sr">/(a(?:x?y?|z){1,2}){2}/</span><span class="p">.</span><span class="nf">match?</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span> <span class="c1">#=> true</span>
</code></pre>
<p>Same behavior in ruby 3.0, 3.1, 3.2</p> Ruby master - Bug #20089 (Open): Fiber#kill transfers to root fiberhttps://bugs.ruby-lang.org/issues/200892023-12-26T16:46:04Zrmosolgo (Robert Mosolgo)rdmosolgo@gmail.com
<p>I was hoping to use <code>Fiber#kill</code> to clean up formerly <code>.transfer</code>-d Fibers and work around <a href="https://bugs.ruby-lang.org/issues/20081" class="external">https://bugs.ruby-lang.org/issues/20081</a>, but I found that <code>Fiber#kill</code> has a similar control flow jump behavior. Is this on purpose, or a bug?</p>
<p>Here's a script to test the behavior:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">manager</span> <span class="o">=</span> <span class="no">Fiber</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">worker</span> <span class="o">=</span> <span class="no">Fiber</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="nb">puts</span> <span class="s2">"2. Begin Worker"</span>
<span class="n">manager</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"This should never print -- killed"</span>
<span class="k">end</span>
<span class="nb">puts</span> <span class="s2">"1. Transfer to Worker"</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"3. Killing Worker"</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">kill</span>
<span class="nb">puts</span> <span class="s2">"4. Finished manager"</span>
<span class="k">end</span>
<span class="n">manager</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"5. Finished script"</span>
</code></pre>
<p>I expected items <code>1</code> through <code>5</code> to be printed in order, but in fact, <code>4</code> is never printed:</p>
<pre><code>$ ruby fiber_transfer_test.rb
1. Transfer to Worker
2. Begin Worker
3. Killing Worker
5. Finished script
</code></pre>
<p>It seems like <code>worker.kill</code> is transferring control to the top-level fiber instead of giving it back to <code>manager</code>.</p>
<p>I also tried having the thread kill <em>itself</em>, hoping it would return to the fiber that originally <code>.transfer</code>ed to it, but it also seems to jump out:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">manager</span> <span class="o">=</span> <span class="no">Fiber</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">worker</span> <span class="o">=</span> <span class="no">Fiber</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="nb">puts</span> <span class="s2">"2. Begin Worker"</span>
<span class="n">manager</span><span class="p">.</span><span class="nf">transfer</span>
<span class="no">Fiber</span><span class="p">.</span><span class="nf">current</span><span class="p">.</span><span class="nf">kill</span>
<span class="nb">puts</span> <span class="s2">"This should never print -- killed"</span>
<span class="k">end</span>
<span class="nb">puts</span> <span class="s2">"1. Transfer to Worker"</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"3. Killing Worker"</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"4. Finished manager"</span>
<span class="k">end</span>
<span class="n">manager</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"5. Finished script"</span>
</code></pre>
<p>Prints:</p>
<pre><code>1. Transfer to Worker
2. Begin Worker
3. Killing Worker
5. Finished script
</code></pre> Ruby master - Bug #20045 (Assigned): `TestDir#test_home` fails on i686https://bugs.ruby-lang.org/issues/200452023-12-07T09:28:07Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<p>This is followup to <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: `TestFileExhaustive#test_expand_path_for_existent_username` and `TestDir#test_home` fails on i686 (Closed)" href="https://bugs.ruby-lang.org/issues/19147">#19147</a>. Testing on Fedora 38 and Fedora Rawhide, we are facing this test failure:</p>
<pre><code>$ tar xf build/SOURCES/ruby-3.2.2.tar.xz
$ cd ruby-3.2.2/
$ ./configure && make
... snip ...
---
Configuration summary for ruby version 3.2.2
* Installation prefix: /usr/local
* exec prefix: ${prefix}
* arch: i686-linux
* site arch: ${arch}
* RUBY_BASE_NAME: ruby
* ruby lib prefix: ${libdir}/${RUBY_BASE_NAME}
* site libraries path: ${rubylibprefix}/${sitearch}
* vendor path: ${rubylibprefix}/vendor_ruby
* target OS: linux
* compiler: gcc
* with thread: pthread
* with coroutine: x86
* enable shared libs: no
* dynamic library ext: so
* CFLAGS: ${optflags} ${debugflags} ${warnflags}
* LDFLAGS: -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic
* DLDFLAGS: -Wl,--compress-debug-sections=zlib
* optflags: -O3 -fno-fast-math
* debugflags: -ggdb3
* warnflags: -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition \
-Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat \
-Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef
* strip command: strip -S -x
* install doc: rdoc
* MJIT support: yes
* YJIT support: no
* man page type: doc
---
... snip ...
$ LANG=C make test-all 'TESTS=-v -n /TestDir#test_home/'
config.status: creating ruby-runner.h
making mjit_build_dir.so
generating i686-linux-fake.rb
i686-linux-fake.rb updated
Run options:
--seed=10517
"--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems"
--excludes-dir=./test/excludes
--name=!/memory_leak/
-v
-n
/TestDir#test_home/
# Running tests:
[1/0] TestDir#test_home = 0.00 s
1) Error:
TestDir#test_home:
RuntimeError: can't set length of shared string
/builddir/ruby-3.2.2/test/ruby/test_dir.rb:557:in `expand_path'
/builddir/ruby-3.2.2/test/ruby/test_dir.rb:557:in `block in test_home'
Finished tests in 4.164691s, 0.2401 tests/s, 1.6808 assertions/s.
1 tests, 7 assertions, 0 failures, 1 errors, 0 skips
ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [i686-linux]
make: *** [uncommon.mk:855: yes-test-all] Error 1
</code></pre>
<p>Please note that having the <code>C</code> locale is essential. The test passes just fine with e.g. <code>C.UTF-8</code> locale.</p>
<p>We were able to reduce the test case to the following:</p>
<pre><code>$ whoami
mockbuild
$ echo 'File.expand_path("~mockbuild")' > test.rb
$ LANG=C RUBYLIB=/builddir/ruby-3.2.2/.ext/i686-linux LD_LIBRARY_PATH=. ./ruby --disable-gems test.rb
test.rb:1:in `expand_path': can't set length of shared string (RuntimeError)
from test.rb:1:in `<main>'
</code></pre>
<p>As I said earlier, the <code>LANG=C</code> is essential as well as the <code>RUBYLIB=/builddir/ruby-3.2.2/.ext/i386-linux</code>. Adding the path to <code>RUBYLIB</code> enables Ruby to load the following libraries:</p>
<pre><code>/builddir/ruby-3.2.2/.ext/i686-linux/enc/encdb.so
/builddir/ruby-3.2.2/.ext/i686-linux/enc/trans/transdb.so
</code></pre>
<p>And that makes the difference. Also, the <code>File.expand_path("~mockbuild")</code> must be in some file, replacing this by <code>-e 'File.expand_path("~mockbuild")'</code> does not reproduce the issue.</p>
<p>We also believe that this was introduced by <a href="https://github.com/ruby/ruby/pull/6699" class="external">https://github.com/ruby/ruby/pull/6699</a>, specifically by <a class="changeset" title="Transition shape when object's capacity changes This commit adds a `capacity` field to shapes, a..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/5246f4027ec574e77809845e1b1f7822cc2a5cef">git|5246f4027ec574e77809845e1b1f7822cc2a5cef</a> and fixed in master by <a class="changeset" title="Enable 5 size pools on 32 bit systems This commit will allow 32 bit systems to take advantage of..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/b4571097df4a6bd848f1195026d82a92f3a7f9d8">git|b4571097df4a6bd848f1195026d82a92f3a7f9d8</a>.</p>
<p>Unfortunately, we were not able to discover what is the mechanism behind this, why this depends on locale, why the test must be in file, why the string is shared etc. But I hope we have provided enough details for someone else more knowledgeable.</p>
<p>Some background for this issue is also available here:</p>
<p><a href="https://src.fedoraproject.org/rpms/ruby/pull-request/164" class="external">https://src.fedoraproject.org/rpms/ruby/pull-request/164</a></p> Ruby master - Bug #19996 (Assigned): `RUBY_MN_THREADS=1` triggers Action Cable unit test failureshttps://bugs.ruby-lang.org/issues/199962023-11-10T04:16:56Zyahonda (Yasuo Honda)yasuo.honda@gmail.com
<a name="Steps-to-reproduce"></a>
<h3 >Steps to reproduce<a href="#Steps-to-reproduce" class="wiki-anchor">¶</a></h3>
<ol>
<li>Install <code>ruby 3.3.0dev</code>
</li>
<li>Set <code>RUBY_MN_THREADS=1</code> environment variable</li>
<li>Follow these steps</li>
</ol>
<pre><code>git clone https://github.com/rails/rails
cd rails
rm Gemfile.lock
bundle install
cd actioncable
bin/test test/channel/base_test.rb test/subscription_adapter/redis_test.rb test/channel/test_case_test.rb test/subscription_adapter/redis_test.rb test/client_test.rb --seed 14800
</code></pre>
<a name="Expected-behavior"></a>
<h3 >Expected behavior<a href="#Expected-behavior" class="wiki-anchor">¶</a></h3>
<p>It should pass as not setting <code>RUBY_MN_THREADS</code>.</p>
<pre><code>$ unset RUBY_MN_THREADS
$ bin/test test/channel/base_test.rb test/subscription_adapter/redis_test.rb test/channel/test_case_test.rb test/subscription_adapter/redis_test.rb test/client_test.rb --seed 14800
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:3: warning: mutex_m which will no longer be part of the default gems since Ruby 3.4.0. Add mutex_m to your Gemfile or gemspec.
Run options: --seed 14800
# Running:
.........................................................................
Finished in 12.031310s, 6.0675 runs/s, 46.7115 assertions/s.
73 runs, 562 assertions, 0 failures, 0 errors, 0 skips
$
</code></pre>
<a name="Actual-behavior"></a>
<h3 >Actual behavior<a href="#Actual-behavior" class="wiki-anchor">¶</a></h3>
<p>It usually fails as follows.</p>
<pre><code>$ bin/test test/channel/base_test.rb test/subscription_adapter/redis_test.rb test/channel/test_case_test.rb test/subscription_adapter/redis_test.rb test/client_test.rb --seed 14800
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:3: warning: mutex_m which will no longer be part of the default gems since Ruby 3.4.0. Add mutex_m to your Gemfile or gemspec.
Run options: --seed 14800
# Running:
..................................................F
Failure:
RedisAdapterTest::AlternateConfiguration#test_channel_prefix [/home/yahonda/src/github.com/rails/rails/actioncable/test/subscription_adapter/common.rb:35]:
Expected #<Concurrent::Event:0x00007f0b2698d4f0 @__Lock__=#<Thread::Mutex:0x00007f0b26f8cab8>, @__Condition__=#<Thread::ConditionVariable:0x00007f0b26f8ca90>, @set=false, @iteration=0> to be set?.
bin/test test/subscription_adapter/channel_prefix.rb:6
.F
Failure:
RedisAdapterTest::AlternateConfiguration#test_multiple_broadcast [/home/yahonda/src/github.com/rails/rails/actioncable/test/subscription_adapter/common.rb:35]:
Expected #<Concurrent::Event:0x00007f0b2698a4d0 @__Lock__=#<Thread::Mutex:0x00007f0b26fac688>, @__Condition__=#<Thread::ConditionVariable:0x00007f0b26fac4f8>, @set=false, @iteration=0> to be set?.
bin/test test/subscription_adapter/common.rb:74
E
Error:
ClientTest#test_interacting_clients:
ThreadError: queue empty
<internal:thread_sync>:18:in `pop'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:168:in `read_message'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:241:in `block (2 levels) in test_interacting_clients'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:218:in `block (2 levels) in concurrently'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb:1583:in `evaluate_to'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb:1766:in `block in on_resolvable'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
<internal:kernel>:187:in `loop'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb:1258:in `raise'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb:1258:in `wait_until_resolved!'
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb:988:in `value!'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:218:in `map'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:218:in `concurrently'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:240:in `block in test_interacting_clients'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:90:in `with_puma_server'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:234:in `test_interacting_clients'
bin/test test/client_test.rb:233
E
Error:
ClientTest#test_disappearing_client:
ThreadError: queue empty
<internal:thread_sync>:18:in `pop'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:168:in `read_message'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:275:in `block in test_disappearing_client'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:90:in `with_puma_server'
/home/yahonda/src/github.com/rails/rails/actioncable/test/client_test.rb:273:in `test_disappearing_client'
bin/test test/client_test.rb:272
..................
Finished in 1323.812615s, 0.0551 runs/s, 0.3830 assertions/s.
73 runs, 507 assertions, 2 failures, 2 errors, 0 skips
$
</code></pre> Ruby master - Bug #19794 (Assigned): Ruby 3.2.2 fails to build on macOS Sonoma betashttps://bugs.ruby-lang.org/issues/197942023-08-02T05:08:15Zjhaungs (Jim Haungs)
<p>With Big Sur, Apple deprecated putting dylibs in /usr/local/lib. In Sonoma (beta 4), this directory has disappeared completely. However, ruby's configure script depends on its existence. So, virtually every ruby installer (RVM, rbenv, asdf, ruby-build, and even building from source tarball) fails.</p>
<p>When building ruby 3.2.2 from source, the configure step outputs the irritatingly useless "something wrong with LDFLAGS" error message and fails to build.</p>
<p>The solution was to <code>cd /usr/local; sudo mkdir lib</code> to create the missing lib directory under /usr/local.</p>
<p>It would be nice to remove this dependency from the configure script.</p> Ruby master - Bug #19410 (Assigned): If move from ractor fails with error, some objects are left ...https://bugs.ruby-lang.org/issues/194102023-02-03T20:02:50Zluke-gru (Luke Gruber)luke.gru@gmail.com
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">receive</span>
<span class="k">end</span>
<span class="n">a</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="n">obj</span> <span class="o">=</span> <span class="p">[</span><span class="n">a</span><span class="p">,</span> <span class="nb">proc</span> <span class="p">{</span> <span class="p">}]</span>
<span class="k">begin</span>
<span class="n">r</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="ss">move: </span><span class="kp">true</span><span class="p">)</span>
<span class="k">rescue</span> <span class="o">=></span> <span class="n">e</span>
<span class="nb">puts</span> <span class="s2">"couldn't move"</span>
<span class="k">end</span>
<span class="nb">p</span> <span class="n">a</span> <span class="c1"># a is moved, this errors out. But it's not really moved because the other ractor can't access it. It's in limbo :)</span>
<span class="n">r</span> <span class="o"><<</span> <span class="ss">:end</span>
<span class="n">r</span><span class="p">.</span><span class="nf">take</span>
</code></pre>
<p>This might be tricky to fix, as it requires some sort of commit function for moving objects after every object is checked for ability to move.</p> Ruby master - Bug #19408 (Assigned): Object no longer frozen after moved from a ractorhttps://bugs.ruby-lang.org/issues/194082023-02-03T18:55:10Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>I think frozen objects should still be frozen after a move.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">receive</span>
<span class="nb">p</span> <span class="n">obj</span><span class="p">.</span><span class="nf">frozen?</span> <span class="c1"># should be true but is false</span>
<span class="nb">p</span> <span class="n">obj</span>
<span class="k">end</span>
<span class="n">obj</span> <span class="o">=</span> <span class="p">[</span><span class="no">Object</span><span class="p">.</span><span class="nf">new</span><span class="p">].</span><span class="nf">freeze</span>
<span class="n">r</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="ss">move: </span><span class="kp">true</span><span class="p">)</span>
<span class="n">r</span><span class="p">.</span><span class="nf">take</span>
</code></pre> Ruby master - Bug #19407 (Assigned): 2 threads taking from current ractor will hang foreverhttps://bugs.ruby-lang.org/issues/194072023-02-03T18:43:11Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>In the current implementation of Ractors, it's possible to <code>take</code> from the current ractor. This could be useful<br>
when co-ordinating threads:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">t</span> <span class="o">=</span> <span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">obj</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">current</span><span class="p">.</span><span class="nf">take</span>
<span class="nb">p</span> <span class="n">obj</span> <span class="c1"># do some work with obj</span>
<span class="k">end</span>
<span class="n">t0</span> <span class="o">=</span> <span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">obj</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">current</span><span class="p">.</span><span class="nf">take</span>
<span class="nb">p</span> <span class="n">obj</span> <span class="c1"># do some work with obj</span>
<span class="k">end</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">yield</span> <span class="ss">:go</span>
</code></pre>
<p>However it hangs forever:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">t</span> <span class="o">=</span> <span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">obj</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">current</span><span class="p">.</span><span class="nf">take</span>
<span class="nb">p</span> <span class="n">obj</span>
<span class="k">end</span>
<span class="n">t0</span> <span class="o">=</span> <span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">obj</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">current</span><span class="p">.</span><span class="nf">take</span>
<span class="nb">p</span> <span class="n">obj</span>
<span class="k">end</span>
<span class="nb">sleep</span> <span class="mf">0.5</span>
</code></pre>
<p>Should "self-take" be disabled, or was it designed to allow it but this is just a bug?</p> Ruby master - Bug #19383 (Assigned): Time.now.zone encoding for German display language in Window...https://bugs.ruby-lang.org/issues/193832023-01-26T20:52:24Zstringsn88keys (Thomas Powell)
<p>OS:<br>
Verified on Windows 10 and Windows Server 2022 and Ruby 2.7.7 through 3.1.3</p>
<p>Display language:<br>
Verified on German, but may impact other languages in which Time.now.zone returns characters that aren't [A-Za-z].</p>
<p>Time zone:<br>
CET (UTC +01:00) Amsterdam, Berlin, ...</p>
<p>Time.now.zone # => "Mitteleuro\xE3ische Zeit"<br>
Time.now.zone.encoding # => #<a href="Encoding:IBM437" class="external">Encoding:IBM437</a><br>
puts Time.now.zone # => "Mitteleurop∑ische Zeit" (should be "Mitteleuropäische Zeit")<br>
Time.now.zone.encode(Encoding::UTF_8) # => "Mitteleurop∑ische Zeit"</p>
<p>Doing a force_encoding on all encodings in Encoding.list reveals that ISO-8859-(1..16) and Windows-125(0,2,4,7) work to coerce the ä out of the time zone string:<br>
Time.now.zone.force_encoding(Encoding::WINDOWS_1252) # => "Mitteleuro\xE3ische Zeit"<br>
... but ...<br>
Time.now.zone.force_encoding(Encoding::WINDOWS_1252).encode(Encoding::UTF_8) #=> "Mitteleuropäische Zeit"</p>
<p>Related issue: This improper encoding/rendering caused Ohai's JSON output to be unparseable. Workaround was forcing to Windows-1252.<br>
<a href="https://github.com/chef/ohai/pull/1781" class="external">https://github.com/chef/ohai/pull/1781</a></p> Ruby master - Bug #19378 (Assigned): Windows: Use less syscalls for faster require of big gemshttps://bugs.ruby-lang.org/issues/193782023-01-26T07:02:23Zaidog (Andi Idogawa)andi@idogawa.com
<p>Hello 🙂</p>
<a name="Problem"></a>
<h2 >Problem<a href="#Problem" class="wiki-anchor">¶</a></h2>
<p>require is slow on windows for big gems. (example: require 'gtk3'=> 3 seconds+). This is a problem for people who want to make cross platform GUI apps with ruby.</p>
<a name="Possible-Reason"></a>
<h2 >Possible Reason<a href="#Possible-Reason" class="wiki-anchor">¶</a></h2>
<p>As touched on in <a href="https://bugs.ruby-lang.org/issues/15797" class="external">#15797</a> it seems like require uses realpath, which is emulated on windows. It checks every parent directory. The same syscalls run many times.</p>
<a name="Testfile"></a>
<h2 >Testfile<a href="#Testfile" class="wiki-anchor">¶</a></h2>
<p>C:\tmp\speedtest\testrequire.rb:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="n">__dir__</span> <span class="o">+</span> <span class="s2">"/helloworld1.rb"</span>
<span class="nb">require</span> <span class="n">__dir__</span> <span class="o">+</span> <span class="s2">"/helloworld2.rb"</span>
</code></pre>
<pre><code class="shell syntaxhl" data-language="shell">ruby <span class="nt">--disable-gems</span> C:<span class="se">\t</span>mp<span class="se">\s</span>peedtest<span class="se">\t</span>estrequire.rb
</code></pre>
<a name="Syscalls-per-FileDirectory"></a>
<h3 >Syscalls per File/Directory:<a href="#Syscalls-per-FileDirectory" class="wiki-anchor">¶</a></h3>
<ol>
<li>CreateFile</li>
<li>QueryInformationVolume</li>
<li>QueryIdInformation</li>
<li>QueryAllInformationFile</li>
<li>QueryNameInformationFile</li>
<li>QueryNameInformationFile</li>
<li>QueryNormalizedNameInformationFile</li>
<li>CloseFile</li>
</ol>
<a name="FilesDirectories-checked"></a>
<h3 >Files/Directories checked<a href="#FilesDirectories-checked" class="wiki-anchor">¶</a></h3>
<ol>
<li>C:\tmp</li>
<li>C:\tmp\speedtest</li>
<li>C:\tmp\speedtest\helloworld1.rb</li>
<li>C:\tmp</li>
<li>C:\tmp\speedtest</li>
<li>C:\tmp\speedtest\helloworld2.rb</li>
</ol>
<p>For two required files Ruby had to do 8*6 = <strong>48</strong> syscalls.<br>
The syscalls orginate from rb_w32_reparse_symlink_p / lstat</p>
<p>Rubygems live in subfolders with 9+ parts: "C:\Ruby32-x64\lib\ruby\gems\3.2.0\gems\glib2-4.0.8\lib\glib2\variant.rb"<br>
Each file takes 8 * 9 = <strong>72</strong>+ calls. For variant.rb it is <strong>80</strong> calls.<br>
The result for the syscalls don't change in such a short time, so it should be possible to cache it.</p>
<p>With require_relative it's twice as many calls.</p>
<a name="Other-testcases"></a>
<h2 >Other testcases<a href="#Other-testcases" class="wiki-anchor">¶</a></h2>
<p>Same result:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">File</span><span class="p">.</span><span class="nf">realpath</span> <span class="n">__dir__</span> <span class="o">+</span> <span class="s2">"/helloworld1.rb"</span>
<span class="no">File</span><span class="p">.</span><span class="nf">realpath</span> <span class="n">__dir__</span> <span class="o">+</span> <span class="s2">"/helloworld2.rb"</span>
</code></pre>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">File</span><span class="p">.</span><span class="nf">stat</span> <span class="n">__dir__</span> <span class="o">+</span> <span class="s2">"/helloworld1.rb"</span>
<span class="no">File</span><span class="p">.</span><span class="nf">stat</span> <span class="n">__dir__</span> <span class="o">+</span> <span class="s2">"/helloworld2.rb"</span>
</code></pre>
<p>It does not happen in $LOAD_PATH.resolve_feature_path(<strong>dir</strong> + "/helloworld1.rb")</p>
<a name="Request"></a>
<h2 >Request<a href="#Request" class="wiki-anchor">¶</a></h2>
<p>Would it be possible to cache the stat calls when using require?<br>
I tried to implement a cache inside the ruby source code, but failed.<br>
If not, is there now a way to combine ruby files into one?</p>
<p>I previously talked about require here: <a href="https://bugs.ruby-lang.org/issues/19325#note-11" class="external">YJIT: Windows support lacking.</a></p>
<a name="How-to-reproduce"></a>
<h2 >How to reproduce<a href="#How-to-reproduce" class="wiki-anchor">¶</a></h2>
<p>Ruby versions: At least 3.0+, most likely older ones too.<br>
Tested using Ruby Installer 3.1 and 3.2.<br>
<a href="https://learn.microsoft.com/en-us/sysinternals/downloads/procmon" class="external">Procmon Software by Sysinternals</a></p> Ruby master - Bug #19374 (Assigned): Issue with Ractor.make_shareable with curried procshttps://bugs.ruby-lang.org/issues/193742023-01-24T12:40:33Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>This works, but shouldn't:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Worker</span>
<span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="o">&</span><span class="n">blk</span><span class="p">)</span>
<span class="n">blk</span> <span class="o">=</span> <span class="n">blk</span><span class="p">.</span><span class="nf">curry</span> <span class="c1"># bug in ruby allows sharing of non-shareable proc</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">make_shareable</span><span class="p">(</span><span class="n">blk</span><span class="p">)</span>
<span class="vi">@ractor</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">blk</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">b</span><span class="o">|</span>
<span class="n">main</span> <span class="o">=</span> <span class="n">b</span><span class="p">.</span><span class="nf">call</span>
<span class="nb">p</span> <span class="s2">"from ractor: </span><span class="si">#{</span><span class="n">main</span><span class="si">}</span><span class="s2">"</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">work</span>
<span class="vi">@ractor</span><span class="p">.</span><span class="nf">take</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">worker</span> <span class="o">=</span> <span class="no">Worker</span><span class="p">.</span><span class="nf">new</span>
<span class="n">a</span> <span class="o">=</span> <span class="nb">self</span> <span class="c1"># unshareable main object</span>
<span class="nb">p</span> <span class="s2">"from main: </span><span class="si">#{</span><span class="n">a</span><span class="si">}</span><span class="s2">"</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">start</span> <span class="p">{</span> <span class="n">a</span> <span class="p">}</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">work</span>
</code></pre>
<p>The curried proc has a reference to the original proc and it's not checked for shareability.</p> Ruby master - Bug #19372 (Assigned): Proc objects are not traversed for shareable check during Ra...https://bugs.ruby-lang.org/issues/193722023-01-23T19:23:33Zluke-gru (Luke Gruber)luke.gru@gmail.com
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Proc</span>
<span class="nb">attr_accessor</span> <span class="ss">:obj1</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="vi">@obj1</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="nb">p</span> <span class="o">=</span> <span class="kp">true</span><span class="p">.</span><span class="nf">instance_eval</span> <span class="p">{</span> <span class="no">Proc</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span> <span class="nb">puts</span> <span class="s2">"hi"</span> <span class="p">}</span> <span class="p">}</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">make_shareable</span><span class="p">(</span><span class="nb">p</span><span class="p">)</span>
<span class="nb">p</span> <span class="s2">"Obj1 frozen?"</span><span class="p">,</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">shareable?</span><span class="p">(</span><span class="nb">p</span><span class="p">.</span><span class="nf">obj1</span><span class="p">)</span>
<span class="no">P</span> <span class="o">=</span> <span class="nb">p</span>
<span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">pp</span> <span class="o">=</span> <span class="no">P</span>
<span class="nb">p</span> <span class="n">pp</span><span class="p">.</span><span class="nf">obj1</span> <span class="c1"># gives error in debug builds (rb_ractor_confirm_belonging rb_bug() call)</span>
<span class="k">end</span>
</code></pre> Ruby master - Bug #19369 (Assigned): Small corner-case issue that breaks Ractor isolation: change...https://bugs.ruby-lang.org/issues/193692023-01-23T01:28:22Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>I was looking into how objects are traversed for deep cloning and I came up with a way to break it. I don't think it'll ever happen in real life so it's not really an issue, just<br>
an interesting case. Run with warnings disabled.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">obj</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="nb">p</span> <span class="s2">"unshareable obj:"</span><span class="p">,</span> <span class="n">obj</span>
<span class="no">UNSHAREABLE</span> <span class="o">=</span> <span class="n">obj</span>
<span class="no">GO</span> <span class="o">=</span> <span class="kp">false</span>
<span class="no">SET</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">class</span> <span class="nc">Object</span>
<span class="nb">attr_accessor</span> <span class="ss">:unshareable</span>
<span class="k">def</span> <span class="nf">initialize_clone</span><span class="p">(</span><span class="n">orig</span><span class="p">)</span>
<span class="nb">puts</span> <span class="s2">"Clone called for </span><span class="si">#{</span><span class="n">orig</span><span class="p">.</span><span class="nf">inspect</span><span class="si">}</span><span class="s2">, self = </span><span class="si">#{</span><span class="nb">self</span><span class="p">.</span><span class="nf">inspect</span><span class="si">}</span><span class="s2">"</span>
<span class="n">_self</span> <span class="o">=</span> <span class="nb">self</span>
<span class="k">if</span> <span class="n">orig</span> <span class="o">==</span> <span class="no">UNSHAREABLE</span>
<span class="n">t</span> <span class="o">=</span> <span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="nb">puts</span> <span class="s2">"In thread"</span>
<span class="no">Thread</span><span class="p">.</span><span class="nf">pass</span> <span class="k">until</span> <span class="no">GO</span>
<span class="nb">puts</span> <span class="s2">"Setting unshareable!"</span>
<span class="c1"># this must be done in separate thread to bypass object traversal deep-cloning</span>
<span class="n">_self</span><span class="p">.</span><span class="nf">unshareable</span> <span class="o">=</span> <span class="no">UNSHAREABLE</span>
<span class="no">Object</span><span class="p">.</span><span class="nf">const_set</span><span class="p">(</span><span class="ss">:SET</span><span class="p">,</span> <span class="kp">true</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">super</span><span class="p">(</span><span class="n">orig</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">r</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">o</span><span class="o">|</span>
<span class="nb">puts</span> <span class="s2">"from r</span><span class="si">#{</span><span class="no">Ractor</span><span class="p">.</span><span class="nf">current</span><span class="p">.</span><span class="nf">object_id</span><span class="si">}</span><span class="s2"> obj </span><span class="si">#{</span><span class="n">o</span><span class="p">.</span><span class="nf">inspect</span><span class="si">}</span><span class="s2">"</span>
<span class="no">GO</span> <span class="o">=</span> <span class="kp">true</span>
<span class="kp">loop</span> <span class="k">until</span> <span class="no">SET</span>
<span class="nb">p</span> <span class="s2">"from ractor, got unshareable:"</span><span class="p">,</span> <span class="n">o</span><span class="p">.</span><span class="nf">unshareable</span>
<span class="k">end</span>
<span class="n">r</span><span class="p">.</span><span class="nf">take</span>
</code></pre> Ruby master - Bug #19368 (Assigned): Small issue with isolated procs and evalhttps://bugs.ruby-lang.org/issues/193682023-01-22T17:40:38Zluke-gru (Luke Gruber)luke.gru@gmail.com
<pre><code>a = Object.new # non-shareable
prok = Ractor.current.instance_eval do
Proc.new do
eval('a')
end
end
prok.call # this should work, we're in the main ractor and the proc is not isolated
Ractor.make_shareable(prok) # this doesn't currently work, but I think it should. It gives Ractor::IsolationError. See below for reasoning on why I think it should work.
# A flag seems to be set on the proc after it's run and accesses outers...
</code></pre>
<p>Because this work fine:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">a</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span> <span class="c1"># non-shareable</span>
<span class="n">prok</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">current</span><span class="p">.</span><span class="nf">instance_eval</span> <span class="k">do</span>
<span class="no">Proc</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="nb">eval</span><span class="p">(</span><span class="s1">'a'</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">make_shareable</span><span class="p">(</span><span class="n">prok</span><span class="p">)</span> <span class="c1"># this works, and it's okay because we get a different error when actually running the shareable proc inside a ractor that accesses outers through eval.</span>
</code></pre> Ruby master - Bug #19367 (Assigned): Issue with ractor local storage APIhttps://bugs.ruby-lang.org/issues/193672023-01-22T14:46:45Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>In a non-main ractor, you can do Ractor.main[:key] = 'val', but it only affects storage for Ractor.current, not Ractor.main (which is good!).<br>
I think it should throw a RuntimeError if trying to get/set ractor-local storage for non-current ractor.</p>
<p>Patch coming.</p> Ruby master - Bug #19364 (Assigned): Issue with tracepoint enable/disable across ractorshttps://bugs.ruby-lang.org/issues/193642023-01-21T22:54:58Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>This sometimes segfaults:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">test_enable_disable_in_multiple_ractors_with_target</span>
<span class="n">rs</span> <span class="o">=</span> <span class="p">[]</span>
<span class="mi">100</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span>
<span class="c1"># setup new iseqs</span>
<span class="no">Kernel</span><span class="p">.</span><span class="nf">define_method</span> <span class="ss">:"my_method_to_change_for_tracing_</span><span class="si">#{</span><span class="n">i</span><span class="si">}</span><span class="ss">"</span> <span class="k">do</span>
<span class="kp">true</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="mi">100</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span>
<span class="n">rs</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">j</span><span class="o">|</span>
<span class="n">meth</span> <span class="o">=</span> <span class="ss">:"my_method_to_change_for_tracing_</span><span class="si">#{</span><span class="n">j</span><span class="si">}</span><span class="ss">"</span>
<span class="n">tp</span> <span class="o">=</span> <span class="no">TracePoint</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">:line</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span> <span class="c1"># local to ractor</span>
<span class="mi">100</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
<span class="n">tp</span><span class="p">.</span><span class="nf">enable</span><span class="p">(</span><span class="ss">target: </span><span class="nb">method</span><span class="p">(</span><span class="n">meth</span><span class="p">))</span> <span class="c1"># change iseq internals of given method, should be done with lock</span>
<span class="n">tp</span><span class="p">.</span><span class="nf">disable</span> <span class="c1"># disable hooks should hold lock too, changes method definition internals</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">rs</span><span class="p">.</span><span class="nf">each</span><span class="p">(</span><span class="o">&</span><span class="ss">:take</span><span class="p">)</span> <span class="c1"># shouldn't raise</span>
<span class="k">end</span>
<span class="n">test_enable_disable_in_multiple_ractors_with_target</span><span class="p">()</span>
</code></pre>
<p>Changing iseq internals is done without the VM lock. This is true in Tracepoint#enable and Tracepoint#disable methods.<br>
I have a patch coming.</p> Ruby master - Bug #19338 (Assigned): Ruby hangs when ouputting warnings inside ractor with VM loc...https://bugs.ruby-lang.org/issues/193382023-01-14T18:15:37Zluke-gru (Luke Gruber)luke.gru@gmail.com
<p>This code causes Ruby to hang:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">rs</span> <span class="o">=</span> <span class="p">[]</span>
<span class="mi">2</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
<span class="n">rs</span> <span class="o"><<</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="no">MYCONSTANT</span> <span class="o">=</span> <span class="mi">2</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">rs</span><span class="p">.</span><span class="nf">each</span><span class="p">(</span><span class="o">&</span><span class="ss">:take</span><span class="p">)</span>
</code></pre>
<p>There is a problem when the warning is being outputted with multiple ractors. A thread is calling RB_VM_LOCK() while holding the VM lock in ractor.c (ractor_check_blocking())</p>
<p>If the code is changed to RB_VM_LOCK_ENTER() and RB_VM_LOCK_LEAVE() then it fixes it, but I don't know if there's a better way.</p>
<p>Thanks!</p> Test - Bug #19186 (Open): test2https://bugs.ruby-lang.org/issues/191862022-12-06T01:25:49Zshugo (Shugo Maeda)
<p>Hello, this is a test issue.<br>
This is a second line with umlaut: ü</p> Test - Bug #19185 (Open): testhttps://bugs.ruby-lang.org/issues/191852022-12-06T01:24:24Zshugo (Shugo Maeda)
<p>hello, this is a test issue.<br>
This is a second line.</p> Ruby master - Bug #18940 (Assigned): Ruby Ractor fails with IOError when handling higher concurrencyhttps://bugs.ruby-lang.org/issues/189402022-07-26T18:33:12Zbrodock (Gabriel Mazetto)brodock@gmail.com
<p>Reproduction server:</p>
<pre><code>require 'socket'
# Set based on CPU count
CONCURRENCY = 8
server = TCPServer.new(8080)
workers = CONCURRENCY.times.map do
Ractor.new do
loop do
# receive TCPSocket
session = Ractor.recv
request = session.gets
puts request
session.print "HTTP/1.1 200\r\n"
session.print "Content-Type: text/html\r\n"
session.print "\r\n"
session.print "Hello world! Current time is #{Time.now}"
session.close
end
end
end
loop do
conn, _ = server.accept
# pass TCPSocket to one of the workers
workers.sample.send(conn, move: true)
end
</code></pre>
<p>run apache benchmark against code above:</p>
<pre><code>ab -n 20000 -c 20 http://localhost:8080/
</code></pre>
<p>or run using hey (<a href="https://github.com/rakyll/hey" class="external">https://github.com/rakyll/hey</a>):</p>
<pre><code>hey -n 20000 -c 20 http://localhost:8080/
</code></pre>
<p>you should see something like this on the benchmark tool side:</p>
<pre><code>Summary:
Total: 32.9538 secs
Slowest: 2.6317 secs
Fastest: 0.0002 secs
Average: 0.0331 secs
Requests/sec: 606.9098
Response time histogram:
0.000 [1] |
0.263 [16968] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.527 [1740] |■■■■
0.790 [0] |
1.053 [0] |
1.316 [0] |
1.579 [0] |
1.842 [0] |
2.105 [20] |
2.369 [0] |
2.632 [6] |
Latency distribution:
10% in 0.0008 secs
25% in 0.0010 secs
50% in 0.0012 secs
75% in 0.0016 secs
90% in 0.0075 secs
95% in 0.3101 secs
99% in 0.3175 secs
Details (average, fastest, slowest):
DNS+dialup: 0.0322 secs, 0.0002 secs, 2.6317 secs
DNS-lookup: 0.0006 secs, 0.0000 secs, 0.0127 secs
req write: 0.0001 secs, 0.0000 secs, 0.0095 secs
resp wait: 0.0007 secs, 0.0000 secs, 0.0140 secs
resp read: 0.0001 secs, 0.0000 secs, 0.0088 secs
Status code distribution:
[200] 18735 responses
Error distribution:
[1231] Get "http://localhost:8080/": dial tcp [::1]:8080: connect: connection refused
[16] Get "http://localhost:8080/": dial tcp [::1]:8080: connect: connection reset by peer
[1] Get "http://localhost:8080/": net/http: HTTP/1.x transport connection broken: unexpected EOF
[1] Get "http://localhost:8080/": read tcp 127.0.0.1:57078->127.0.0.1:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57054->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57058->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57059->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57062->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57067->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57068->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57069->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57070->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57071->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57072->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57075->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57076->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57087->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57088->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57089->[::1]:8080: read: connection reset by peer
[1] Get "http://localhost:8080/": read tcp [::1]:57090->[::1]:8080: read: connection reset by peer
</code></pre>
<p>and this on the ruby process:</p>
<pre><code>...
GET / HTTP/1.1
GET / HTTP/1.1
#<Thread:0x0000000100fbf6e8 run> terminated with exception (report_on_exception is true):
ractor.rb:21:in `write': GET / HTTP/1.1
uninitialized stream (IOError)
from ractor.rb:21:in `print'
from ractor.rb:21:in `block (3 levels) in <main>'
from ractor.rb:11:in `loop'
from ractor.rb:11:in `block (2 levels) in <main>'
GET / HTTP/1.1
GET / HTTP/1.1
</code></pre> Ruby master - Bug #18677 (Assigned): BigDecimal#power (**) returns FloatDomainError when passing ...https://bugs.ruby-lang.org/issues/186772022-04-04T09:27:59Zdorianmariefr (Dorian Marié)
<p>Example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="o">></span> <span class="no">BigDecimal</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="o">**</span> <span class="no">BigDecimal</span><span class="p">(</span><span class="s2">"Infinity"</span><span class="p">)</span>
<span class="no">FloatDomainError</span><span class="p">:</span> <span class="no">Computation</span> <span class="n">results</span> <span class="k">in</span> <span class="s1">'Infinity'</span>
</code></pre>
<p>Maybe:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s2">"bigdecimal/util"</span>
<span class="k">class</span> <span class="nc">BigDecimal</span> <span class="o"><</span> <span class="no">Numeric</span>
<span class="k">def</span> <span class="nf">**</span><span class="p">(</span><span class="n">other</span><span class="p">)</span>
<span class="k">if</span> <span class="n">other</span><span class="p">.</span><span class="nf">infinite?</span> <span class="o">==</span> <span class="mi">1</span>
<span class="k">if</span> <span class="nb">self</span> <span class="o">></span> <span class="mi">1</span>
<span class="no">BigDecimal</span><span class="o">::</span><span class="no">INFINITY</span>
<span class="k">elsif</span> <span class="nb">self</span> <span class="o">==</span> <span class="mi">1</span>
<span class="nb">self</span>
<span class="k">elsif</span> <span class="nb">self</span> <span class="o">>=</span> <span class="mi">0</span>
<span class="no">BigDecimal</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="k">else</span>
<span class="n">power</span><span class="p">(</span><span class="n">other</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">else</span>
<span class="n">power</span><span class="p">(</span><span class="n">other</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">puts_and_eval</span><span class="p">(</span><span class="n">string</span><span class="p">)</span>
<span class="nb">puts</span> <span class="n">string</span>
<span class="nb">p</span> <span class="nb">eval</span><span class="p">(</span><span class="n">string</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">puts_and_eval</span> <span class="s2">"10 ** BigDecimal::INFINITY"</span>
<span class="n">puts_and_eval</span> <span class="s2">"1 ** BigDecimal::INFINITY"</span>
<span class="n">puts_and_eval</span> <span class="s2">"0.1 ** BigDecimal::INFINITY"</span>
<span class="n">puts_and_eval</span> <span class="s2">"0 ** BigDecimal::INFINITY"</span>
<span class="n">puts_and_eval</span> <span class="s2">"-1 ** BigDecimal::INFINITY"</span>
</code></pre>
<p>Seems like ruby is doing very different things from math though</p> Ruby master - Bug #18337 (Assigned): Ruby allows zero-width characters in identifiershttps://bugs.ruby-lang.org/issues/183372021-11-15T00:14:21Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<p>Ruby allows zero-width characters in identifiers, which can be shown with the following small test:</p>
<p>irb(main):001:0> script = "ab = 20; a\u200Bb = 30; puts ab;"<br>
=> "ab = 20; ab = 30; puts ab;"<br>
irb(main):002:0> eval(script)<br>
20<br>
=> nil</p>
<p>The first line creates the script. It contains a zero-width space (ZWSP), but that's not visible in most contexts (see next line). Looking at the script, one expects 30 as an output, but the output is 20 because there are two variables involved, one with a ZWSP and one without. I propose we fix this by disallowing such characters in identifiers. I'll give more details in a followup.</p> Ruby master - Bug #18119 (Assigned): Ractor crashes when instantiating classeshttps://bugs.ruby-lang.org/issues/181192021-08-19T13:23:40Zpeterzhu2118 (Peter Zhu)peter@peterzhu.ca
<p>The following script crashes with a segfault (tested on Ubuntu 20.04 and macOS 11.5.2):</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">workers</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="o">...</span><span class="mi">8</span><span class="p">).</span><span class="nf">map</span> <span class="k">do</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="kp">loop</span> <span class="k">do</span>
<span class="mi">100</span><span class="p">.</span><span class="nf">times</span><span class="p">.</span><span class="nf">map</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="no">Ractor</span><span class="p">.</span><span class="nf">yield</span> <span class="kp">nil</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="mi">100</span><span class="p">.</span><span class="nf">times</span> <span class="p">{</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">select</span><span class="p">(</span><span class="o">*</span><span class="n">workers</span><span class="p">)</span> <span class="p">}</span>
</code></pre>
<p>Crash error:</p>
<pre><code><internal:ractor>:267: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
test.rb:4: [BUG] Segmentation fault at 0x0000000000000040
ruby 3.1.0dev (2021-08-19T08:44:48Z master 6963f8f743) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0010 p:---- s:0033 e:000032 CFUNC :new
c:0009 p:0011 s:0029 e:000028 BLOCK test.rb:4 [FINISH]
c:0008 p:---- s:0026 e:000025 IFUNC
c:0007 p:---- s:0023 e:000022 CFUNC :times
c:0006 p:---- s:0020 e:000019 CFUNC :each
c:0005 p:---- s:0017 e:000016 CFUNC :map
c:0004 p:0007 s:0013 e:000012 BLOCK test.rb:4 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC :loop
c:0002 p:0004 s:0006 e:000005 BLOCK test.rb:3 [FINISH]
c:0001 p:---- s:0003 e:000002 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
test.rb:3:in `block (2 levels) in <main>'
test.rb:3:in `loop'
test.rb:4:in `block (3 levels) in <main>'
test.rb:4:in `map'
test.rb:4:in `each'
test.rb:4:in `times'
test.rb:4:in `block (4 levels) in <main>'
test.rb:4:in `new'
-- Machine register context ------------------------------------------------
RIP: 0x0000562c1f9cd2cb RBP: 0x00007f6c3736d378 RSP: 0x00007f6c368285f0
RAX: 0x00007f6c1c00e208 RBX: 0x00007f6c3736d378 RCX: 0x0000562c20ed8330
RDX: 0x0000000000000000 RDI: 0x00007f6c100095c0 RSI: 0x0000000000000000
R8: 0x0000000000000007 R9: 0x0000562c20ed8120 R10: 0x0000000000000022
R11: 0x0000562c21180760 R12: 0x0000000000000000 R13: 0x00007f6c3736c000
R14: 0x0000000000000000 R15: 0x00007f6c3736d378 EFL: 0x0000000000010202
-- C level backtrace information -------------------------------------------
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_print_backtrace+0x11) [0x562c1f995e38] ../vm_dump.c:759
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_bugreport) ../vm_dump.c:1041
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_bug_for_fatal_signal+0xec) [0x562c1f78a0bc] ../error.c:815
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(sigsegv+0x4d) [0x562c1f8ebcbd] ../signal.c:961
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7f6c3b2c63c0]
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_class_remove_from_super_subclasses+0x2b) [0x562c1f9cd2cb] ../class.c:99
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(obj_free+0x37a) [0x562c1f7ae95a] ../gc.c:3123
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(gc_plane_sweep+0x21) [0x562c1f7aef3d] ../gc.c:5322
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(gc_page_sweep) ../gc.c:5464
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(gc_sweep_step) ../gc.c:5630
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(gc_heap_prepare_minimum_pages+0x0) [0x562c1f7afd94] ../gc.c:5834
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(gc_sweep) ../gc.c:5837
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(gc_marks+0x1c0) [0x562c1f7b3df8] ../gc.c:8144
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(gc_start) ../gc.c:9013
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(heap_prepare+0x2f) [0x562c1f7b8b6f] ../gc.c:2131
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(heap_next_freepage) ../gc.c:2422
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(ractor_cache_slots) ../gc.c:2454
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(newobj_slowpath) ../gc.c:2495
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(newobj_slowpath_wb_protected) ../gc.c:2519
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(newobj_of0+0x5) [0x562c1f7b8ebd] ../gc.c:2562
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(newobj_of) ../gc.c:2572
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_wb_protected_newobj_of) ../gc.c:2596
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(class_alloc+0x5) [0x562c1f9cd49e] ../class.c:185
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_class_boot) ../class.c:230
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(class_call_alloc_func+0x5) [0x562c1f84e5d3] ../object.c:2075
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_class_alloc) ../object.c:2047
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_class_new_instance_pass_kw) ../object.c:2120
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_cfp_consistent_p+0x0) [0x562c1f96d6bc] ../vm_insnhelper.c:2989
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call_cfunc_with_frame) ../vm_insnhelper.c:2991
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_sendish+0x303) [0x562c1f978393] ../vm_insnhelper.c:4562
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_exec_core+0xcd) [0x562c1f98316d] ../insns.def:775
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_exec+0x197) [0x562c1f978fc7] ../vm.c:2164
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(collect_i+0x12) [0x562c1fa27bf2] ../enum.c:608
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_pop_frame+0x0) [0x562c1f976ba8] ../vm_insnhelper.c:3795
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_yield_with_cfunc) ../vm_insnhelper.c:3796
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(invoke_block_from_c_bh+0x10) [0x562c1f97d0d3] ../vm.c:1359
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_yield) ../vm.c:1399
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_yield_0) ../vm_eval.c:1350
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_yield_1) ../vm_eval.c:1356
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(int_dotimes+0x5c) [0x562c1f83a49c] ../numeric.c:5014
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_cfp_consistent_p+0x0) [0x562c1f97dd4f] ../vm_eval.c:135
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call0_cfunc_with_frame) ../vm_eval.c:137
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call0_cfunc) ../vm_eval.c:149
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call0_body) ../vm_eval.c:182
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_call0+0x1ea) [0x562c1f9812fa] ../vm_eval.c:72
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(iterate_method+0x3b) [0x562c1f981e9b] ../vm_eval.c:847
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_iterate0+0x101) [0x562c1f973001] ../vm_eval.c:1534
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_block_call_kw+0x76) [0x562c1f9731f6] ../vm_eval.c:1566
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(enumerator_block_call+0x59) [0x562c1fa358e9] ../enumerator.c:553
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_cfp_consistent_p+0x0) [0x562c1f97dd4f] ../vm_eval.c:135
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call0_cfunc_with_frame) ../vm_eval.c:137
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call0_cfunc) ../vm_eval.c:149
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call0_body) ../vm_eval.c:182
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_call0+0x1ea) [0x562c1f9812fa] ../vm_eval.c:72
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(iterate_method+0x3b) [0x562c1f981e9b] ../vm_eval.c:847
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_iterate0+0x101) [0x562c1f973001] ../vm_eval.c:1534
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_lambda_call+0x75) [0x562c1f973295] ../vm_eval.c:1633
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(enum_collect+0x5b) [0x562c1fa29acb] ../enum.c:647
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_cfp_consistent_p+0x0) [0x562c1f96d6bc] ../vm_insnhelper.c:2989
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call_cfunc_with_frame) ../vm_insnhelper.c:2991
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_sendish+0x303) [0x562c1f978393] ../vm_insnhelper.c:4562
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_exec_core+0x130) [0x562c1f9831d0] ../insns.def:756
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_exec+0x197) [0x562c1f978fc7] ../vm.c:2164
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(invoke_block_from_c_bh+0x130) [0x562c1f97c85a] ../vm.c:1264
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_yield) ../vm.c:1399
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_yield_0) ../vm_eval.c:1350
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(loop_i) ../vm_eval.c:1449
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vrescue2+0x114) [0x562c1f794694] ../eval.c:1023
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_rescue2+0x8e) [0x562c1f79490e] ../eval.c:1000
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_cfp_consistent_p+0x0) [0x562c1f96d6bc] ../vm_insnhelper.c:2989
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call_cfunc_with_frame) ../vm_insnhelper.c:2991
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_sendish+0x303) [0x562c1f978393] ../vm_insnhelper.c:4562
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_exec_core+0x130) [0x562c1f9831d0] ../insns.def:756
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_exec+0x197) [0x562c1f978fc7] ../vm.c:2164
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_do_start_proc+0x294) [0x562c1f930f24] ../thread.c:716
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_do_start+0xc) [0x562c1f9336fc] ../thread.c:760
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_start_func_2) ../thread.c:835
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_native_cond_initialize+0x0) [0x562c1f933a09] ../thread_pthread.c:1051
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(register_cached_thread_and_wait) ../thread_pthread.c:1103
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_start_func_1) ../thread_pthread.c:1058
/lib/x86_64-linux-gnu/libpthread.so.0(0x9609) [0x7f6c3b2ba609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7f6c3b044293]
</code></pre> Ruby master - Bug #17998 (Assigned): ractor: process hanging (with ractors initialized, but not b...https://bugs.ruby-lang.org/issues/179982021-06-17T13:45:50Zchucke (Tiago Cardoso)
<p>I couldn't figure out how to reproduce this in a more contained way, so I'll share what I'm doing <a href="https://github.com/HoneyryderChuck/minitest/tree/issue-872" class="external">in this minitest branch</a>.</p>
<p>I'm trying to make minitest's parallel mode use ractors. If you look at the last commit of the branch, I'm:</p>
<ul>
<li>replacing the parallel executor with a ractor-based one;</li>
<li>I'm defining the ractor executor, where I have a ractor pipe that a pool will consume work from</li>
<li>I'm turning off parallel subset of tests (to reproduce the bug that I'll be describing).</li>
</ul>
<p>When I run <code>rake test</code> in my Mac (BigSur 11.4), the process hangs. I can see that the ractor threads are executing and running, but the test process doesn't respond to the INFO signal interrupt (which should tell me where the process is hanging). This seems like a bug in the VM, as no work is being sent to the parallel executor, i.e. all ractors should be sleeping (I've <code>puts</code>'d also the executor shutdown process, and it never reaches it).</p>
<p>If I replace the ractor-based executor back with the thread based executor, everything works as expected.</p> Ruby master - Bug #17882 (Assigned): bootstraptest/test_ractor.rb:224 segfaults on Cygwinhttps://bugs.ruby-lang.org/issues/178822021-05-22T16:03:35Zxtkoba (Tee KOBAYASHI)
<p>The attached test code is excerpted from <code>bootstraptest/test_ractor.rb:224</code>. This code causes a segmentation fault every time when run on <code>x86_64-cygwin</code>. There are at least 3 types of dying messages, as shown below.</p>
<p>I have no idea whether this is relevant to <a class="issue tracker-1 status-1 priority-4 priority-default" title="Bug: bootstraptest/test_ractor.rb:224 a random failing test with "The outgoing-port is already closed ... (Open)" href="https://bugs.ruby-lang.org/issues/17878">#17878</a>, which is an issue with the very same test code.</p>
<p>Type 1 (null pointer dereference):</p>
<pre><code>Thread 6 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 5368]
VM_CF_BLOCK_HANDLER (cfp=0x0) at ../vm.c:115
115 const VALUE *ep = VM_CF_LEP(cfp);
(gdb) bt
#0 VM_CF_BLOCK_HANDLER (cfp=0x0) at ../vm.c:115
#1 0x00007ff6acedb495 in rb_vm_frame_block_handler (cfp=<optimized out>) at ../vm.c:128
#2 0x00007ff6acdd954e in pass_passed_block_handler (ec=0x80012bba0) at ../eval_intern.h:17
#3 rb_obj_call_init_kw (obj=obj@entry=123145240968920, argc=argc@entry=1, argv=argv@entry=0xffd0ca08, kw_splat=kw_splat@entry=0) at ../eval.c:1724
#4 0x00007ff6ace3efc2 in rb_class_new_instance (argc=argc@entry=1, argv=argv@entry=0xffd0ca08, klass=klass@entry=123145300575160) at ../object.c:2192
#5 0x00007ff6acdd1c30 in rb_exc_new_str (etype=etype@entry=123145300575160, str=<optimized out>) at ../error.c:1123
#6 0x00007ff6acdd29ad in rb_vraise (exc=123145300575160, fmt=<optimized out>, ap=<optimized out>) at ../error.c:2922
#7 0x00007ff6acdd29e5 in rb_raise (exc=0, fmt=0x0) at ../error.c:2930
#8 0x00007ff6acdf90e8 in rb_io_check_initialized (fptr=0x0) at ../io.c:767
#9 rb_io_check_initialized (fptr=<optimized out>) at ../io.c:764
#10 0x00007ff6acdf90fb in rb_io_check_closed (fptr=0x0) at ../io.c:774
#11 0x00007ff6ace011ec in prep_stdio (f=0x18023acb8 <reent_data+1336>, fmode=fmode@entry=1, klass=123145300573360, klass@entry=140697440105184, path=path@entry=0x7ff6acf158e0 <prelude_table+2944> "<STDIN>") at ../io.c:8239
#12 0x00007ff6ace0122f in rb_io_prep_stdin () at ../io.c:8255
#13 0x00007ff6acebc980 in thread_start_func_2 (th=0x0, th@entry=0x80011cbf0, stack_start=stack_start@entry=0xffd0ccf8) at ../thread.c:801
#14 0x00007ff6acebd032 in thread_start_func_1 (th_ptr=<optimized out>) at ../thread_pthread.c:1035
#15 0x000000018016d45f in pthread::thread_init_wrapper(void*) () from target:/usr/bin/cygwin1.dll
#16 0x00000001800ddbba in pthread_wrapper () from target:/usr/bin/cygwin1.dll
#17 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
</code></pre>
<p>Type 2 (<code>rb_gc_mark()</code>: <code><address></code> is <code>T_ZOMBIE</code>):</p>
<pre><code>Thread 7 hit Breakpoint 1, rb_bug (fmt=0x7ff6acf1396a <stat_data_type+8138> "rb_gc_mark(): %p is T_ZOMBIE") at ../error.c:782
782 {
(gdb) bt
#0 rb_bug (fmt=0x7ff6acf1396a <stat_data_type+8138> "rb_gc_mark(): %p is T_ZOMBIE") at ../error.c:782
#1 0x00007ff6acdeae8f in gc_mark_children (objspace=objspace@entry=0x800053970, obj=obj@entry=123145240171400) at ../gc.c:6934
#2 0x00007ff6acdeafb0 in gc_mark_stacked_objects (objspace=0x800053970, incremental=incremental@entry=0, count=count@entry=0) at ../gc.c:6961
#3 0x00007ff6acded415 in gc_mark_stacked_objects_all (objspace=0x800053970) at ../gc.c:7001
#4 gc_marks_rest (objspace=objspace@entry=0x800053970) at ../gc.c:7972
#5 0x00007ff6acdec08c in gc_marks (full_mark=<optimized out>, objspace=0x800053970) at ../gc.c:8028
#6 gc_start (objspace=objspace@entry=0x800053970, reason=<optimized out>, reason@entry=256) at ../gc.c:8862
#7 0x00007ff6acdee522 in heap_prepare (heap=0x800053998, objspace=0x800053970) at ../gc.c:2153
#8 heap_next_freepage (heap=0x800053998, objspace=0x800053970) at ../gc.c:2444
#9 ractor_cache_slots (objspace=objspace@entry=0x800053970, cr=cr@entry=0x800135d60) at ../gc.c:2476
#10 0x00007ff6acdee61a in newobj_slowpath (alloc_size=<optimized out>, wb_protected=0, cr=0x800135d60, objspace=0x800053970, flags=11, klass=123145300573360) at ../gc.c:2517
#11 newobj_slowpath_wb_unprotected (klass=123145300573360, flags=11, objspace=0x800053970, cr=0x800135d60, alloc_size=<optimized out>) at ../gc.c:2547
#12 0x00007ff6acdee815 in newobj_of0 (klass=klass@entry=123145300573360, flags=flags@entry=11, wb_protected=wb_protected@entry=0, cr=<optimized out>, alloc_size=<optimized out>) at ../gc.c:2585
#13 0x00007ff6acdee86d in newobj_of (klass=klass@entry=123145300573360, flags=flags@entry=11, v1=v1@entry=0, v2=v2@entry=0, v3=v3@entry=0, wb_protected=wb_protected@entry=0, alloc_size=40) at ../gc.c:2594
#14 0x00007ff6acdeec23 in rb_wb_unprotected_newobj_of (klass=klass@entry=123145300573360, flags=flags@entry=11, size=40, size@entry=0) at ../gc.c:2610
#15 0x00007ff6acdf666c in io_alloc (klass=klass@entry=123145300573360) at ../io.c:1038
#16 0x00007ff6acdfbca9 in prep_io (fd=2, fmode=fmode@entry=65546, klass=klass@entry=123145300573360, path=path@entry=0x7ff6acf158f1 <prelude_table+2961> "<STDERR>") at ../io.c:8206
#17 0x00007ff6ace011d4 in prep_stdio (f=0x18023ae28 <reent_data+1704>, fmode=fmode@entry=10, klass=123145300573360, klass@entry=34361007456, path=path@entry=0x7ff6acf158f1 <prelude_table+2961> "<STDERR>") at ../io.c:8237
#18 0x00007ff6ace01295 in rb_io_prep_stderr () at ../io.c:8267
#19 0x00007ff6acebc9a6 in thread_start_func_2 (th=0x0, th@entry=0x800134550, stack_start=stack_start@entry=0xffa0ccf8) at ../thread.c:803
#20 0x00007ff6acebd032 in thread_start_func_1 (th_ptr=<optimized out>) at ../thread_pthread.c:1035
#21 0x000000018016d45f in pthread::thread_init_wrapper(void*) () from target:/usr/bin/cygwin1.dll
#22 0x00000001800ddbba in pthread_wrapper () from target:/usr/bin/cygwin1.dll
#23 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
</code></pre>
<p>Type 3 (try to mark <code>T_NONE</code> object):</p>
<pre><code><OBJ_INFO:gc_mark_ptr@../gc.c:6580> 0x00006fffffe7fb70 [0 M ] T_NONE
------------------------------------------------------------------------
Thread 7 hit Breakpoint 1, rb_bug (fmt=fmt@entry=0x7ff6acf138a0 <stat_data_type+7936> "try to mark T_NONE object") at ../error.c:782
782 {
(gdb) bt
#0 rb_bug (fmt=fmt@entry=0x7ff6acf138a0 <stat_data_type+7936> "try to mark T_NONE object") at ../error.c:782
#1 0x00007ff6acdea5c9 in gc_mark_ptr (objspace=0x800053970, obj=123145300736880) at ../gc.c:6581
#2 0x00007ff6ace672ea in ractor_mark (ptr=0x800117240) at ../ractor.c:197
#3 0x00007ff6acdeafb0 in gc_mark_stacked_objects (objspace=objspace@entry=0x800053970, incremental=incremental@entry=1, count=count@entry=2147483647) at ../gc.c:6961
#4 0x00007ff6acded3f9 in gc_mark_stacked_objects_incremental (count=2147483647, objspace=0x800053970) at ../gc.c:6995
#5 gc_marks_rest (objspace=objspace@entry=0x800053970) at ../gc.c:7968
#6 0x00007ff6acdee4f1 in gc_marks_continue (heap=0x800053998, objspace=0x800053970) at ../gc.c:8012
#7 heap_prepare (heap=0x800053998, objspace=0x800053970) at ../gc.c:2148
#8 heap_next_freepage (heap=0x800053998, objspace=0x800053970) at ../gc.c:2444
#9 ractor_cache_slots (objspace=objspace@entry=0x800053970, cr=cr@entry=0x800129350) at ../gc.c:2476
#10 0x00007ff6acdee61a in newobj_slowpath (alloc_size=<optimized out>, wb_protected=0, cr=0x800129350, objspace=0x800053970, flags=11, klass=123145300573360) at ../gc.c:2517
#11 newobj_slowpath_wb_unprotected (klass=123145300573360, flags=11, objspace=0x800053970, cr=0x800129350, alloc_size=<optimized out>) at ../gc.c:2547
#12 0x00007ff6acdee815 in newobj_of0 (klass=klass@entry=123145300573360, flags=flags@entry=11, wb_protected=wb_protected@entry=0, cr=<optimized out>, alloc_size=<optimized out>) at ../gc.c:2585
#13 0x00007ff6acdee86d in newobj_of (klass=klass@entry=123145300573360, flags=flags@entry=11, v1=v1@entry=0, v2=v2@entry=0, v3=v3@entry=0, wb_protected=wb_protected@entry=0, alloc_size=40) at ../gc.c:2594
#14 0x00007ff6acdeec23 in rb_wb_unprotected_newobj_of (klass=klass@entry=123145300573360, flags=flags@entry=11, size=40, size@entry=0) at ../gc.c:2610
#15 0x00007ff6acdf666c in io_alloc (klass=klass@entry=123145300573360) at ../io.c:1038
#16 0x00007ff6acdfbca9 in prep_io (fd=0, fmode=fmode@entry=65537, klass=klass@entry=123145300573360, path=path@entry=0x7ff6acf158e0 <prelude_table+2944> "<STDIN>") at ../io.c:8206
#17 0x00007ff6ace011d4 in prep_stdio (f=0x18023acb8 <reent_data+1336>, fmode=fmode@entry=1, klass=123145300573360, klass@entry=140697440105184, path=path@entry=0x7ff6acf158e0 <prelude_table+2944> "<STDIN>") at ../io.c:8237
#18 0x00007ff6ace0122f in rb_io_prep_stdin () at ../io.c:8255
#19 0x00007ff6acebc980 in thread_start_func_2 (th=0x0, th@entry=0x80010dcb0, stack_start=stack_start@entry=0xffa0ccf8) at ../thread.c:801
#20 0x00007ff6acebd032 in thread_start_func_1 (th_ptr=<optimized out>) at ../thread_pthread.c:1035
#21 0x000000018016d45f in pthread::thread_init_wrapper(void*) () from target:/usr/bin/cygwin1.dll
#22 0x00000001800ddbba in pthread_wrapper () from target:/usr/bin/cygwin1.dll
#23 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
</code></pre> Ruby master - Bug #17678 (Assigned): Ractors do not restart after forkhttps://bugs.ruby-lang.org/issues/176782021-03-08T16:19:45Zivoanjo (Ivo Anjo)ivo.anjo@datadoghq.com
<p>Hello there! I'm working at Datadog on the <code>ddtrace</code> gem -- <a href="https://github.com/DataDog/dd-trace-rb" class="external">https://github.com/DataDog/dd-trace-rb</a> and we're experimenting with using Ractors in our library but run into a few issues.</p>
<a name="Background"></a>
<h3 >Background<a href="#Background" class="wiki-anchor">¶</a></h3>
<p>When running a Ractor as a background process, the Ractor stops & does not restart when the application forks.</p>
<a name="How-to-reproduce-Ruby-version-amp-script"></a>
<h3 >How to reproduce (Ruby version & script)<a href="#How-to-reproduce-Ruby-version-amp-script" class="wiki-anchor">¶</a></h3>
<p><code>ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]</code></p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r2</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="kp">loop</span> <span class="p">{</span> <span class="nb">puts</span> <span class="s2">"[</span><span class="si">#{</span><span class="no">Process</span><span class="p">.</span><span class="nf">pid</span><span class="si">}</span><span class="s2">] Ractor"</span><span class="p">;</span> <span class="nb">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="nb">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="nb">puts</span> <span class="s2">"[</span><span class="si">#{</span><span class="no">Process</span><span class="p">.</span><span class="nf">pid</span><span class="si">}</span><span class="s2">] Forking..."</span>
<span class="nb">fork</span> <span class="k">do</span>
<span class="nb">sleep</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="nb">puts</span> <span class="s2">"[</span><span class="si">#{</span><span class="no">Process</span><span class="p">.</span><span class="nf">pid</span><span class="si">}</span><span class="s2">] End fork."</span>
<span class="k">end</span>
<span class="kp">loop</span> <span class="k">do</span>
<span class="nb">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<a name="Expectation-and-result"></a>
<h3 >Expectation and result<a href="#Expectation-and-result" class="wiki-anchor">¶</a></h3>
<p>The application prints “Ractor” each second in the main process, but not in the fork.</p>
<p>Expected the Ractor (defined as <code>r2</code>) to run in the fork.</p>
<pre><code>[29] Ractor
[29] Ractor
[29] Forking...
[29] Ractor
[29] Ractor
[29] Ractor
[29] Ractor
[29] Ractor
[32] End fork.
[29] Ractor
[29] Ractor
[29] Ractor
</code></pre>
<a name="Additional-notes"></a>
<h3 >Additional notes<a href="#Additional-notes" class="wiki-anchor">¶</a></h3>
<p>Threads do not restart across forks either, so it might not be unreasonable to expect consistent behavior. However, it’s possible to detect a dead Thread and recreate it after a fork (e.g. with <code>#alive?</code>, <code>#status</code>), but there’s no such mechanism for Ractors.</p>
<a name="Suggested-solutions"></a>
<h3 >Suggested solutions<a href="#Suggested-solutions" class="wiki-anchor">¶</a></h3>
<ol>
<li>Auto-restart Ractors after fork</li>
<li>Add additional methods to Ractors that allow users to check & manage the status of the Ractor, similar to Thread.</li>
</ol> Ruby master - Bug #17677 (Assigned): Ractor crashes fork when blockinghttps://bugs.ruby-lang.org/issues/176772021-03-08T16:19:22Zdelner (David Elner)
<a name="Background"></a>
<h2 >Background<a href="#Background" class="wiki-anchor">¶</a></h2>
<p>If you create a Ractor which blocks (e.g. <code>receive</code>), then fork the process, the fork will segfault upon completion.</p>
<a name="How-to-reproduce"></a>
<h2 >How to reproduce<a href="#How-to-reproduce" class="wiki-anchor">¶</a></h2>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r2</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="no">Ractor</span><span class="p">.</span><span class="nf">receive</span>
<span class="k">end</span>
<span class="nb">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="nb">puts</span> <span class="s2">"Forking..."</span>
<span class="nb">fork</span> <span class="k">do</span>
<span class="nb">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="nb">puts</span> <span class="s2">"End fork."</span>
<span class="k">end</span>
<span class="kp">loop</span> <span class="k">do</span>
<span class="nb">puts</span> <span class="s2">"Main thread."</span>
<span class="nb">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<a name="Expectation-and-result"></a>
<h2 >Expectation and result<a href="#Expectation-and-result" class="wiki-anchor">¶</a></h2>
<p>Application prints “Main thread” from main process every second, while fork prints “End fork.” then produces a segfault. Main process continues to run.</p>
<p>Expected fork to not raise a segfault.</p>
<pre><code><internal:ractor>:267: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
Forking...
Main thread.
Main thread.
End fork.
app/sandbox.rb:80: [BUG]: Device or resource busy (EBUSY)
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0003 p:---- s:0011 e:000010 CFUNC :fork
c:0002 p:0048 s:0007 E:001b48 EVAL app/sandbox.rb:80 [FINISH]
c:0001 p:0000 s:0003 E:002590 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
app/sandbox.rb:80:in `<main>'
app/sandbox.rb:80:in `fork'
-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.3.0(rb_print_backtrace+0x11) [0x7f9848528cfb] vm_dump.c:758
/usr/local/lib/libruby.so.3.0(rb_vm_bugreport) vm_dump.c:998
/usr/local/lib/libruby.so.3.0(bug_report_end+0x0) [0x7f9848354808] error.c:763
/usr/local/lib/libruby.so.3.0(rb_bug_without_die) error.c:763
/usr/local/lib/libruby.so.3.0(die+0x0) [0x7f98482c6902] error.c:771
/usr/local/lib/libruby.so.3.0(rb_bug) error.c:773
/usr/local/lib/libruby.so.3.0(rb_bug_errno+0x3c) [0x7f9848354a1c] error.c:802
/usr/local/lib/libruby.so.3.0(rb_native_mutex_destroy+0x20) [0x7f98484ce380] thread_pthread.c:444
/usr/local/lib/libruby.so.3.0(rb_native_cond_initialize) (null):0
/usr/local/lib/libruby.so.3.0(ractor_free+0xd) [0x7f984844487d] ractor.c:229
/usr/local/lib/libruby.so.3.0(run_final+0xb) [0x7f9848371c66] gc.c:3670
/usr/local/lib/libruby.so.3.0(finalize_list) gc.c:3689
/usr/local/lib/libruby.so.3.0(rb_objspace_call_finalizer+0x33d) [0x7f984837cc5d] gc.c:3852
/usr/local/lib/libruby.so.3.0(rb_ec_cleanup+0x311) [0x7f984835f0b1] eval.c:184
/usr/local/lib/libruby.so.3.0(ruby_stop+0x9) [0x7f984835f339] eval.c:329
/usr/local/lib/libruby.so.3.0(rb_f_fork+0x1f) [0x7f98484402f8] process.c:4348
/usr/local/lib/libruby.so.3.0(rb_f_fork) process.c:4338
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame+0x11b) [0x7f984850672b] vm_insnhelper.c:2898
/usr/local/lib/libruby.so.3.0(vm_call_method_each_type+0xf9) [0x7f98485192c9] vm_insnhelper.c:3388
/usr/local/lib/libruby.so.3.0(vm_call_method+0xb4) [0x7f9848519b24] vm_insnhelper.c:3506
/usr/local/lib/libruby.so.3.0(vm_sendish+0xb3) [0x7f984850a3d3] vm_insnhelper.c:4499
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x140) [0x7f98485123e0] insns.def:770
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x176) [0x7f9848517b26] vm.c:2163
/usr/local/lib/libruby.so.3.0(rb_ec_exec_node+0xd9) [0x7f9848359719] eval.c:317
/usr/local/lib/libruby.so.3.0(ruby_run_node+0x55) [0x7f984835f395] eval.c:375
/usr/local/bin/ruby(main+0x5b) [0x565147e5410b] ./main.c:50
...
Main thread.
Main thread.
Main thread.
</code></pre>
<a name="Additional-notes"></a>
<h2 >Additional notes<a href="#Additional-notes" class="wiki-anchor">¶</a></h2>
<p>This does not happen if a blocking operation does not occur in the Ractor. E.g.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">r2</span> <span class="o">=</span> <span class="no">Ractor</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="kp">loop</span> <span class="p">{</span> <span class="nb">puts</span> <span class="s2">"[</span><span class="si">#{</span><span class="no">Process</span><span class="p">.</span><span class="nf">pid</span><span class="si">}</span><span class="s2">] Ractor"</span><span class="p">;</span> <span class="nb">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
</code></pre>
<p>Segfault can also be prevented by invoking <code>close_incoming</code> prior to forking, although this raises another error internally.</p>
<p>It also does not crash on MacOS 10.15.7: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19].</p>
<a name="Suggested-solutions"></a>
<h2 >Suggested solutions<a href="#Suggested-solutions" class="wiki-anchor">¶</a></h2>
<p>(None)</p> Ruby master - Bug #17578 (Assigned): mkmf experimental C++ Supporthttps://bugs.ruby-lang.org/issues/175782021-01-25T06:26:31Zcfis (Charlie Savage)
<p>I've been working on the Rice gem (<a href="https://github.com/jasonroelofs/rice" class="external">https://github.com/jasonroelofs/rice</a>) that wraps C++ code for use in Ruby.</p>
<p>I noticed that some c++ support was added to mkmf for Ruby 2.7. However, if I try to use it find a header it fails to work. For example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">find_header</span><span class="p">(</span><span class="s1">'rice.hpp'</span><span class="p">)</span>
</code></pre>
<p>The reason is the conftest uses gcc -E instead of g++ -E. To fix that requires overlading the cpp_command to support C++.</p>
<p>This the fix I have put in that works:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">MakeMakefile</span><span class="p">[</span><span class="s1">'C++'</span><span class="p">].</span><span class="nf">module_eval</span> <span class="k">do</span>
<span class="k">def</span> <span class="nf">cpp_command</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="n">opt</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span>
<span class="n">conf</span> <span class="o">=</span> <span class="n">cc_config</span><span class="p">(</span><span class="n">opt</span><span class="p">)</span>
<span class="k">if</span> <span class="vg">$universal</span> <span class="ow">and</span> <span class="p">(</span><span class="n">arch_flag</span> <span class="o">=</span> <span class="n">conf</span><span class="p">[</span><span class="s1">'ARCH_FLAG'</span><span class="p">])</span> <span class="ow">and</span> <span class="o">!</span><span class="n">arch_flag</span><span class="p">.</span><span class="nf">empty?</span>
<span class="n">conf</span><span class="p">[</span><span class="s1">'ARCH_FLAG'</span><span class="p">]</span> <span class="o">=</span> <span class="n">arch_flag</span><span class="p">.</span><span class="nf">gsub</span><span class="p">(</span><span class="sr">/(?:\G|\s)-arch\s+\S+/</span><span class="p">,</span> <span class="s1">''</span><span class="p">)</span>
<span class="k">end</span>
<span class="no">RbConfig</span><span class="o">::</span><span class="n">expand</span><span class="p">(</span><span class="s2">"$(CXX) -E </span><span class="si">#$INCFLAGS</span><span class="s2"> </span><span class="si">#$CPPFLAGS</span><span class="s2"> </span><span class="si">#$CFLAGS</span><span class="s2"> </span><span class="si">#{</span><span class="n">opt</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="no">CONFTEST_CXX</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">outfile</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span>
<span class="n">conf</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>The two changes over the default method are:</p>
<p>$(CC) -> $(CXX) -E<br>
#{CONFTEST_c} -> #{CONFTEST_cxx}</p>
<p>Could this change be merged in? I can provide a patch file if you would like.</p>
<p>Last, it wasn't obvious to me how to activate the C++ support in mkfm. I ended up doing this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="kp">include</span> <span class="no">MakeMakefile</span><span class="p">[</span><span class="s1">'C++'</span><span class="p">]</span>
</code></pre>
<p>Is that correct?</p> Ruby master - Bug #17516 (Assigned): forking in a ractor causes Ruby to crashhttps://bugs.ruby-lang.org/issues/175162021-01-06T10:56:50Zpkmuldoon (Phil Muldoon)
<p>I just want to point out, there's absolutely no reason to do this, but</p>
<p>r = Ractor.new do<br>
Process.fork()<br>
end</p>
<p>Will cause:</p>
<p><a href="internal:ractor" class="external">internal:ractor</a>:267: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.<br>
[BUG] rb_thread_terminate_all: called by child thread (0x0000700004ddca40, 0x00007f981b567ee0)<br>
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]</p>
<p>-- Crash Report log information --------------------------------------------<br>
See Crash Report log file under the one of following:<br>
* ~/Library/Logs/DiagnosticReports<br>
* /Library/Logs/DiagnosticReports<br>
for more details.<br>
Don't forget to include the above Crash Report log file in bug reports.</p>
<p>-- Control frame information -----------------------------------------------<br>
c:0001 p:---- s:0003 e:000002 (none) [FINISH]</p>
<p>-- C level backtrace information -------------------------------------------<br>
=> #<Ractor:#3 (pry):5 terminated><br>
[4] pry(main)> /Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(rb_vm_bugreport+0x6cf) [0x103084d1f]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(rb_bug_without_die+0x206) [0x102e9e2b6]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(rb_bug+0x71) [0x103091e6b]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(rb_thread_terminate_all+0x329) [0x10301e5b9]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(rb_ractor_terminate_all+0xa3) [0x102f8acc3]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(rb_ec_cleanup+0x229) [0x102ea9299]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(ruby_stop+0x9) [0x102ea9509]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(thread_start_func_2+0x8ce) [0x103027fce]<br>
/Users/phillipmuldoon/.rubies/ruby-3.0.0/bin/ruby(thread_start_func_1+0x10d) [0x10302753d]<br>
/usr/lib/system/libsystem_pthread.dylib(_pthread_start+0xe0) [0x7fff20382950]</p> Ruby master - Bug #16819 (Assigned): Line reporting off by one when reporting line of a hash?https://bugs.ruby-lang.org/issues/168192020-04-27T18:18:58Zenebo (Thomas Enebo)tom.enebo@gmail.com
<p>If I run this program:</p>
<pre><code>TracePoint.new(:line) { |t| p t.lineno}.enable
def foo(a, b) # 2
a + b # 3
end # 4
# 5
foo 1, 2 # 6
# 7
A = { # 8
a: 1, # 9
b: 2 # 10
} # 11
</code></pre>
<p>I see:</p>
<pre><code>system ~/work/jruby no_sourceposition * 2388% mri26 ../snippets/ast1.rb
2
6
3
9
</code></pre>
<p>I believe this 9 should be an 8 (it is what we currently emit for JRuby). I tried to figure out why this is the case and I patched RubyVM::AbstractSyntaxTree with the ability to note newline flag:</p>
<pre><code>diff --git a/ast.c b/ast.c
index f0e8dd2eaf..df58006a96 100644
--- a/ast.c
+++ b/ast.c
@@ -7,6 +7,8 @@
#include "vm_core.h"
#include "iseq.h"
+#define RBOOL(v) ((v) ? Qtrue : Qfalse)
+
static VALUE rb_mAST;
static VALUE rb_cNode;
@@ -731,6 +733,16 @@ rb_ast_node_inspect(VALUE self)
return str;
}
+static VALUE
+rb_ast_node_newline(VALUE self)
+{
+ struct ASTNodeData *data;
+ TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
+
+ return RBOOL(data->node->flags & NODE_FL_NEWLINE);
+}
+
+
void
Init_ast(void)
{
@@ -756,5 +768,6 @@ Init_ast(void)
rb_define_method(rb_cNode, "last_lineno", rb_ast_node_last_lineno, 0);
rb_define_method(rb_cNode, "last_column", rb_ast_node_last_column, 0);
rb_define_method(rb_cNode, "children", rb_ast_node_children, 0);
+ rb_define_method(rb_cNode, "newline?", rb_ast_node_newline, 0);
rb_define_method(rb_cNode, "inspect", rb_ast_node_inspect, 0);
}
</code></pre>
<p>I also made a simple script:</p>
<pre><code>source = File.read ARGV.shift
root = RubyVM::AbstractSyntaxTree.parse source
def print_node(node, indent = "")
if node.respond_to? :first_lineno
eol = node.newline? ? " <-- newline" : ""
$stdout.write "#{indent}(#{node.type}@#{node.first_lineno-1}-#{node.last_lineno-1})"
case node.type
when :LIT, :STR
puts " = #{node.children[0].inspect}#{eol}"
when :ARRAY
puts eol
node.children[0..-2].each do |child|
print_node(child, indent + " ")
end
when :FCALL
puts " = #{node.children[0]}#{eol}"
node.children[1..-1].each do |child|
print_node(child, indent + " ")
end
else
puts eol
node.children.each do |child|
print_node(child, indent + " ")
end
end
elsif node.nil?
puts "#{indent}nil"
else
puts "#{indent}#{node.inspect}"
end
end
print_node root
puts RubyVM::InstructionSequence.compile(source).disasm
</code></pre>
<p>If I run this I see MRI has line 8 marked as the newline (which JRuby also matches) but if we look at the disasm it would appear compile.c decided to put the line in a different location:</p>
<pre><code>../ruby/ruby --disable-gems ../snippets/ast_mri.rb ../snippets/ast1.rb
(SCOPE@0-10)
[]
nil
(BLOCK@0-10)
(CALL@0-0) <-- newline
(ITER@0-0)
(CALL@0-0)
(CONST@0-0)
:TracePoint
:new
(ARRAY@0-0)
(LIT@0-0) = :line
(SCOPE@0-0)
[:t]
(ARGS@0-0)
1
nil
nil
nil
0
nil
nil
nil
nil
nil
(FCALL@0-0) = p <-- newline
(ARRAY@0-0)
(CALL@0-0)
(DVAR@0-0)
:t
:lineno
nil
:enable
nil
(DEFN@1-3) <-- newline
:foo
(SCOPE@1-3)
[:a, :b]
(ARGS@1-1)
2
nil
nil
nil
0
nil
nil
nil
nil
nil
(OPCALL@2-2) <-- newline
(LVAR@2-2)
:a
:+
(ARRAY@2-2)
(LVAR@2-2)
:b
(FCALL@5-5) = foo <-- newline
(ARRAY@5-5)
(LIT@5-5) = 1
(LIT@5-5) = 2
(CDECL@7-10) <-- newline
:A
(HASH@7-10)
(ARRAY@8-9)
(LIT@8-8) = :a
(LIT@8-8) = 1
(LIT@9-9) = :b
(LIT@9-9) = 2
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(11,18)> (catch: FALSE)
== catch table
| catch type: break st: 0000 ed: 0013 sp: 0000 cont: 0013
| == disasm: #<ISeq:block in <compiled>@<compiled>:1 (1,22)-(1,39)> (catch: FALSE)
| == catch table
| | catch type: redo st: 0001 ed: 0010 sp: 0000 cont: 0001
| | catch type: next st: 0001 ed: 0010 sp: 0000 cont: 0010
| |------------------------------------------------------------------------
| local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
| [ 1] t@0<Arg>
| 0000 nop ( 1)[Bc]
| 0001 putself [Li]
| 0002 getlocal_WC_0 t@0
| 0004 opt_send_without_block <callinfo!mid:lineno, argc:0, ARGS_SIMPLE>, <callcache>
| 0007 opt_send_without_block <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
| 0010 nop
| 0011 leave ( 1)[Br]
|------------------------------------------------------------------------
0000 opt_getinlinecache 7, <is:0> ( 1)[Li]
0003 getconstant :TracePoint
0005 opt_setinlinecache <is:0>
0007 putobject :line
0009 send <callinfo!mid:new, argc:1>, <callcache>, block in <compiled>
0013 nop
0014 opt_send_without_block <callinfo!mid:enable, argc:0, ARGS_SIMPLE>, <callcache>( 1)
0017 pop
0018 putspecialobject 1 ( 2)[Li]
0020 putobject :foo
0022 putiseq foo
0024 opt_send_without_block <callinfo!mid:core#define_method, argc:2, ARGS_SIMPLE>, <callcache>
0027 pop
0028 putself ( 6)[Li]
0029 putobject_INT2FIX_1_
0030 putobject 2
0032 opt_send_without_block <callinfo!mid:foo, argc:2, FCALL|ARGS_SIMPLE>, <callcache>
0035 pop
0036 duphash {:a=>1, :b=>2} ( 9)[Li]
0038 dup ( 8)
0039 putspecialobject 3
0041 setconstant :A
0043 leave
== disasm: #<ISeq:foo@<compiled>:2 (2,0)-(4,3)> (catch: FALSE)
local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] a@0<Arg> [ 1] b@1<Arg>
0000 getlocal_WC_0 a@0 ( 3)[LiCa]
0002 getlocal_WC_0 b@1
0004 opt_plus <callinfo!mid:+, argc:1, ARGS_SIMPLE>, <callcache>
0007 leave ( 4)[Re]
</code></pre> Ruby master - Bug #16776 (Assigned): Regression in coverage libraryhttps://bugs.ruby-lang.org/issues/167762020-04-10T16:39:29Zdeivid (David Rodríguez)
<p>Hi!</p>
<p>I noticed a regression in the coverage library. I tried to write a minimal program to show it, hopefully it gives some clues or where the issue might lie.</p>
<p>In ruby 2.5.8 and earlier, the following program would print <code>{:lines=>[1, 1, nil]}</code>, showing that the body of the "foo" method was run once. However, on newer rubies, it prints <code>{:lines=>[1, 0, nil]}</code>, which is incorrect because the "foo" method body has actually been run once.</p>
<p>This is the repro script:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># frozen_string_literal: true</span>
<span class="nb">require</span> <span class="s2">"coverage"</span>
<span class="no">Coverage</span><span class="p">.</span><span class="nf">start</span><span class="p">(</span><span class="ss">lines: </span><span class="kp">true</span><span class="p">)</span>
<span class="n">code</span> <span class="o">=</span> <span class="o"><<~</span><span class="no">RUBY</span><span class="sh">
def foo
"LOL"
end
</span><span class="no">RUBY</span>
<span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s2">"foo.rb"</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="p">{</span> <span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="p">.</span><span class="nf">write</span><span class="p">(</span><span class="n">code</span><span class="p">)</span> <span class="p">}</span>
<span class="nb">require_relative</span> <span class="s2">"foo"</span>
<span class="no">TracePoint</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">:line</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">_tp</span><span class="o">|</span>
<span class="n">foo</span>
<span class="k">end</span><span class="p">.</span><span class="nf">enable</span> <span class="k">do</span>
<span class="nb">sleep</span> <span class="mi">0</span>
<span class="k">end</span>
<span class="n">res</span> <span class="o">=</span> <span class="no">Coverage</span><span class="p">.</span><span class="nf">result</span>
<span class="nb">puts</span> <span class="n">res</span><span class="p">[</span><span class="no">File</span><span class="p">.</span><span class="nf">expand_path</span><span class="p">(</span><span class="s2">"foo.rb"</span><span class="p">)]</span>
</code></pre> Ruby master - Bug #16497 (Assigned): StringIO#internal_encoding is broken (more severely in 2.7)https://bugs.ruby-lang.org/issues/164972020-01-10T11:18:31Zzverok (Victor Shepelev)zverok.offline@gmail.com
<p>To the best of my understanding from <a href="https://docs.ruby-lang.org/en/master/Encoding.html" class="external">Encoding</a> docs, the following is true:</p>
<ul>
<li>external encoding (explicitly specified or taken from <code>Encoding.default_external</code>) specifies how the IO understands input and stores it internally</li>
<li>internal encoding (explicitly specified or taken from <code>Encoding.default_internal</code>) specifies how the IO converts what it reads.</li>
</ul>
<p>Demonstration with regular files:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># prepare data</span>
<span class="no">File</span><span class="p">.</span><span class="nf">write</span><span class="p">(</span><span class="s1">'test.txt'</span><span class="p">,</span> <span class="s1">'Україна'</span><span class="p">.</span><span class="nf">encode</span><span class="p">(</span><span class="s1">'KOI8-U'</span><span class="p">),</span> <span class="ss">encoding: </span><span class="s1">'KOI8-U'</span><span class="p">)</span> <span class="c1">#=> 7</span>
<span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="n">io</span><span class="p">)</span>
<span class="n">str</span> <span class="o">=</span> <span class="n">io</span><span class="p">.</span><span class="nf">read</span>
<span class="p">[</span><span class="n">io</span><span class="p">.</span><span class="nf">external_encoding</span><span class="p">,</span> <span class="n">io</span><span class="p">.</span><span class="nf">internal_encoding</span><span class="p">,</span> <span class="n">str</span><span class="p">,</span> <span class="n">str</span><span class="p">.</span><span class="nf">encoding</span><span class="p">]</span>
<span class="k">end</span>
<span class="c1"># read it:</span>
<span class="nb">test</span><span class="p">(</span><span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s1">'test.txt'</span><span class="p">,</span> <span class="s1">'r:KOI8-U'</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:KOI8-U>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:KOI8-U>]</span>
<span class="c1"># We can specify internal encoding when opening the file:</span>
<span class="nb">test</span><span class="p">(</span><span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s1">'test.txt'</span><span class="p">,</span> <span class="s1">'r:KOI8-U:UTF-8'</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:KOI8-U>, #<Encoding:UTF-8>, "Україна", #<Encoding:UTF-8>]</span>
<span class="c1"># ...or when it is already opened</span>
<span class="nb">test</span><span class="p">(</span><span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s1">'test.txt'</span><span class="p">).</span><span class="nf">tap</span> <span class="p">{</span> <span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="p">.</span><span class="nf">set_encoding</span><span class="p">(</span><span class="s1">'KOI8-U'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span> <span class="p">})</span>
<span class="c1"># => [#<Encoding:KOI8-U>, #<Encoding:UTF-8>, "Україна", #<Encoding:UTF-8>]</span>
<span class="c1"># ...or with Encoding.default_internal</span>
<span class="no">Encoding</span><span class="p">.</span><span class="nf">default_internal</span> <span class="o">=</span> <span class="s1">'UTF-8'</span>
<span class="nb">test</span><span class="p">(</span><span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s1">'test.txt'</span><span class="p">,</span> <span class="s1">'r:KOI8-U'</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:KOI8-U>, #<Encoding:UTF-8>, "Україна", #<Encoding:UTF-8>]</span>
</code></pre>
<p>But with StringIO, <strong>internal encoding can't be set</strong> in Ruby <strong>2.6</strong>:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'stringio'</span>
<span class="no">Encoding</span><span class="p">.</span><span class="nf">default_internal</span> <span class="o">=</span> <span class="kp">nil</span>
<span class="n">str</span> <span class="o">=</span> <span class="s1">'Україна'</span><span class="p">.</span><span class="nf">encode</span><span class="p">(</span><span class="s1">'KOI8-U'</span><span class="p">)</span>
<span class="c1"># Simplest form:</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:KOI8-U>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:KOI8-U>]</span>
<span class="c1"># Try to set via mode</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="s1">'r:KOI8-U:UTF-8'</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:KOI8-U>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:KOI8-U>]</span>
<span class="c1"># Try to set via set_encoding:</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="s1">'r:KOI8-U:UTF-8'</span><span class="p">).</span><span class="nf">tap</span> <span class="p">{</span> <span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="p">.</span><span class="nf">set_encoding</span><span class="p">(</span><span class="s1">'KOI8-U'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span> <span class="p">})</span>
<span class="c1"># => [#<Encoding:KOI8-U>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:KOI8-U>]</span>
<span class="c1"># Try to set via Enoding.default_internal:</span>
<span class="no">Encoding</span><span class="p">.</span><span class="nf">default_internal</span> <span class="o">=</span> <span class="s1">'UTF-8'</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:KOI8-U>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:KOI8-U>]</span>
</code></pre>
<p>So, in 2.6, any attempt to do something with StringIO's internal encoding are <strong>just ignored</strong>.</p>
<p>In <strong>2.7</strong>, though, matters became much worse:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'stringio'</span>
<span class="no">Encoding</span><span class="p">.</span><span class="nf">default_internal</span> <span class="o">=</span> <span class="kp">nil</span>
<span class="n">str</span> <span class="o">=</span> <span class="s1">'Україна'</span><span class="p">.</span><span class="nf">encode</span><span class="p">(</span><span class="s1">'KOI8-U'</span><span class="p">)</span>
<span class="c1"># Behaves same as 2.6</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:KOI8-U>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:KOI8-U>]</span>
<span class="c1"># Try to set via mode: WEIRD behavior starts</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="s1">'r:KOI8-U:UTF-8'</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:UTF-8>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:UTF-8>]</span>
<span class="c1"># Try to set via set_encoding: still just ignored</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="s1">'r:KOI8-U:UTF-8'</span><span class="p">).</span><span class="nf">tap</span> <span class="p">{</span> <span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="p">.</span><span class="nf">set_encoding</span><span class="p">(</span><span class="s1">'KOI8-U'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span> <span class="p">})</span>
<span class="c1"># => [#<Encoding:KOI8-U>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:KOI8-U>]</span>
<span class="c1"># Try to set via Enoding.default_internal: WEIRD behavior again</span>
<span class="no">Encoding</span><span class="p">.</span><span class="nf">default_internal</span> <span class="o">=</span> <span class="s1">'UTF-8'</span>
<span class="nb">test</span><span class="p">(</span><span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">str</span><span class="p">))</span>
<span class="c1"># => [#<Encoding:UTF-8>, nil, "\xF5\xCB\xD2\xC1\xA7\xCE\xC1", #<Encoding:UTF-8>]</span>
</code></pre>
<p>So, <strong>2.7</strong> not just ignores attempts to set <strong>internal</strong> encoding, but erroneously sets it to <strong>external</strong> one, so strings are not recoded, but their encoding is forced to change.</p>
<p>I believe it is severe bug (more severe than 2.6's "just ignoring").</p>
<p><a href="https://www.reddit.com/r/ruby/comments/emd6q4/is_this_a_stringio_bug_in_ruby_270/" class="external">This Reddit thread</a> shows how it breaks existing code:</p>
<ul>
<li>the author uses <code>StringIO</code> to work with <code>ASCII-8BIT</code> strings;</li>
<li>the code is performed in Rails environment (which sets <code>internal_encoding</code> to <code>UTF-8</code> by default);</li>
<li>under <strong>2.7</strong>, <code>StringIO#read</code> returns <code>ASCII-8BIT</code> content in Strings saying their encoding is <code>UTF-8</code>.</li>
</ul> Ruby master - Bug #15550 (Assigned): Windows - gem bin files - can't run from bash shellhttps://bugs.ruby-lang.org/issues/155502019-01-20T00:45:45ZMSP-Greg (Greg L)
<p>As I recall, ruby-loco is no longer touching the gem related files located in the bin folder. Previously, there were two files associated with each gem, one with a .cmd/.bat extension, one without.</p>
<p>Currently, there is just one file with a .cmd extension. I have seen this before, and just came across it again, where gems are using *nix scripts run with either the MSYS2 shell or the Git shell in their CI. Hence, there is an expectation for the plain (extensionless) file to exist.</p>
<p>Not sure if this is considered a breaking change or a bug/issue.</p>
<p>Thanks, Greg</p> Ruby master - Bug #15499 (Assigned): Breaking behavior on ruby 2.6: rb_thread_call_without_gvl do...https://bugs.ruby-lang.org/issues/154992019-01-03T01:37:49Zapolcyn (alex polcyn)
<p>This issue was noticed when trying to add ruby 2.6 support to the "grpc" ruby gem (this gem is a native C-extension), and was caught by a unit test.</p>
<p>There are several APIs on the grpc ruby gem (<a href="https://github.com/grpc/grpc/tree/master/src/ruby" class="external">https://github.com/grpc/grpc/tree/master/src/ruby</a>) that invoke "rb_thread_call_without_gvl" on the current thread, doing a blocking operation in the "without gvl" callback and cancel that blocking operation in the "unblocking function". These APIs work in ruby versions prior to ruby 2.6 (e.g. ruby 2.5), but have problems when used on ruby 2.6</p>
<p>Minimal repro:</p>
<p>My system:</p>
<pre><code>> lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.6 (stretch)
Release: 9.6
Codename: stretch
> ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux
# I installed ruby 2.6.0 with rvm - https://rvm.io/rvm/install
> GRPC_CONFIG=dbg gem install grpc --platform ruby # build grpc gem from source with debug symbols
</code></pre>
<p>ruby script, "repro.rb" that looks like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'grpc'</span>
<span class="n">ch</span> <span class="o">=</span> <span class="no">GRPC</span><span class="o">::</span><span class="no">Core</span><span class="o">::</span><span class="no">Channel</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s1">'localhost:1234'</span><span class="p">,</span> <span class="p">{},</span> <span class="ss">:this_channel_is_insecure</span><span class="p">)</span>
<span class="n">ch</span><span class="p">.</span><span class="nf">watch_connectivity_state</span><span class="p">(</span><span class="n">ch</span><span class="p">.</span><span class="nf">connectivity_state</span><span class="p">,</span> <span class="no">Time</span><span class="p">.</span><span class="nf">now</span> <span class="o">+</span> <span class="mi">360</span><span class="p">)</span>
</code></pre>
<p>Run "ruby repro.rb" with an interactive shell, and it will hang there. At this point, ctrl^C the process, and it will not terminate.<br>
What should happen is this unblocking func should be invoked: <a href="https://github.com/grpc/grpc/blob/master/src/ruby/ext/grpc/rb_channel.c#L354" class="external">https://github.com/grpc/grpc/blob/master/src/ruby/ext/grpc/rb_channel.c#L354</a>, but as seen with logging or debuggers, that unblocking func is never ran. Thus the blocking operation never completes and the main thread is stuck.</p>
<p>When the same repro.rb is ran on e.g. ruby 2.5.3 or ruby 2.4.1, the blocking operation is unblocked and the process terminates, as expected, when sending it a SIGINT.</p>
<p>Also note that if the blocking operation is put in a background thread, e.g. with this script:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'grpc'</span>
<span class="n">th</span> <span class="o">=</span> <span class="no">Thread</span><span class="p">.</span><span class="nf">new</span> <span class="k">do</span>
<span class="n">ch</span> <span class="o">=</span> <span class="no">GRPC</span><span class="o">::</span><span class="no">Core</span><span class="o">::</span><span class="no">Channel</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s1">'localhost:1234'</span><span class="p">,</span> <span class="p">{},</span> <span class="ss">:this_channel_is_insecure</span><span class="p">)</span>
<span class="n">ch</span><span class="p">.</span><span class="nf">watch_connectivity_state</span><span class="p">(</span><span class="n">ch</span><span class="p">.</span><span class="nf">connectivity_state</span><span class="p">,</span> <span class="no">Time</span><span class="p">.</span><span class="nf">now</span> <span class="o">+</span> <span class="mi">360</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">th</span><span class="p">.</span><span class="nf">join</span>
</code></pre>
<p>then "unblocking" functions will in fact be invoked upon sending the process a SIGINT, so this looks like a problem specifically with rb_thread_call_without_gvl being used on the main thread.</p>
<p>Please let me know and I can provide more details or alternative repro cases.</p>
<p>Thanks in advance.</p> Ruby master - Bug #14727 (Assigned): TestQueue#test_queue_with_trap always timeout on Windows10https://bugs.ruby-lang.org/issues/147272018-05-01T02:27:47Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<p>表題の通りです。ささださんも把握しているそうなので、備忘録として。</p>
<pre><code>[19/35] TestQueue#test_queue_with_trap = 10.13 s
1) Error:
TestQueue#test_queue_with_trap:
Timeout::Error: execution of assert_in_out_err expired timeout (10 sec)
pid 11608 exit 0
|
C:/Users/usa/develop/ruby/core/mytree/test/thread/test_queue.rb:553:in `test_queue_with_trap'
</code></pre> Ruby master - Bug #14090 (Assigned): `TestGc#test_interrupt_in_finalizer` fails very rarelyhttps://bugs.ruby-lang.org/issues/140902017-11-07T07:35:25Zmame (Yusuke Endoh)mame@ruby-lang.org
<p><code>TestGc#test_interrupt_in_finalizer</code> fails very rarely, only once every handred or thousand runs.</p>
<pre><code># Running tests:
[1/1] TestGc#test_interrupt_in_finalizer = 10.13 s
1) Error:
TestGc#test_interrupt_in_finalizer:
Timeout::Error: execution of assert_in_out_err expired
pid 24697 killed by SIGABRT (signal 6) (core dumped)
|
| [BUG] Segmentation fault at 0x000003e800006075
| ruby 2.5.0dev (2017-11-07) [x86_64-linux]
|
| -- Control frame information -----------------------------------------------
|
|
| -- Machine register context ------------------------------------------------
| RIP: 0x00007f80612bb072 RBP: 0x000055c3587e1efc RSP: 0x00007ffc4f8100b0
| RAX: 0xfffffffffffffffc RBX: 0x000055c3587e1ee4 RCX: 0x00007f80612bb072
| RDX: 0x0000000000000000 RDI: 0x000055c3587e1efc RSI: 0x0000000000000080
| R8: 0x00000000000000ca R9: 0x0000000000000000 R10: 0x0000000000000000
| R11: 0x0000000000000246 R12: 0x000055c3587e1ed0 R13: 0x00007ffc4f810110
| R14: 0x000055c3587e1f38 R15: 0x0000000000000003 EFL: 0x0000000000000246
|
| -- C level backtrace information -------------------------------------------
| /home/mame/work/ruby.tmp/ruby(rb_vm_bugreport+0x7d3) [0x55c357e7a333] vm_dump.c:703
| /home/mame/work/ruby.tmp/ruby(rb_bug_context+0xd1) [0x55c357e6de11] error.c:554
| /home/mame/work/ruby.tmp/ruby(sigsegv+0x42) [0x55c357d5e602] signal.c:928
| /lib/x86_64-linux-gnu/libpthread.so.0 [0x7f80612c0150]
| /lib/x86_64-linux-gnu/libpthread.so.0(pthread_cond_wait+0x152) [0x7f80612bb072]
| /home/mame/work/ruby.tmp/ruby(native_sleep.constprop.79+0x1de) [0x55c357d967fe] thread_pthread.c:340
| /home/mame/work/ruby.tmp/ruby(rb_thread_terminate_all+0x1e0) [0x55c357d9aba0] thread.c:507
| /home/mame/work/ruby.tmp/ruby(ruby_cleanup+0x17e) [0x55c357c6078e] eval.c:188
| /home/mame/work/ruby.tmp/ruby(ruby_run_node+0x36) [0x55c357c60aa6] eval.c:302
| /home/mame/work/ruby.tmp/ruby(main+0x5f) [0x55c357c5ca1f] encoding.c:164
|
| -- Other runtime information -----------------------------------------------
|
| * Loaded script: -e
|
| * Loaded features:
|
| 0 enumerator.so
| 1 thread.rb
| 2 rational.so
| 3 complex.so
| 4 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/encdb.so
| 5 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/trans/transdb.so
| 6 /home/mame/work/ruby.tmp/rbconfig.rb
| 7 /home/mame/work/ruby.tmp/lib/rubygems/compatibility.rb
| 8 /home/mame/work/ruby.tmp/lib/rubygems/defaults.rb
| 9 /home/mame/work/ruby.tmp/lib/rubygems/deprecate.rb
| 10 /home/mame/work/ruby.tmp/lib/rubygems/errors.rb
| 11 /home/mame/work/ruby.tmp/lib/rubygems/version.rb
| 12 /home/mame/work/ruby.tmp/lib/rubygems/requirement.rb
| 13 /home/mame/work/ruby.tmp/lib/rubygems/platform.rb
| 14 /home/mame/work/ruby.tmp/lib/rubygems/basic_specification.rb
| 15 /home/mame/work/ruby.tmp/lib/rubygems/stub_specification.rb
| 16 /home/mame/work/ruby.tmp/lib/rubygems/util/list.rb
| 17 /home/mame/work/ruby.tmp/.ext/x86_64-linux/stringio.so
| 18 /home/mame/work/ruby.tmp/lib/rubygems/specification.rb
| 19 /home/mame/work/ruby.tmp/lib/rubygems/exceptions.rb
| 20 /home/mame/work/ruby.tmp/lib/rubygems/core_ext/kernel_gem.rb
| 21 /home/mame/work/ruby.tmp/lib/monitor.rb
| 22 /home/mame/work/ruby.tmp/lib/rubygems/core_ext/kernel_require.rb
| 23 /home/mame/work/ruby.tmp/lib/rubygems.rb
| 24 /home/mame/work/ruby.tmp/lib/rubygems/dependency.rb
| 25 /home/mame/work/ruby.tmp/lib/rubygems/path_support.rb
|
| * Process memory map:
|
| 55c357c3a000-55c357f55000 r-xp 00000000 fd:01 21892603 /home/mame/work/ruby.tmp/ruby
| 55c358155000-55c35815a000 r--p 0031b000 fd:01 21892603 /home/mame/work/ruby.tmp/ruby
| 55c35815a000-55c35815b000 rw-p 00320000 fd:01 21892603 /home/mame/work/ruby.tmp/ruby
| 55c35815b000-55c35816c000 rw-p 00000000 00:00 0
| 55c3587e1000-55c358b0d000 rw-p 00000000 00:00 0 [heap]
| 7f8058000000-7f8058021000 rw-p 00000000 00:00 0
| 7f8058021000-7f805c000000 ---p 00000000 00:00 0
| 7f805e93f000-7f805eb1e000 r--s 00000000 fd:01 15604574 /lib/x86_64-linux-gnu/libc-2.26.so
| 7f805eb1e000-7f805fb92000 r--s 00000000 fd:01 21892603 /home/mame/work/ruby.tmp/ruby
| 7f805fb92000-7f805fba8000 r-xp 00000000 fd:01 15597591 /lib/x86_64-linux-gnu/libgcc_s.so.1
| 7f805fba8000-7f805fda7000 ---p 00016000 fd:01 15597591 /lib/x86_64-linux-gnu/libgcc_s.so.1
| 7f805fda7000-7f805fda8000 r--p 00015000 fd:01 15597591 /lib/x86_64-linux-gnu/libgcc_s.so.1
| 7f805fda8000-7f805fda9000 rw-p 00016000 fd:01 15597591 /lib/x86_64-linux-gnu/libgcc_s.so.1
| 7f805fda9000-7f805feaa000 rw-p 00000000 00:00 0
| 7f805feaa000-7f805feb3000 r-xp 00000000 fd:01 23333969 /home/mame/work/ruby.tmp/.ext/x86_64-linux/stringio.so
| 7f805feb3000-7f80600b2000 ---p 00009000 fd:01 23333969 /home/mame/work/ruby.tmp/.ext/x86_64-linux/stringio.so
| 7f80600b2000-7f80600b3000 r--p 00008000 fd:01 23333969 /home/mame/work/ruby.tmp/.ext/x86_64-linux/stringio.so
| 7f80600b3000-7f80600b4000 rw-p 00009000 fd:01 23333969 /home/mame/work/ruby.tmp/.ext/x86_64-linux/stringio.so
| 7f80600b4000-7f80600b6000 r-xp 00000000 fd:01 23333689 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/trans/transdb.so
| 7f80600b6000-7f80602b6000 ---p 00002000 fd:01 23333689 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/trans/transdb.so
| 7f80602b6000-7f80602b7000 r--p 00002000 fd:01 23333689 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/trans/transdb.so
| 7f80602b7000-7f80602b8000 rw-p 00003000 fd:01 23333689 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/trans/transdb.so
| 7f80602b8000-7f80602ba000 r-xp 00000000 fd:01 23333649 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/encdb.so
| 7f80602ba000-7f80604b9000 ---p 00002000 fd:01 23333649 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/encdb.so
| 7f80604b9000-7f80604ba000 r--p 00001000 fd:01 23333649 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/encdb.so
| 7f80604ba000-7f80604bb000 rw-p 00002000 fd:01 23333649 /home/mame/work/ruby.tmp/.ext/x86_64-linux/enc/encdb.so
| 7f80604bb000-7f8060691000 r-xp 00000000 fd:01 15604574 /lib/x86_64-linux-gnu/libc-2.26.so
| 7f8060691000-7f8060891000 ---p 001d6000 fd:01 15604574 /lib/x86_64-linux-gnu/libc-2.26.so
| 7f8060891000-7f8060895000 r--p 001d6000 fd:01 15604574 /lib/x86_64-linux-gnu/libc-2.26.so
| 7f8060895000-7f8060897000 rw-p 001da000 fd:01 15604574 /lib/x86_64-linux-gnu/libc-2.26.so
| 7f8060897000-7f806089b000 rw-p 00000000 00:00 0
| 7f806089b000-7f80609f0000 r-xp 00000000 fd:01 15604578 /lib/x86_64-linux-gnu/libm-2.26.so
| 7f80609f0000-7f8060bef000 ---p 00155000 fd:01 15604578 /lib/x86_64-linux-gnu/libm-2.26.so
| 7f8060bef000-7f8060bf0000 r--p 00154000 fd:01 15604578 /lib/x86_64-linux-gnu/libm-2.26.so
| 7f8060bf0000-7f8060bf1000 rw-p 00155000 fd:01 15604578 /lib/x86_64-linux-gnu/libm-2.26.so
| 7f8060bf1000-7f8060bfa000 r-xp 00000000 fd:01 15604576 /lib/x86_64-linux-gnu/libcrypt-2.26.so
| 7f8060bfa000-7f8060df9000 ---p 00009000 fd:01 15604576 /lib/x86_64-linux-gnu/libcrypt-2.26.so
| 7f8060df9000-7f8060dfa000 r--p 00008000 fd:01 15604576 /lib/x86_64-linux-gnu/libcrypt-2.26.so
| 7f8060dfa000-7f8060dfb000 rw-p 00009000 fd:01 15604576 /lib/x86_64-linux-gnu/libcrypt-2.26.so
| 7f8060dfb000-7f8060e29000 rw-p 00000000 00:00 0
| 7f8060e29000-7f8060e2c000 r-xp 00000000 fd:01 15604577 /lib/x86_64-linux-gnu/libdl-2.26.so
| 7f8060e2c000-7f806102b000 ---p 00003000 fd:01 15604577 /lib/x86_64-linux-gnu/libdl-2.26.so
| 7f806102b000-7f806102c000 r--p 00002000 fd:01 15604577 /lib/x86_64-linux-gnu/libdl-2.26.so
| 7f806102c000-7f806102d000 rw-p 00003000 fd:01 15604577 /lib/x86_64-linux-gnu/libdl-2.26.so
| 7f806102d000-7f80610ab000 r-xp 00000000 fd:01 12068737 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
| 7f80610ab000-7f80612ab000 ---p 0007e000 fd:01 12068737 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
| 7f80612ab000-7f80612ac000 r--p 0007e000 fd:01 12068737 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
| 7f80612ac000-7f80612ad000 rw-p 0007f000 fd:01 12068737 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
| 7f80612ad000-7f80612c7000 r-xp 00000000 fd:01 15604589 /lib/x86_64-linux-gnu/libpthread-2.26.so
| 7f80612c7000-7f80614c6000 ---p 0001a000 fd:01 15604589 /lib/x86_64-linux-gnu/libpthread-2.26.so
| 7f80614c6000-7f80614c7000 r--p 00019000 fd:01 15604589 /lib/x86_64-linux-gnu/libpthread-2.26.so
| 7f80614c7000-7f80614c8000 rw-p 0001a000 fd:01 15604589 /lib/x86_64-linux-gnu/libpthread-2.26.so
| 7f80614c8000-7f80614cc000 rw-p 00000000 00:00 0
| 7f80614cc000-7f80614f3000 r-xp 00000000 fd:01 15602223 /lib/x86_64-linux-gnu/ld-2.26.so
| 7f8061592000-7f80615b6000 r--s 00000000 fd:01 15604589 /lib/x86_64-linux-gnu/libpthread-2.26.so
| 7f80615b6000-7f80616bc000 rw-p 00000000 00:00 0
| 7f80616cb000-7f80616cc000 ---p 00000000 00:00 0
| 7f80616cc000-7f80616ec000 rw-p 00000000 00:00 0
| 7f80616ec000-7f80616ed000 ---p 00000000 00:00 0
| 7f80616ed000-7f80616f3000 rw-p 00000000 00:00 0
| 7f80616f3000-7f80616f4000 r--p 00027000 fd:01 15602223 /lib/x86_64-linux-gnu/ld-2.26.so
| 7f80616f4000-7f80616f5000 rw-p 00028000 fd:01 15602223 /lib/x86_64-linux-gnu/ld-2.26.so
| 7f80616f5000-7f80616f6000 rw-p 00000000 00:00 0
| 7ffc4f013000-7ffc4f812000 rw-p 00000000 00:00 0 [stack]
| 7ffc4f904000-7ffc4f907000 r--p 00000000 00:00 0 [vvar]
| 7ffc4f907000-7ffc4f909000 r-xp 00000000 00:00 0 [vdso]
| ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
|
|
| [NOTE]
| You may have encountered a bug in the Ruby interpreter or extension libraries.
| Bug reports are welcome.
| For details: http://www.ruby-lang.org/bugreport.html
|
/home/mame/work/ruby.tmp/test/ruby/test_gc.rb:354:in `test_interrupt_in_finalizer'
Finished tests in 10.127763s, 0.0987 tests/s, 0.2962 assertions/s.
1 tests, 3 assertions, 0 failures, 1 errors, 0 skips
</code></pre>
<a name="How-to-reproduce"></a>
<h2 >How to reproduce<a href="#How-to-reproduce" class="wiki-anchor">¶</a></h2>
<ol>
<li>Apply this patch. This removes a mitigation of this issue.</li>
</ol>
<pre><code>diff --git a/thread.c b/thread.c
index bfa903c6a4..dfaf75d1ce 100644
--- a/thread.c
+++ b/thread.c
@@ -507,7 +507,7 @@ rb_thread_terminate_all(void)
* me when the last sub-thread exit.
*/
sleeping = 1;
- native_sleep(th, &tv);
+ native_sleep(th, 0);
RUBY_VM_CHECK_INTS_BLOCKING(ec);
sleeping = 0;
}
</code></pre>
<ol start="2">
<li>Run <code>make test-all</code> many times. The following command would be useful.</li>
</ol>
<pre><code>make && while make test-all TESTOPTS="test/ruby/test_gc.rb -n test_interrupt_in_finalizer"; do date; done
</code></pre>
<p>FYI: With execution counter</p>
<pre><code>make && i=0 && while make test-all TESTOPTS="test/ruby/test_gc.rb -n test_interrupt_in_finalizer"; do echo; date; echo "trial:$i"; i=`expr $i + 1`; done
</code></pre>
<a name="Details"></a>
<h2 >Details<a href="#Details" class="wiki-anchor">¶</a></h2>
<p><code>TestGc#test_interrupt_in_finalizer</code> checks if SIGINT can interrupt the GC finalizers. This test itself runs on a child process, and the process should end with SIGINT. If the process does not end in ten seconds, the parent sends SIGSEGV to the child, terminates the test, and reports it as a failure. ("C level backtrace information" has "sigsegv", but don't worry, this SEGV would be the one the parent sent. I guess this bug is not so significant, parhaps.)</p>
<p>When a main thread of Ruby process ends, it terminates all child threads and waits for them. However, for unknown reason (maybe depending upon the timing of SIGINT?), it sometimes fails synchronization: all child threads end, and the main thread meaninglessly waits forever.</p>
<p>Based on Ko1's proposal, I committed a tiny change to mitigate this issue at r60694: instead of waiting forever, the main thread wakes up every one second to monitor all child threads. This is not an essential solution for this issue, but just hides. To debug this issue, we need remove the mitigation by the patch described above.</p> Ruby master - Bug #13999 (Assigned): Cygwin 環境で ripper_state_lex.rb がコアダンプするhttps://bugs.ruby-lang.org/issues/139992017-10-11T05:19:02Zhigaki (masaru higaki)mas.higa@gmail.com
<p>いくつかの gem をインストールした際にコアダンプしました。</p>
<p>--no-ri を付けるとコアダンプしないことから ri の何かが関係していそうです。</p>
<p>$ gem install bitclust-core # コアダンプ<br>
$ gem install --no-ri bitclust-core # コアダンプしない</p>
<p>標準出力、エラー出力を添付します。</p> Ruby master - Bug #13671 (Assigned): Regexp with lookbehind and case-insensitivity raises RegexpE...https://bugs.ruby-lang.org/issues/136712017-06-22T23:28:58Zdschweisguth (Dave Schweisguth)dave@schweisguth.org
<p>Here is a test program:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="n">description</span><span class="p">)</span>
<span class="k">begin</span>
<span class="k">yield</span>
<span class="nb">puts</span> <span class="s2">"</span><span class="si">#{</span><span class="n">description</span><span class="si">}</span><span class="s2"> is OK"</span>
<span class="k">rescue</span> <span class="no">RegexpError</span>
<span class="nb">puts</span> <span class="s2">"</span><span class="si">#{</span><span class="n">description</span><span class="si">}</span><span class="s2"> raises RegexpError"</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="nb">test</span><span class="p">(</span><span class="s2">"ass, case-insensitive, special"</span><span class="p">)</span> <span class="p">{</span> <span class="sr">/(?<!ass)/i</span> <span class="o">=~</span> <span class="s1">'✨'</span> <span class="p">}</span>
<span class="nb">test</span><span class="p">(</span><span class="s2">"bss, case-insensitive, special"</span><span class="p">)</span> <span class="p">{</span> <span class="sr">/(?<!bss)/i</span> <span class="o">=~</span> <span class="s1">'✨'</span> <span class="p">}</span>
<span class="nb">test</span><span class="p">(</span><span class="s2">"as, case-insensitive, special"</span><span class="p">)</span> <span class="p">{</span> <span class="sr">/(?<!as)/i</span> <span class="o">=~</span> <span class="s1">'✨'</span> <span class="p">}</span>
<span class="nb">test</span><span class="p">(</span><span class="s2">"ss, case-insensitive, special"</span><span class="p">)</span> <span class="p">{</span> <span class="sr">/(?<!ss)/i</span> <span class="o">=~</span> <span class="s1">'✨'</span> <span class="p">}</span>
<span class="nb">test</span><span class="p">(</span><span class="s2">"ass, case-sensitive, special"</span><span class="p">)</span> <span class="p">{</span> <span class="sr">/(?<!ass)/</span> <span class="o">=~</span> <span class="s1">'✨'</span> <span class="p">}</span>
<span class="nb">test</span><span class="p">(</span><span class="s2">"ass, case-insensitive, regular"</span><span class="p">)</span> <span class="p">{</span> <span class="sr">/(?<!ass)/i</span> <span class="o">=~</span> <span class="s1">'x'</span> <span class="p">}</span>
</code></pre>
<p>Running the test program with Ruby 2.4.1 (macOS) gives</p>
<pre><code>ass, case-insensitive, special raises RegexpError
bss, case-insensitive, special raises RegexpError
as, case-insensitive, special is OK
ss, case-insensitive, special is OK
ass, case-sensitive, special is OK
ass, case-insensitive, regular is OK
</code></pre>
<p>The RegexpError is "invalid pattern in look-behind: /(?<!ass)/i (RegexpError)"</p>
<p>Side note: in the real code in which I found this error I was able to work around the error by using (?i) after the lookbehind instead of //i.</p>
<p>Running the test program with Ruby 2.3.4 does not report any RegexpErrors.</p>
<p>I think this is a regression, although I might be wrong and it might be saving me from an incorrect result with certain strings.</p> Ruby master - Bug #12725 (Assigned): Trying to use ./miniruby before it existshttps://bugs.ruby-lang.org/issues/127252016-09-05T05:04:23Zduerst (Martin Dürst)duerst@it.aoyama.ac.jpRuby master - Bug #12582 (Assigned): OpenSSL Authenticated Encryption should check for tag lengthhttps://bugs.ruby-lang.org/issues/125822016-07-11T07:35:30Zpatrick.oscity (Patrick Oscity)
<p>The current API for using ciphers with Authenticated Encryption (currently only AES-GCM) is rather misleading and quickly leads to subtle bugs related to the length of <code>auth_tag</code>.</p>
<p>In particular, the current implementation will <em>not</em> check for the length of the <code>auth_tag</code>. Because GCM mode allows arbitrary sizes of the <code>auth_tag</code> up to 128 bytes, only a single byte needs to be supplied to make the authentication pass. This means that an attacker needs at most 256 attempts in order to forge a valid <code>auth_tag</code>.</p>
<pre><code>data = 'secret'
cipher = OpenSSL::Cipher.new('aes-128-gcm')
cipher.encrypt
key = cipher.random_key
iv = cipher.random_iv
cipher.auth_data = 'auth_data'
ciphertext = cipher.update(data) + cipher.final
auth_tag = cipher.auth_tag
auth_tag = auth_tag[0] # single byte is sufficient
cipher = OpenSSL::Cipher.new('aes-128-gcm')
cipher.decrypt
cipher.key = key
cipher.iv = iv
cipher.auth_tag = auth_tag
cipher.auth_data = 'auth_data'
data = cipher.update(ciphertext) + cipher.final
# NO error raised
</code></pre>
<p>Currently, the only way to prevent such attacks is to manually assert the correct <code>auth_tag</code> length when decrypting/authenticating.</p>
<pre><code>raise 'incorrect auth_tag length' unless auth_tag.length == 16
</code></pre>
<p>I suggest the following improvements:</p>
<a name="Documentation-should-mention-the-importance-of-manually-checking-auth_tag-length"></a>
<h3 >Documentation should mention the importance of manually checking <code>auth_tag</code> length<a href="#Documentation-should-mention-the-importance-of-manually-checking-auth_tag-length" class="wiki-anchor">¶</a></h3>
<p>This can/should be done immediately even if the API should not change.</p>
<a name="Authentication-tag-length-should-be-an-input-parameter-to-the-cipher"></a>
<h3 >Authentication tag length should be an input parameter to the cipher<a href="#Authentication-tag-length-should-be-an-input-parameter-to-the-cipher" class="wiki-anchor">¶</a></h3>
<p>To improve the usability of the API and unburden users from performing additional manual checks without compromising security, I suggest to add an <code>auth_tag_len</code> accessor. This can be used to determine the size of the <code>auth_tag</code> both when generating and when authenticating the <code>auth_tag</code>. The default value should be 16 bytes (see below).</p>
<h3>
<code>#auth_tag</code> should use <code>auth_tag_len</code> to determine the output length</h3>
<p>During encryption:</p>
<p>If no parameter is given, <code>#auth_tag</code> should return an authentication tag according to the length configured in <code>auth_tag_len</code>.</p>
<p>If a length parameter is given, <code>#auth_tag</code> should use the supplied parameter to determine the length of the authentication tag. Although this parameter is not as useful any more it should be kept for backwards compatibility. Maybe it should be deprecated.</p>
<p>Currently the API supports different tag lengths by passing the length parameter to <code>#auth_tag</code>. This currently defaults to 16 bytes, which should be the default value for <code>auth_tag_len</code> in order to keep backwards compatibility.</p>
<h3>
<code>#final</code> should use <code>auth_tag_len</code> to assert the correct length of the <code>auth_tag</code>
</h3>
<p>During decryption:</p>
<p><code>auth_tag_len</code> should be used to assert that the supplied <code>auth_tag</code> has the correct length. The big difference to the existing API lies here, because users need to actively change the value of <code>auth_tag_len</code> in order to allow shorter tags.</p>
<p>When the check fails, an <code>OpenSSL::Cipher::CipherError</code> should be raised. The same type of error is already raised when authentication fails, so existing users should be fine without having to touch their error handling. A descriptive error message should be helpful. In order to distinguish between such errors and "actual" verification errors, we could also add a descriptive message for the latter.</p>
<p>I'd be happy to implement these changes, but I wanted to discuss them first.</p> Ruby master - Bug #12506 (Assigned): On cygwin, Feature #5994 does not workhttps://bugs.ruby-lang.org/issues/125062016-06-19T08:18:47Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<p>On cygwin, Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Dir.glob without wildcards returns pattern, not filename (Closed)" href="https://bugs.ruby-lang.org/issues/5994">#5994</a> doesn't seem to have been implemented. This can be confirmed with test/ruby/test_dir.rb (see the very end of this report), or even simpler, as follows:</p>
<pre><code>duerst@Arnisee /cygdrive/c/Data/testCygwin
$ ruby -e 'Dir.mkdir("Matsumoto")'
duerst@Arnisee /cygdrive/c/Data/testCygwin
$ ruby -e 'puts Dir.glob("Ma*to")'
Matsumoto
duerst@Arnisee /cygdrive/c/Data/testCygwin
$ ruby -e 'puts Dir.glob("ma*to")'
duerst@Arnisee /cygdrive/c/Data/testCygwin
$ ruby -e 'puts Dir.glob("matsumoto")'
matsumoto
</code></pre>
<p>The 4th execution shows the problem. Please note that the third execution is also strange.</p>
<pre><code>$ bin/ruby test/runner.rb test/ruby/test_dir.rb
Run options:
# Running tests:
[10/23] TestDir#test_glob_cases = 0.11 s
1) Failure:
TestDir#test_glob_cases [/cygdrive/c/Data/ruby/test/ruby/test_dir.rb:255]:
<a href="/issues/5994">[ruby-core:42469]</a> [Feature #5994]
Dir.glob should return the filename with actual cases on the filesystem.
<["FileWithCases"]> expected but was
<["filewithcases"]>.
Finished tests in 3.294094s, 6.9822 tests/s, 77.7148 assertions/s.
23 tests, 256 assertions, 1 failures, 0 errors, 0 skips
ruby -v: ruby 2.4.0dev (2016-06-19 trunk 55452) [x86_64-cygwin]
</code></pre> Ruby master - Bug #12445 (Assigned): Testing TestIO#test_open_fifo_does_not_block_other_threads r...https://bugs.ruby-lang.org/issues/124452016-05-31T10:15:12Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<p>When I run <code>bin/ruby test/runner.rb test/ruby/test_*</code>, testing stops at <code>TestIO#test_open_fifo_does_not_block_other_threads</code>. Checking the task manager shows that this is a deadlock (there are two ruby interpreters running, but they don't use any CPU at all).</p>
<p>This is what I see for ages:</p>
<pre><code>[1589/4545] TestIO#test_open_fifo_does_not_block_other_threads
</code></pre> Ruby master - Bug #12444 (Assigned): Segmentation fault when running TestException#test_machine_s...https://bugs.ruby-lang.org/issues/124442016-05-31T10:10:48Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<p>When I try to run <code>bin/ruby test/runner.rb test/ruby/test_*</code>, I get the error below. This is immediately followed by a very similar error for TestException#test_machine_stackoverflow_by_define_method.</p>
<pre><code>[ 942/4545] TestException#test_machine_stackoverflow = 1.27 s
19) Failure:
TestException#test_machine_stackoverflow [/cygdrive/c/Data/ruby/test/ruby/test_exception.rb:577]:
pid 16416 killed by SIGABRT (signal 6) (core dumped)
| -:7: [BUG] Segmentation fault at 0x000000ffe03fc0
| ruby 2.4.0dev (2016-05-31 trunk 55228) [x86_64-cygwin]
|
| -- Control frame information -----------------------------------------------
| c:0690 p:0014 s:1387 e:001386 LAMBDA -:7 [FINISH]
| c:0689 p:0014 s:1385 e:001384 LAMBDA -:7 [FINISH]
| c:0688 p:0014 s:1383 e:001382 LAMBDA -:7 [FINISH]
| c:0687 p:0014 s:1381 e:001380 LAMBDA -:7 [FINISH]
| c:0686 p:0014 s:1379 e:001378 LAMBDA -:7 [FINISH]
| c:0685 p:0014 s:1377 e:001376 LAMBDA -:7 [FINISH]
| c:0684 p:0014 s:1375 e:001374 LAMBDA -:7 [FINISH]
| c:0683 p:0014 s:1373 e:001372 LAMBDA -:7 [FINISH]
| c:0682 p:0014 s:1371 e:001370 LAMBDA -:7 [FINISH]
| c:0681 p:0014 s:1369 e:001368 LAMBDA -:7 [FINISH]
</code></pre>
<p>[very long list, ending in]</p>
<pre><code>| c:0009 p:0014 s:0025 e:000024 LAMBDA -:7 [FINISH]
| c:0008 p:0014 s:0023 e:000022 LAMBDA -:7 [FINISH]
| c:0007 p:0014 s:0021 e:000020 LAMBDA -:7 [FINISH]
| c:0006 p:0014 s:0019 e:000018 LAMBDA -:7 [FINISH]
| c:0005 p:0014 s:0017 e:000016 LAMBDA -:7 [FINISH]
| c:0004 p:0028 s:0015 E:001588 BLOCK -:8
| c:0003 p:0052 s:0012 e:000011 METHOD /cygdrive/c/Data/ruby/test/lib/test/unit/assertions.rb:74
| c:0002 p:0047 s:0004 E:000610 EVAL -:6 [FINISH]
| c:0001 p:0000 s:0002 E:001930 (none) [FINISH]
|
| -- Ruby level backtrace information ----------------------------------------
| -:6:in `<main>'
| /cygdrive/c/Data/ruby/test/lib/test/unit/assertions.rb:74:in `assert_raise'
| -:8:in `block in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
</code></pre>
<p>[again very long list, probably about same length, ending with]</p>
<pre><code>| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
| -:7:in `block (2 levels) in <main>'
|
| -- Other runtime information -----------------------------------------------
|
| * Loaded script: -
|
| * Loaded features:
|
| 0 enumerator.so
| 1 thread.rb
| 2 rational.so
| 3 complex.so
| 4 /cygdrive/c/Data/ruby/lib/ruby/2.4.0/x86_64-cygwin/enc/encdb.so
| 5 /cygdrive/c/Data/ruby/lib/ruby/2.4.0/x86_64-cygwin/enc/trans/transdb.so
| 6 /cygdrive/c/Data/ruby/lib/ruby/2.4.0/x86_64-cygwin/enc/windows_31j.so
| 7 /cygdrive/c/Data/ruby/lib/ruby/vendor_ruby/unicode_normalize.rb
| 8 /cygdrive/c/Data/ruby/lib/ruby/vendor_ruby/optparse.rb
| 9 /cygdrive/c/Data/ruby/lib/ruby/2.4.0/x86_64-cygwin/rbconfig.rb
| 10 /cygdrive/c/Data/ruby/test/lib/leakchecker.rb
| 11 /cygdrive/c/Data/ruby/test/lib/minitest/unit.rb
| 12 /cygdrive/c/Data/ruby/lib/ruby/vendor_ruby/prettyprint.rb
| 13 /cygdrive/c/Data/ruby/lib/ruby/vendor_ruby/pp.rb
| 14 /cygdrive/c/Data/ruby/test/lib/test/unit/assertions.rb
| 15 /cygdrive/c/Data/ruby/lib/ruby/vendor_ruby/open3.rb
| 16 /cygdrive/c/Data/ruby/lib/ruby/vendor_ruby/timeout.rb
| 17 /cygdrive/c/Data/ruby/test/lib/find_executable.rb
| 18 /cygdrive/c/Data/ruby/lib/ruby/2.4.0/x86_64-cygwin/rbconfig/sizeof.so
| 19 /cygdrive/c/Data/ruby/test/lib/envutil.rb
| 20 /cygdrive/c/Data/ruby/test/lib/test/unit/testcase.rb
| 21 /cygdrive/c/Data/ruby/test/lib/test/unit.rb
|
| [NOTE]
| You may have encountered a bug in the Ruby interpreter or extension libraries.
| Bug reports are welcome.
| For details: http://www.ruby-lang.org/bugreport.html
|
</code></pre> Ruby master - Bug #12442 (Assigned): TestArgf#test_textmode fails on cygwinhttps://bugs.ruby-lang.org/issues/124422016-05-31T10:01:19Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<p>When I try to run <code>bin/ruby test/runner.rb test/ruby/test_*</code> (because <code>make test-all</code> doesn't work), the first failure that I get is as below.</p>
<pre><code>$ bin/ruby test/runner.rb test/ruby/test_*
Run options:
# Running tests:
[ 156/4545] TestArgf#test_textmode = 1.60 s
1) Failure:
TestArgf#test_textmode [/cygdrive/c/Data/ruby/test/ruby/test_argf.rb:685]:
<a href="/issues/5268">[ruby-core:39234]</a>.
<"1\n2\n3\n4\n5\n6\n"> expected but was
<"1\n2\n3\n4\n5\r\n6\r\n">.
</code></pre> Ruby master - Bug #12040 (Assigned): [Win32] File.stat fails on a mounted volumehttps://bugs.ruby-lang.org/issues/120402016-02-01T08:13:24Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<p>On Windows, <code>File.stat</code> fails on the volume mount point directory whose name contains <code>"..."</code>.</p>
<p>Where <code>%vol%</code> is the volume ID of a new VHD volume,</p>
<pre><code>C:> set vol
\\?\Volume{3C458AE9-C8B1-11E5-A233-0800271D089F}\
C:> mkdir x...y
C:> mountvol x...y %vol%
C:> .\miniruby -e "p Dir.chdir('x...y'){File.stat('.')}" -e "p File.stat('x...y')"
#<File::Stat dev=0x2, ino=1407374883553285, mode=040755, nlink=1, uid=0, gid=0, rdev=0x2, size=4096, blksize=nil, blocks=nil, atime=2016-02-01 16:35:45 +0900, mtime=2016-02-01 16:35:45 +0900, ctime=2016-02-01 16:35:45 +0900>
-e:2:in `stat': No such file or directory @ rb_file_s_stat - x...y (Errno::ENOENT)
from -e:2:in `<main>'
</code></pre>
<p>Note that <code>Dir.chdir</code> and <code>File.stat</code> there succeed.<br>
This failures depends on the mount point name, because of <code>check_valid_dir()</code>.</p> Ruby master - Bug #9189 (Assigned): Build failure on Windows in case of nonascii TEMP environment.https://bugs.ruby-lang.org/issues/91892013-12-01T18:06:20Zphasis68 (Heesob Park)phasis@gmail.com
<p>I experienced a build failure during build extension library with trunk on Windows.</p>
<pre><code>make[2]: Entering directory `/c/work/ruby-2.1.0-r43936/ext/bigdecimal'
generating bigdecimal-i386-mingw32.def
compiling bigdecimal.c
In file included from bigdecimal.c:20:0:
bigdecimal.h:62:1: error: static declaration of 'labs' follows non-static declar
ation
make[2]: *** [bigdecimal.o] Error 1
make[2]: Leaving directory `/c/work/ruby-2.1.0-r43936/ext/bigdecimal'
make[1]: *** [ext/bigdecimal/all] Error 2
make[1]: Leaving directory `/c/work/ruby-2.1.0-r43936'
make: *** [build-ext] Error 2
</code></pre>
<p>I found the cause of this error is mkmk failure.<br>
Here is a part of mkmf.log</p>
<pre><code>have_func: checking for labs() in stdlib.h... -------------------- no
"i686-w64-mingw32-gcc -o conftest.exe -I../../.ext/include/i386-mingw32 -I../.././include -I../.././ext/bigdecimal -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -L../.. -L. -lmsvcrt-ruby210-static -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Cannot create temporary file in C:\Users\??苑?AppData\Local\Temp\: Invalid argument
</code></pre>
<p>The TEMP environment varable is</p>
<pre><code>C:\work\ruby-2.1.0-r43936>set TEMP
TEMP=C:\Users\희섭\AppData\Local\Temp
</code></pre>
<p>It seems that miniruby cannot handle encoding properly.</p>
<pre><code>C:\work\ruby-2.1.0-r43936>miniruby -ve "p ENV['TEMP']"
ruby 2.1.0dev (2013-11-30 trunk 43936) [i386-mingw32]
"C:\\Users\\\xED\x9D\xAC\xEC\x84\xAD\\AppData\\Local\\Temp"
C:\work\ruby-2.1.0-r43936>miniruby.exe -ve "p ENV['TEMP'].encoding"
ruby 2.1.0dev (2013-11-30 trunk 43936) [i386-mingw32]
#<Encoding:ASCII-8BIT>
</code></pre>
<p>Whereas, the final ruby can handle encoding properly.</p>
<pre><code>C:\work>ruby -ve "p ENV['TEMP']"
ruby 2.1.0dev (2013-11-30 trunk 43923) [i386-mingw32]
"C:\\Users\\희섭\\AppData\\Local\\Temp"
C:\work>ruby -ve "p ENV['TEMP'].encoding"
ruby 2.1.0dev (2013-11-30 trunk 43923) [i386-mingw32]
#<Encoding:CP949>
</code></pre> Ruby master - Bug #9115 (Assigned): Logger traps all exceptions; breaks Timeouthttps://bugs.ruby-lang.org/issues/91152013-11-16T12:30:25Zcphoenix (Chris Phoenix)cphoenix@gmail.com
<p>Line 577-579 of logger.rb</p>
<pre><code> rescue Exception => ignored
warn("log writing failed. #{ignored}")
end
</code></pre>
<p>Thus, when the system times out in the middle of writing a log message, it warns "log writing failed. execution expired" and just keeps right on running.</p>
<p>This is true in 1.9.3 as well. I haven't looked at older versions.</p>
<p>Pardon me while I go grep "rescue Exception" in the entire Ruby codebase, and see whether I can reliably use Timeout at all...</p>
<p>OK, you might check out C:\Ruby200\lib\ruby\gems\2.0.0\gems\activerecord-3.2.13\lib\active_record\railties\databases.rake</p>
<p>All the other "rescue Exception" seem to re-raise it, except maybe C:\Ruby200\lib\ruby\2.0.0\xmlrpc\server.rb and C:\Ruby200\lib\ruby\gems\2.0.0\gems\activesupport-3.2.13\lib\active_support\callbacks.rb</p> Ruby master - Bug #9010 (Assigned): ./configure --prefix= cannot handle directories with spaceshttps://bugs.ruby-lang.org/issues/90102013-10-10T07:50:41Zpostmodern (Hal Brodigan)postmodern.mod3@gmail.com
<p>It appears that the linking task fails when the --prefix value contains spaces.</p>
<p>Steps to Reproduce:</p>
<ol>
<li>./configure --prefix="$HOME/foo bar"</li>
<li>make</li>
</ol>
<p>Expected Result: success<br>
Actual Result:</p>
<p>make[2]: Entering directory <code>/home/hal/src/ruby-2.0.0-p247' linking ruby gcc: error: bar/lib: No such file or directory gcc: error: bar/lib: No such file or directory make[2]: *** [ruby] Error 1 make[2]: Leaving directory </code>/home/hal/src/ruby-2.0.0-p247'<br>
make[1]: *** [all] Error 2<br>
make[1]: Leaving directory `/home/hal/src/ruby-2.0.0-p247'<br>
make: *** [build-ext] Error 2</p> Ruby master - Bug #8445 (Assigned): IO.open and IO#set_enconding does not support :fallback optionhttps://bugs.ruby-lang.org/issues/84452013-05-24T22:03:00Zpjmtdw (Haruhiro Yoshimoto)pjmtdw@gmail.com
<p>RubyDoc says that <code>IO.open</code> and <code>IO#set_encoding</code> supports optional argument defined in <code>String#encode</code>.<br>
<a href="http://ruby-doc.org/core-2.0/IO.html#method-c-new-label-Options" class="external">http://ruby-doc.org/core-2.0/IO.html#method-c-new-label-Options</a><br>
In fact, <code>:invalid, :undef and :replace</code> works as expected.</p>
<p>However, <code>:fallback</code> option does not work neither for <code>IO.open</code> and <code>IO#set_encoding</code>.<br>
Following is the example code which does not work.<br>
<code>f(x)</code> is never called even if hoge.txt contains non convertible character.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s2">"./hoge.txt"</span><span class="p">,</span><span class="s2">"r:Shift_JIS:utf-8"</span><span class="p">,</span> <span class="ss">:fallback</span> <span class="o">=></span> <span class="nb">lambda</span><span class="p">{</span><span class="o">|</span><span class="n">x</span><span class="o">|</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">)}){</span><span class="o">|</span><span class="n">f</span><span class="o">|</span>
<span class="o">...</span>
<span class="p">}</span>
<span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s2">"./hoge.txt"</span><span class="p">){</span><span class="o">|</span><span class="n">f</span><span class="o">|</span>
<span class="n">f</span><span class="p">.</span><span class="nf">set_encoding</span><span class="p">(</span><span class="s2">"Shift_JIS"</span><span class="p">,</span><span class="s2">"utf-8"</span><span class="p">,</span><span class="ss">:fallback</span> <span class="o">=></span> <span class="nb">lambda</span><span class="p">{</span><span class="o">|</span><span class="n">x</span><span class="o">|</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">)})</span>
<span class="o">...</span>
<span class="p">}</span>
</code></pre>
<p>I Think this is because <code>fill_cbuf()</code> in <code>io.c</code> calls <code>rb_econv_convert()</code> from <code>transcode.c</code> directly.<br>
On the other hand, <code>fallback_func</code> is called in <code>transcode_loop()</code>, which is called by <code>str_encode()</code>.</p>
<p>Since <code>transcode_loop()</code> also calls <code>rb_econv_convert()</code>, I wrote a small patch which moves some codes from<br>
<code>transcode_loop()</code> to <code>rb_econv_convert()</code> to fix the problem.</p>
<p>The attached file is the patch. Hope this helps.</p> Ruby master - Bug #7968 (Assigned): Poor UDPSocket#send performance in ruby 2.0.0 on windowshttps://bugs.ruby-lang.org/issues/79682013-02-26T20:55:25Zcs96and (Alan Davies)alan.n.davies@gmail.com
<p>I have noticed that the performance of UDPSocket#send on ruby 2.0.0 on windows is much poorer than that of 1.9.3 or 1.8.7. Running the attahced script on 2.0.0 gives the following...</p>
<p>d:\scripts>bash -c "ruby --version"<br>
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]</p>
<p>d:\scripts>bash -c "time ruby socketsendtest.rb"</p>
<p>real 0m2.572s<br>
user 0m0.000s<br>
sys 0m0.016s</p>
<p>However, running the same test with 1.9.3 is much faster...</p>
<p>d:\scripts>pik 193</p>
<p>d:\scripts>bash -c "ruby --version"<br>
ruby 1.9.3p374 (2013-01-15) [i386-mingw32]</p>
<p>d:\scripts>bash -c "time ruby socketsendtest.rb"</p>
<p>real 0m0.993s<br>
user 0m0.015s<br>
sys 0m0.016s</p>
<p>Additionally, if I change the send call to a print (commented out in the script), then the performance is fine on 2.0.0....</p>
<p>d:\scripts>pik 200</p>
<p>d:\scripts>bash -c "ruby --version"<br>
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]</p>
<p>d:\scripts>bash -c "time ruby socketsendtest.rb"</p>
<p>real 0m0.907s<br>
user 0m0.000s<br>
sys 0m0.015s</p>
<p>What is send() doing that print() doesn't do that is causing the massive performance drop?</p>
<p>Thanks<br>
Alan.</p> Ruby master - Bug #7964 (Assigned): Writing an ASCII-8BIT String to a StringIO created from a UTF...https://bugs.ruby-lang.org/issues/79642013-02-26T16:32:50Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
In the following script, an ASCII-8BIT String is written to a StringIO created with a UTF-8 String without error. However, a << b or a + b will raise an exception, as will writing an ASCII-8BIT String to a File with UTF-8 external encoding.</p>
<ul>
<li>
<p>$ cat file_enc.rb</p>
<a name="encoding-utf-8"></a>
<h1 >encoding: utf-8<a href="#encoding-utf-8" class="wiki-anchor">¶</a></h1>
<p>require 'stringio'</p>
<p>a = "On a very cold morning, it was -8°F."<br>
b = a.dup.force_encoding "ascii-8bit"</p>
<p>io = StringIO.new a<br>
io.write(b)<br>
p io.string.encoding</p>
<p>File.open "data.txt", "w:utf-8" do |f|<br>
f.write a<br>
f.write b<br>
end</p>
</li>
<li>
<p>$ ruby2.0 -v file_enc.rb<br>
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin10.8.0]<br>
#<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
file_enc.rb:13:in <code>write': "\xC2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) from file_enc.rb:13:in </code>block in '<br>
from file_enc.rb:11:in <code>open' from file_enc.rb:11:in </code>'</p>
</li>
<li>
<p>$ ruby1.9.3 -v file_enc.rb<br>
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin10.8.0]<br>
#<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
file_enc.rb:13:in <code>write': "\xC2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) from file_enc.rb:13:in </code>block in '<br>
from file_enc.rb:11:in <code>open' from file_enc.rb:11:in </code>'<br>
=end</p>
</li>
</ul> Ruby master - Bug #6360 (Assigned): Debug information build even without requesting ithttps://bugs.ruby-lang.org/issues/63602012-04-26T08:46:44Zluislavena (Luis Lavena)luislavena@gmail.com
<p>Hello,</p>
<p>While working on latest RubyInstaller release for 1.9.3-p194 our team detected a bigger shared library and import library being generated.</p>
<p>After further inspection, we found this commit:<br>
<a href="https://github.com/ruby/ruby/commit/ffdaca1d748804f2b5ca2de612f17cf6c78d351b" class="external">https://github.com/ruby/ruby/commit/ffdaca1d748804f2b5ca2de612f17cf6c78d351b</a></p>
<p>Backported r34840 into ruby_1_9_3 branch</p>
<p>The above change added -ggdb to CFLAGS even when was not provided by debugflags configure option.</p>
<p>The following is the comparison of "make" summary with and without the change:</p>
<p>Current trunk:</p>
<pre>
C:\Users\Luis\Projects\oss\ruby\build32>make
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -O3 -fno-omit-frame-pointer -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration
XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -DFD_SETSIZE=32767 -D_WIN32_WINNT=0x0501 -I. -I.ext/include/i386-mingw32 -I../include -I..
DLDFLAGS = -Wl,--enable-auto-image-base,--enable-auto-import -Wl,--out-implib=libmsvcrt-ruby200.dll.a msvcrt-ruby200.def -Wl,--stack,0x00200000,--enable-auto-import
SOLIBS = msvcrt-ruby200.res.o -lshell32 -lws2_32 -limagehlp
</pre>
<p>Reverting r34840:</p>
<pre>
C:\Users\Luis\Projects\oss\ruby\build32>make
CC = gcc
LD = ld
LDSHARED = gcc -shared -s
CFLAGS = -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration
XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -DFD_SETSIZE=32767 -D_WIN32_WINNT=0x0501 -I. -I.ext/include/i386-mingw32 -I../include -I..
DLDFLAGS = -Wl,--enable-auto-image-base,--enable-auto-import -Wl,--out-implib=libmsvcrt-ruby200.dll.a msvcrt-ruby200.def -Wl,--stack,0x00200000,--enable-auto-import
SOLIBS = msvcrt-ruby200.res.o -lshell32 -lws2_32 -limagehlp
</pre>
<p>Notice that -g changed into -ggdb instead.</p>
<p>I think debug symbols shouldn't be compiled unless requested and this is a regression.</p> Ruby master - Bug #6351 (Assigned): transcode table generator does not support multi characters o...https://bugs.ruby-lang.org/issues/63512012-04-24T20:41:39Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<p>改めてチケット起こします。<a href="/issues/6349">[ruby-dev:45576]</a> より。</p>
<p>On 2012/04/24 17:11, "Martin J. Dürst" wrote:</p>
<blockquote>
<p>On 2012/04/24 17:02, U.Nakamura wrote:</p>
<blockquote>
<p>データは例によってNetBSDのものが利用できそうです。<br>
なのですが、transcodeってUnicodeの第0面(BMP)以外はサポートし<br>
てましたっけ?</p>
</blockquote>
<p>もちろんです :-)</p>
</blockquote>
<p>もうちょっと調べました。BMP 以外は transcode の最初から全く問題ないです<br>
が、現時点で引っかかるのは次のものです<br>
(<a href="http://x0213.org/codetable/euc-jis-2004-std.txt" class="external">http://x0213.org/codetable/euc-jis-2004-std.txt</a> から抜粋):</p>
<p>0xA4F7 U+304B+309A # [2000]<br>
0xA4F8 U+304D+309A # [2000]<br>
0xA4F9 U+304F+309A # [2000]<br>
0xA4FA U+3051+309A # [2000]<br>
0xA4FB U+3053+309A # [2000]</p>
<p>0xA5F7 U+30AB+309A # [2000]<br>
0xA5F8 U+30AD+309A # [2000]<br>
0xA5F9 U+30AF+309A # [2000]<br>
0xA5FA U+30B1+309A # [2000]<br>
0xA5FB U+30B3+309A # [2000]<br>
0xA5FC U+30BB+309A # [2000]<br>
0xA5FD U+30C4+309A # [2000]<br>
0xA5FE U+30C8+309A # [2000]</p>
<p>0xA6F8 U+31F7+309A # [2000]</p>
<p>0xABC4 U+00E6+0300 # [2000]</p>
<p>0xABC8 U+0254+0300 # [2000]<br>
0xABC9 U+0254+0301 # [2000]<br>
0xABCA U+028C+0300 # [2000]<br>
0xABCB U+028C+0301 # [2000]<br>
0xABCC U+0259+0300 # [2000]<br>
0xABCD U+0259+0301 # [2000]<br>
0xABCE U+025A+0300 # [2000]<br>
0xABCF U+025A+0301 # [2000]</p>
<p>0xABE5 U+02E9+02E5 # [2000]<br>
0xABE6 U+02E5+02E9 # [2000]</p>
<p>ようするに、JIS X 0213 で一文字になっているが、Unicode で二文字になって<br>
いるものです。EUC-JISX0213 から UTF-8 は問題ないですが、逆は現在引っかか<br>
ります。windows-1258 も (逆ですが) 同じ問題がありますので、いずれはなく<br>
さないといけないと思いましたが、今回はいいきっかけのではないかと思います。</p>
<p>よろしくお願いします。 Martin.</p>