Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112024-03-01T16:26:28ZRuby Issue Tracking System
Redmine Ruby master - Misc #20320 (Open): Using OSU Open Source Lab native ppc64le/s390x CI services trig...https://bugs.ruby-lang.org/issues/203202024-03-01T16:26:28Zjaruga (Jun Aruga)
<p>We have been using Travis CI to run unit tests the native arm64/ppc64le/s390x in the ruby/ruby, ruby/zlib and ruby/prism repositories in the Ruby project.</p>
<p>One of the challenges is Travis CI's chronic unstable infra issues. To be fair, folks at Travis CI support are helpful, usually responding quickly, sometimes not. And I hope Travis CI will find the root causes of the issues. However, I would like to find alternative way to run the native ppc64le/s390x pipelines on pull-requests to change the current challenge fundamentally.</p>
<p>And I heard from folks at IBM that the there were CI services that we could run on the pull-requests. The CI services are Jenkins services provided by Oregon State University (OSU) Open Source Lab below. The CI services are the only alternative of running the native ppc64le/s390x pipelines on pull-requests as far as I know. As a note, we are already using SSH-accessing servers provided by OSU Open Source Lab.</p>
<ul>
<li>PowerPC64 (ppc64le): <a href="https://osuosl.org/services/powerdev/" class="external">https://osuosl.org/services/powerdev/</a> - POWER Continuous Integration (POWER CI)</li>
<li>IBM Z (s390x): <a href="https://osuosl.org/services/ibm-z/" class="external">https://osuosl.org/services/ibm-z/</a> - IBM Z Continuous Integration (IBM Z CI)</li>
</ul>
<p>Today I requested the CI services from the request form pages above. And I will try the services by myself first. Then if it looks good to us, I want to migrate the Travis CI ppc64le/s390x pipelines to the OSU Open Source Lab's ones. I will comment on this ticket when there are updates.</p>
<p>Note:<br>
Oregon State University Open Source Lab (OSUOSL) support email: <a href="mailto:support@osuosl.org" class="email">support@osuosl.org</a> and <a href="https://osuosl.org/contact/" class="external">other contacts</a>.</p> Ruby master - Misc #20240 (Open): Unable to build ruby 3.1.0 on macOS when shared due to dylibs (...https://bugs.ruby-lang.org/issues/202402024-02-06T10:53:26Zjmarrec (Julien Marrec)
<p>I am trying to develop a conan (the C/C++ package manager) recipe for Ruby. The recipe would allow downstream users to 1) get a runnable ruby executable, and 2) be able to link to ruby, or embbed it in a C/C++ program if built statically, in an easy way.</p>
<p>Currently there is an existing ruby 3.1.0 recipe that I'm trying to adapt, so I have to support this version.</p>
<p>First off, let me say that I can succesfully build with 3.3.0, so I know something has changed for the better since then. I'm just at a lost when figuring out what I need to backport to make 3.1.0 work.</p>
<p>The original issue is that it appears miniruby is looking for some dylibs and not finding them. Even if I do define <code>LD_LIBRARY_PATH</code>, <code>DYLD_LIBRARY_PATH</code> or <code>DYLD_FALLBACK_LIBRARY_PATH</code> (any combinations of these three) in my env.</p>
<pre><code class="shell syntaxhl" data-language="shell">dsymutil exe/ruby<span class="p">;</span> <span class="o">{</span> <span class="nb">test</span> <span class="nt">-z</span> <span class="s1">''</span> <span class="o">||</span> codesign <span class="nt">-s</span> <span class="s1">''</span> <span class="nt">-f</span> exe/ruby<span class="p">;</span> <span class="o">}</span>
./miniruby <span class="se">\</span>
<span class="nt">-e</span> <span class="s1">'prog, dest, inst = ARGV; dest += "/ruby"'</span> <span class="se">\</span>
<span class="nt">-e</span> <span class="s1">'exit unless prog==inst'</span> <span class="se">\</span>
<span class="nt">-e</span> <span class="s1">'unless prog=="ruby"'</span> <span class="se">\</span>
<span class="nt">-e</span> <span class="s1">' begin File.unlink(dest); rescue Errno::ENOENT; end'</span> <span class="se">\</span>
<span class="nt">-e</span> <span class="s1">' File.symlink(prog, dest)'</span> <span class="se">\</span>
<span class="nt">-e</span> <span class="s1">'end'</span> <span class="se">\</span>
ruby exe ruby
dyld[59344]: Library not loaded: @rpath/libgmp.10.dylib
Referenced from: <356E0011-6223-321A-9179-D55618D248D0> /Users/julien/.conan2/p/b/ruby9cafa28a7060d/b/build-release/miniruby
Reason: no LC_RPATH<span class="s1">'s found
make: *** [exe/ruby] Abort trap: 6
make: *** Deleting file `exe/ruby'</span>
</code></pre>
<p>It seems that something is unsetting the variables, because this for eg works fine</p>
<pre><code class="shell syntaxhl" data-language="shell"><span class="nv">DYLD_LIBRARY_PATH</span><span class="o">=</span>/Users/julien/.conan2/p/b/zlib1f8e7d96319f0/p/lib:/Users/julien/.conan2/p/b/opense854e464e8ff6/p/lib:/Users/julien/.conan2/p/b/libyae2f0aa15c9e92/p/lib:/Users/julien/.conan2/p/b/libff05fe9d5b96f79/p/lib:/Users/julien/.conan2/p/b/readl0d0041a63fa03/p/lib:/Users/julien/.conan2/p/b/termc22b5bb1515971/p/lib:/Users/julien/.conan2/p/b/gmp676fa41eaa3d6/p/lib: /Users/julien/.conan2/p/b/ruby9cafa28a7060d/b/build-release/miniruby <span class="nt">-e</span> <span class="s2">"puts 'Hello, world'"</span>
</code></pre>
<p>My configure call is like this:</p>
<pre><code class="shell syntaxhl" data-language="shell">./configure <span class="nt">--enable-shared</span> <span class="nt">--disable-static</span> <span class="nt">--prefix</span><span class="o">=</span>/ <span class="s1">'--bindir=${prefix}/bin'</span> <span class="s1">'--sbindir=${prefix}/bin'</span> <span class="s1">'--libdir=${prefix}/lib'</span> <span class="s1">'--includedir=${prefix}/include'</span> <span class="s1">'--oldincludedir=${prefix}/include'</span> <span class="nt">--disable-install-doc</span> <span class="nt">--enable-load-relative</span> <span class="nt">--with-zlib-dir</span><span class="o">=</span>/Users/julien/.conan2/p/b/zlib1f8e7d96319f0/p <span class="nt">--with-openssl-dir</span><span class="o">=</span>/Users/julien/.conan2/p/b/opense854e464e8ff6/p <span class="nt">--with-libffi-dir</span><span class="o">=</span>/Users/julien/.conan2/p/b/libff05fe9d5b96f79/p <span class="nt">--with-libyaml-dir</span><span class="o">=</span>/Users/julien/.conan2/p/b/libyae2f0aa15c9e92/p <span class="nt">--with-readline-dir</span><span class="o">=</span>/Users/julien/.conan2/p/b/readl0d0041a63fa03/p <span class="nt">--with-gmp-dir</span><span class="o">=</span>/Users/julien/.conan2/p/b/gmp676fa41eaa3d6/p <span class="nt">--with-opt-dir</span><span class="o">=</span>/Users/julien/.conan2/p/b/opense854e464e8ff6/p:/Users/julien/.conan2/p/b/libff05fe9d5b96f79/p:/Users/julien/.conan2/p/b/libyae2f0aa15c9e92/p:/Users/julien/.conan2/p/b/readl0d0041a63fa03/p:/Users/julien/.conan2/p/b/gmp676fa41eaa3d6/p <span class="nt">--disable-jit-support</span>
</code></pre>
<p>I have tried to backport <a href="https://github.com/ruby/ruby/pull/6296/files" class="external">https://github.com/ruby/ruby/pull/6296/files</a> and <a href="https://github.com/ruby/ruby/commit/48644e71096c70132be9dfdcbfb414ec2e68d18b" class="external">https://github.com/ruby/ruby/commit/48644e71096c70132be9dfdcbfb414ec2e68d18b</a> and <a href="https://github.com/ruby/ruby/pull/8730" class="external">https://github.com/ruby/ruby/pull/8730</a> amongst other things but I can't make it work. (I even tried a more brute force approach patching a lot of files by diffing 3.3.0 with 3.1.0, but please note I don't know what I'm doing... and I can get to the install step but then I get some errors about Psych / libymal and undefined Gem::Install:Zlib).</p>
<p>I would <strong>greatly</strong> appreciate if someone can spare some time to help me wrap this up (I've been trying to make the recipe work for so long that I'm about to give up...)</p> Ruby master - Misc #20238 (Open): Use prism for mk_builtin_loader.rbhttps://bugs.ruby-lang.org/issues/202382024-02-05T20:52:02Zkddnewton (Kevin Newton)kddnewton@gmail.com
<p>I would like to propose that we use prism for mk_builtin_loader.rb.</p>
<p>Right now the Ruby syntax that you can use in builtin classes is restricted to the base Ruby version (2.7). This means you can't use a lot of the nicer syntax that Ruby has shipped in the last couple of years.</p>
<p>If we switch to using prism to parse the builtin files instead of using ripper, then we can always use the latest version of Ruby syntax. A pull request for this is here: <a href="https://github.com/kddnewton/ruby/pull/65" class="external">https://github.com/kddnewton/ruby/pull/65</a>. The approach for the PR is taken from how RJIT bindgen works.</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 #20081 (Open): Transfered Fiber doesn't return to Fiber that started ithttps://bugs.ruby-lang.org/issues/200812023-12-23T17:44:10Zrmosolgo (Robert Mosolgo)rdmosolgo@gmail.com
<p>Hi! I'm trying to figure out how to make sure that Fibers started with <code>.transfer</code> end up <em>terminated</em>, not just suspended. (If they're suspended, Rails thinks they're still alive, and they continue to hold onto database connections, see: <a href="https://github.com/rmosolgo/graphql-ruby/issues/4739#issuecomment-1866930914" class="external">https://github.com/rmosolgo/graphql-ruby/issues/4739#issuecomment-1866930914</a>.)</p>
<p>So, I'm looking for way to make sure that any Fiber I start with <code>.transfer</code> will be properly terminated. But what I noticed is that when a transfer-based Fiber terminates, it gives control back to the top-most Fiber, not the Fiber which transfered to it. Is this intended? Here's a script to replicate the issue:</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">parent</span> <span class="o">=</span> <span class="no">Fiber</span><span class="p">.</span><span class="nf">current</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">parent</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"4. End Worker"</span>
<span class="k">end</span>
<span class="nb">puts</span> <span class="s2">"1. Transfer 1"</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"3. Transfer 2"</span>
<span class="n">worker</span><span class="p">.</span><span class="nf">transfer</span>
<span class="nb">puts</span> <span class="s2">"5. 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">"6. Finished script"</span>
</code></pre>
<p>I expect the steps to print in order:</p>
<pre><code>1. Transfer 1
2. Begin Worker
3. Transfer 2
4. End Worker
5. Finished manager
6. Finished script
</code></pre>
<p>But instead, <code>5. ...</code> is skipped:</p>
<pre><code>1. Transfer 1
2. Begin Worker
3. Transfer 2
4. End Worker
6. Finished script
</code></pre>
<p>I think that's because my <code>worker</code> fiber terminates and passes control back to the top-level Fiber.</p>
<p>Should it have passed control back to the <code>manager</code>? Or is there another way to make sure <code>worker</code> is terminated, and <code>manager</code> gets control?</p> Ruby master - Misc #20013 (Open): Travis CI statushttps://bugs.ruby-lang.org/issues/200132023-11-21T14:10:56Zjaruga (Jun Aruga)
<p>I would like to use this ticket to manage our activities to report Travis CI status.</p>
<p>Because there is Travis CI status page provided by Travis CI. However, even when the page shows ok, I actually see infra issues.<br>
<a href="https://www.traviscistatus.com/" class="external">https://www.traviscistatus.com/</a></p>
<p>I would share my activities and report the Travis CI status on the ticket.<br>
The ticket's status is not closed until we stop using Travis CI.</p>
<p>The easiest option to fix the Travis infra issue is to email Travis CI support <code>support _AT_ travis-ci.com</code>.</p>
<p>You can check <a href="https://github.com/ruby/ruby/wiki/CI-Servers#travis-ci" class="external">this ruby/ruby Travis CI wiki page</a> for details.</p> Ruby master - Bug #19986 (Open): Win32: `HOME` is set to just `HOMEDRIVE` if `HOMEPATH` is unsethttps://bugs.ruby-lang.org/issues/199862023-11-05T03:15:02Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<pre><code>$ env -u HOME -u USERPROFILE -u HOMEPATH HOMEDRIVE=no/such/home ./miniruby.exe -e 'p ENV["HOME"], Dir.home'
"no/such/home"
"no/such/home"
</code></pre>
<p><code>HOMEDRIVE</code> should be ignored without <code>HOMEPATH</code>, and <code>HOME</code> should fallback to <code>CSIDL_PROFILE</code>.</p> Ruby master - Feature #19915 (Open): URI::HTTP.build accepts user: and password: keyboard argumen...https://bugs.ruby-lang.org/issues/199152023-10-08T23:10:10Zpostmodern (Hal Brodigan)postmodern.mod3@gmail.com
<p>I noticed that <code>URI::HTTP.build</code> accepts the <code>user:</code> and <code>password:</code> keyword arguments, but does not actually set the <code>user</code> or <code>password</code> attributes of the built URI object. It does however correctly accept a <code>userinfo:</code> keyword argument.</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="n">uri</span> <span class="o">=</span> <span class="no">URI</span><span class="o">::</span><span class="no">HTTP</span><span class="p">.</span><span class="nf">build</span><span class="p">(</span><span class="ss">user: </span><span class="s1">'bob'</span><span class="p">,</span> <span class="ss">password: </span><span class="s1">'secret'</span><span class="p">,</span> <span class="ss">host: </span><span class="s1">'example.com'</span><span class="p">,</span> <span class="ss">path: </span><span class="s1">'/foo'</span><span class="p">)</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">user</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">password</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">to_s</span>
</code></pre>
<a name="Expected-Results"></a>
<h3 >Expected Results<a href="#Expected-Results" class="wiki-anchor">¶</a></h3>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">uri</span><span class="p">.</span><span class="nf">user</span>
<span class="c1"># => "bob"</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">password</span>
<span class="c1"># => "secret"</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">to_s</span>
<span class="c1"># => "http://bob:secret@example.com/foo"</span>
</code></pre>
<a name="Actual-Results"></a>
<h3 >Actual Results<a href="#Actual-Results" class="wiki-anchor">¶</a></h3>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">uri</span><span class="p">.</span><span class="nf">user</span>
<span class="c1"># => nil</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">password</span>
<span class="c1"># => nil</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">to_s</span>
<span class="c1"># => "http://example.com/foo"</span>
</code></pre> Ruby master - Bug #19831 (Open): warning message of linker with macOS Sonoma betahttps://bugs.ruby-lang.org/issues/198312023-08-04T09:21:01Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<p>Xcode 15 beta and macOS Sonoma beta show the following warnings with <code>make</code></p>
<pre><code>(snip)
linking miniruby
ld: warning: ignoring duplicate library '-lpthread'
miniruby: replacing existing signature
exe/ruby: replacing existing signature
builtin_binary.inc updated
compiling builtin.c
linking static-library libruby.3.3-static.a
linking ruby
ld: warning: ignoring duplicate library '-lgmp'
ld: warning: ignoring duplicate library '-ldl'
ld: warning: ignoring duplicate library '-lobjc'
ld: warning: ignoring duplicate library '-lpthread'
ld: warning: ignoring duplicate library '-lpthread'
(snip)
</code></pre>
<p>I'm not investigate that yet. It may be caused by <code>ld-prime</code> that is new linker of macOS platform.</p>
<pre><code>$ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 15.0.0.0.1.1690355577
volume: /
location: /
install-time: 1690967267
</code></pre> Ruby master - Bug #19756 (Open): URI::HTTP.build does not accept a host of `_gateway`, but `URI.p...https://bugs.ruby-lang.org/issues/197562023-07-04T02:11:27Zpostmodern (Hal Brodigan)postmodern.mod3@gmail.com
<p>I noticed a difference in behavior between <code>URI::HTTP.build</code> and <code>URI.parse</code>. <code>URI::HTTP.build</code> will not accept <code>host:</code> value of <code>_gateway</code>, but <code>URI.parse</code> will.</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="no">URI</span><span class="o">::</span><span class="no">HTTP</span><span class="p">.</span><span class="nf">build</span><span class="p">(</span><span class="ss">host: </span><span class="s2">"_gateway"</span><span class="p">)</span>
</code></pre>
<p>vs.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">URI</span><span class="p">.</span><span class="nf">parse</span><span class="p">(</span><span class="s2">"http://_gateway"</span><span class="p">)</span>
</code></pre>
<a name="Expected-Results"></a>
<h3 >Expected Results<a href="#Expected-Results" class="wiki-anchor">¶</a></h3>
<p>Both raise the same exception, or return the same URI object.</p>
<a name="Actual-Results"></a>
<h3 >Actual Results<a href="#Actual-Results" class="wiki-anchor">¶</a></h3>
<pre><code>URI::HTTP.build(host: "_gateway")
/usr/share/ruby/uri/generic.rb:601:in `check_host': bad component(expected host component): _gateway (URI::InvalidComponentError)
from /usr/share/ruby/uri/generic.rb:640:in `host='
from /usr/share/ruby/uri/generic.rb:673:in `hostname='
from /usr/share/ruby/uri/generic.rb:190:in `initialize'
from /usr/share/ruby/uri/generic.rb:136:in `new'
from /usr/share/ruby/uri/generic.rb:136:in `build'
from /usr/share/ruby/uri/http.rb:61:in `build'
from (irb):2:in `<main>'
from /usr/local/share/gems/gems/irb-1.7.0/exe/irb:9:in `<top (required)>'
from /usr/local/bin/irb:25:in `load'
from /usr/local/bin/irb:25:in `<main>'
</code></pre>
<pre><code>URI.parse("https://_gateway")
# => #<URI::HTTPS https://_gateway>
</code></pre>
<a name="Additional-Information"></a>
<h2 >Additional Information<a href="#Additional-Information" class="wiki-anchor">¶</a></h2>
<pre><code>$ gem list uri
uri (default: 0.12.1)
</code></pre> Ruby master - Bug #19696 (Open): YJIT panicked - branch stubs should never enlarge brancheshttps://bugs.ruby-lang.org/issues/196962023-05-25T21:19:56Zwildmaples (Maple Ong)
<a name="Description"></a>
<h3 >Description<a href="#Description" class="wiki-anchor">¶</a></h3>
<p>We found this error on Rails CI with YJIT enabled. I'm not quite sure how to reproduce it since the error was intermittent.</p>
<p>I'm posting here to see if it is helpful or if anyone else has encountered this.</p>
<pre><code>thread '<unnamed>' panicked at 'branch stubs should never enlarge branches (start_addr: 0x7fa19e55cb99, old_size: 5, new_size: 14)', ./yjit/src/core.rs:1858:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:587: [BUG] YJIT panicked
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +jemalloc +YJIT [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0131 p:0008 s:0680 e:000679 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract_a
c:0130 p:0004 s:0676 e:000675 BLOCK /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/c
c:0129 p:0079 s:0673 e:000671 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/callbacks.rb:107
c:0128 p:0009 s:0663 e:000662 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/callbacks.rb:929
c:0127 p:0005 s:0658 e:000657 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/c
c:0126 p:0013 s:0653 e:000652 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/c
c:0125 p:0011 s:0648 e:000647 METHOD /var/www/components/rails-backports/lib/rails/backports/7.0/abstract_adapter_thread_local_by_default.rb:97
c:0124 p:0021 s:0642 e:000638 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/c
c:0123 p:0172 s:0635 e:000634 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/c
c:0122 p:0014 s:0625 e:000624 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_handling.rb:313
c:0121 p:0003 s:0621 e:000620 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_handling.rb:280
c:0120 p:0004 s:0617 e:000616 BLOCK /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/fixtures.rb:560
c:0119 p:0087 s:0614 E:000b90 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/fixtures.rb:575
c:0118 p:0015 s:0601 e:000600 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/test_fixtures.rb:275
c:0117 p:0104 s:0596 E:002188 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/test_fixtures.rb:125
c:0116 p:0008 s:0591 e:000590 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/isolator-0.8.0/lib/isolator/railtie.rb:27
c:0115 p:0003 s:0586 e:000585 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/test_fixtures.rb:10
c:0114 p:0009 s:0582 e:000581 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/current_attributes/test_help
c:0113 p:0009 s:0578 e:000577 METHOD /var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/execution_context/test_helpe
c:0112 p:0003 s:0574 e:000573 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-rails-6.0.2/lib/rspec/rails/adapters.rb:74 [FINISH]
c:0111 p:---- s:0570 e:000569 CFUNC :instance_exec
c:0110 p:0013 s:0565 e:000564 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0109 p:0010 s:0559 e:000558 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0108 p:0009 s:0553 e:000552 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0107 p:0018 s:0550 e:000549 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0106 p:0004 s:0544 e:000543 BLOCK /var/www/packs/tax_predictions/spec/support/tax_predictions.rb:11
c:0105 p:0018 s:0541 e:000540 METHOD /var/www/packs/tax_predictions/app/services/tax_predictions/testing.rb:14
c:0104 p:0021 s:0536 e:000535 BLOCK /var/www/packs/tax_predictions/spec/support/tax_predictions.rb:10 [FINISH]
c:0103 p:---- s:0532 e:000531 CFUNC :instance_exec
c:0102 p:0013 s:0527 e:000526 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0101 p:0010 s:0521 e:000520 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0100 p:0009 s:0515 e:000514 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0099 p:0018 s:0512 e:000511 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0098 p:0005 s:0506 e:000505 BLOCK /var/www/spec/support/initializers/system_exit.rb:14 [FINISH]
c:0097 p:---- s:0502 e:000501 CFUNC :instance_exec
c:0096 p:0013 s:0497 e:000496 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0095 p:0010 s:0491 e:000490 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0094 p:0009 s:0485 e:000484 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0093 p:0018 s:0482 e:000481 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0092 p:0041 s:0476 e:000475 BLOCK /var/www/spec/support/initializers/sidekiq_batch_middleware.rb:17 [FINISH]
c:0091 p:---- s:0471 e:000470 CFUNC :instance_exec
c:0090 p:0013 s:0466 e:000465 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0089 p:0010 s:0460 e:000459 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0088 p:0009 s:0454 e:000453 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0087 p:0018 s:0451 e:000450 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0086 p:0004 s:0445 e:000444 BLOCK /var/www/spec/support/initializers/sidekiq.rb:38
c:0085 p:0018 s:0442 e:000441 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/sidekiq-6.5.8/lib/sidekiq/testing.rb:16
c:0084 p:0009 s:0436 e:000435 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/sidekiq-6.5.8/lib/sidekiq/testing.rb:30
c:0083 p:0010 s:0431 e:000430 BLOCK /var/www/spec/support/initializers/sidekiq.rb:38 [FINISH]
c:0082 p:---- s:0427 e:000426 CFUNC :instance_exec
c:0081 p:0013 s:0422 e:000421 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0080 p:0010 s:0416 e:000415 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0079 p:0009 s:0410 e:000409 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0078 p:0018 s:0407 e:000406 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0077 p:0025 s:0401 e:000400 BLOCK /var/www/spec/support/initializers/rake.rb:18 [FINISH]
c:0076 p:---- s:0397 e:000396 CFUNC :instance_exec
c:0075 p:0013 s:0392 e:000391 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0074 p:0010 s:0386 e:000385 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0073 p:0009 s:0380 e:000379 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0072 p:0018 s:0377 e:000376 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352 [FINISH]
c:0071 p:---- s:0371 e:000370 IFUNC
c:0070 p:0116 s:0368 E:002008 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/prosopite-1.3.1/lib/prosopite.rb:49
c:0069 p:0023 s:0363 e:000362 BLOCK /var/www/spec/support/initializers/prosopite.rb:36 [FINISH]
c:0068 p:---- s:0359 e:000358 CFUNC :instance_exec
c:0067 p:0013 s:0354 e:000353 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0066 p:0010 s:0348 e:000347 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0065 p:0009 s:0342 e:000341 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0064 p:0018 s:0339 e:000338 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0063 p:0023 s:0333 e:000332 BLOCK /var/www/spec/support/initializers/logged_examples.rb:8 [FINISH]
c:0062 p:---- s:0329 e:000328 CFUNC :instance_exec
c:0061 p:0013 s:0324 e:000323 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0060 p:0010 s:0318 e:000317 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0059 p:0009 s:0312 e:000311 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0058 p:0018 s:0309 e:000308 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0057 p:0116 s:0303 e:000302 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-3.11.0/lib/knapsack_pro/adapters/rspec_adapter.rb:72 [FINISH]
c:0056 p:---- s:0298 e:000297 CFUNC :instance_exec
c:0055 p:0013 s:0293 e:000292 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0054 p:0010 s:0287 e:000286 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0053 p:0009 s:0281 e:000280 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0052 p:0018 s:0278 e:000277 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0051 p:0032 s:0272 e:000271 BLOCK /var/www/spec/support/initializers/flake_quarantine.rb:131 [FINISH]
c:0050 p:---- s:0268 e:000267 CFUNC :instance_exec
c:0049 p:0013 s:0263 e:000262 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0048 p:0010 s:0257 e:000256 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0047 p:0009 s:0251 e:000250 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0046 p:0018 s:0248 e:000247 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0045 p:0020 s:0242 e:000241 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/singed-0.2.1/lib/singed/rspec.rb:8 [FINISH]
c:0044 p:---- s:0238 e:000237 CFUNC :instance_exec
c:0043 p:0013 s:0233 e:000232 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0042 p:0010 s:0227 e:000226 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0041 p:0009 s:0221 e:000220 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0040 p:0018 s:0218 e:000217 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352 [FINISH]
c:0039 p:---- s:0212 e:000211 IFUNC
c:0038 p:0007 s:0209 e:000208 METHOD /var/www/spec/support/lib/stream_interceptor.rb:38
c:0037 p:0007 s:0205 e:000204 BLOCK /var/www/spec/support/initializers/stream_interception.rb:10 [FINISH]
c:0036 p:---- s:0201 e:000200 CFUNC :instance_exec
c:0035 p:0013 s:0196 e:000195 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457
c:0034 p:0010 s:0190 e:000189 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390
c:0033 p:0009 s:0184 e:000183 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628
c:0032 p:0018 s:0181 e:000180 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352
c:0031 p:0037 s:0175 E:0002c8 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:629
c:0030 p:0104 s:0168 E:000248 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:486
c:0029 p:0018 s:0161 E:0026e8 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:468
c:0028 p:0019 s:0156 E:002178 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:511
c:0027 p:0076 s:0151 E:000188 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:259
c:0026 p:0036 s:0144 e:000143 METHOD /var/www/components/flake_quarantine/lib/flake_quarantine/rspec/example.rb:11
c:0025 p:0037 s:0139 e:000138 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:646 [FINISH]
c:0024 p:---- s:0133 e:000132 CFUNC :map
c:0023 p:0011 s:0129 e:000128 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:642
c:0022 p:0052 s:0124 e:000123 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:607
c:0021 p:0006 s:0115 e:000114 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608 [FINISH]
c:0020 p:---- s:0111 e:000110 CFUNC :map
c:0019 p:0065 s:0107 e:000106 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608
c:0018 p:0006 s:0098 e:000097 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608 [FINISH]
c:0017 p:---- s:0094 e:000093 CFUNC :map
c:0016 p:0065 s:0090 e:000089 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608
c:0015 p:0007 s:0081 e:000080 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:121 [FINISH]
c:0014 p:---- s:0077 e:000076 CFUNC :map
c:0013 p:0030 s:0073 e:000072 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:121
c:0012 p:0026 s:0070 e:000069 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/configuration.rb:2070
c:0011 p:0007 s:0066 e:000065 BLOCK /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:116
c:0010 p:0009 s:0062 e:000061 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/reporter.rb:74
c:0009 p:0019 s:0057 e:000056 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:115
c:0008 p:0035 s:0050 e:000049 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:89
c:0007 p:0201 s:0044 e:000043 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-3.11.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:93
c:0006 p:0161 s:0027 e:000026 METHOD /var/www/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-3.11.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:40
c:0005 p:0041 s:0019 E:000928 METHOD bin/rspec_runner:60
c:0004 p:0016 s:0014 e:000013 METHOD bin/rspec_runner:43
c:0003 p:0005 s:0010 e:000009 METHOD bin/rspec_runner:18
c:0002 p:0060 s:0006 e:000005 EVAL bin/rspec_runner:166 [FINISH]
c:0001 p:0000 s:0003 E:000c50 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
bin/rspec_runner:166:in `<main>'
bin/rspec_runner:18:in `run'
bin/rspec_runner:43:in `run'
bin/rspec_runner:60:in `run_with_knapsack_pro'
/var/www/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-3.11.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:40:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-3.11.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:93:in `run_tests'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:89:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:115:in `run_specs'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/reporter.rb:74:in `report'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:116:in `block in run_specs'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/configuration.rb:2070:in `with_suite_hooks'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:121:in `map'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608:in `map'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608:in `block in run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608:in `map'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:608:in `block in run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:607:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:642:in `run_examples'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:642:in `map'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example_group.rb:646:in `block in run_examples'
/var/www/components/flake_quarantine/lib/flake_quarantine/rspec/example.rb:11:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:259:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:511:in `with_around_and_singleton_context_hooks'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:468:in `with_around_example_hooks'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:486:in `run'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:629:in `run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/stream_interception.rb:10:in `block (2 levels) in <top (required)>'
/var/www/spec/support/lib/stream_interceptor.rb:38:in `intercept'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/singed-0.2.1/lib/singed/rspec.rb:8:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/flake_quarantine.rb:131:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-3.11.0/lib/knapsack_pro/adapters/rspec_adapter.rb:72:in `block (2 levels) in bind_time_tracker'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/logged_examples.rb:8:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/prosopite.rb:36:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/prosopite-1.3.1/lib/prosopite.rb:49:in `scan'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/rake.rb:18:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/sidekiq.rb:38:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/sidekiq-6.5.8/lib/sidekiq/testing.rb:30:in `fake!'
/var/www/vendor/bundle/ruby/3.2.0/gems/sidekiq-6.5.8/lib/sidekiq/testing.rb:16:in `__set_test_mode'
/var/www/spec/support/initializers/sidekiq.rb:38:in `block (3 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/sidekiq_batch_middleware.rb:17:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/spec/support/initializers/system_exit.rb:14:in `block (2 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/packs/tax_predictions/spec/support/tax_predictions.rb:10:in `block (2 levels) in <main>'
/var/www/packs/tax_predictions/app/services/tax_predictions/testing.rb:14:in `recompute_on_fetch!'
/var/www/packs/tax_predictions/spec/support/tax_predictions.rb:11:in `block (3 levels) in <main>'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:352:in `call'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/hooks.rb:390:in `execute_with'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-core-3.12.2/lib/rspec/core/example.rb:457:in `instance_exec'
/var/www/vendor/bundle/ruby/3.2.0/gems/rspec-rails-6.0.2/lib/rspec/rails/adapters.rb:74:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/execution_context/test_helper.rb:6:in `before_setup'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/current_attributes/test_helper.rb:6:in `before_setup'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/test_fixtures.rb:10:in `before_setup'
/var/www/vendor/bundle/ruby/3.2.0/gems/isolator-0.8.0/lib/isolator/railtie.rb:27:in `setup_fixtures'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/test_fixtures.rb:125:in `setup_fixtures'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/test_fixtures.rb:275:in `load_fixtures'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/fixtures.rb:575:in `create_fixtures'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/fixtures.rb:560:in `block in create_fixtures'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_handling.rb:280:in `connection'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_handling.rb:313:in `retrieve_connection'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in `retrieve_connection'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection'
/var/www/components/rails-backports/lib/rails/backports/7.0/abstract_adapter_thread_local_by_default.rb:97:in `checkout'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in `checkout'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:704:in `checkout_and_verify'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/callbacks.rb:929:in `_run_checkout_callbacks'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activesupport/lib/active_support/callbacks.rb:107:in `run_callbacks'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in `block in checkout_and_verify'
/var/www/vendor/bundle/ruby/3.2.0/bundler/gems/rails-c15ee6e7b506/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:587:in `verify!'
-- C level backtrace information -------------------------------------------
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(rb_vm_bugreport+0xb2b) [0x7fa19a87c18b]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(rb_bug_without_die+0x77) [0x7fa19a675937]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(rb_bug+0x9f) [0x7fa19a5d0cd2]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN4yjit4yjit17rb_bug_panic_hook28_$u7b$$u7b$closure$u7d$$u7d$17hfc31c2f18ccadc75E.llvm.12746241947442316067+0x5a) [0x7fa19a8b8d7a]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN3std9panicking20rust_panic_with_hook17h66309baf5235212fE+0x3d3) [0x7fa19a8c9d73]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN3std9panicking19begin_panic_handler28_$u7b$$u7b$closure$u7d$$u7d$17h3a147548aa082356E+0xb7) [0x7fa19a8ecb17]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN3std10sys_common9backtrace26__rust_end_short_backtrace17hcc62583c733bef84E+0x14) [0x7fa19a8ec824]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(rust_begin_unwind+0x42) [0x7fa19a8c9772]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN4core9panicking9panic_fmt17h8531284c14f462dcE+0x33) [0x7fa19a5d8823]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN4yjit4core20branch_stub_hit_body17h45fd758b20fb7aa6E+0xa03) [0x7fa19a89add3]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN4yjit5cruby12with_vm_lock17h09508b1ca41af130E+0x49) [0x7fa19a8936b9]
/usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/libruby.so.3.2(_ZN4yjit4core15branch_stub_hit17h5cf8bd0b5727e3b9E.llvm.7796580109460741199+0x71) [0x7fa19a89ea31]
[0x7fa19b08501f]
-- Other runtime information -----------------------------------------------
* Loaded script: bin/rspec_runner
* Loaded features:
0 enumerator.so
1 thread.rb
2 fiber.so
3 rational.so
4 complex.so
5 ruby2_keywords.rb
6 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/x86_64-linux/enc/encdb.so
7 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/x86_64-linux/enc/trans/transdb.so
8 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/x86_64-linux/rbconfig.rb
9 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/compatibility.rb
10 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/defaults.rb
11 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/deprecate.rb
12 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/errors.rb
13 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/unknown_command_spell_checker.rb
14 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/exceptions.rb
15 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/basic_specification.rb
16 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/stub_specification.rb
17 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/platform.rb
18 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/util/list.rb
19 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/version.rb
20 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/requirement.rb
21 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/specification.rb
22 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/util.rb
23 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/dependency.rb
24 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/core_ext/kernel_gem.rb
25 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/x86_64-linux/monitor.so
26 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/monitor.rb
27 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems.rb
28 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/rubygems/path_support.rb
29 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/error_highlight/version.rb
30 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/error_highlight/base.rb
31 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/error_highlight/formatter.rb
32 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/error_highlight/core_ext.rb
33 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/error_highlight.rb
34 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/version.rb
35 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/core_ext/name_error.rb
36 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/levenshtein.rb
37 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/jaro_winkler.rb
38 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checker.rb
39 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
40 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
41 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/name_error_checkers.rb
42 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/method_name_checker.rb
43 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/key_error_checker.rb
44 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/null_checker.rb
45 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/tree_spell_checker.rb
46 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/require_path_checker.rb
47 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/spell_checkers/pattern_key_name_checker.rb
48 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean/formatter.rb
49 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/did_you_mean.rb
50 /usr/lib/fullstaq-ruby/versions/3.2.2-jemalloc/lib/ruby/3.2.0/syntax_suggest/core_ext.rb
</code></pre> Test - Feature #19618 (Open): hash#dig testshttps://bugs.ruby-lang.org/issues/196182023-04-26T06:13:55Zhdiwan415 (Hasan Diwan)
<p>diff --git a/spec/ruby/core/hash/hash_spec.rb b/spec/ruby/core/hash/hash_spec.rb<br>
index 2ccb483120..3b583b338b 100644<br>
--- a/spec/ruby/core/hash/hash_spec.rb<br>
+++ b/spec/ruby/core/hash/hash_spec.rb<br>
@@ -1,4 +1,4 @@<br>
-require_relative '../../spec_helper'<br>
+require_relative "../../spec_helper"</p>
<p>describe "Hash" do<br>
it "includes Enumerable" do<br>
@@ -6,9 +6,18 @@<br>
end<br>
end</p>
<p>+describe "Hash#dig" do</p>
<ul>
<li>it "handles nested hash" do</li>
<li>{ foo: { bar: { baz: 2 } } }.dig(:foo).should == { :bar => { :baz => 2 } }</li>
<li>{ foo: { bar: { baz: 2 } } }.dig(:foo, :bar).should == { :baz => 2 }</li>
<li>{ foo: { bar: { baz: 2 } } }.dig(:foo, :bar, :baz).should == 2</li>
<li>{ foo: { bar: { baz: 2 } } }.dig(:BAZ).should.nil?</li>
<li>end<br>
+end</li>
<li>
</ul>
<p>describe "Hash#hash" do<br>
it "returns a value which doesn't depend on the hash order" do</p>
<ul>
<li>{ 0=>2, 11=>1 }.hash.should == { 11=>1, 0=>2 }.hash</li>
</ul>
<ul>
<li>{ 0 => 2, 11 => 1 }.hash.should == { 11 => 1, 0 => 2 }.hash<br>
end</li>
</ul>
<p>it "returns a value in which element values do not cancel each other out" do<br>
@@ -26,9 +35,9 @@<br>
end</p>
<p>it "returns the same hash for recursive hashes" do</p>
<ul>
<li>h = {} ; h[:x] = h</li>
<li>h.hash.should == {x: h}.hash</li>
<li>h.hash.should == {x: {x: h}}.hash</li>
</ul>
<ul>
<li>h = {}; h[:x] = h</li>
<li>h.hash.should == { x: h }.hash</li>
<li>h.hash.should == { x: { x: h } }.hash
<a name="This-is-because-heqlx-h"></a>
<h1 >This is because h.eql?(x: h)<a href="#This-is-because-heqlx-h" class="wiki-anchor">¶</a></h1>
<a name="Remember-that-if-two-objects-are-eql"></a>
<h1 >Remember that if two objects are eql?<a href="#Remember-that-if-two-objects-are-eql" class="wiki-anchor">¶</a></h1>
<a name="then-the-need-to-have-the-same-hash"></a>
<h1 >then the need to have the same hash.<a href="#then-the-need-to-have-the-same-hash" class="wiki-anchor">¶</a></h1>
</li>
</ul>
<p>@@ -36,9 +45,9 @@<br>
end</p>
<p>it "returns the same hash for recursive hashes through arrays" do</p>
<ul>
<li>h = {} ; rec = [h] ; h[:x] = rec</li>
<li>h.hash.should == {x: rec}.hash</li>
<li>h.hash.should == {x: [h]}.hash</li>
</ul>
<ul>
<li>h = {}; rec = [h]; h[:x] = rec</li>
<li>h.hash.should == { x: rec }.hash</li>
<li>h.hash.should == { x: [h] }.hash
<a name="Like-above-because-heqlx-h"></a>
<h1 >Like above, because h.eql?(x: [h])<a href="#Like-above-because-heqlx-h" class="wiki-anchor">¶</a></h1>
</li>
</ul>
<p>end</p>
<p>@@ -47,7 +56,7 @@<br>
a = 1<br>
b = 2</p>
<ul>
<li>
<pre><code>eval('{a:, b:}.should == { a: 1, b: 2 }')
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> eval("{a:, b:}.should == { a: 1, b: 2 }")
</code></pre>
end<br>
end<br>
end</li>
</ul>
<a name="adds-tests-forHashdig"></a>
<h1 >adds tests for.Hash#dig<a href="#adds-tests-forHashdig" class="wiki-anchor">¶</a></h1> Ruby master - Feature #19604 (Open): XOAUTH2 support in net-pophttps://bugs.ruby-lang.org/issues/196042023-04-17T15:28:41Zcheez331 (Alessio Cosenza)
<p>I would like to add support to XOAUTH2 in the net-pop library.<br>
I've opened a PR on the GitHub repo and I would like to gather some feedback and having it reviewed/merged.</p>
<p>The PR is here: <a href="https://github.com/ruby/net-pop/pull/16" class="external">https://github.com/ruby/net-pop/pull/16</a> and the documentation about XOAUTH2 for pop3 can be found:</p>
<ul>
<li><a href="https://www.rfc-editor.org/rfc/rfc1734" class="external">https://www.rfc-editor.org/rfc/rfc1734</a></li>
<li><a href="https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth" class="external">https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth</a></li>
</ul>
<p>Thanks!</p> Ruby master - Bug #19266 (Open): URI::Generic should use URI::RFC3986_PARSER instead of URI::DEFA...https://bugs.ruby-lang.org/issues/192662022-12-26T18:52:36Zgareth (Gareth Adams)
<p>In June 2014, <a href="https://github.com/ruby/ruby/commit/bb83f32dc3e0424d25fa4e55d8ff32b061320e41" class="external"><code>uri/common</code> was updated</a> to introduce a RFC3986-compliant parser (<code>URI::RFC3986_PARSER</code>) as an alternative to the previous RFC2396 parser, and common methods like <code>URI()</code> were updated to use that new parser by default. The only methods in <code>common</code> not updated were <a href="https://github.com/ruby/ruby/blob/28a17436503c3c4cb7a35b423a894b697cd80da9/lib/uri/common.rb#L233-L297" class="external"><code>URI.extract</code> and <code>URI.regexp</code></a> which are marked as obsolete. (The old parser was kept in the <code>DEFAULT_PARSER</code> constant despite it not being the default for those methods, presumably for backward compatibility.)</p>
<p>However, similar <a href="https://github.com/ruby/ruby/blob/28a17436503c3c4cb7a35b423a894b697cd80da9/lib/uri/generic.rb#L169-L175" class="external">methods called on <code>URI::Generic</code></a> were never updated to use this new parser. This means that methods like <code>URI::Generic.build</code> fail when given input that succeeds normally, and this also affects subclasses like URI::HTTP:</p>
<pre><code>$ pry -r uri -r uri/common -r uri/generic
[1] pry(main)> URI::Generic.build(host: "underscore_host.example")
URI::InvalidComponentError: bad component(expected host component): underscore_host.example
from /Users/gareth/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/uri/generic.rb:591:in `check_host'
[2] pry(main)> URI::HTTP.build(host: "underscore_host.example")
URI::InvalidComponentError: bad component(expected host component): underscore_host.example
from /Users/gareth/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/uri/generic.rb:591:in `check_host'
[3] pry(main)> URI("http://underscore_host.example")
=> #<URI::HTTP http://underscore_host.example>
</code></pre>
<p><code>URI::Generic.new</code> allows a configurable <code>parser</code> positional argument to override the class' default parser, but other factory methods like <code>.build</code> don't allow this override.</p>
<p>Arguably this doesn't cause problems because at least in the case above, the URI can be built with the polymorphic constructor, but having the option to build URIs from explicit named parts is useful, and leaving the outdated functionality in the <code>Generic</code> class is ambiguous. It's possible that the whole Generic class and its subclasses aren't intended to be used directly how I'm intending here, but there's nothing I could see that suggested this is the case.</p>
<p>I'm not aware of the entire list of differences between RFC2396 and RFC3986. The relevant difference here is that in RFC2396 an individual segment of a host (<a href="https://www.rfc-editor.org/rfc/rfc2396#section-3.2.2" class="external"><code>domainlabel</code>s</a>) could only be <code>alphanum | alphanum *( alphanum | "-" ) alphanum</code>, whereas RFC3986 allows <a href="https://www.rfc-editor.org/rfc/rfc3986#page-13" class="external">hostnames</a> to include any of <code>ALPHA / DIGIT / "-" / "." / "_" / "~"</code>. It's possible that other differences might cause issues for developers, but since this has gone over 8 years without anyone else caring about this, this is definitely not especially urgent.</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 - Feature #19171 (Open): Update Unicode data to Unicode Version 15.1https://bugs.ruby-lang.org/issues/191712022-12-02T07:59:33Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<p>According to <a href="http://blog.unicode.org/2022/11/the-unicode-standard-2023-release.html" class="external">http://blog.unicode.org/2022/11/the-unicode-standard-2023-release.html</a>, Unicode plans to release Version 15.1 in September 2023. According to <a href="https://www.unicode.org/versions/beta.html" class="external">https://www.unicode.org/versions/beta.html</a>, public alpha review starts Feb. 7, 2023, and ends April 4, 2023. Because alpha review may not include all the files we use, it may be difficult for us to participate.</p>
<p>Public beta review is planned to start May 23, 2023, ending July 4, 2023. At this point, we should be able to test things.</p> Ruby master - Bug #19157 (Open): URI bad component validation can be trickedhttps://bugs.ruby-lang.org/issues/191572022-11-28T23:46:13Zstraight-shoota (Johannes Müller)
<p><code>URI::HTTP</code> checks the validity of the URI components. For example, the path of a URI with authority component must be either empty or start with a slash.</p>
<p>This validation applies on the <code>.build</code> constructor as well as on the <code>path</code> setter.<br>
But it can be tricked when setting an empty authority component and scheme before setting a relative path, and then setting the authority and scheme again.<br>
This produces an invalid and incorrect URI.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s2">"uri"</span>
<span class="n">uri</span> <span class="o">=</span> <span class="no">URI</span><span class="o">::</span><span class="no">HTTP</span><span class="p">.</span><span class="nf">build</span><span class="p">({})</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">scheme</span> <span class="o">=</span> <span class="kp">nil</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">path</span> <span class="o">=</span> <span class="s2">"resource"</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">host</span> <span class="o">=</span> <span class="s2">"example.com"</span> <span class="c1"># this should raise URI::InvalidComponentError</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">scheme</span> <span class="o">=</span> <span class="s2">"http"</span>
<span class="n">uri</span><span class="p">.</span><span class="nf">to_s</span> <span class="c1"># => "http://example.comresource"</span>
</code></pre> Ruby master - Misc #19122 (Open): Use MADV_DONTNEED instead of MADV_FREE when freeing a Fiber's s...https://bugs.ruby-lang.org/issues/191222022-11-11T16:06:08Zsmcgivern (Sean McGivern)
<p>I'd like to propose that Ruby stops using MADV_FREE when freeing a Fiber's stack, and switches to using MADV_DONTNEED even when MADV_FREE is supported.</p>
<p>MADV_FREE is used in one place in the Ruby codebase, when freeing the stack of a freed Fiber: <a href="https://git.ruby-lang.org/ruby.git/tree/cont.c#n683" class="external">https://git.ruby-lang.org/ruby.git/tree/cont.c#n683</a></p>
<p>The comment for <code>fiber_pool_stack_free</code> says:</p>
<pre><code class="c syntaxhl" data-language="c"><span class="c1">// We advise the operating system that the stack memory pages are no longer being used.</span>
<span class="c1">// This introduce some performance overhead but allows system to relaim memory when there is pressure.</span>
</code></pre>
<p>Where possible (i.e. on Linux 4.5 and later), <code>fiber_pool_stack_free</code> uses <code>MADV_FREE</code> over <code>MADV_DONTNEED</code>. This has the side effect that memory statistics such as RSS will not reduce until and unless the OS actually reclaims that memory. If that doesn't happen, then the reported memory usage via RSS will be much higher than the 'real' memory usage.</p>
<p>If this was pervasive throughtout the Ruby codebase then that would be one thing, but currently this is just for Fiber. This means that:</p>
<ol>
<li>A program that doesn't use Fiber will have somewhat reliable RSS statistics on recent Linux.</li>
<li>A program that heavily uses Fiber (such as something using Async::HTTP) will see an inflated RSS statistic.</li>
</ol>
<p>Go made a similar change to the one I'm proposing here for similar reasons: <a href="https://github.com/golang/go/issues/42330" class="external">https://github.com/golang/go/issues/42330</a></p>
<blockquote>
<p>While <code>MADV_FREE</code> is somewhat faster than <code>MADV_DONTNEED</code>, it doesn't affect many of the statistics that <code>MADV_DONTNEED</code> does until the memory is actually reclaimed. This generally leads to poor user experience, like confusing stats in <code>top</code> and other monitoring tools; and bad integration with management systems that respond to memory usage.<br>
[...]<br>
I propose we change the default to prefer <code>MADV_DONTNEED</code> over <code>MADV_FREE</code>, to favor user-friendliness and minimal surprise over performance. I think it's become clear that Linux's implementation of <code>MADV_FREE</code> ultimately doesn't meet our needs.</p>
</blockquote>
<p>As an aside, MADV_FREE was not used in Ruby 3.1 (<a href="https://bugs.ruby-lang.org/issues/19101" class="external">https://bugs.ruby-lang.org/issues/19101</a>), and I haven't found any bugs filed about this behaviour other than that one.</p> Ruby master - Feature #19064 (Open): UDPSocket#bind does not take AddrInfo, despite documentation...https://bugs.ruby-lang.org/issues/190642022-10-17T00:50:44Zmcr (Michael Richardson)mcr@sandelman.ca
<p><a href="https://docs.ruby-lang.org/en/master/Socket.html#method-i-bind" class="external">https://docs.ruby-lang.org/en/master/Socket.html#method-i-bind</a> says that this code should work:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'socket'</span>
<span class="c1"># use Addrinfo</span>
<span class="n">socket</span> <span class="o">=</span> <span class="no">Socket</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">:INET</span><span class="p">,</span> <span class="ss">:STREAM</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">socket</span><span class="p">.</span><span class="nf">bind</span><span class="p">(</span><span class="no">Addrinfo</span><span class="p">.</span><span class="nf">tcp</span><span class="p">(</span><span class="s2">"127.0.0.1"</span><span class="p">,</span> <span class="mi">2222</span><span class="p">))</span>
<span class="nb">p</span> <span class="n">socket</span><span class="p">.</span><span class="nf">local_address</span> <span class="c1">#=> #<Addrinfo: 127.0.0.1:2222 TCP></span>
</code></pre>
<p>and it does, but UDPSocket does <em>not</em> like Addrinfo:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">socket</span> <span class="o">=</span> <span class="no">UDPSocket</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Socket</span><span class="o">::</span><span class="no">AF_INET6</span><span class="p">)</span>
<span class="n">ai</span><span class="o">=</span><span class="no">Addrinfo</span><span class="p">.</span><span class="nf">udp</span><span class="p">(</span><span class="s2">"127.0.0.1"</span><span class="p">,</span> <span class="mi">2224</span><span class="p">)</span>
<span class="n">socket</span><span class="p">.</span><span class="nf">bind</span><span class="p">(</span><span class="n">ai</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</code></pre>
<p>A reason to use an Addrinfo rather than a string is because it came from, for instance, Socket.getifaddrs, and might have scope and other information attached, like:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1">#<Addrinfo: fe80::f58e:d5ea:41e0:2555%eth0></span>
</code></pre>
<p>Seen on versions back to 2.6.6, but tested with ruby-head to be sure.</p> Ruby master - Feature #19022 (Open): Use __builtin_ppc_get_timebase on POWER with clanghttps://bugs.ruby-lang.org/issues/190222022-09-26T22:02:06Zpkubaj (Piotr Kubaj)
<p>Use __builtin_ppc_get_timebase on POWER with clang.<br>
<a href="https://github.com/ruby/ruby/pull/5856" class="external">https://github.com/ruby/ruby/pull/5856</a></p> Ruby master - Bug #18947 (Open): Unexpected Errno::ENAMETOOLONG on Windowshttps://bugs.ruby-lang.org/issues/189472022-07-29T07:08:19Zinversion (Yura Babak)
<p>On Windows 10, I am working on a script to copy a complex folder structure.</p>
<p>Pathname and FileUtils work fine for me until there is a folder with a <strong>very long path</strong> (>260 chars).</p>
<p>Normally you cannot access such a folder with Ruby.<br>
The next operations will raise <code>Errno::ENOENT</code></p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Pathname</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="mi">300</span><span class="n">_chars_path</span><span class="p">).</span><span class="nf">children</span>
<span class="no">FileUtils</span><span class="p">.</span><span class="nf">mkpath</span><span class="p">(</span><span class="mi">300</span><span class="n">_chars_path</span><span class="p">)</span>
</code></pre>
<p>But there is a way in Windows to remove the MAX_PATH limitation.<br>
You can find a small .reg file in this article:<br>
<a href="https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry" class="external">https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry</a></p>
<p>After changing this system option, things start to work strangely in Ruby.</p>
<p>This will now raise <code>Errno::ENAMETOOLONG</code>:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Pathname</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="mi">300</span><span class="n">_chars_path</span><span class="p">).</span><span class="nf">children</span>
</code></pre>
<p>But at the same time, you can create a folder with such a long path and write-read a file in it</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">FileUtils</span><span class="p">.</span><span class="nf">mkpath</span><span class="p">(</span><span class="mi">300</span><span class="n">_chars_path</span><span class="p">)</span>
<span class="n">file</span> <span class="o">=</span> <span class="no">Pathname</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="mi">300</span><span class="n">_chars_path</span><span class="o">+</span><span class="s1">'/file.txt'</span><span class="p">)</span>
<span class="n">file</span><span class="p">.</span><span class="nf">write</span> <span class="s1">'oooooooooo'</span>
<span class="nb">puts</span> <span class="no">Pathname</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="mi">300</span><span class="n">_chars_path</span><span class="o">+</span><span class="s1">'/file.txt'</span><span class="p">).</span><span class="nf">read</span>
</code></pre>
<p>So you can work with individual items but attempts to list such folders' content fail (<code>.children</code>, <code>.glob</code>, <code>.copy</code>, etc).<br>
In my case, deep <code>.glob</code> is broken for all the parent folders of that deep long-path folder ((</p>
<p>The only way I found for listing is</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'win32ole'</span>
<span class="n">fso</span> <span class="o">=</span> <span class="no">WIN32OLE</span><span class="p">.</span><span class="nf">new</span> <span class="s1">'Scripting.FileSystemObject'</span>
<span class="k">for</span> <span class="n">file</span> <span class="k">in</span> <span class="n">fso</span><span class="o">.</span><span class="no">GetFolder</span><span class="p">(</span><span class="mi">300</span><span class="n">_chars_path</span><span class="p">).</span><span class="nf">files</span>
<span class="n">file</span><span class="p">.</span><span class="nf">name</span>
<span class="n">file</span><span class="p">.</span><span class="nf">path</span><span class="p">.</span><span class="nf">length</span>
<span class="k">end</span>
</code></pre>
<p>But using this workaround breaks all my code workflow built on top of Pathname and FileUtils ((.</p>
<p>So for me, it looks like some operations with long-path folders are not working just because in Ruby there is a check for the path length and not a real operation problem. And in some places (see .mkpath) there is no such check and all works fine.</p>
<p>Also notice that other applications on Windows have no problems with long-path folders (like Total Commander).</p>
<p>Please consider reviewing if we really need to raise <code>Errno::ENAMETOOLONG</code> if the <code>LongPathsEnabled</code> option is enabled in the Windows registry.</p> Ruby master - Bug #18794 (Open): Windows - intermittent SEGV TestObjSpace#test_reachable_objects_...https://bugs.ruby-lang.org/issues/187942022-05-20T17:19:08ZMSP-Greg (Greg L)
<p>Test runs in retry, generates the following (removed path from x64-ucrt-ruby320.dll). mswin build runs it as a single test, I don't believe it's failed.</p>
<pre><code> 1) Failure:
TestObjSpace#test_reachable_objects_during_iteration Line: 145
assert_separately failed with error message
pid 70572 exit 3
| -:8: [BUG] Unnormalized Fixnum value 0x0000023f8eeb2119
| ruby 3.2.0dev (2022-05-20T15:42:07Z master 11336c7ddb) [x64-mingw-ucrt]
|
| -- Control frame information -----------------------------------------------
| c:0006 p:---- s:0021 e:000020 CFUNC :to_s
| c:0005 p:---- s:0018 e:000017 CFUNC :inspect
| c:0004 p:0004 s:0014 e:000013 BLOCK -:8 [FINISH]
| c:0003 p:---- s:0010 e:000009 CFUNC :each_object
| c:0002 p:0073 s:0006 e:000005 EVAL -:7 [FINISH]
| c:0001 p:0000 s:0003 E:002060 (none) [FINISH]
|
| -- Ruby level backtrace information ----------------------------------------
| -:7:in `<main>'
| -:7:in `each_object'
| -:8:in `block in <main>'
| -:8:in `inspect'
| -:8:in `to_s'
|
| -- C level backtrace information -------------------------------------------
| C:\Windows\SYSTEM32\ntdll.dll(NtWaitForSingleObject+0x14) [0x00007ffbdb40ef74]
| C:\Windows\System32\KERNELBASE.dll(WaitForSingleObjectEx+0x8e) [0x00007ffbd89fe7ae]
| x64-ucrt-ruby320.dll(rb_vm_bugreport+0x313) [0x00007ffba62417c3]
| x64-ucrt-ruby320.dll(rb_bug_without_die+0x75) [0x00007ffba6039d15]
| x64-ucrt-ruby320.dll(rb_bug+0x33) [0x00007ffba626e014]
| x64-ucrt-ruby320.dll(rb_out_of_int+0x42) [0x00007ffba626f81b]
| x64-ucrt-ruby320.dll(rb_vm_invoke_proc+0x22c) [0x00007ffba622c34c]
| x64-ucrt-ruby320.dll(rb_eval_cmd_kw+0x5ea) [0x00007ffba6230e7a]
| x64-ucrt-ruby320.dll(rb_funcallv+0x11) [0x00007ffba62310c1]
| x64-ucrt-ruby320.dll(rb_inspect+0x17) [0x00007ffba60f9417]
| x64-ucrt-ruby320.dll(rb_hash_values+0xfc1) [0x00007ffba606e791]
| x64-ucrt-ruby320.dll(rb_hash_values+0x102c) [0x00007ffba606e7fc]
| x64-ucrt-ruby320.dll(rb_st_foreach_check+0x77) [0x00007ffba61a1637]
| x64-ucrt-ruby320.dll(rb_hash_set_default_proc+0x1e19) [0x00007ffba60724a9]
| x64-ucrt-ruby320.dll(rb_ensure+0x18f) [0x00007ffba60453af]
| x64-ucrt-ruby320.dll(rb_hash_set_default_proc+0x2272) [0x00007ffba6072902]
| x64-ucrt-ruby320.dll(rb_hash_aset+0x1d1f) [0x00007ffba6077c2f]
| x64-ucrt-ruby320.dll(rb_mutex_trylock+0x51c) [0x00007ffba61d864c]
| x64-ucrt-ruby320.dll(rb_exec_recursive+0x17) [0x00007ffba61e0217]
| x64-ucrt-ruby320.dll(rb_error_arity+0x26e) [0x00007ffba62182ee]
| x64-ucrt-ruby320.dll(rb_vm_call_with_refinements+0x47d) [0x00007ffba6233fed]
| x64-ucrt-ruby320.dll(rb_vm_exec+0x255) [0x00007ffba62252a5]
| x64-ucrt-ruby320.dll(rb_yield+0x1e8) [0x00007ffba622ac88]
| x64-ucrt-ruby320.dll(rb_obj_id+0x1c94) [0x00007ffba6057024]
| x64-ucrt-ruby320.dll(rb_size_mul_or_raise+0x154) [0x00007ffba605c464]
| x64-ucrt-ruby320.dll(rb_ensure+0x18f) [0x00007ffba60453af]
| x64-ucrt-ruby320.dll(rb_objspace_each_objects_without_setup+0x1ac) [0x00007ffba606562c]
| x64-ucrt-ruby320.dll(rb_error_arity+0x26e) [0x00007ffba62182ee]
| x64-ucrt-ruby320.dll(rb_vm_search_method_slowpath+0x723) [0x00007ffba621ce33]
| x64-ucrt-ruby320.dll(rb_vm_call_with_refinements+0x4e8) [0x00007ffba6234058]
| x64-ucrt-ruby320.dll(rb_vm_exec+0x255) [0x00007ffba62252a5]
| x64-ucrt-ruby320.dll(rb_call_end_proc+0x130) [0x00007ffba603e400]
| x64-ucrt-ruby320.dll(ruby_run_node+0xa5) [0x00007ffba6044145]
| [0x00007ff62fcc15a8]
| [0x00007ff62fcc13b1]
| [0x00007ff62fcc14e6]
| C:\Windows\System32\KERNEL32.DLL(BaseThreadInitThunk+0x10) [0x00007ffbd93c4ed0]
</code></pre> Ruby master - Bug #18740 (Open): Use of rightward assignment changes line number needed for line-...https://bugs.ruby-lang.org/issues/187402022-04-18T10:00:41Zhurricup (Alexandr Evstigneev)hurricup@gmail.com
<p>Affected ruby 3.1.1</p>
<p>Sample illustrating the problem (<code>test.rb</code>):</p>
<pre><code>def foo
File.read("test.rb")
.split("\n")
.map(&:strip)
.reject(&:empty?)
.first(10) => lines
puts lines
end
TracePoint.new(:line){ puts 'Hi' }.enable(target: RubyVM::InstructionSequence.of(method :foo), target_line: 2)
foo
</code></pre>
<p>produces</p>
<pre><code><internal:trace_point>:212:in `enable': can not enable any hooks (ArgumentError)
</code></pre>
<p>iseq for method:</p>
<pre><code>== disasm: #<ISeq:foo@/home/hurricup/test.rb:1 (1,0)-(9,3)> (catch: FALSE)
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] lines@0
0000 putnil ( 6)[LiCa]
0001 putnil
0002 putobject false
0004 putnil
0005 putnil
0006 opt_getinlinecache 15, <is:0> ( 2)
0009 putobject true
0011 getconstant :File
0013 opt_setinlinecache <is:0>
0015 putstring "test.rb"
0017 opt_send_without_block <calldata!mid:read, argc:1, ARGS_SIMPLE>
0019 putstring "\n" ( 3)
0021 opt_send_without_block <calldata!mid:split, argc:1, ARGS_SIMPLE>
0023 putobject :strip ( 4)
0025 send <calldata!mid:map, argc:0, ARGS_BLOCKARG>, nil
0028 putobject :empty? ( 5)
0030 send <calldata!mid:reject, argc:0, ARGS_BLOCKARG>, nil
0033 putobject 10 ( 6)
0035 opt_send_without_block <calldata!mid:first, argc:1, ARGS_SIMPLE>
0037 dup
0038 setlocal_WC_0 lines@0
0040 jump 88
0042 putspecialobject 1 ( 2)
0044 topn 4
0046 branchif 64
0048 putobject NoMatchingPatternError
0050 putspecialobject 1
0052 putobject "%p: %s"
0054 topn 4
0056 topn 7
0058 opt_send_without_block <calldata!mid:core#sprintf, argc:3, ARGS_SIMPLE>
0060 opt_send_without_block <calldata!mid:core#raise, argc:2, ARGS_SIMPLE>
0062 jump 84
0064 putobject NoMatchingPatternKeyError
0066 putspecialobject 1
0068 putobject "%p: %s"
0070 topn 4
0072 topn 7
0074 opt_send_without_block <calldata!mid:core#sprintf, argc:3, ARGS_SIMPLE>
0076 topn 7
0078 topn 9
0080 opt_send_without_block <calldata!mid:new, argc:3, kw:[matchee,key], KWARG>
0082 opt_send_without_block <calldata!mid:core#raise, argc:1, ARGS_SIMPLE>
0084 adjuststack 7
0086 jump 90
0088 adjuststack 6 ( 6)
0090 putself ( 8)[Li]
0091 getlocal_WC_0 lines@0
0093 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
0095 leave ( 9)[Re]
</code></pre>
<p>Works like a charm without <code>=> lines</code></p> Ruby master - Misc #18587 (Open): What was the reason behind Ruby choosing SipHash for Hash?https://bugs.ruby-lang.org/issues/185872022-02-16T15:42:48Zmidnight (Sarun R)
<p>Hello</p>
<p>I am digging into the history behind Ruby using SipHash for its Hash.<br>
I found that in 2012 there were CVE-2012-5371 showing up;<br>
the Ruby maintainers went with the decision to switch algorithms, probably, because we wanted something quick to implement at the time.<br>
The change went live in late 2012.</p>
<p>Fast forward with the Ruby 3x3 initiative, we now seem to care about the performance again.<br>
And hash DoSing does not seem to be an urgent threat now; we have time to be deliberate about Hash again.</p>
<p>I can't find the old discussion related to Ruby's SipHash decision.<br>
I just found that SipHash is not the only solution to prevent hashtable DoSing.<br>
There is an interesting discussion on golang side in late 2015:<br>
<a href="https://github.com/golang/go/issues/9365" class="external">https://github.com/golang/go/issues/9365</a></p>
<p>Just to recap, Go's authors argue that:</p>
<ul>
<li>Cryptographic hash is not needed to construct a DoS-resistant hashtable.</li>
<li>If the random seed is per-hashtable bases, the attack vector exploitable from a remote adversary seems unlikely.</li>
<li>If we want to be extra careful about it, and since the collision is unlikely, when collision actually does occur despite the per-hashtable seed, we can handle that as a special case where we can rerandom the seed and rehash the key.</li>
<li>The way random seeds are folded into the hash does matter, for example, CityHash does f(g(msg), seed); in such case, collision in g will cause a collision in f because the output of g is independent of the seed.</li>
<li>Slowing down hashtable for everyone to prevent hard-to-exploit DoS doesn't seem to be a good trade-off.</li>
</ul>
<p>On the actual implementation, they use AES-NI to achieve good pseudo-random functions' properties. And use some fallback non-cryptographic hashing function on the platform without AES-NI.</p>
<p>Now, I read the rationale on golang side, I want to understand the rationale on the Ruby side too.<br>
I am not there 10-years-ago, and I can't find records or discussions at the time. There might be some Ruby limitations that the approach described by go's authors does not apply.</p>
<p>So, I asked in the hope of someone still remembering what was happening, the situation we are in 10 years ago, or the limitation of Ruby that prevents per-Hash seeds.</p> Ruby master - Bug #18510 (Open): Unexpected waiting for console when starting ruby on windowshttps://bugs.ruby-lang.org/issues/185102022-01-23T14:53:12ZYO4 (Yoshinao Muramatsu)
<a name="ruby-version"></a>
<h1 >ruby version<a href="#ruby-version" class="wiki-anchor">¶</a></h1>
<p>C:\Ruby31-x64\bin>"c:\Ruby31-x64\bin\ruby.exe" -v<br>
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]</p>
<p>older versions have same issue too.</p>
<a name="how-to-reproduce"></a>
<h1 >how to reproduce<a href="#how-to-reproduce" class="wiki-anchor">¶</a></h1>
<p>execute ruby.exe from cmd.exe command promput like concatenating the quoted path and file name notation</p>
<pre><code>C:\Ruby31-x64\bin>"c:\Ruby31-x64\bin\"ruby.exe -v
# => wait for console input unexpectedly
puts "This is Console Input"^Z
=> This is Console Input
# ruby terminated, version not appear
</code></pre>
<p>It seems to commandline separation issue.</p> Ruby master - Bug #18444 (Open): Trapped TSTP causes a locking deadlock in 3.0.3 onwardhttps://bugs.ruby-lang.org/issues/184442021-12-28T16:01:45Zwhy-el (Mohamed Wael Khobalatte)
<p>A curious case:</p>
<p><code>ruby -e 'Signal.trap("TSTP") { puts "Received a terminal stop signal, but i will sleep instead."; sleep 10 }; loop {puts 1}'</code></p>
<p>this fails with <code>deadlock; recursive locking (ThreadError)</code> when I send the SIGTSTP via my terminal. This is on Mac OS Monterey (M1). It only happens in 3.0.3 and onward (I tried 3.1.0-preview1 as well, fails there too), when I try 3.0.2, the signal is handled properly.</p> Ruby master - Feature #18376 (Open): Version comparison APIhttps://bugs.ruby-lang.org/issues/183762021-12-01T16:56:05Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<p>Is there a chance to have version comparison API? For example if <code>Gem::Version</code> was extracted into <code>::Version</code>. This idea was triggered by this PR <a href="https://github.com/mperham/connection_pool/pull/157" class="external">1</a> and <a href="https://github.com/mperham/connection_pool/issues/158" class="external">2</a>, where the <code>Gem::Version</code> API is used for comparing Ruby versions. While RubyGems might be available everywhere, it does not look correct to introduce dependencies on RubyGems into libraries which could run without them just fine.</p> Ruby master - Feature #18369 (Open): users.detect(:name, "Dorian") as shorthand for users.detect ...https://bugs.ruby-lang.org/issues/183692021-11-30T12:40:09Zdorianmariefr (Dorian Marié)
<p>Hi,</p>
<p>I was thinking I often do things like <code>collection.detect { |item| item.attribute == value }</code> and a shorthand like <code>collection.detect(:attribute, value)</code> would be quite useful</p>
<p>What do you think?</p>
<p>And I know there is <code>collection.detect { _1.attribute == value }</code> but I try not to use <code>_1</code> and this syntax would be shorter and simpler</p>
<p>Could also apply to other methods like <code>all?</code> (<code>collection.all?(:attribute, value)</code>), and basically any Enumerable method <a href="https://rubydoc.info/stdlib/core/Enumerable" class="external">https://rubydoc.info/stdlib/core/Enumerable</a></p> Ruby master - Bug #18359 (Open): [Windows MinGW] warning Please include winsock2.h before windows.hhttps://bugs.ruby-lang.org/issues/183592021-11-23T17:05:03ZMSP-Greg (Greg L)
<p>Compile warning from <code>include/ruby/win32.h</code>? Appears with both MINGW64 & UCRT64 builds.</p>
<pre><code>In file included from D:/ruby-mingw/include/ruby-3.1.0/ruby/win32.h:41,
from D:/ruby-mingw/include/ruby-3.1.0/ruby/internal/dosish.h:38,
from D:/ruby-mingw/include/ruby-3.1.0/ruby/defines.h:78,
from D:/ruby-mingw/include/ruby-3.1.0/ruby/ruby.h:25,
from D:/ruby-mingw/include/ruby-3.1.0/ruby.h:38,
from ../../../../ext/nokogiri/nokogiri.h:68,
from ../../../../ext/nokogiri/gumbo.c:30:
C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
15 | #warning Please include winsock2.h before windows.h
| ^~~~~~~
</code></pre> Ruby master - Misc #18352 (Open): What is the Hash#grep expected?https://bugs.ruby-lang.org/issues/183522021-11-20T09:50:09Zzw963 (Wei Zheng)
<p>Current ruby implement, When use Array#grep, the method name means is expected.</p>
<pre><code>[19] pry(#<App>)> [:foo1, :foo2, :bar].grep /foo/
[
:foo1,
:foo2
]
</code></pre>
<p>But when use with hash, the result is really confusing ...</p>
<pre><code class="rb syntaxhl" data-language="rb"><span class="p">[</span><span class="mi">12</span><span class="p">]</span> <span class="n">pry</span><span class="p">(</span><span class="c1">#<App>)> {foo: '100', bar: '200'}.grep /foo/ </span>
<span class="p">[]</span>
</code></pre>
<p>This result almost make Include Enumerable#grep into Hash is totally meaningless, right?</p>
<p>so, i consider if we should introduce a <code>Hash#grep</code> method instead.</p>
<p>Following is what is expected. (=== is matching on hash key, as Hash#slice)</p>
<pre><code class="rb syntaxhl" data-language="rb"><span class="p">[</span><span class="mi">20</span><span class="p">]</span> <span class="n">pry</span><span class="p">(</span><span class="c1">#<App>)> {foo1: '100', foo2: '200', bar: '200'}.grep /foo/ </span>
<span class="p">{</span>
<span class="ss">:foo1</span> <span class="o">=></span> <span class="s2">"100"</span><span class="p">,</span>
<span class="ss">:foo2</span> <span class="o">=></span> <span class="s2">"200"</span>
<span class="p">}</span>
</code></pre> Ruby master - Feature #18291 (Open): When use =~ with named group, if regex is on the right side,...https://bugs.ruby-lang.org/issues/182912021-11-05T15:12:55Zzw963 (Wei Zheng)
<p>Following code not work.</p>
<pre><code class="rb syntaxhl" data-language="rb"><span class="k">if</span> <span class="s2">"Billy Zheng"</span> <span class="o">=~</span> <span class="sr">/(?<first_name>\w+)\s+(?<last_name>\w+)/</span>
<span class="nb">p</span> <span class="n">first_name</span>
<span class="nb">p</span> <span class="n">last_name</span>
<span class="k">end</span>
<span class="c1"># NameError: undefined local variable or method `first_name' for main:Object</span>
</code></pre>
<p>But, if we switch left and right between =~</p>
<pre><code class="rb syntaxhl" data-language="rb"><span class="k">if</span> <span class="sr">/(?<first_name>\w+)\s+(?<last_name>\w+)/</span> <span class="o">=~</span> <span class="s2">"Billy Zheng"</span>
<span class="nb">p</span> <span class="n">first_name</span>
<span class="nb">p</span> <span class="n">last_name</span>
<span class="k">end</span>
<span class="c1"># => "Billy"</span>
<span class="c1"># =>"Zheng"</span>
</code></pre>
<p>I know ruby keep this same behavior since 1.9, but i am curious if we can improve this?</p>
<p>I consider this as a bug, because that not good, when i want to use this way, i have to<br>
take care must write regexp before =~</p>
<p>Thank you.</p> Ruby master - Bug #18013 (Open): Unexpected results when mxiing negated character classes and cas...https://bugs.ruby-lang.org/issues/180132021-06-29T08:55:22Zjirkamarsik (Jirka Marsik)
<pre><code>irb(main):001:0> /[^a-c]/i.match("A")
=> nil
irb(main):002:0> /[[^a-c]]/i.match("A")
=> #<MatchData "A">
</code></pre>
<p>The two regular expressions above match different strings, because the character classes denote different sets of characters. In order for <code>/[^a-c]/i</code> to produce correct results, Oniguruma provided a fix that can still be easily seen in the code as it is hidden behind an always-on preprocessor flag (<code>CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS</code>, <a href="https://github.com/ruby/ruby/blob/9eae8cdefba61e9e51feb30a4b98525593169666/regparse.c#L5528" class="external">https://github.com/ruby/ruby/blob/9eae8cdefba61e9e51feb30a4b98525593169666/regparse.c#L5528</a>). The idea of the fix is to first case-fold a character class and only then apply the negation (essentially moving the case-fold operator <em>inside</em> the negation).</p>
<p>In the case of our first regular expression, <code>[a-c]</code> is case-folded into <code>[a-cA-C]</code> and that is then inverted into <code>[^a-cA-C]</code>, which is the expected result. However, this case-folding logic is currently only being applied to the top-most character class and so if we use a nested negated character class, the order of the operations will be switched.</p>
<p>With our second regular expression, <code>[a-c]</code> will first be negated to yield <code>[^a-c]</code>, which will then be case-folded into <code>.</code>, the set of all characters (since <code>[^a-c]</code> contains <code>A-C</code>, which case-fold into <code>a-c</code>).</p>
<p>A way to fix this would be to apply case-folding for nested character classes as well, so that the nested character classes behave the same as the top-most character class. Then, we would get the same semantics for both expressions.</p> Ruby master - Feature #17950 (Open): Unable to pattern-match against a String keyhttps://bugs.ruby-lang.org/issues/179502021-06-12T15:36:53Zchucke (Tiago Cardoso)
<p>I'm unable to parse against an internal hash, when the internal hash contains strings as keys:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">case</span> <span class="p">{</span><span class="ss">status: </span><span class="mi">200</span><span class="p">,</span> <span class="ss">headers: </span><span class="p">{</span><span class="s2">"content-type"</span> <span class="o">=></span> <span class="s2">"application/json"</span><span class="p">},</span> <span class="ss">body: </span><span class="s2">"bla"</span><span class="p">}</span>
<span class="k">in</span> <span class="p">{</span> <span class="ss">status: </span><span class="p">,</span> <span class="ss">headers: </span><span class="p">{</span><span class="s2">"content-type"</span> <span class="o">=></span> <span class="n">type</span><span class="p">},</span> <span class="ss">body: </span><span class="p">}</span>
<span class="c1"># syntax error, unexpected terminator, expecting literal content or tSTRING_DBEG or tSTRING_DVAR or tLABEL_END</span>
<span class="c1"># ...tus: , headers: {"content-type" => type}, body: }</span>
</code></pre>
<p>however, this works:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">h</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"content-type"</span> <span class="o">=></span> <span class="s2">"application/json"</span><span class="p">}</span>
<span class="k">case</span> <span class="p">{</span><span class="ss">status: </span><span class="mi">200</span><span class="p">,</span> <span class="ss">headers: </span><span class="p">{</span><span class="s2">"content-type"</span> <span class="o">=></span> <span class="s2">"application/json"</span><span class="p">},</span> <span class="ss">body: </span><span class="s2">"bla"</span><span class="p">}</span>
<span class="k">in</span> <span class="p">{</span> <span class="ss">status: </span><span class="p">,</span> <span class="ss">headers: </span><span class="o">^</span><span class="n">h</span><span class="p">,</span> <span class="ss">body: </span><span class="p">}</span>
</code></pre> Ruby master - Feature #17825 (Open): Uniformize Float::INFINITY and Date::infinity.newhttps://bugs.ruby-lang.org/issues/178252021-04-25T11:05:32ZAoernis (lucas billaudot)
<p>With <code>Float</code> you can do</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Float</span><span class="o">::</span><span class="no">INFINITY</span> <span class="c1"># Infinity</span>
</code></pre>
<p>and with <code>Date</code> you can do</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Date</span><span class="o">::</span><span class="no">Infinity</span><span class="p">.</span><span class="nf">new</span> <span class="c1"># #<Date::Infinity:0x00007f8d46a59ee0 @d=1></span>
</code></pre>
<p>but not</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Date</span><span class="o">::</span><span class="no">INFINITY</span> <span class="c1"># uninitialized constant Date::INFINITY</span>
</code></pre>
<a name="Background"></a>
<h4 >Background<a href="#Background" class="wiki-anchor">¶</a></h4>
<p><code>Date::Infinity.new</code> and <code>Float::INFINITY</code> have both the same ancestors and have same using purpose<br>
So it feel odd no be able to call them the same way</p>
<a name="Proposal"></a>
<h4 >Proposal<a href="#Proposal" class="wiki-anchor">¶</a></h4>
<p>Just make <code>Date::INFINITY</code> a working thing<br>
And maybe mark <code>Date::Infinity.new</code> as deprecated ¯_(ツ)_/¯</p>
<p>Thanks for reading</p> Ruby master - Bug #17617 (Open): When a Ractor's incoming port is closed, Ractor.receive_if does ...https://bugs.ruby-lang.org/issues/176172021-02-09T16:24:27Zdazuma (Daniel Azuma)dazuma@gmail.com
<p>If Ractor#close_incoming is called on a Ractor, any pending Ractor.receive call will raise Ractor::ClosedError. However, any pending Ractor.receive_if call will not; instead, it never returns.</p>
<pre><code>r1 = Ractor.new do
Ractor.receive
rescue => e
e
end
r1.close_incoming
result = r1.take
puts "**** taken: #{result}" # displays the Ractor::ClosedError
r2 = Ractor.new do
Ractor.receive_if { true }
puts "**** never reaches here"
rescue => e
puts "**** never reaches here"
e
end
r2.close_incoming
puts "**** hangs here..."
r2.take
puts "**** never reaches here"
</code></pre>
<p>This was tested against both 3.0.0 and 3.1.0 head, with the same result.</p>
<pre><code>% ruby -v
ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20]
</code></pre>
<pre><code>% ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20
</code></pre>
<p>I have also tried including sleep statements to force the Ractor.receive_if to execute both before and after the Ractor#close_incoming call. The result is the same either way. receive_if hangs regardless of whether the incoming port is already closed when receive_if is invoked, or whether the port is closed while the receive_if is already blocking.</p> Ruby master - Misc #17569 (Open): `uri` lib maintainershiphttps://bugs.ruby-lang.org/issues/175692021-01-22T15:48:33Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<p>I’d like to merge <a href="https://github.com/ruby/uri/pull/15" class="external">https://github.com/ruby/uri/pull/15</a> but it is an API change. I would release v1.0.0. <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/271">@akr (Akira Tanaka)</a> is the official maintainer of <code>uri</code>… Is he still interested in this role? Otherwise we could put “Ruby core team” in the listing…</p> Ruby master - Feature #17566 (Open): Tune thread QoS / efficiency on macOShttps://bugs.ruby-lang.org/issues/175662021-01-20T20:25:26Zmperham (Mike Perham)mperham@gmail.com
<p>Hi, new Apple M1 processors have "performance" and "efficiency" cores. Apple provides a QoS API so threads can tune which cores they should execute on. Some threads should be executed as high-priority, some should be treated as low-priority.</p>
<p>This page shows the pthread APIs that Apple provides:</p>
<p><a href="https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/PrioritizeWorkAtTheTaskLevel.html" class="external">https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/PrioritizeWorkAtTheTaskLevel.html</a></p>
<pre><code>pthread_set_qos_class_self_np(QOS_CLASS_BACKGROUND, 0)
</code></pre>
<p>I noticed Ruby already provides <code>Thread#priority=</code> which says <code>This is just hint for Ruby thread scheduler. It may be ignored on some platform</code>. Does this API work still or was it only active for Ruby 1.8's green threads? Should this API use the QoS APIs on macOS?</p> Ruby master - Feature #17562 (Open): Update -E option in --helphttps://bugs.ruby-lang.org/issues/175622021-01-19T16:42:45Zima1zumi (Mari Imaizumi)
<p>I would like to propose explaining the arguments of the -E option specifically in --help.</p>
<p>The current explanation is a bit difficult for beginners to understand.<br>
I tried to change <code>Encoding.default_internal</code>, but I changed <code>Encoding.default_external</code> by mistake. That confused me because I didn't know how to use it. Therefore, I have updated the explanation.</p>
<p>before:</p>
<pre><code> -Eex[:in], --encoding=ex[:in]
specify the default external and internal character encodings
</code></pre>
<p>after:</p>
<pre><code> -Eexternal-encoding[:internal-encoding], --encoding=external-encoding[:internal-encoding]
specify the default external and internal character encodings
</code></pre>
<p>diff:</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/ruby.c b/ruby.c
index 5bac96b5e1..4f8975a399 100644
</span><span class="gd">--- a/ruby.c
</span><span class="gi">+++ b/ruby.c
</span><span class="p">@@ -281,7 +281,7 @@</span> usage(const char *name, int help, int highlight, int columns)
M("-Cdirectory", "", "cd to directory before executing your script"),
M("-d", ", --debug", "set debugging flags (set $DEBUG to true)"),
M("-e 'command'", "", "one line of script. Several -e's allowed. Omit [programfile]"),
<span class="gd">- M("-Eex[:in]", ", --encoding=ex[:in]", "specify the default external and internal character encodings"),
</span><span class="gi">+ M("-Eexternal-encoding[:internal-encoding]",", --encoding=external-encoding[:internal-encoding]","specify the default external and internal character encodings"),
</span> M("-Fpattern", "", "split() pattern for autosplit (-a)"),
M("-i[extension]", "", "edit ARGV files in place (make backup if extension supplied)"),
M("-Idirectory", "", "specify $LOAD_PATH directory (may be used more than once)"),
</code></pre>
<p>PR: <a href="https://github.com/ruby/ruby/pull/4099" class="external">https://github.com/ruby/ruby/pull/4099</a></p> Ruby master - Feature #17550 (Open): Why no function to get all subdirectories of a directory?https://bugs.ruby-lang.org/issues/175502021-01-17T20:59:19Zasfarley (Alexander Farley)
<p>Googling around, this seems to be a relatively common request. Would you be willing to accept a pull request implementing this feature?</p> Ruby master - Bug #17420 (Open): Unsafe mutation of $" when doing non-RubyGems require in Ractorhttps://bugs.ruby-lang.org/issues/174202020-12-21T18:31:49ZEregon (Benoit Daloze)
<p>With an empty file <code>a.rb</code>:</p>
<pre><code>$ ruby --disable-gems -e 'Ractor.new { puts $" }.take'
-e:1:in `block in <main>': can not access global variables $" from non-main Ractors (RuntimeError)
</code></pre>
<p>That is expected, given the rules for global variables.</p>
<pre><code>ruby --disable-gems -e 'Ractor.new { require "./a.rb"; }.take; p $"'
[... , "/home/eregon/a.rb"]
</code></pre>
<p>Is it OK that the Ractor can do <code>require</code>, which does modify <code>$"</code>?</p>
<p>I think it's not, and it might lead to segfaults if e.g. the main Ractor mutates <code>$"</code> in parallel to some other Ractor doing <code>require</code>.</p>
<p>Probably <code>require</code> needs to be forbidden in non-main Ractors (it does mutate <code>$"</code>, so it's logical), or there needs to be always VM-global synchronization on any access to <code>$"</code> (otherwise, segfaults are possible).<br>
The latter doesn't seem reasonable, especially when considering the user might do <code>$".each { ... }</code>.</p>
<hr>
<p>Note that RubyGems' <code>require</code> does not work on non-main Ractors (pretty much expected given it depends on a lot of global state):</p>
<pre><code>$ ruby -e 'Ractor.new { require "./a.rb"; }.take'
<internal:/home/eregon/prefix/ruby-master/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require': can not access non-shareable objects in constant Kernel::RUBYGEMS_ACTIVATION_MONITOR by non-main ractor. (NameError)
</code></pre>
<p>This probably also has consequences for <code>autoload</code>.<br>
Maybe the <code>zeitwerk</code> gem can help with the mode to resolve all autoload at once.</p> Ruby master - Misc #17309 (Open): URI.escape being deprecated, yet there is no replacementhttps://bugs.ruby-lang.org/issues/173092020-11-07T01:26:10Zchucke (Tiago Cardoso)
<p>I'm on ruby 2.7.2 . The moment I do</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">uri</span> <span class="o">=</span> <span class="s2">"http://bücher.ch"</span>
<span class="no">URI</span><span class="p">.</span><span class="nf">escape</span> <span class="n">uri</span>
<span class="p">(</span><span class="n">irb</span><span class="p">):</span><span class="mi">5</span><span class="p">:</span> <span class="ss">warning: </span><span class="no">URI</span><span class="p">.</span><span class="nf">escape</span>
<span class="s2">"http://b%C3%BCcher.ch"</span>
</code></pre>
<p>I get that warning. Rubocop also tells me:</p>
<p>"""<br>
URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.<br>
"""</p>
<p>However, none of the suggestions does the same as <code>URI.escape</code>.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">CGI</span><span class="p">.</span><span class="nf">escape</span> <span class="n">uri</span>
<span class="o">=></span> <span class="s2">"http%3A%2F%2Fb%C3%BCcher.ch"</span>
<span class="no">URI</span><span class="p">.</span><span class="nf">encode_www_form_component</span> <span class="n">uri</span>
<span class="o">=></span> <span class="s2">"http%3A%2F%2Fb%C3%BCcher.ch"</span>
<span class="no">URI</span><span class="p">.</span><span class="nf">encode_www_form</span> <span class="n">uri</span>
<span class="no">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
<span class="no">NoMethodError</span> <span class="p">(</span><span class="n">undefined</span> <span class="nb">method</span> <span class="sb">`map' for "http://bücher.ch":String)
Did you mean? tap
</span></code></pre>
<p>So my question is: why is this being deprecated? And if there's still reason, what to exactly replace it for, so I can keep the exact same behaviour?</p> Ruby master - Misc #17154 (Open): Update Pathname Documentation to Clarify Expected Behaviorhttps://bugs.ruby-lang.org/issues/171542020-09-05T02:29:29Zresperat (Ralph Esperat)
<p>I would like to suggest adding a sentence to the documentation for <a href="https://ruby-doc.org/stdlib-2.7.1/libdoc/pathname/rdoc/Pathname.html" class="external">Pathname</a> to make clear the unusual behavior of <code>Pathname#+</code> when an absolute path is included in the arguments. In such a situation, <code>Pathname#+</code> drops the paths prior to the last absolute path which I understand to be the intended behavior, but it is not obviously intended, only showing up tangentially as an example in the documentation.</p>
<pre><code>p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
</code></pre>
<p>The Pathname documentation states that " <strong>All functionality</strong> from File, FileTest, and some from Dir and FileUtils is included, <strong>in an unsurprising way</strong> ..." and later when referring to core methods such as <code>Pathname#+</code> "These methods are <strong>effectively manipulating a String</strong> , because that's all a path is." However, similar uses of both <a href="https://ruby-doc.org/core-2.7.1/File.html" class="external">File</a> and <a href="https://ruby-doc.org/core-2.7.1/String.html" class="external">String</a> would produce the expected result of including all of the arguments:</p>
<pre><code>s1 = "/usr"
s2 = s1 + "/etc/passwd" # "/usr/etc/passwd"
f1 = File.new("/usr" + "/etc/passwd") # (No such file or directory @ rb_sysopen - /usr/etc/passwd)
</code></pre>
<p>A bug report was previously filed to "fix" this functionality (<a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Status: Rejected" href="https://bugs.ruby-lang.org/issues/15564">Bug #15564: Pathname#+(pathpart) returns pathpart when pathpart is absolute</a>), not understanding it to be intentional. Other common help websites such as <a href="https://stackoverflow.com/questions/12464361/concatenating-absolute-paths-with-the-pathname-class" class="external">Stack Overflow</a> also show users who do not expect this behavior from this method. Adding a statement to the documentation for the <a href="https://ruby-doc.org/stdlib-2.7.1/libdoc/pathname/rdoc/Pathname.html#method-i-2B" class="external">Pathname#+</a> method will make it clear to users exactly what to expect and that this is the intended behavior. I would suggest simply the following, the first sentence of which is already present:</p>
<p><code>Appends a pathname fragment to self to produce a new Pathname object. If an absolute path is provided as any of the arguments, discards all arguments prior to the last absolute path provided.</code></p>
<p>I appreciate your consideration of this request.</p>
<p>ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]</p> Ruby master - Feature #16971 (Open): weak_ref&.some_method should behave like object&.some_methodhttps://bugs.ruby-lang.org/issues/169712020-06-19T15:07:55Zkwerle (Kurt Werle)kurt@CircleW.org
<p>The following patterns mean basically the same thing and should behave the same:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">weak_ref</span> <span class="o">=</span> <span class="no">WeakRef</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">some_object</span><span class="p">)</span>
<span class="o">...</span>
<span class="n">weak_ref</span><span class="p">.</span><span class="nf">some_method</span> <span class="k">if</span> <span class="n">weak_ref</span><span class="p">.</span><span class="nf">weakref_alive?</span><span class="p">()</span>
<span class="n">some_object</span><span class="p">.</span><span class="nf">some_method</span> <span class="k">if</span> <span class="n">some_object</span><span class="p">.</span><span class="nf">present?</span>
</code></pre>
<p>The some_object predicate got cleaned up by using &.some_method. It would be super clean if WeakRef did the same.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">weak_ref</span> <span class="o">=</span> <span class="no">WeakRef</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">some_object</span><span class="p">)</span>
<span class="o">...</span>
<span class="n">weak_ref</span><span class="o">&</span><span class="p">.</span><span class="nf">some_method</span> <span class="c1"># should not raise WeakRef::RefError</span>
</code></pre> Ruby master - Feature #16755 (Open): warning: `if' at the end of line without an expressionhttps://bugs.ruby-lang.org/issues/167552020-04-03T14:47:11Zmpapis (Michal Papis)mpapis@gmail.com
<p>I'm using this notation in a lot of scripts:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">if</span>
<span class="kp">true</span>
<span class="k">then</span>
<span class="nb">puts</span> <span class="ss">:a</span>
<span class="k">else</span>
<span class="nb">puts</span> <span class="ss">:b</span>
<span class="k">end</span>
</code></pre>
<p>Using ruby 2.6.5 I'm getting expected response:</p>
<pre><code class="shell syntaxhl" data-language="shell"><span class="o">(</span>0<span class="o">)</span> 2.6.5 mpapis@mpapis-linux:~/tmp>ruby <span class="nt">-w</span> test.rb
a
</code></pre>
<p>Using ruby 2.7.1 I'm getting extra warning:</p>
<pre><code class="shell syntaxhl" data-language="shell"><span class="o">(</span>0<span class="o">)</span> 2.7.1 mpapis@mpapis-linux:~/tmp>ruby <span class="nt">-w</span> test.rb
test.rb:1: warning: <span class="sb">`</span><span class="k">if</span><span class="s1">' at the end of line without an expression
a
</span></code></pre>
<p>I've tracked it to the following git commits:</p>
<ul>
<li>ba35c14325ebbf1da8f200df83c45ee9937ff8a1</li>
<li>c303854e134043d905baff2385add44cc2c28756</li>
<li>26316cc350109ba71d42f944f3b976985627c042</li>
<li>e91e3274bebc803b97971ad0a6f4ee3a8c646a60</li>
<li>a087e027bf7cf0fbb825f1d55668f85ab1f3c9e6</li>
<li>30a74aaef00a99364f5423439ac44babf5066dc0</li>
</ul> Ruby master - Feature #16684 (Open): Use the word "to" instead of "from" in backtracehttps://bugs.ruby-lang.org/issues/166842020-03-10T16:00:53Zsawa (Tsuyoshi Sawada)
<p>The most-recent-call-last order of backtrace introduced by <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add option to print backtrace in reverse order (stack frames first and error last) (Closed)" href="https://bugs.ruby-lang.org/issues/8661">#8661</a>:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">a</span><span class="p">;</span> <span class="k">raise</span> <span class="k">end</span>
<span class="k">def</span> <span class="nf">b</span><span class="p">;</span> <span class="n">a</span> <span class="k">end</span>
<span class="k">def</span> <span class="nf">c</span><span class="p">;</span> <span class="n">b</span> <span class="k">end</span>
<span class="n">c</span>
</code></pre>
<p><strong>Current</strong></p>
<pre><code>Traceback (most recent call last):
3: from foo.rb:4:in `<main>'
2: from foo.rb:3:in `c'
1: from foo.rb:2:in `b'
foo.rb:1:in `a': unhandled exception
</code></pre>
<p>is intuitive to me, and I hope it is retained. However, there are people complaining that it is confusing. I believe the unnaturalness is (at least partly) due to the fact that the word "from" is used, which made sense when backtrace was displayed in most-recent-call-first order,</p>
<pre><code>foo.rb:1:in `a': unhandled exception
1: from foo.rb:2:in `b'
2: from foo.rb:3:in `c'
3: from foo.rb:4:in `<main>'
</code></pre>
<p>but not any more. Here, my understanding is that "from" means that the previous line was called <strong>from</strong> that line.</p>
<p>I propose that, so long as the most-recent-call-last order is adopted, the word "to" should be used rather than "from", which would mean that the previous line leads <strong>to</strong> that line:</p>
<p><strong>Proposed 1</strong></p>
<pre><code>Traceback (most recent call last):
3: to foo.rb:4:in `<main>'
2: to foo.rb:3:in `c'
1: to foo.rb:2:in `b'
foo.rb:1:in `a': unhandled exception
</code></pre>
<p>Or, as an alternative, if it looks unnatural to have "to" in the first line, and to lack one before the message line, we may put it at the end of a line:</p>
<p><strong>Proposed 2</strong></p>
<pre><code>Traceback (most recent call last)
3: foo.rb:4:in `<main>' to:
2: foo.rb:3:in `c' to:
1: foo.rb:2:in `b' to:
foo.rb:1:in `a': unhandled exception
</code></pre>
<p>By using different words, it would become easier to understand the display order at a glance, and even by just looking at a single line.</p> Ruby master - Misc #16507 (Open): =~ vs include? or match?https://bugs.ruby-lang.org/issues/165072020-01-12T23:27:07ZMSP-Greg (Greg L)
<p>While working on getting the mswin build working on Actions, I thought adding mswin? and ci? methods to Minitest::Unit::Guard in tool/lib/minitest/unit.rb would be helpful.</p>
<p>Currently some tests are failing that are guarded/skipped based on ENV['APPVEYOR']. For ci?, I'd combine Travis, AppVeyor, & Actions.</p>
<p>There are quite a few instances where =~ is used for a boolean return. Would it be considered appropriate to replace those calls with include? or match?</p> Ruby master - Feature #16471 (Open): Two feature requests for WeakRef: get original object, callb...https://bugs.ruby-lang.org/issues/164712020-01-01T19:16:52ZSnappingturtle (Mike O'Sullivan)
<p>I'd like to request two features for <code>WeakRef</code>. I'll explain what I want, then provide a real world use case.</p>
<p>First, add the ability to pull the original object out of the <code>WeakRef</code> object, something like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">myhash</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">myhash</span> <span class="o">=</span> <span class="no">WeakRef</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">myhash</span><span class="p">)</span>
<span class="n">myhash</span> <span class="o">=</span> <span class="n">myhash</span><span class="p">.</span><span class="nf">original_object</span><span class="p">()</span>
</code></pre>
<p>Second, add a callback feature for when a WeakRef's object is being purged by GC. It would work something like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">wr</span> <span class="o">=</span> <span class="no">WeakRef</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">myobject</span><span class="p">)</span>
<span class="n">wr</span><span class="p">.</span><span class="nf">on_garbage</span><span class="p">()</span> <span class="k">do</span> <span class="o">|</span><span class="n">wr</span><span class="o">|</span>
<span class="nb">puts</span> <span class="s1">'trashing'</span>
<span class="k">end</span>
<span class="c1"># time goes by...</span>
<span class="c1"># myobject goes out of scope</span>
<span class="c1"># outputs "trashing"</span>
</code></pre>
<p>Here's the specific use case I would want it for. I'm developing a database system which includes a class called <code>Node</code>. A <code>Node</code> object holds a reference to a database handle and the primary key of a record in that database. It also has methods for getting and setting values in that record. So a simplified version looks something like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Node</span>
<span class="nb">attr_reader</span> <span class="ss">:dbh</span>
<span class="nb">attr_reader</span> <span class="ss">:pk</span>
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">dbh</span><span class="p">,</span> <span class="n">pk</span><span class="p">)</span>
<span class="vi">@dbh</span> <span class="o">=</span> <span class="n">dbh</span>
<span class="vi">@pk</span> <span class="o">=</span> <span class="n">pk</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">set</span><span class="p">(</span><span class="n">fieldname</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="c1"># a bunch of SQL to set the value</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="n">fieldname</span><span class="p">)</span>
<span class="c1"># a bunch of SQL to get the value</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">node</span> <span class="o">=</span> <span class="no">Node</span><span class="p">.</span><span class="nf">new</span> <span class="n">dbh</span><span class="p">,</span> <span class="s1">'abc'</span>
<span class="n">node</span><span class="p">.</span><span class="nf">set</span> <span class="s1">'name'</span><span class="p">,</span> <span class="s1">'Fred'</span>
</code></pre>
<p>The database object will have a node method, so you would usually get nodes like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">node</span> <span class="o">=</span> <span class="n">dbh</span><span class="p">.</span><span class="nf">node</span><span class="p">(</span><span class="s1">'abc'</span><span class="p">)</span>
</code></pre>
<p>Make sense so far? It's a pretty simple concept. It works, but I'd like to make a small improvement. (Whether or not it's actually an improvement is a judgement call... I expect some disagreement on this point. But work with me here.)</p>
<p>I'd like the database object to keep a cache of <code>Node</code> objects. However, the database doesn't keep those node objects alive: they can fall out of scope and get purged by the GC. However, if that cache is never purged of dead objects, it just grows bigger and bigger. I could occasionally just run a routine to work through the cache and purge dead references, but that seems very inefficient. It would be better to just have them purged as they die.</p>
<p>So I could implement it something like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">DataBase</span>
<span class="nb">attr_reader</span> <span class="ss">:cache</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="vi">@cache</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">node</span><span class="p">(</span><span class="n">pk</span><span class="p">)</span>
<span class="k">if</span> <span class="vi">@cache</span><span class="p">[</span><span class="n">pk</span><span class="p">]</span>
<span class="c1"># Here's where we need to get at the original object</span>
<span class="k">return</span> <span class="vi">@cache</span><span class="p">[</span><span class="n">pk</span><span class="p">].</span><span class="nf">original_object</span>
<span class="k">else</span>
<span class="n">new_node</span> <span class="o">=</span> <span class="no">Node</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="nb">self</span><span class="p">,</span> <span class="n">pk</span><span class="p">)</span>
<span class="vi">@cache</span><span class="p">[</span><span class="n">pk</span><span class="p">]</span> <span class="o">=</span> <span class="no">WeakRef</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">new_node</span><span class="p">)</span>
<span class="c1"># Here's where we set the callback</span>
<span class="vi">@cache</span><span class="p">[</span><span class="n">pk</span><span class="p">].</span><span class="nf">on_garbage</span> <span class="k">do</span> <span class="o">|</span><span class="n">wr</span><span class="o">|</span>
<span class="n">wr</span><span class="p">.</span><span class="nf">db</span><span class="p">.</span><span class="nf">cache</span><span class="p">.</span><span class="nf">delete</span> <span class="n">wr</span><span class="p">.</span><span class="nf">pk</span>
<span class="k">end</span>
<span class="k">return</span> <span class="n">new_node</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>So when a <code>Node</code> object is garbage collected, it's deleted from the cache. The cache stays clean of dead objects.</p>
<p>I'll be interested to hear what you think of this idea and how difficult it would be to implement it.</p> Ruby master - Misc #16396 (Open): What is the reason for this behaviour of Find.find?https://bugs.ruby-lang.org/issues/163962019-12-03T13:03:26Zstiuna (Juan Gregorio)cart4for1@mail.com
<p>When I have a script at <code>D:\Downloads\Ruby 2.5.3\rbL\comp\codeShort.rb</code> with few other files in the same folder, the following searches only the folder where the <code>.rb</code> script is located:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Find</span><span class="p">.</span><span class="nf">find</span><span class="p">(</span><span class="s1">'D:'</span><span class="p">)</span>
</code></pre>
<p>When I have a script at <code>D:\Downloads\Ruby 2.5.3\rbL\codeShort.rb</code> with many other files in the same folder, the same code as above searches the entire disk D.</p>
<p>To search the entire disk D in the first case, I did this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Find</span><span class="p">.</span><span class="nf">find</span><span class="p">(</span><span class="s1">'D:/'</span><span class="p">)</span>
</code></pre>
<p>But I don't understand why the two cases behave differently with the same instruction just because they script are in different directories.</p> Ruby master - Misc #16188 (Open): What are the performance implications of the new keyword argume...https://bugs.ruby-lang.org/issues/161882019-09-29T18:27:43ZEregon (Benoit Daloze)
<p>In <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: "Real" keyword argument (Closed)" href="https://bugs.ruby-lang.org/issues/14183">#14183</a>, keyword arguments became further separated from positional arguments.</p>
<p>Contrary to the original design though, keyword and positional arguments are not fully separated for methods not accepting keyword arguments.<br>
Example: <code>foo(key: :value)</code> will <code>def foo(hash)</code> will pass a positional argument.<br>
This is of course better for compatibility, but I wonder what are the performance implications.</p>
<p>The block argument is completely separate in all versions, so no need to concern ourselves about that.</p>
<p>In Ruby <= 2.6:</p>
<ul>
<li>The caller never needs to know about the callee's arguments, it can just take all arguments and pass them as an array.<br>
The last argument might be used to extract keyword, but this is all done at the callee side.</li>
<li>Splitting kwargs composed of Symbol and non-Symbol keys can be fairly expensive, but it is a rare occurrence.<br>
If inlining the callee and kwargs are all passed as a literal Hash at the call site, there shouldn't be any overhead compared to positional arguments once JIT'ed.</li>
</ul>
<p>In Ruby 2.7:</p>
<ul>
<li>The caller needs to pass positional and keyword arguments separately, at least when calling a method accepting kwargs.<br>
But, if it calls a methods not accepting kwargs, then the "kwargs" (e.g. <code>foo(key: :value)</code>) should be treated just like a final Hash positional argument.</li>
<li>(If we had complete separation, then we could always pass positional and keyword arguments separately, so the caller could once again ignore the callee)</li>
</ul>
<p>How is the logic implemented in MRI for 2.7?</p>
<p>Specializing the caller for a given callee is a well-known technique.<br>
However, it becomes more difficult if different methods are called from the same callsite (polymorphic call), especially if one accepts kwargs and another does not.<br>
In that case, I think we will see a performance cost to this approach, by having to pass arguments differently based on the method to be called.</p>
<p>What about delegation using <code>ruby2_keywords</code>?<br>
Which checks does that add (compared to 2.6) in the merged approach with the Hash flag?</p> Ruby master - Misc #16157 (Open): What is the correct and *portable* way to do generic delegation?https://bugs.ruby-lang.org/issues/161572019-09-09T14:10:42ZDan0042 (Daniel DeLorme)
<p>With the keyword argument changes in 2.7 we must now specify keyword arguments explicitly when doing generic delegation. But this change is not compatible with 2.6, where it adds an empty hash to the argument list of methods that do not need/accept keyword arguments.</p>
<p>To illustrate the problem:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">ProxyWithoutKW</span> <span class="o"><</span> <span class="no">BasicObject</span>
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">target</span><span class="p">)</span>
<span class="vi">@target</span> <span class="o">=</span> <span class="n">target</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">method_missing</span><span class="p">(</span><span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="o">&</span><span class="n">b</span><span class="p">)</span>
<span class="vi">@target</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="o">&</span><span class="n">b</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">ProxyWithKW</span> <span class="o"><</span> <span class="no">BasicObject</span>
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">target</span><span class="p">)</span>
<span class="vi">@target</span> <span class="o">=</span> <span class="n">target</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">method_missing</span><span class="p">(</span><span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="o">**</span><span class="n">o</span><span class="p">,</span> <span class="o">&</span><span class="n">b</span><span class="p">)</span>
<span class="vi">@target</span><span class="p">.</span><span class="nf">send</span><span class="p">(</span><span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="o">**</span><span class="n">o</span><span class="p">,</span> <span class="o">&</span><span class="n">b</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Test</span>
<span class="k">def</span> <span class="nf">args</span><span class="p">(</span><span class="o">*</span><span class="n">a</span><span class="p">)</span> <span class="n">a</span> <span class="k">end</span>
<span class="k">def</span> <span class="nf">arg</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="n">a</span> <span class="k">end</span>
<span class="k">def</span> <span class="nf">opts</span><span class="p">(</span><span class="o">**</span><span class="n">o</span><span class="p">)</span> <span class="n">o</span> <span class="k">end</span>
<span class="k">end</span>
<span class="c1"># 2.6 2.7 3.0</span>
<span class="no">ProxyWithoutKW</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Test</span><span class="p">.</span><span class="nf">new</span><span class="p">).</span><span class="nf">args</span><span class="p">(</span><span class="mi">42</span><span class="p">)</span> <span class="c1"># [42] [42] [42] ok</span>
<span class="no">ProxyWithoutKW</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Test</span><span class="p">.</span><span class="nf">new</span><span class="p">).</span><span class="nf">arg</span><span class="p">(</span><span class="mi">42</span><span class="p">)</span> <span class="c1"># 42 42 42 ok</span>
<span class="no">ProxyWithoutKW</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Test</span><span class="p">.</span><span class="nf">new</span><span class="p">).</span><span class="nf">opts</span><span class="p">(</span><span class="ss">k: </span><span class="mi">42</span><span class="p">)</span> <span class="c1"># {:k=>42} {:k=>42} +warn [{:k=>42}] incompatible with >= 2.7</span>
<span class="no">ProxyWithKW</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Test</span><span class="p">.</span><span class="nf">new</span><span class="p">).</span><span class="nf">args</span><span class="p">(</span><span class="mi">42</span><span class="p">)</span> <span class="c1"># [42, {}] [42] [42] incompatible with <= 2.6</span>
<span class="no">ProxyWithKW</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Test</span><span class="p">.</span><span class="nf">new</span><span class="p">).</span><span class="nf">arg</span><span class="p">(</span><span class="mi">42</span><span class="p">)</span> <span class="c1"># error 42 42 incompatible with <= 2.6</span>
<span class="no">ProxyWithKW</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">Test</span><span class="p">.</span><span class="nf">new</span><span class="p">).</span><span class="nf">opts</span><span class="p">(</span><span class="ss">k: </span><span class="mi">42</span><span class="p">)</span> <span class="c1"># {:k=>42} {:k=>42} +warn {:k=>42} must ignore warning? cannot use pass_positional_hash in 2.6</span>
</code></pre>
<p>I don't know how to solve this, so I'm asking for the <strong>official</strong> correct way to write portable delegation code. And by <strong>portable</strong> I mean code that can be used in gems that target ruby 2.6 and above.</p> Ruby master - Feature #16128 (Open): Would it be possible for ruby to warn about case/when menu o...https://bugs.ruby-lang.org/issues/161282019-08-25T15:52:14Zshevegen (Robert A. Heiler)shevegen@gmail.com
<p>I was not sure whether the following behaviour is a bug or not, so I filed this under "feature", mostly because<br>
this may change existing behaviour; and even if I think the current behaviour in this context may not make a<br>
lot of sense, perhaps there are caveats; or it may be too insignificant to want to change.</p>
<p>Anyway, without further ado, I will next show the ruby code that can be used to reproduce the issue/behaviour<br>
that I refer to:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Foo</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="n">menu</span><span class="p">(</span><span class="ss">:random_colour</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">menu</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<span class="k">case</span> <span class="n">i</span><span class="p">.</span><span class="nf">to_s</span>
<span class="k">when</span> <span class="sr">/^-?-?random(-|_)?colou?r$/i</span><span class="p">,</span>
<span class="sr">/rcolour$/i</span><span class="p">,</span>
<span class="s1">'RCOL'</span><span class="p">,</span>
<span class="n">print_foobar</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">print_foobar</span>
<span class="nb">print</span> <span class="s1">'foobar'</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="no">Foo</span><span class="p">.</span><span class="nf">new</span>
</code></pre>
<p>To those who may not immediately see the problem - it is the last ',' character<br>
in the case/when menu, right after the string 'RCOL'.</p>
<p>The above snippet was part of a much larger class/codebase, so I narrowed it<br>
down to this smaller example.</p>
<p>If you run this code, you will see no output. The reason is due to the ','.</p>
<p>If you remove the ',', then you get the desired output - the invocation of<br>
the method called print_foobar() which will print 'foobar'.</p>
<p>I discovered this strange behaviour by accident in a much larger case/when<br>
menu (my case/when menu interfaces can be excessively long, I admit this).</p>
<p>Sometimes I re-arrange the case menu, and then I may forget the ',' there,<br>
so I paste the ',' with the line, which sometimes leads to above situation,<br>
which tends to confuse me. I am quite used to this at this point, so<br>
discovering the problem does not take me long - but I was wondering whether<br>
this current behaviour is useful for anything?</p>
<p>Because if not then perhaps there could be a warning by ruby, possibly by<br>
the did-you-mean gem, or by ruby directly even without the did-you-mean<br>
gem (although I think this may fit the did-you-mean gem). I have, however<br>
had, decided to first report this to ruby core anyway, because perhaps I<br>
am missing something obvious that may explain the behaviour. Or perhaps it<br>
is difficult to distuingish what the next lines should be. But I assume<br>
that the ruby parser assumes another case/when statement here, after the<br>
',', so does not treat the above as an error or problematic behaviour.</p>
<p>Perhaps the above can still be reported based on additional information,<br>
such as correct indent level? I indent uniformly and consistently, so<br>
the above could provide additional cues what the ruby user at hand may<br>
have wanted to see - as in the example above, I don't think the trailing<br>
',' is useful; it was just a typo. I am not sure how easy it is to distinguish<br>
this case between cases where the user wanted to have a ','.</p>
<p>I am not sure how easy it would be to change the behaviour of ruby in<br>
this regard, or if it is wanted, or if it takes too much time, but I thought<br>
it is better to report it anyway - others can give their opinion in this<br>
case. Thanks!</p> Ruby master - Feature #15854 (Open): Tracing instance variable assignmenthttps://bugs.ruby-lang.org/issues/158542019-05-16T06:34:55Zigaiga (Kuniaki Igarashi)igaiga@gmail.com
<p>I suggest a feature "tracing instance variable assignment". It's useful for debugging.</p>
<p>Use case:</p>
<p>In Rails, we use instance variables in views and controllers. When we got a bug caused by instance variable unintentional values, if we traced instance variable assignment timing, it would be good informations.</p>
<p>And in Rails views, there are no source codes of self class. That's built dynamically.</p>
<p>Current behavior (Ruby2.6):</p>
<p>In Ruby 2.6, only if there is a source code file to assign instance variable, we can trace instance variable assignment by following code (check_instance_variable_assignment.rb). But it's difficult if the assignment codes are defined dynamically. For example, in Rails view.</p>
<p>(And in another story, global variables assignment are traced by Kernel#trace_var.)</p>
<p>check_instance_variable_assignment.rb</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">trace_start</span>
<span class="no">TracePoint</span><span class="p">.</span><span class="nf">trace</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">target_class_name</span> <span class="o">=</span> <span class="s2">"Foo"</span>
<span class="n">target_instance_variable_name</span> <span class="o">=</span> <span class="s2">"@bar"</span>
<span class="n">line</span> <span class="o">=</span> <span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="n">tp</span><span class="p">.</span><span class="nf">path</span><span class="p">,</span> <span class="s2">"r"</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">readlines</span><span class="p">[</span><span class="n">tp</span><span class="p">.</span><span class="nf">lineno</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="p">}</span>
<span class="n">node</span> <span class="o">=</span> <span class="no">RubyVM</span><span class="o">::</span><span class="no">AbstractSyntaxTree</span><span class="p">.</span><span class="nf">parse</span><span class="p">(</span><span class="n">line</span><span class="p">).</span><span class="nf">children</span><span class="p">.</span><span class="nf">last</span>
<span class="c1"># check instance variable assignment</span>
<span class="k">next</span> <span class="k">unless</span> <span class="n">node</span><span class="p">.</span><span class="nf">type</span> <span class="o">==</span> <span class="ss">:IASGN</span>
<span class="c1"># check class name</span>
<span class="n">target_class</span> <span class="o">=</span> <span class="no">Kernel</span><span class="p">.</span><span class="nf">const_get</span><span class="p">(</span><span class="n">target_class_name</span><span class="p">)</span>
<span class="k">next</span> <span class="k">unless</span> <span class="n">tp</span><span class="p">.</span><span class="nf">self</span><span class="p">.</span><span class="nf">is_a?</span><span class="p">(</span><span class="n">target_class</span><span class="p">)</span>
<span class="c1"># check variable name</span>
<span class="n">instance_variable_name</span> <span class="o">=</span> <span class="n">node</span><span class="p">.</span><span class="nf">children</span><span class="p">.</span><span class="nf">first</span>
<span class="k">next</span> <span class="k">unless</span> <span class="n">instance_variable_name</span> <span class="o">==</span> <span class="n">target_instance_variable_name</span><span class="p">.</span><span class="nf">to_sym</span>
<span class="nb">puts</span> <span class="s2">"</span><span class="si">#{</span><span class="n">target_class_name</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">target_instance_variable_name</span><span class="si">}</span><span class="s2"> is assigned in </span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">path</span><span class="si">}</span><span class="s2">:</span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">lineno</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">defined_class</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">method_id</span><span class="si">}</span><span class="s2">"</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Foo</span>
<span class="k">def</span> <span class="nf">bar</span>
<span class="vi">@bar</span> <span class="o">=</span> <span class="s2">"text"</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">trace_start</span>
<span class="no">Foo</span><span class="p">.</span><span class="nf">new</span><span class="p">.</span><span class="nf">bar</span>
<span class="c1">#=> Foo @bar is assigned in check_instance_variable_assignment.rb:25 Foo bar</span>
</code></pre>
<p>Suggesting feature example:</p>
<p>Add new arguments for TracePoint.new method like :line and :call to trace instance variables assignment.</p>
<ul>
<li>:iasgn (IASGN name from RubyVM::AbstractSyntaxTree::Node)</li>
<li>:casgn (CVASGN (or CASGN?) name from RubyVM::AbstractSyntaxTree::Node. I think class variables tracing is useful too.)</li>
</ul>
<p>And get informations</p>
<ul>
<li>class name (It might be get by trace_point.self)</li>
<li>variable name ("@foo", "@@foo")</li>
</ul>
<p>A sample code to use the feature:</p>
<p>tp_iasgn.rb</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">TracePoint</span><span class="p">.</span><span class="nf">trace</span><span class="p">(</span><span class="ss">:iasgn</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">target_class_name</span> <span class="o">=</span> <span class="s2">"Foo"</span>
<span class="n">target_instance_variable_name</span> <span class="o">=</span> <span class="s2">"@bar"</span>
<span class="c1"># check class name</span>
<span class="n">target_class</span> <span class="o">=</span> <span class="no">Kernel</span><span class="p">.</span><span class="nf">const_get</span><span class="p">(</span><span class="n">target_class_name</span><span class="p">)</span>
<span class="k">next</span> <span class="k">unless</span> <span class="n">tp</span><span class="p">.</span><span class="nf">self</span><span class="p">.</span><span class="nf">is_a?</span><span class="p">(</span><span class="n">target_class</span><span class="p">)</span>
<span class="c1"># check variable name</span>
<span class="k">next</span> <span class="k">unless</span> <span class="n">target_instance_variable_name</span> <span class="o">==</span> <span class="n">tp</span><span class="p">.</span><span class="nf">variable_name</span>
<span class="nb">puts</span> <span class="s2">"</span><span class="si">#{</span><span class="n">target_class_name</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">target_instance_variable_name</span><span class="si">}</span><span class="s2"> is assigned in </span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">path</span><span class="si">}</span><span class="s2">:</span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">lineno</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">method_id</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">tp</span><span class="p">.</span><span class="nf">defined_class</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">puts</span> <span class="nb">caller</span> <span class="c1"># even in dynamic code case, we can get caller informations.</span>
<span class="k">end</span>
</code></pre> Ruby master - Feature #15817 (Open): Warnings for undef_method and remove_method on initialize()https://bugs.ruby-lang.org/issues/158172019-05-02T09:11:49Zshevegen (Robert A. Heiler)shevegen@gmail.com
<p>Title: Warnings for undef_method and remove_method on initialize()</p>
<p>Right now ruby warns you if you remove or undefine initialize, at the least if you<br>
run in verbose mode e. g. the -w flag.</p>
<p>Example for such a warning:</p>
<pre><code>gtk_combo_box.rb:17: warning: undefining `initialize' may cause serious problems
</code></pre>
<p>What am I trying to do here, that caused this warning to appear, actually?</p>
<p>I am modifying some of the ruby-gtk code to extend the core gtk widgets with some<br>
"shortcuts", that is, functionality that I may use in order to write less code when<br>
I write ruby-gtk specific code.</p>
<p>Part of this means that I have to modify how initialize works for some of these<br>
widgets; in particular enabling support for some Symbols via blocks given to the<br>
initializer (I happily use/abuse Symbols that way; ruby-gtk has also added a few<br>
Symbols in the last few years, in particular to avoid having to type long CONSTANT<br>
names when it is not necessary - see Kouhei Sutou's continued efforts here).</p>
<p>In order to do this, and modify these gtk-widgets, I thus modify initialize - and<br>
ruby gives me warnings here.</p>
<p>The first warning I actually got was:</p>
<p>"warning: method redefined; discarding old initialize"</p>
<p>Ok, fair enough. So my idea was ... "I'll simply remove the old initialize, and<br>
then set a new one, aka my own variant. That way I won't get the warning anymore."</p>
<p>I then tried to use both remove_method, and undef_method, and while initialize is<br>
removed, ruby still warns me, e. g. with the "may cause serious problems" issue.<br>
This was the reason (and moment) for creating the issue request here.</p>
<p>I should say that I always run all my ruby code with warning flags enabled, set in<br>
the shebang-header in a .rb file. I find it very useful that ruby tells me if<br>
there may be something wrong in general. However had, in this particular case, I<br>
actually consider ruby warning me to be a feature that I would prefer to not have,<br>
in that particular instance. The reason is that I am actually specifically telling<br>
ruby to get rid of the old initialize, so it is a bit surprising to me that ruby<br>
warns me. Here the assumption may be that the ruby user did not know what was done,<br>
and although I am still quite clueless, I actually think that in this case I knew<br>
what I wanted to do - that is, getting rid of the old initialize, then setting a<br>
new initialize. (Perhaps ruby could detect such a case, where the ruby users removes<br>
the old initialize, then specifically defines a new one; this may solve the issue<br>
here, but I have no idea how feasible this may be, or how much work. Just mentioning<br>
it really.)</p>
<p>We can say that my approach is not a good one; this may well be, but the primary question<br>
is whether ruby should warn/notify us in such a case either way.</p>
<p>I think you can find arguments for both cases, e. g. that ruby warns us (some people may<br>
want this, even in this case) when it comes to undef_method/remove_method on initialize<br>
only - but it may also equally be the case that the ruby user at hands knows what she/he/it<br>
is doing. And I believe that in the latter case ruby should NOT warn about this. Obviously<br>
ruby then would need a way to distinguish between these two cases:</p>
<p>a) the case where the user wants to see a warning, because it may be helpful or for any other reason<br>
b) the case where the user does not want to see the warning, for whatever reason</p>
<p>This makes the issue request here a bit complicated, because while I actually think that<br>
ruby should not warn in regards to undef_method/remove_method, there are also perfectly<br>
valid use cases for the latter, where ruby should warn. One use case can be when people<br>
dynamically add/remove methods and may "accidentally" - and automatically - remove initialize,<br>
so in this case it would be a GOOD thing that ruby warns them. But in other cases, such as in<br>
the use case described here, I would rather prefer to not have ruby print anything about this<br>
to me.</p>
<p>There are workarounds of course - for example, I can temporarily silence on $VERBOSE, and then<br>
re-set it to the old value. I do this in other gems.</p>
<p>There may be other workarounds - perhaps working on a new copy of initialize and then replacing<br>
the old one differently (not sure if these work ... perhaps with some variant of the *eval-family).<br>
All of which is fine - my primary reason here is that I believe it should be simple for the<br>
ruby user to tell ruby to not warn about a specific error at hand, e. g. in all the cases where<br>
the user knows the problem domain (and thus does not need the warning at hand).</p>
<p>I have no really good general suggestion in how to improve this aspect here, because it may be<br>
better to make warnings in ruby more flexible in general. Perhaps even on a per module/class<br>
"namespace" - a bit similar to refinements, but with a simple(r) API and a simple(r) concept.</p>
<p>I don't have a good proposal here either, so this is just a little bit of feedback really. (If<br>
there are more similar comments about warnings in ruby in general, please feel free to close<br>
the issue here and gather discussions in any other tracker issue if you feel this to be better.)</p>
<p>To further explain the above issue - my use case was primarily motivated in order to silence the<br>
first warning. It took me a little bit by surprise that my course of action then led to another<br>
warning, which sort of defeated my original intent of silencing the other warning, since I now<br>
had a new warning issued on the commandline. :)</p>
<p>Hopefully I could describe the intent/idea behind the suggestion. It is of course nothing that<br>
is hugely important, since it is just a warning and the code works fine, but I kind of like<br>
seeing no warnings on the commandline actually (don't know why but I dislike seeing warnings<br>
when I can avoid them).</p>
<p>PS: I think for the particular issue at hand, I will do the old trick with temporarily modifying<br>
$VERBOSE. It feels a bit hackish, but it also kind of works, and I can then silence the specific<br>
warning at hand, e. g. "wrap" the offending code part between $VERBOSE or two method calls that<br>
modify $VERBOSE; so perhaps a more general solution may be to be able to modify $VERBOSE through<br>
method calls in general, though I don't know if this would make the code too slow, or where this<br>
method should reside (Kernel? Not sure) - I just think it may be nicer to read, API-wise, to have<br>
a method rather than have to modify $VERBOSE. But that is just an opinion really; the more<br>
important thing is that modifying $VERBOSE does work, so the functionality already exists<br>
for us to use as-is.</p> Ruby master - Feature #15781 (Open): Unify Method List Introspection?https://bugs.ruby-lang.org/issues/157812019-04-21T20:43:58Zrbjl (Jan Lelis)hi@ruby.consulting
<p>Although Ruby has many core methods for retrieving the list of methods available to an object, or to the instances of a class, I believe they have gotten a little confusing (<a href="https://idiosyncratic-ruby.com/25-meta-methodology.html" class="external">also see</a>):</p>
<ul>
<li>
<code>Object#methods</code> and <code>Module#instance_methods</code> do not include <strong>private</strong> methods (at the same time they do include <strong>protected</strong> ones). There is already <code>Object#public_methods</code> (and <code>Object#protected_methods</code>) for distinguishing visibility scope , but no way to get <em>all</em> methods of an object.</li>
<li>There is the inconsistency that in most cases the argument being passed to <code>*_methods</code> methods let's you decide if you want to consider the inheritance chain, or not - But the prominent exception is <code>Object#methods</code> which instead toggles inheritance to singleton only! (for which we also have <code>Object#singleton_methods</code>)</li>
<li>There is no direct API for getting a list of private singleton methods</li>
</ul>
<p>Now that we have keyword arguments, we could provide a single API for listing methods. One way of doing so could be the <a href="https://github.com/janlelis/object_shadow#method-introspection" class="external">Object#shadow's methods method</a>. Having a keyword arguments based API would allow users to specify the dimensions of their requests better - should it:</p>
<ul>
<li>return the object's methods, or methods of its instances?</li>
<li>return only methods of a specific visibility scope?</li>
<li>return only methods of a specific inheritance level (e.g. only singleton, or all the way down to <code>BasicObject</code>)?</li>
</ul>
<p>What do you think about having one unified way for retrieving an object's method list?</p> Ruby master - Bug #15764 (Open): Whitespace and control characters should not be permitted in tokenshttps://bugs.ruby-lang.org/issues/157642019-04-11T20:59:47ZBatmanAoD (Kyle Strand)kyle.j.strand@gmail.com
<p>As of Ruby 2.5.1p57, it appears that all valid Unicode code-points above 128 are permitted in tokens. This includes whitespace and control characters.</p>
<p>This was demonstrated here: <a href="https://gist.github.com/qrohlf/7045823" class="external">https://gist.github.com/qrohlf/7045823</a></p>
<p>I have attached the raw download from the above gist.</p>
<p>The issue has been discussed on StackOverflow: <a href="https://stackoverflow.com/q/34455427/1858225" class="external">https://stackoverflow.com/q/34455427/1858225</a></p>
<p>I would say this is arguably a bug, but I am marking this ticket as a "feature" since the current behavior could be considered by-design.</p> Ruby master - Feature #15554 (Open): warn/error passing a block to a method which never use a blockhttps://bugs.ruby-lang.org/issues/155542019-01-22T04:48:10Zko1 (Koichi Sasada)
<a name="Abstract"></a>
<h1 >Abstract<a href="#Abstract" class="wiki-anchor">¶</a></h1>
<p>Warn or raise an ArgumentError if block is passed to a method which does not use a block.<br>
In other words, detect "block user methods" implicitly and only "block user methods" can accept a block.</p>
<a name="Background"></a>
<h1 >Background<a href="#Background" class="wiki-anchor">¶</a></h1>
<p>Sometimes, we pass a block to a method which ignores the passed block accidentally.</p>
<pre><code>def my_open(name)
open(name)
end
# user hopes it works as Kernel#open which invokes a block with opened file.
my_open(name){|f| important_work_with f }
# but simply ignored...
</code></pre>
<p>To solve this issue, this feature request propose showing warnings or raising an exception on such case.</p>
<p>Last developer's meeting, matz proposed <code>&nil</code> which declares this method never receive a block. It is explicit, but it is tough to add this <code>&nil</code> parameter declaration to all of methods (do you want to add it to <code>def []=(i, e, &nil)</code>?).<br>
(I agree <code>&nil</code> is valuable on some situations)</p>
<a name="Spec"></a>
<h1 >Spec<a href="#Spec" class="wiki-anchor">¶</a></h1>
<a name="Define-use-a-block-methods"></a>
<h2 >Define "use a block" methods<a href="#Define-use-a-block-methods" class="wiki-anchor">¶</a></h2>
<p>We need to define which method accepts a block and which method does not.</p>
<ul>
<li>(1) method has a block parameter (<code>&b</code>)</li>
<li>(2) method body has `yield'</li>
<li>(3) method body has <code>super</code> (ZSUPER in internal terminology) or <code>super(...)</code>
</li>
<li>(4) method body has singleton method (optional)</li>
</ul>
<p>(1) and (2) is very clear. I need to explain about (3) and (4).</p>
<p>(3). <code>super</code> (ZSUPER) passes all parameters as arguments. So there is no surprise that which can accept <code>block</code>.<br>
However <code>super(...)</code> also passes a block if no explicit block passing (like <code>super(){}</code> or <code>super(&b)</code>) are written.<br>
I'm not sure we need to continue this strange specification, but to keep compatibility depending this spec, I add this rule.</p>
<p>(4). surprisingly, the following code invoke a block:</p>
<pre><code>def foo
class << Object.new
yield
end
end
foo{ p :ok } #=> :ok
</code></pre>
<p>I'm also not sure we need to keep this spec, but to allow this spec, I added (4) rule.<br>
Strictly speaking, it is not required, but we don't keep the link from singleton class ISeq to lexical parent iseq now, so I added it.</p>
<a name="Exceptional-cases"></a>
<h2 >Exceptional cases<a href="#Exceptional-cases" class="wiki-anchor">¶</a></h2>
<p>A method called by <code>super</code> doesn<code>t warn warning even if this method doesn't use a block. The rule (3) can pass blocks easily and there are many methods don</code>t use a block.</p>
<p>So my patch ignores callings by <code>super</code>.</p>
<a name="corner-cases"></a>
<h2 >corner cases<a href="#corner-cases" class="wiki-anchor">¶</a></h2>
<p>There are several cases to use block without (1)-(4) rules.</p>
<h3>
<code>Proc.new/proc/lambda</code> without a block</h3>
<p>Now it was deprecated in r66772 (<a class="changeset" title="proc.c: proc without block * proc.c (proc_new): promoted lambda/proc/Proc.new with no block in..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/9f1fb0a17febc59356d58cef5e98db61a3c03550">9f1fb0a17febc59356d58cef5e98db61a3c03550</a>).<br>
Related discussion: [Bug <a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Bug: Proc.new with no block shouldn't always warn (Rejected)" href="https://bugs.ruby-lang.org/issues/15539">#15539</a>]</p>
<a name="block_given"></a>
<h3 ><code>block_given?</code><a href="#block_given" class="wiki-anchor">¶</a></h3>
<p><code>block_given?</code> expects block, but I believe we use it with <code>yield</code> or a block parameter.<br>
If you know the usecase without them, please tell us.</p>
<h3>
<code>yield</code> in <code>eval</code>
</h3>
<p>We can't know <code>yield</code> (or (3), (4) rule) in an <code>eval</code> evaluating string at calling time.</p>
<pre><code>def foo
eval('yield`)
end
foo{} # at calling time,
# we can't know the method foo can accept a block or not.
</code></pre>
<p>So I added a warning to use <code>yield</code> in <code>eval</code> like that: <code>test.rb:4: warning: use yield in eval will not be supported in Ruby 3.</code></p>
<p>Workaround is use a block parameter explicitly.</p>
<pre><code>def foo &b
eval('b.call')
end
foo{ p :ok }
</code></pre>
<a name="Implementation"></a>
<h1 >Implementation<a href="#Implementation" class="wiki-anchor">¶</a></h1>
<p>Strategy is:</p>
<ul>
<li>[compile time] introduce <code>iseq::has_yield</code> field and check it if the iseq (or child iseq) contains <code>yield</code> (or something)</li>
<li>[calling time] if block is given, check <code>iseq::has_yield</code> flag and show warning (or raise an exception)</li>
</ul>
<p><a href="https://gist.github.com/ko1/c9148ad0224bf5befa3cc76ed2220c0b" class="external">https://gist.github.com/ko1/c9148ad0224bf5befa3cc76ed2220c0b</a></p>
<p>On this patch, now it raises an error to make it easy to detect.<br>
It is easy to switch to show the warning.</p>
<a name="Evaluation-and-discussion"></a>
<h1 >Evaluation and discussion<a href="#Evaluation-and-discussion" class="wiki-anchor">¶</a></h1>
<p>I tried to avoid ruby's tests.</p>
<p><a href="https://gist.github.com/ko1/37483e7940cdc4390bf8eb0001883786" class="external">https://gist.github.com/ko1/37483e7940cdc4390bf8eb0001883786</a></p>
<p>Here is a patch.</p>
<p>There are several patterns to avoid warnings.</p>
<a name="tests-for-block_given-Procnew-and-similar-without-block"></a>
<h2 >tests for <code>block_given?</code>, <code>Proc.new</code> (and similar) without block<a href="#tests-for-block_given-Procnew-and-similar-without-block" class="wiki-anchor">¶</a></h2>
<p>Add a dummy block parameter.<br>
It is test-specific issue.</p>
<h2>empty <code>each</code>
</h2>
<p>Some tests add <code>each</code> methods do not <code>yield</code>, like: <code>def each; end</code>.<br>
Maybe test-specific issue, and adding a dummy block parameter.</p>
<a name="Subtyping-duck-typing"></a>
<h2 >Subtyping / duck typing<a href="#Subtyping-duck-typing" class="wiki-anchor">¶</a></h2>
<p><a href="https://github.com/ruby/ruby/blob/c01a5ee85e2d6a7128cccafb143bfa694284ca87/lib/optparse.rb#L698" class="external">https://github.com/ruby/ruby/blob/c01a5ee85e2d6a7128cccafb143bfa694284ca87/lib/optparse.rb#L698</a></p>
<p>This <code>parse</code> method doesn't use <code>yield</code>, but other sub-type's <code>parse</code> methods use.</p>
<h2>
<code>super</code> with <code>new</code> method</h2>
<p><a href="https://gist.github.com/ko1/37483e7940cdc4390bf8eb0001883786#file-tests-patch-L61" class="external">https://gist.github.com/ko1/37483e7940cdc4390bf8eb0001883786#file-tests-patch-L61</a></p>
<p>This method override <code>Class#new</code> method and introduce a hook with block (yield a block in this hook code).</p>
<p><a href="https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package/tar_writer.rb#L81" class="external">https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package/tar_writer.rb#L81</a></p>
<p>In this method, call <code>super</code> and it also passing a block. However, called <code>initialize</code> doesn't use a block.</p>
<a name="Change-robustness"></a>
<h2 >Change robustness<a href="#Change-robustness" class="wiki-anchor">¶</a></h2>
<p>This change reduce robustness for API change.</p>
<p><code>Delegator</code> requires to support <code>__getobj__</code> for client classes.<br>
Now <code>__getobj__</code> should accept block but most of <code>__getobj__</code> clients do not call given block.</p>
<p><a href="https://github.com/ruby/ruby/blob/trunk/lib/delegate.rb#L80" class="external">https://github.com/ruby/ruby/blob/trunk/lib/delegate.rb#L80</a></p>
<p>This is because of delegator.rb's API change.</p>
<p><a href="https://gist.github.com/ko1/37483e7940cdc4390bf8eb0001883786#file-tests-patch-L86" class="external">https://gist.github.com/ko1/37483e7940cdc4390bf8eb0001883786#file-tests-patch-L86</a></p>
<p>Nobu says calling block is not required (ignoring a block is no problem) so it is not a bug for delegator client classes.</p>
<a name="Found-issues"></a>
<h2 >Found issues.<a href="#Found-issues" class="wiki-anchor">¶</a></h2>
<pre><code>[ 2945/20449] Rinda::TestRingServer#test_do_reply = 0.00 s
1) Error:
Rinda::TestRingServer#test_do_reply:
ArgumentError: passing block to the method "with_timeout" (defined at /home/ko1/src/ruby/trunk/test/rinda/test_rinda.rb:787) is never used.
/home/ko1/src/ruby/trunk/test/rinda/test_rinda.rb:635:in `test_do_reply'
[ 2946/20449] Rinda::TestRingServer#test_do_reply_local = 0.00 s
2) Error:
Rinda::TestRingServer#test_do_reply_local:
ArgumentError: passing block to the method "with_timeout" (defined at /home/ko1/src/ruby/trunk/test/rinda/test_rinda.rb:787) is never used.
/home/ko1/src/ruby/trunk/test/rinda/test_rinda.rb:657:in `test_do_reply_local'
[10024/20449] TestGemRequestSetGemDependencyAPI#test_platform_mswin = 0.01 s
3) Error:
TestGemRequestSetGemDependencyAPI#test_platform_mswin:
ArgumentError: passing block to the method "util_set_arch" (defined at /home/ko1/src/ruby/trunk/lib/rubygems/test_case.rb:1053) is never used.
/home/ko1/src/ruby/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb:655:in `test_platform_mswin'
[10025/20449] TestGemRequestSetGemDependencyAPI#test_platforms = 0.01 s
4) Error:
TestGemRequestSetGemDependencyAPI#test_platforms:
ArgumentError: passing block to the method "util_set_arch" (defined at /home/ko1/src/ruby/trunk/lib/rubygems/test_case.rb:1053) is never used.
/home/ko1/src/ruby/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb:711:in `test_platforms'
</code></pre>
<p>These 4 detection show the problem. <code>with_timeout</code> method (used in Rinda test) and <code>util_set_arch</code> method (used in Rubygems test) simply ignore the given block.<br>
So these tests are simply ignored.</p>
<p>I reported them. (<a href="https://github.com/rubygems/rubygems/issues/2601" class="external">https://github.com/rubygems/rubygems/issues/2601</a>)</p>
<a name="raise-an-error-or-show-a-warning"></a>
<h2 >raise an error or show a warning?<a href="#raise-an-error-or-show-a-warning" class="wiki-anchor">¶</a></h2>
<p>At least, Ruby 2.7 should show warning for this kind of violation with <code>-w</code>.<br>
How about for Ruby3?</p> Ruby master - Feature #15413 (Open): unmarkable C stack (3rd stack)https://bugs.ruby-lang.org/issues/154132018-12-14T21:32:15Znormalperson (Eric Wong)normalperson@yhbt.net
<p>The current machine (C) stack can get pretty big for some C functions<br>
(rb_ensure, rb_f_select/rb_thread_fd_select/...). This is harmful when we stop<br>
a fiber/thread and all that stack becomes eligible for marking.</p>
<p>We should experiment a bump allocator for temporary allocations which<br>
behaves like the stack, but does not get marked by GC. VALUEs will continue<br>
to be allocated on normal C stack, but non-VALUE stuff can go to the<br>
unmarkable machine stack.</p>
<p>Maybe we call it "UMMS" for Un-Markable Machine Stack</p>
<p>We cannot remove marking of the current C stack for compatibility;<br>
but we can transition existing C code to use UMMS.</p>
<p>I probably won't be around to work on it for 2.7, unfortunately.</p> Ruby master - Bug #15247 (Open): Windows - TEMP folder, non 8.3 & drive, fails & errors in test-a...https://bugs.ruby-lang.org/issues/152472018-10-23T17:02:28ZMSP-Greg (Greg L)
<p>While working with Azure pipelines, two issues came up related to the TEMP folder.</p>
<p>1. The standard Windows TEMP folder is located in a user directory. The user for pipeplines is 'buildguest', which is greater than 8 characters, and hence, its short and long paths differ. When I created a new user account locally on Windows 10, both ENV['TEMP'] and ENV['TMP'] were set to the short path.</p>
<p>This is causes two failures in <code>test/rdoc/test_rdoc_rdoc.rb</code> and one failure in <code>test_dir.rb</code>, the failures are listed in the attached file temp_short-long.txt.</p>
<p>2. Azure pipelines has the normal TEMP folder on drive C:, but, unlike Appveyor, the repo is placed on drive D:. This causes one failure in <code>test/rdoc/test_rdoc_options.rb</code>, and two errors from the same file, but in the std-Lib file <code>pathname.rb</code>. See attached file temp_drive.txt.</p>
<p>I'm not really sure what I think the solution for this is, as the issue is really due to Windows setting ENV['TEMP'] and ENV['TMP'] to short paths. I do recall the same issues happened on my old multi-drive desktop system. At the time, there were more significant issues with build/test, so I reconfigured the env for that...</p> Ruby master - Feature #15031 (Open): T_RANGE for testing whether object is a Rangehttps://bugs.ruby-lang.org/issues/150312018-08-27T05:28:28Zv0dro (Sameer Deshmukh)sameer.deshmukh93@gmail.com
<p>Range is an in-built type of Ruby and it would be better for C extension<br>
writers if there existed a constant <code>T_RANGE</code> that could be directly used<br>
for checking whether a <code>VALUE</code> is a <code>Range</code>.</p>
<p>Currently we need to write <code>CLASS_OF(obj) == rb_cRange</code> in order to make this<br>
happen. Having a <code>T_RANGE</code> would help in making C code more idiomatic and fast<br>
in some cases.</p>
<p>That way, one can write <code>RB_TYPE_P(obj, T_RANGE)</code>.</p> Ruby master - Misc #14825 (Open): When redefining `attr_xx` methods the visibility becomes `public` https://bugs.ruby-lang.org/issues/148252018-06-05T05:57:56Zy-yagi (Yuji Yaginuma)
<p>Hi.</p>
<p>If redefine <code>attr_xx</code> methods, the original visibility is lost and all visibility is public.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># attr.rb</span>
<span class="k">module</span> <span class="nn">ClassMethods</span>
<span class="k">def</span> <span class="nf">attr_reader</span><span class="p">(</span><span class="o">*</span><span class="p">)</span>
<span class="k">super</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">attr_writer</span><span class="p">(</span><span class="o">*</span><span class="p">)</span>
<span class="k">super</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">attr_accessor</span><span class="p">(</span><span class="o">*</span><span class="p">)</span>
<span class="k">super</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Foo</span>
<span class="kp">extend</span> <span class="no">ClassMethods</span>
<span class="k">class</span> <span class="o"><<</span> <span class="nb">self</span>
<span class="k">def</span> <span class="nf">method_visibility</span><span class="p">(</span><span class="nb">method</span><span class="p">)</span>
<span class="k">case</span>
<span class="k">when</span> <span class="nb">private_method_defined?</span><span class="p">(</span><span class="nb">method</span><span class="p">)</span>
<span class="ss">:private</span>
<span class="k">when</span> <span class="nb">protected_method_defined?</span><span class="p">(</span><span class="nb">method</span><span class="p">)</span>
<span class="ss">:protected</span>
<span class="k">else</span>
<span class="ss">:public</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="nb">attr_reader</span> <span class="ss">:pub</span>
<span class="kp">protected</span>
<span class="nb">attr_reader</span> <span class="ss">:prot</span>
<span class="k">alias</span> <span class="n">protalias</span> <span class="n">prot</span>
<span class="kp">alias_method</span> <span class="ss">:protaliasmethod</span><span class="p">,</span> <span class="ss">:prot</span>
<span class="kp">private</span>
<span class="nb">attr_reader</span> <span class="ss">:priv</span>
<span class="k">alias</span> <span class="n">privalias</span> <span class="n">priv</span>
<span class="kp">alias_method</span> <span class="ss">:privaliasmethod</span><span class="p">,</span> <span class="ss">:priv</span>
<span class="k">end</span>
<span class="n">f</span> <span class="o">=</span> <span class="no">Foo</span><span class="p">.</span><span class="nf">new</span>
<span class="nb">puts</span> <span class="s2">"Public"</span>
<span class="n">f</span><span class="p">.</span><span class="nf">pub</span>
<span class="nb">puts</span>
<span class="nb">puts</span> <span class="s2">"Protected"</span>
<span class="nb">puts</span> <span class="s2">"prot: </span><span class="si">#{</span><span class="no">Foo</span><span class="p">.</span><span class="nf">method_visibility</span><span class="p">(</span><span class="ss">:prot</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">puts</span> <span class="s2">"protalias: </span><span class="si">#{</span><span class="no">Foo</span><span class="p">.</span><span class="nf">method_visibility</span><span class="p">(</span><span class="ss">:protalias</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">puts</span> <span class="s2">"protaliasmethod </span><span class="si">#{</span><span class="no">Foo</span><span class="p">.</span><span class="nf">method_visibility</span><span class="p">(</span><span class="ss">:protaliasmethod</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">puts</span>
<span class="nb">puts</span> <span class="s2">"Private"</span>
<span class="nb">puts</span> <span class="s2">"priv: </span><span class="si">#{</span><span class="no">Foo</span><span class="p">.</span><span class="nf">method_visibility</span><span class="p">(</span><span class="ss">:priv</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">puts</span> <span class="s2">"privalias: </span><span class="si">#{</span><span class="no">Foo</span><span class="p">.</span><span class="nf">method_visibility</span><span class="p">(</span><span class="ss">:privalias</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">puts</span> <span class="s2">"privaliasmethod: </span><span class="si">#{</span><span class="no">Foo</span><span class="p">.</span><span class="nf">method_visibility</span><span class="p">(</span><span class="ss">:privaliasmethod</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span>
</code></pre>
<pre><code>$ ruby -v attr.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Public
Protected
prot: public
protalias: public
protaliasmethod public
Private
priv: public
privalias: public
privaliasmethod: public
</code></pre>
<p>Is this intentional?</p> Ruby master - Feature #14800 (Open): Zlib::GzipReader#read does not support 2nd argumenthttps://bugs.ruby-lang.org/issues/148002018-05-31T14:32:52Zokkez (okkez _)
<p><code>Zlib::GzipReader#read</code> does not support 2nd argument for output buffer.<br>
It is not same as <code>IO#read</code> and <code>StringIO#read</code>.</p>
<p>It is useful for duck typing to copy both plain files and gzipped files.</p>
<p>See also</p>
<ul>
<li><a href="https://docs.ruby-lang.org/en/2.5.0/Zlib/GzipReader.html#method-i-read" class="external">https://docs.ruby-lang.org/en/2.5.0/Zlib/GzipReader.html#method-i-read</a></li>
<li><a href="https://docs.ruby-lang.org/en/2.5.0/IO.html#method-i-read" class="external">https://docs.ruby-lang.org/en/2.5.0/IO.html#method-i-read</a></li>
<li><a href="https://docs.ruby-lang.org/en/2.5.0/StringIO.html#method-i-read" class="external">https://docs.ruby-lang.org/en/2.5.0/StringIO.html#method-i-read</a></li>
</ul> Ruby master - Feature #14723 (Open): [WIP] sleepy GChttps://bugs.ruby-lang.org/issues/147232018-04-29T03:57:07Znormalperson (Eric Wong)normalperson@yhbt.net
<p>The idea is to use "idle time" when process is otherwise sleeping<br>
and using no CPU time to perform GC. It makes sense because real<br>
world traffic sees idle time due to network latency and waiting<br>
for user input.</p>
<p>Right now, it's Linux-only. Future patches will affect other sleeping<br>
functions:</p>
<p>IO.select, Kernel#sleep, Thread#join, Process.waitpid, etc...</p>
<p>I don't know if this patch can be implemented for win32, right<br>
now it's just dummy functions and that will be somebody elses<br>
job. But all pthreads platforms should eventually benefit.</p>
<p>Before this patch, the entropy-dependent script below takes 95MB<br>
consistently on my system. Now, depending on the amount of<br>
entropy on my system, it takes anywhere from 43MB to 75MB.</p>
<p>I'm using /dev/urandom to simulate real-world network latency<br>
variations. There is no improvement when using /dev/zero<br>
because the process is never idle.</p>
<p>require 'net/http'<br>
require 'digest/md5'<br>
Thread.abort_on_exception = true<br>
s = TCPServer.new('127.0.0.1', 0)<br>
len = 1024 * 1024 * 1024<br>
th = Thread.new do<br>
c = s.accept<br>
c.readpartial(16384)<br>
c.write("HTTP/1.0 200 OK\r\nContent-Length: #{len}\r\n\r\n")<br>
IO.copy_stream('/dev/urandom', c, len)<br>
c.close<br>
end</p>
<p>addr = s.addr<br>
Net::HTTP.start(addr[3], addr[1]) do |http|<br>
http.request_get('/') do |res|<br>
dig = Digest::MD5.new<br>
res.read_body { |buf|<br>
dig.update(buf)<br>
}<br>
puts dig.hexdigest<br>
end<br>
end</p>
<p>The above script is also dependent on net/protocol using<br>
read_nonblock. Ordinary IO objects will need IO#nonblock=true<br>
to see benefits (because they never hit rb_wait_for_single_fd)</p>
<ul>
<li>gc.c (rb_gc_inprogress): new function<br>
(rb_gc_step): ditto</li>
<li>internal.h: declare prototypes for new gc.c functions</li>
<li>thread_pthread.c (gvl_contended_p): new function</li>
<li>thread_win32.c (gvl_contended_p): ditto (dummy)</li>
<li>thread.c (rb_wait_for_single_fd w/ ppoll):<br>
use new functions to perform GC while GVL is uncontended<br>
and GC is lazy sweeping or incremental marking<br>
<a href="https://blade.ruby-lang.org/ruby-core/86265">[ruby-core:86265]</a></li>
</ul>
<pre><code>
2 part patch broken out
https://80x24.org/spew/20180429035007.6499-2-e@80x24.org/raw
https://80x24.org/spew/20180429035007.6499-3-e@80x24.org/raw
Also on my "sleepy-gc" git branch @ git://80x24.org/ruby.git
</code></pre> Ruby master - Feature #14718 (Open): Use jemalloc by default?https://bugs.ruby-lang.org/issues/147182018-04-27T16:14:10Zmperham (Mike Perham)mperham@gmail.com
<p>I know Sam opened <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Ship Ruby for Linux with jemalloc out-of-the-box (Closed)" href="https://bugs.ruby-lang.org/issues/9113">#9113</a> 4 years ago to suggest this but I'm revisiting the topic to see if there's any movement here for Ruby 2.6 or 2.7. I supply a major piece of Ruby infrastructure (Sidekiq) and I keep hearing over and over how Ruby is terrible with memory, a huge memory hog with their Rails apps. My users switch to jemalloc and a miracle occurs: their memory usage drops massively. Some data points:</p>
<p><a href="https://twitter.com/brandonhilkert/status/987400365627801601" class="external">https://twitter.com/brandonhilkert/status/987400365627801601</a><br>
<a href="https://twitter.com/d_jones/status/989866391787335680" class="external">https://twitter.com/d_jones/status/989866391787335680</a><br>
<a href="https://github.com/mperham/sidekiq/issues/3824#issuecomment-383072469" class="external">https://github.com/mperham/sidekiq/issues/3824#issuecomment-383072469</a></p>
<p>Redis moved to jemalloc many years ago and it solved all of their memory issues too. Their conclusion: the glibc allocator "sucks really really hard". <a href="http://oldblog.antirez.com/post/everything-about-redis-24.html" class="external">http://oldblog.antirez.com/post/everything-about-redis-24.html</a></p>
<p>This is a real pain point for the entire Rails community and would improve Ruby's reputation immensely if we can solve this problem.</p> Ruby master - Bug #14640 (Open): [win32] File.realpath treats a relative path with a drive letter...https://bugs.ruby-lang.org/issues/146402018-03-28T16:18:34Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<p>When <code>t</code> exists in the current directory under the drive C:,</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="p">(</span><span class="s2">"c:t"</span><span class="p">)</span> <span class="c1">#=> No such file or directory @ realpath_rec - c:/t (Errno::ENOENT)</span>
</code></pre>
<p>whereas <code>File.expand_path</code> returns <code>Dir.pwd + "/t"</code>.</p> Ruby master - Feature #14625 (Open): yield_self accepts an argument, calling to_prochttps://bugs.ruby-lang.org/issues/146252018-03-23T08:04:36Zirohiroki (Hiroki Yoshioka)
<p>Currently, yield_self doesn't accept any argument other than a block.</p>
<p>But there are situations where I would like to pass a method object to yield_self.<br>
e.g.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">result</span> <span class="o">=</span> <span class="n">collection</span>
<span class="p">.</span><span class="nf">yield_self</span><span class="p">(</span><span class="o">&</span><span class="nb">method</span><span class="p">(</span><span class="ss">:filter1</span><span class="p">))</span>
<span class="p">.</span><span class="nf">yield_self</span><span class="p">(</span><span class="o">&</span><span class="nb">method</span><span class="p">(</span><span class="ss">:filter2</span><span class="p">))</span>
</code></pre>
<p>Of course, we can get the same result with</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">result</span> <span class="o">=</span> <span class="n">filter2</span><span class="p">(</span><span class="n">filter1</span><span class="p">(</span><span class="n">collection</span><span class="p">))</span>
</code></pre>
<p>but the order of reading/writing doesn't match the order of thinking.</p>
<p>My request is for yield_self to accept a proc-ish object and call to_proc on it so that we can write the code as shown below, which is more readable.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">result</span> <span class="o">=</span> <span class="n">collection</span>
<span class="p">.</span><span class="nf">yield_self</span><span class="p">(</span><span class="nb">method</span> <span class="ss">:filter1</span><span class="p">)</span>
<span class="p">.</span><span class="nf">yield_self</span><span class="p">(</span><span class="nb">method</span> <span class="ss">:filter2</span><span class="p">)</span>
</code></pre> Ruby master - Feature #14602 (Open): Version of dig that raises error if a key is not presenthttps://bugs.ruby-lang.org/issues/146022018-03-13T18:29:57Zamcaplan (Ariel Caplan)ariel.caplan@mail.yu.edu
<p>Currently, if I have a hash like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">{</span>
<span class="ss">:name</span> <span class="o">=></span> <span class="p">{</span>
<span class="ss">:first</span> <span class="o">=></span> <span class="s2">"Ariel"</span><span class="p">,</span>
<span class="ss">:last</span> <span class="o">=></span> <span class="s2">"Caplan"</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>and I want to navigate confidently and raise a KeyError if something is missing, I can do:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">hash</span><span class="p">.</span><span class="nf">fetch</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">fetch</span><span class="p">(</span><span class="ss">:first</span><span class="p">)</span>
</code></pre>
<p>Unfortunately, the length of the name, combined with the need to repeat the method name every time, means most programmers are more likely to do this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">hash</span><span class="p">[</span><span class="ss">:name</span><span class="p">][</span><span class="ss">:first</span><span class="p">]</span>
</code></pre>
<p>which leads to many unexpected errors.</p>
<p>The Hash#dig method made it easy to access methods safely from a nested hash; I'd like to have something similar for access without error protection, and I'd think the most natural name would be Hash#dig!. It would work like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">hash</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">:name</span> <span class="o">=></span> <span class="p">{</span>
<span class="ss">:first</span> <span class="o">=></span> <span class="s2">"Ariel"</span><span class="p">,</span>
<span class="ss">:last</span> <span class="o">=></span> <span class="s2">"Caplan"</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nb">hash</span><span class="p">.</span><span class="nf">dig!</span><span class="p">(</span><span class="ss">:name</span><span class="p">,</span> <span class="ss">:first</span><span class="p">)</span> <span class="c1"># => Ariel</span>
<span class="nb">hash</span><span class="p">.</span><span class="nf">dig!</span><span class="p">(</span><span class="ss">:name</span><span class="p">,</span> <span class="ss">:middle</span><span class="p">)</span> <span class="c1"># raises KeyError (key not found: :middle)</span>
<span class="nb">hash</span><span class="p">.</span><span class="nf">dig!</span><span class="p">(</span><span class="ss">:name</span><span class="p">,</span> <span class="ss">:first</span><span class="p">,</span> <span class="ss">:foo</span><span class="p">)</span> <span class="c1"># raises TypeError (String does not have #dig! method)</span>
</code></pre> Ruby master - Bug #14582 (Open): Unable to use `method__entry` and `method_return` tracing probes...https://bugs.ruby-lang.org/issues/145822018-03-07T06:23:00Zguilhermereiscampos (Guilherme Reis Campos)guilhermekbsa@gmail.com
<p>Hi,</p>
<p>I am trying to use dtrace/systemtap probes and not being able to use it after the 2.5. The 2.4 version works fine. I was hoping this was fixed on 2.6-preview, but apparently not (just downloaded dev and tested).</p>
<p>I tried on OSX using dtrace and also on ubuntu (vagrant).</p>
<pre><code># test.rb
class Foo
def bar
100.times { "Bar" }
end
end
foo = Foo.new
foo.bar
# test.stp
probe process("/home/vagrant/.rbenv/versions/2.4.0/bin/ruby").mark("method__entry") # you will need to change this to your ruby path of your version.
{
printf("%s => %s.%s in %s:%d\n", thread_indent(1), kernel_string($arg1),kernel_string($arg2),kernel_string($arg3),$arg4);
}
probe process("/home/vagrant/.rbenv/versions/2.4.0/bin/ruby").mark("method__return")
{
printf("%s <= %s.%s in %s:%d\n", thread_indent(-1), kernel_string($arg1),kernel_string($arg2),kernel_string($arg3),$arg4);
}
</code></pre>
<p>dtrace was something similar to it.</p>
<p>I was expecting to see this output:</p>
<pre><code># lots of calls
# ....
# then:
4090 ruby(9667): <= Gem::Specification.unresolved_deps in /home/vagrant/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:1298
4095 ruby(9667): => MonitorMixin.mon_exit in /home/vagrant/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:197
4100 ruby(9667): => MonitorMixin.mon_check_owner in /home/vagrant/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:247
4104 ruby(9667): <= MonitorMixin.mon_check_owner in /home/vagrant/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:251
4109 ruby(9667): <= MonitorMixin.mon_exit in /home/vagrant/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:204
4283 ruby(9667): <= Kernel.require in /home/vagrant/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55
4303 ruby(9667): <= Kernel.require in /home/vagrant/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55
0 ruby(9667): => Foo.bar in test.rb:3
16 ruby(9667): <= Foo.bar in test.rb:5
</code></pre>
<p>(The output above is 2.4)</p>
<p>my ruby (all versions that I tested) was install with rb-env:</p>
<pre><code>RUBY_CONFIGURE_OPTS='--enable-dtrace --disable-install-doc' rbenv install 2.5.0
</code></pre>
<p>I am happy to provide details if required. I'd also be happy to fix it if I have guidance.</p>
<p>Thanks,</p> Ruby master - Feature #14411 (Open): URI#secure?https://bugs.ruby-lang.org/issues/144112018-01-27T14:52:52Zartur86 (Artur *)
<p>I wonder if some predicate method (say #secure?) could be added to URI::Generic class. Currently the only way to query if uri is secure is:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">uri</span><span class="p">.</span><span class="nf">instance_of?</span><span class="p">(</span><span class="no">URI</span><span class="o">::</span><span class="no">HTTPS</span><span class="p">)</span>
</code></pre>
<p>Inspired by this question: <a href="https://stackoverflow.com/questions/2212735/ruby-checking-if-uri-is-https" class="external">https://stackoverflow.com/questions/2212735/ruby-checking-if-uri-is-https</a></p> Ruby master - Feature #14348 (Open): win32ole: enable using coclass-es with multiple IDispatch im...https://bugs.ruby-lang.org/issues/143482018-01-10T11:34:49Zgraywolf (Gray Wolf)
<p>Currently win32ole requires coclass to directly implement (one) IDispatch. That<br>
works fine for</p>
<pre><code>coclass Good {
[default] interface GoodIface2;
interface GoodIface1;
};
interface GoodIface1 : IDispatch {
// snip
};
interface GoodIface2 : GoodIface1 {
// snip
};
</code></pre>
<p>however, it fails to work for the following</p>
<pre><code>coclass Bad {
[default] interface BadIface1;
interface BadIface2;
};
interface BadIface1 : IDispatch {
// snip
};
interface BadIface2 : IDispatch {
// snip
};
</code></pre>
<p>I suspect it's because when you ask for <code>IDispatch</code> of <code>Bad</code>, it doesn't know<br>
which one to give you (but I'm no COM expert so correct me if I'm wrong).</p>
<p>Now, please let's not discuss if classes like that are good idea or not (I<br>
think they are not), fact is they do exists and simple patch allows using them<br>
with ruby's win32ole.</p>
<p>Attached patch adds new <code>iface</code> keyword argument which let's you pick interface<br>
to acquire (it must still implement <code>IDispatch</code>). Documentation also says that<br>
you <em>very</em> likely do <em>NOT</em> need to use this argument.</p>
<p>Usage in my particular case would look like this:</p>
<pre><code>LIBNAME = 'xxx'
TYPELIB = WIN32OLE_TYPELIB.new(LIBNAME)
lic = 'xxxx'
foo = WIN32OLE.new(
TYPELIB.ole_type.find { |t| t.name == 'Foo' },
nil,
license: lic,
iface: '{00000000-0000-0000-0000-000000000000}'
)
foo.Bar(1, 2, 'foobar')
</code></pre>
<p>as you can see, except for the need to specify the interface, it works exactly<br>
same as normal classes.</p>
<p>Please consider for merge <code>^_^</code></p> Ruby master - Misc #14190 (Open): What are the semantics of $SAFE?https://bugs.ruby-lang.org/issues/141902017-12-15T16:29:10ZEregon (Benoit Daloze)
<p>$SAFE is documented in many places as thread-local, but it seems more than that.<br>
For example:</p>
<pre><code># a.rb
$SAFE=1
p $SAFE
require "#{Dir.pwd.untaint}/b.rb"
# b.rb
p [:in_b, $SAFE]
</code></pre>
<p>gives:</p>
<pre><code>$ ruby -r./a -e 'p $SAFE'
1
[:in_b, 0]
0
</code></pre>
<p>So in b and in -e, $SAFE is 0.<br>
Is it file-based somehow?</p>
<p>I was trying to understand what<br>
<a href="https://github.com/ruby/ruby/blob/7c4306e6e9c3c4a255f4ad20134c1832dbe45ba2/test/rubygems/test_gem.rb#L9-L13" class="external">https://github.com/ruby/ruby/blob/7c4306e6e9c3c4a255f4ad20134c1832dbe45ba2/test/rubygems/test_gem.rb#L9-L13</a><br>
is supposed to do.<br>
Does it make sense? What does it do?<br>
It seems the test_* methods in that file actually read $SAFE as 0, not 1.</p> Ruby master - Feature #14079 (Open): Validate argument list without calling methodhttps://bugs.ruby-lang.org/issues/140792017-11-04T18:25:54Znate00 (Nate Sullivan)
<p>I would find it useful to check whether a list of arguments matches a method signature, but without calling the method.</p>
<p>I'd like to check the arguments list using a method called, for example, <code>respond_to_arguments?</code>. Here's an example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Foobar</span>
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">baz</span><span class="p">(</span><span class="n">str</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Foobar.baz accepts 1 argument, not 0 or 2:</span>
<span class="no">Foobar</span><span class="p">.</span><span class="nf">respond_to_arguments?</span><span class="p">(</span><span class="ss">:baz</span><span class="p">,</span> <span class="s2">"one"</span><span class="p">,</span> <span class="s2">"two"</span><span class="p">)</span> <span class="c1"># => false</span>
<span class="no">Foobar</span><span class="p">.</span><span class="nf">respond_to_arguments?</span><span class="p">(</span><span class="ss">:baz</span><span class="p">,</span> <span class="s2">"one"</span><span class="p">)</span> <span class="c1"># => true</span>
<span class="no">Foobar</span><span class="p">.</span><span class="nf">respond_to_arguments?</span><span class="p">(</span><span class="ss">:baz</span><span class="p">)</span> <span class="c1"># => false</span>
<span class="c1"># Indeed, we get an ArgumentError if we pass 0 or 2 arguments:</span>
<span class="no">Foobar</span><span class="p">.</span><span class="nf">baz</span><span class="p">(</span><span class="s2">"one"</span><span class="p">,</span> <span class="s2">"two"</span><span class="p">)</span> <span class="c1"># raises ArgumentError</span>
<span class="no">Foobar</span><span class="p">.</span><span class="nf">baz</span><span class="p">(</span><span class="s2">"one"</span><span class="p">)</span> <span class="c1"># success!</span>
<span class="no">Foobar</span><span class="p">.</span><span class="nf">baz</span> <span class="c1"># raises ArgumentError</span>
</code></pre>
<p>My use case is a background job processing system. It works like this: I call <code>MyWorker.perform_async</code> with some arguments; the arguments are serialized and put into a queue; and then a background worker takes those arguments from the queue, deserializes them and passes them to <code>MyWorker.perform</code>. If I passed invalid arguments, I don't know they were invalid until the background worker tries to call <code>perform</code>. But I'd like to know immediately when I call <code>perform_async</code>.</p>
<p>Perhaps a <code>respond_to_arguments_missing?</code> method would be required also.</p>
<p>Maybe <code>respond_to_arguments?</code> is a bad name. You could reasonably assume that it takes the same optional second parameter as <code>respond_to?</code> (i.e., <code>include_all</code>), but my proposal doesn't support an optional second parameter.</p>
<p>Thank you for your consideration!</p> Ruby master - Misc #14037 (Open): Writing doxygen document comments to static functionshttps://bugs.ruby-lang.org/issues/140372017-10-21T07:46:19Zsonots (Naotoshi Seo)sonots@gmail.com
<p>I often feel that C API documents are lacked in C source codes, especially for <code>static</code> functions.</p>
<p>With <a href="https://bugs.ruby-lang.org/issues/904" class="external">https://bugs.ruby-lang.org/issues/904</a>, <code>make install-capi</code> target was introduced to generate c api documents using Doxygen.<br>
However, I feel that it is not utilized among C Ruby developers.</p>
<p>I propose to turn <code>EXTRACT_STATIC = YES</code> flag of Doxygen to YES, and write document comments for static functions as much as possible.</p> Ruby master - Feature #13881 (Open): Use getcontext/setcontext on OS Xhttps://bugs.ruby-lang.org/issues/138812017-09-08T09:10:50Znaruse (Yui NARUSE)naruse@airemix.jp
<p>getcontext/setcontext is first appeared on OS X 10.5 but deprecated on 10.6.<br>
It seems because POSIX removed them from recent specs.</p>
<p>IEEE Std 1003.1, 2004 Edition says makecontext's use of function declarators with empty parentheses<br>
is an obsolescent feature.<br>
<a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/makecontext.html" class="external">http://pubs.opengroup.org/onlinepubs/009695399/functions/makecontext.html</a></p>
<p>Then POSIX.1-2008 removed those functions.</p>
<p>But OS X 10.13 still has them maybe because some essential applications uses them for co-routines.<br>
Therefore we can use them for performance.</p>
<pre><code>diff --git a/configure.in b/configure.in
index 08e109317f..3e75eb3cf2 100644
--- a/configure.in
+++ b/configure.in
@@ -1142,8 +1142,6 @@ AS_CASE(["$target_os"],
ac_cv_header_syscall_h=no
])
AS_IF([test $macosx_10_5 = yes], [
- ac_cv_func_getcontext=no
- ac_cv_func_setcontext=no
], [
AC_DEFINE(BROKEN_SETREUID, 1)
AC_DEFINE(BROKEN_SETREGID, 1)
diff --git a/cont.c b/cont.c
index c86095775c..f94883ef02 100644
--- a/cont.c
+++ b/cont.c
@@ -65,7 +65,15 @@
#ifndef _WIN32
#include <unistd.h>
#include <sys/mman.h>
-#include <ucontext.h>
+# ifdef __APPLE__
+/* avoid deprecated maks on ucontext.h */
+int getcontext(ucontext_t *);
+void makecontext(ucontext_t *, void (*)(), int, ...);
+int setcontext(const ucontext_t *);
+int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict);
+# else
+# include <ucontext.h>
+# endif
#endif
#define RB_PAGE_SIZE (pagesize)
#define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1))
</code></pre> Ruby master - Feature #13763 (Open): Trigger "unused variable warning" for unused variables in pa...https://bugs.ruby-lang.org/issues/137632017-07-24T12:16:29Zrovf (Ronald Fischer)ynnor@mm.st
<p>Consider the following program nowa.rb:</p>
<pre><code>def foo(a)
end
%w(x).each {|y|}
foo(1)
z=5
</code></pre>
<p>If I syntax-check it with <em>ruby -cw nowa.rb</em> I get the following warning:</p>
<pre><code>nowa.rb:5: warning: assigned but unused variable - z
</code></pre>
<p>Ruby complains about z, but does not complain about a and y, even though these are also variables which receive a value which never is used. I suggest to issue a warning in these cases too.</p>
<p>Tested with: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-cygwin]</p> Ruby master - Feature #12928 (Open): Use socket conect_timeout in net stdlib for open_timeouthttps://bugs.ruby-lang.org/issues/129282016-11-13T10:32:38Zxiewenwei (xie wenwei)xiewenwei@gmail.com
<p>Current net/http and net/pop use Timeout.timeout to tigger open_timeout event.<br>
Timeout.timeout is slow. It will create and destroy a thread every time.<br>
Timeout.timeout is also dangerous. see [[http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/]]</p>
<p>It is more effective and safe to use socket timeout to accomplish this.<br>
Follow is the changes need to do.</p>
<ol>
<li>Replace TCPSocket.open with Socket.new</li>
<li>Use socket.connect_nonblock and IO.select to connect and trigger timeout event.</li>
</ol>
<p>The pull request is here:<br>
[[https://github.com/ruby/ruby/pull/1480]]</p> Ruby master - Misc #12911 (Open): Translate docshttps://bugs.ruby-lang.org/issues/129112016-11-08T16:04:00Zsho-h (Sho Hashimoto)sho-h@netlab.jp
<p>translate doc/*.ja.rdoc</p>
<p>c.f. <a href="https://blade.ruby-lang.org/ruby-dev/47319">[ruby-dev:47319]</a></p> Ruby master - Feature #12625 (Open): TypeError.assert, ArgumentError.asserthttps://bugs.ruby-lang.org/issues/126252016-07-24T23:36:24Zeike.rb (Eike Dierks)eike@inter.net
<p>I am well aware that ruby is not typed (and so for a good reason)</p>
<p>But sometimes it makes sense to check the types (or values) of arguments upfront.<br>
(It actually helps to narrow down your arguments to the known)</p>
<p>I'd like to suggest an extension to all the Error types.<br>
(I should obviously come up with a gem first, but you get me)</p>
<p>I frequently write (in the prologue)<br>
raise TypeError.new(...) unless SomeClass === arg</p>
<p>I suggest to extend TypeError so that I could write instead:<br>
TypeError.assert(msg)(SomeClass, arg)<br>
and i'd expect that to raise the exception in the calling frame (which can be done via the binding?)</p>
<p>We might want to do the same for ArgumentError:<br>
ArgumentError.assert(msg){|arg| arg.nil?}<br>
ArgumentError.assert('too low'){|arg| arg<0}</p>
<p>But obviously, this api is just a first shot.</p>
<p>I'm with you: we can't check args at compile time.<br>
But checking args at runtime<br>
should be done via well known verses.</p>
<p>added bonus:<br>
we might want to make that a domain language.<br>
We could attach the argument checking rules to the method.</p>
<p>This might help in generating automated testing rules.</p>
<hr>
<p>No one wants types.<br>
but annotating types helps a lot.</p>
<p>It helps in documenting the code.<br>
It helps in making the code more foolproof.</p>
<pre><code>def foo(arg)
TypeError.assert(String, arg) # should raise in the foo frame if arg is not of type String
...
end
</code></pre> Ruby master - Feature #12589 (Open): VM performance improvement proposalhttps://bugs.ruby-lang.org/issues/125892016-07-18T03:24:41Zvmakarov (Vladimir Makarov)
<p>Hello. I'd like to start a big MRI project but I don't want to<br>
disrupt somebody else plans. Therefore I'd like to have MRI<br>
developer's opinion on the proposed project or information if somebody<br>
is already working on an analogous project.</p>
<p>Basically I want to improve overall MRI VM performance:</p>
<ul>
<li>
<p>First of all, I'd like to change VM insns and move from<br>
<strong>stack-based</strong> insns to <strong>register transfer</strong> ones. The idea behind<br>
it is to decrease VM dispatch overhead as approximately 2 times<br>
less RTL insns are necessary than stack based insns for the same<br>
program (for Ruby it is probably even less as a typical Ruby program<br>
contains a lot of method calls and the arguments are passed through<br>
the stack).</p>
<p>But <em>decreasing memory traffic</em> is even more important advantage<br>
of RTL insns as an RTL insn can address temporaries (stack) and<br>
local variables in any combination. So there is no necessity to<br>
put an insn result on the stack and then move it to a local<br>
variable or put variable value on the stack and then use it as an<br>
insn operand. Insns doing more also provide a bigger scope for C<br>
compiler optimizations.</p>
<p>The biggest changes will be in files compile.c and insns.def (they<br>
will be basically rewritten). <strong>So the project is not a new VM<br>
machine. MRI VM is much more than these 2 files.</strong></p>
<p>The disadvantage of RTL insns is a bigger insn memory footprint<br>
(which can be upto 30% more) although as I wrote there are fewer<br>
number of RTL insns.</p>
<p>Another disadvantage of RTL insns <em>specifically</em> for Ruby is that<br>
insns for call sequences will be basically the same stack based<br>
ones but only bigger as they address the stack explicitly.</p>
</li>
<li>
<p>Secondly, I'd like to <strong>combine some frequent insn sequences</strong> into<br>
bigger insns. Again it decreases insn dispatch overhead and<br>
memory traffic even more. Also it permits to remove some type<br>
checking.</p>
<p>The first thing on my mind is a sequence of a compare insn and a<br>
branch and using immediate operands besides temporary (stack) and<br>
local variables. Also it is not a trivial task for Ruby as the<br>
compare can be implemented as a method.</p>
</li>
</ul>
<p>I already did some experiments. RTL insns & combining insns permits<br>
to speed the following micro-benchmark in more 2 times:</p>
<pre><code>i = 0
while i<30_000_000 # benchmark loop 1
i += 1
end
</code></pre>
<p>The generated RTL insns for the benchmark are</p>
<pre><code>== disasm: #<ISeq:<main>@while.rb>======================================
== catch table
| catch type: break st: 0007 ed: 0020 sp: 0000 cont: 0020
| catch type: next st: 0007 ed: 0020 sp: 0000 cont: 0005
| catch type: redo st: 0007 ed: 0020 sp: 0000 cont: 0007
|------------------------------------------------------------------------
local table (size: 2, temp: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] i
0000 set_local_val 2, 0 ( 1)
0003 jump 13 ( 2)
0005 jump 13
0007 plusi <callcache>, 2, 2, 1, -1 ( 3)
0013 btlti 7, <callcache>, -1, 2, 30000000, -1 ( 2)
0020 local_ret 2, 0 ( 3)
</code></pre>
<p>In this experiment I ignored trace insns (that is another story) and a<br>
complication that a integer compare insn can be re-implemented as a<br>
Ruby method. Insn bflti is combination of LT immediate compare and<br>
branch true.</p>
<p>A modification of fib benchmark is sped up in 1.35 times:</p>
<pre><code>def fib_m n
if n < 1
1
else
fib_m(n-1) * fib_m(n-2)
end
end
fib_m(40)
</code></pre>
<p>The RTL code of fib_m looks like</p>
<pre><code>== disasm: #<ISeq:fib_m@fm.rb>==========================================
local table (size: 2, temp: 3, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] n<Arg>
0000 bflti 10, <callcache>, -1, 2, 1, -1 ( 2)
0007 val_ret 1, 16
0010 minusi <callcache>, -2, 2, 1, -2 ( 5)
0016 simple_call_self <callinfo!mid:fib_m, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, -1
0020 minusi <callcache>, -3, 2, 2, -3
0026 simple_call_self <callinfo!mid:fib_m, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, -2
0030 mult <callcache>, -1, -1, -2, -1
0036 temp_ret -1, 16
</code></pre>
<p>In reality, the improvement of most programs probably will be about<br>
10%. That is because of very dynamic nature of Ruby (a lot of calls,<br>
checks for redefinition of basic type operations, checking overflows<br>
to switch to GMP numbers). For example, integer addition can not be<br>
less than about x86-64 17 insns out of the current 50 insns on the<br>
fast path. So even if you make the rest (33) insns 2 times faster,<br>
the improvement will be only 30%.</p>
<p>A very important part of MRI performance improvement is to make calls<br>
fast because there are a lot of them in Ruby but as I read in some<br>
Koichi Sasada's presentations he pays a lot of attention to it. So I<br>
don't want to touch it.</p>
<ul>
<li>
<p>Thirdly. I want to implement the insns as small inline functions<br>
for future AOT compiler, of course, if the projects described<br>
above are successful. It will permit easy AOT generation of C code<br>
which will be basically calls of the functions.</p>
<p>I'd like to implement AOT compiler which will generate a Ruby<br>
method code, call a C compiler to generate a binary shared code<br>
and load it into MRI for subsequent calls. The key is to minimize<br>
the compilation time. There are many approaches to do it but I<br>
don't want to discuss it right now.</p>
<p>C generation is easy and most portable implementation of AOT but<br>
in future it is possible to use GCC JIT plugin or LLVM IR to<br>
decrease overhead of C scanner/parser.</p>
<p>C compiler will see a bigger scope (all method insns) to do<br>
optimizations. I think using AOT can give another 10%<br>
improvement. It is not that big again because of dynamic nature<br>
of Ruby and any C compiler is not smart enough to figure out<br>
aliasing for typical generated C program.</p>
<p>The life with the performance point of view would be easy if Ruby<br>
did not permit to redefine basic operations for basic types,<br>
e.g. plus for integer. In this case we could evaluate types of<br>
operands and results using some data flow analysis and generate<br>
faster specialized insns. Still a gradual typing if it is<br>
introduced in future versions of Ruby would help to generate such<br>
faster insns.</p>
</li>
</ul>
<p>Again I wrote this proposal for discussion as I don't want to be in<br>
a position to compete with somebody else ongoing big project. It<br>
might be counterproductive for MRI development. Especially I don't<br>
want it because the project is big and long and probably will have a<br>
lot of tehcnical obstacles and have a possibilty to be a failure.</p> Ruby master - Feature #12435 (Open): Using connect_nonblock to open TCP connections in Net::HTTP#...https://bugs.ruby-lang.org/issues/124352016-05-28T19:57:30Zmohamedhafez (Mohamed Hafez)
<p>Hey all, I've got a pull request at <a href="https://github.com/ruby/ruby/pull/1370" class="external">https://github.com/ruby/ruby/pull/1370</a> to start using connect_nonblock to open the TCP socket in Net::HTTP#connect, instead of doing a blocking connect that uses Timeout.timeout to look for timeouts. Using connect_nonblock is more efficient since it doesn't involve spinning up a separate thread to watch for timeouts, and also it avoids the race conditions inherent in the use of Timeout.timeout, as detailed in <a href="http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html" class="external">http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html</a></p>
<p>Over the last few versions of ruby there have been analogous fixes accepted to do this for opening an SSL connection in Net::HTTP#connect, so I'm guessing this shouldn't be too controversial, unless there is some issue I'm not aware of that kept the maintainers from implementing this as well...</p> Ruby master - Feature #12114 (Open): $VERBOSE = true is being ignoredhttps://bugs.ruby-lang.org/issues/121142016-02-26T11:18:06Zrovf (Ronald Fischer)ynnor@mm.st
<p>This programm correctly complains about "assigned but unused variable - p"</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1">#!/usr/bin/ruby -w</span>
<span class="nb">p</span><span class="o">=</span><span class="mi">1</span>
</code></pre>
<p>However, this one doesn't</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1">#!/usr/bin/ruby</span>
<span class="k">BEGIN</span> <span class="p">{</span><span class="vg">$VERBOSE</span> <span class="o">=</span> <span class="kp">true</span><span class="p">}</span>
<span class="nb">p</span><span class="o">=</span><span class="mi">1</span>
</code></pre>
<p>Setting <code>$VERBOSE</code> to true in a <code>BEGIN</code> block should have the same effect as providing it on the command line, but this is obviously not the case.</p> Ruby master - Feature #12086 (Open): using: option for instance_eval etc.https://bugs.ruby-lang.org/issues/120862016-02-19T07:34:02Zshugo (Shugo Maeda)
<p>Currently refinements can be activated only in toplevel or class/module definitions.<br>
If they can be activated in block-level, it's useful to implement internal DSLs.</p>
<p>How about to add a new option using: for Kernel#instance_eval and Moule#{class,module}_eval?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">module</span> <span class="nn">FixnumDivExt</span>
<span class="n">refine</span> <span class="no">Fixnum</span> <span class="k">do</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="n">quo</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="nb">p</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">2</span> <span class="c1">#=> 0</span>
<span class="nb">instance_eval</span><span class="p">(</span><span class="ss">using: </span><span class="no">FixnumDivExt</span><span class="p">)</span> <span class="k">do</span>
<span class="nb">p</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">2</span> <span class="c1">#=> (1/2)</span>
<span class="k">end</span>
<span class="nb">p</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">2</span> <span class="c1">#=> 0</span>
</code></pre>
<p>Proof-of-concept implementation is available at <a href="https://github.com/shugo/ruby/tree/eval_using" class="external">https://github.com/shugo/ruby/tree/eval_using</a>.</p>
<p>In my previous proposal before Ruby 2.0, refinements used in a class or module are<br>
implicitly activated by instance_eval and class_eval, but now I think it's better to<br>
explicitly specify refinements to be activated.</p>
<p>Considerations:</p>
<ul>
<li>In the PoC implementation, refined methods are not cached inline, and thus it decreases<br>
the performance of refined method call.<br>
If there is a way to guarantee that blocks never be evaluated in different environments,<br>
refined methods can be cached inline.</li>
<li>{instance,class,module}_exec cannot be extended in the same way, because they take arbitrary<br>
arguments and there's no way to distinguish an option hash from the last argument hash.</li>
</ul> Ruby master - Feature #11781 (Open): Would it be possible to alias .prepend() towards .unshift() ...https://bugs.ruby-lang.org/issues/117812015-12-07T10:12:22Zshevegen (Robert A. Heiler)shevegen@gmail.com
<p>Hello.</p>
<p>For Strings we can do:</p>
<pre><code>abc = 'world!'
abc[0,0] = 'Hello '
abc # => "Hello world!"
</code></pre>
<p>For Arrays we can do:</p>
<pre><code>abc = ['world!']
abc[0,0] = 'Hello '
abc # => ["Hello ", "world!"]
</code></pre>
<p>This is nice.</p>
<p>For Strings we can also use .prepend() to add to the beginning.</p>
<p>For Arrays, we have to use .unshift().</p>
<p>I have a hard time remembering .unshift though, .prepend() seems<br>
to be easier for me to remember.</p>
<p>I'd like to use both .prepend for Strings and Arrays; right now<br>
I have to use different names. I could alias prepend to unshift<br>
for class Array, but then I'd have to carry these modifications<br>
into my projects, which is not so good - I would prefer to just<br>
stick to what MRI is doing.</p>
<p>Could we have the alias .prepend() for class Array, meaning<br>
.unshift() too? That way I could use .prepend() for both Arrays<br>
and Strings.</p>
<p>Thanks for reading!</p> Ruby master - Feature #11690 (Open): Update Hash during multiple assignmenthttps://bugs.ruby-lang.org/issues/116902015-11-15T16:30:53Zdanielpclark (Daniel P. Clark)6ftdan@gmail.com
<p>Given that we can assign multiple variables at once</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">,</span><span class="n">c</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span>
</code></pre>
<p>It would be nice to be able to update a Hash during multiple assignment rather than replacing it. Currently</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">x</span> <span class="o">=</span> <span class="p">{</span><span class="ss">a: </span><span class="mi">1</span><span class="p">,</span> <span class="ss">b: </span><span class="mi">2</span><span class="p">}</span>
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="p">,</span><span class="n">z</span> <span class="o">=</span> <span class="p">{</span><span class="ss">c: </span><span class="mi">3</span><span class="p">},</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span>
<span class="n">x</span>
<span class="c1"># => {c: 3}</span>
</code></pre>
<p>What I propose is adding <code>Hash#update=</code> to permit updating during multiple assignment.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Hash</span>
<span class="k">def</span> <span class="nf">update</span><span class="o">=</span><span class="p">(</span><span class="n">h</span><span class="p">)</span>
<span class="n">update</span><span class="p">(</span><span class="n">h</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">x</span> <span class="o">=</span> <span class="p">{</span><span class="ss">a: </span><span class="mi">1</span><span class="p">,</span> <span class="ss">b: </span><span class="mi">2</span><span class="p">}</span>
<span class="n">x</span><span class="p">.</span><span class="nf">update</span><span class="p">,</span> <span class="n">y</span> <span class="p">,</span><span class="n">z</span> <span class="o">=</span> <span class="p">{</span><span class="ss">c: </span><span class="mi">3</span><span class="p">},</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span>
<span class="n">x</span>
<span class="c1"># => {a: 1, b: 2, c: 3}</span>
</code></pre>
<p>This would be most useful in scenarios where a method or proc return multiple values. When the method returns the values we don't normally know the key outside where the hash assignment is.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">example</span> <span class="o">=</span> <span class="nb">proc</span> <span class="p">{</span> <span class="p">[{</span><span class="ss">:hi</span> <span class="o">=></span> <span class="ss">:hello</span><span class="p">},</span> <span class="mi">5</span><span class="p">]</span> <span class="p">}</span>
<span class="nb">hash</span> <span class="o">=</span> <span class="p">{}</span>
<span class="c1"># Currently in Ruby with an Unknown key multiple assignment isn't an option</span>
<span class="nb">hash</span><span class="p">[</span><span class="sc">??</span><span class="p">?</span><span class="sc">?]</span><span class="p">,</span> <span class="n">current</span> <span class="o">=</span> <span class="n">example</span><span class="p">.</span><span class="nf">call</span>
<span class="c1"># We currently have to two step it</span>
<span class="n">result</span><span class="p">,</span> <span class="n">current</span> <span class="o">=</span> <span class="n">example</span><span class="p">.</span><span class="nf">call</span>
<span class="nb">hash</span><span class="p">.</span><span class="nf">update</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</code></pre>
<p>But with <code>Hash#update=</code> we don't have to know the key.</p> Ruby master - Misc #10983 (Open): Why blocks make Ruby methods 439% slower ?https://bugs.ruby-lang.org/issues/109832015-03-19T09:03:44ZSega100500 (Сергей Е)Sergey.V.Ezhov@gmail.com
<p><a href="https://www.omniref.com/ruby/2.2.0/symbols/Proc/yield#annotation=4087638&line=711&hn=1" class="external">https://www.omniref.com/ruby/2.2.0/symbols/Proc/yield#annotation=4087638&line=711&hn=1</a></p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'benchmark/ips'</span>
<span class="k">def</span> <span class="nf">block_call</span><span class="p">(</span><span class="o">&</span><span class="n">block</span><span class="p">)</span>
<span class="n">block</span><span class="p">.</span><span class="nf">call</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">just_yield</span>
<span class="k">yield</span>
<span class="k">end</span>
<span class="no">Benchmark</span><span class="p">.</span><span class="nf">ips</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">"call"</span><span class="p">)</span> <span class="k">do</span>
<span class="n">block_call</span> <span class="p">{</span> <span class="mi">1</span> <span class="o">+</span> <span class="mi">1</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">"just yield"</span><span class="p">)</span> <span class="k">do</span>
<span class="n">just_yield</span> <span class="p">{</span> <span class="mi">1</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">}</span>
<span class="k">end</span>
<span class="n">x</span><span class="p">.</span><span class="nf">compare!</span>
<span class="k">end</span>
</code></pre>
<p>I run on Ruby 2.2.1</p>
<pre><code>Calculating -------------------------------------
call 40.754k i/100ms
just yield 69.031k i/100ms
-------------------------------------------------
call 814.929k (± 4.0%) i/s - 4.075M
just yield 2.871M (±25.1%) i/s - 12.909M
Comparison:
just yield: 2871127.3 i/s
call: 814929.3 i/s - 3.52x slower
</code></pre> Ruby master - Feature #10879 (Open): UnboundMethod#to_prochttps://bugs.ruby-lang.org/issues/108792015-02-21T19:56:44ZGondolin (Damien Robert)Damien.Olivier.Robert+ruby@gmail.com
<p>Since unbound methods from modules can now be bound to any object, I use them a lot.<br>
I think it would be very natural to be able to convert them to Proc:</p>
<pre><code>module UnboundMethod
def to_proc
return lambda do |obj,*args,&b|
self.bind(obj).call(*args,&b)
end
end
end
</code></pre>
<p>This would allow things like</p>
<pre><code>module Foo
def foo
self+"foo"
end
end
["bar","baz"].map(&Foo.instance_method(:foo)) => ["barfoo", "bazfoo"]
</code></pre> Ruby master - Feature #10755 (Open): Use rb_define_alias instead of rb_define_method for rb_cHashhttps://bugs.ruby-lang.org/issues/107552015-01-18T03:10:08Zgogotanaka (Kazuki Tanaka)mail@tanakakazuki.com
<p>Hi, there.</p>
<p>The main reason for using <code>rb_define_alias</code> is generating more prefer Document and making code more readable.</p>
<p>Is there any reason <code>rb_define_method</code> is prefered to <code>rb_define_alias</code>?<br>
If so, please let me know :)<br>
If not so, I'm gonna do same thing for other part of code.</p>
<p>I've sorted some methods in terms of <code>rb_define_alias</code> being very after original.</p> Ruby master - Feature #10728 (Open): Warning for Fixnum#size to use RbConfig::SIZEOF['long']https://bugs.ruby-lang.org/issues/107282015-01-10T11:42:23Zakr (Akira Tanaka)akr@fsij.org
<p>How about add a warning for Fixnum#size ?</p>
<pre><code>% ./ruby -e 'p 0.size'
-e:1: warning: Use RbConfig::SIZEOF['long'] instead of Fixnum#size
8
</code></pre>
<p>Currently it returns sizeof(long) which is 4 or 8.</p>
<p>However it is implementation detail and<br>
it may difficult to define it in Ruby implementations other than CRuby.</p>
<p>There is a way to obtain sizeof(long): RbConfig::SIZEOF['long']<br>
It works since Ruby 2.1.</p>
<pre><code>% ruby -rrbconfig/sizeof -e "p RbConfig::SIZEOF['long']"
8
</code></pre>
<p>So the warning is a migration path to use RbConfig::SIZEOF['long'].</p>
<p>Note that this may affect many code.<br>
So this issue may irritate many people.<br>
fixnum-size-search.txt is a search result in gems.</p> Ruby master - Feature #10371 (Open): Use Thread#handle_interrupt in MonitorMixinhttps://bugs.ruby-lang.org/issues/103712014-10-12T06:41:48Znerdrew (Andrew Lazarus)nerdrew@gmail.com
<p>Now that ruby has Thread#handle_interrupt, MonitorMixin can always unlock the mutex even when a timeout exception is raised.</p>
<p>Currently, if a timeout exception is raised in MonitorMixin#mon_exit at just the wrong time, the @mon_owner is set to nil, but the @mon_mutex is still locked. ThreadError: deadlock; recursive locking is raised the next time the resource is accessed.</p> Ruby master - Feature #10251 (Open): URI: Support wildcards (globbing) in no_proxyhttps://bugs.ruby-lang.org/issues/102512014-09-17T17:24:01Zjustindossey (Justin Dossey)jbd@justindossey.com
<p>The current implementation of URI#find_proxy will only exclude exact matches when processing the no_proxy environment variable.</p>
<p>This diverges from the commonly-used no_proxy specification that supports globs (e.g. <em>.example.com, 192.168.</em>).</p>
<p>Adding globbing support (perhaps using File.fnmatch) would make URI behave the same as other implementations.</p> Ruby master - Feature #10237 (Open): Transform all elements of one Encoding into another Encoding...https://bugs.ruby-lang.org/issues/102372014-09-13T22:59:19Zshevegen (Robert A. Heiler)shevegen@gmail.com
<p>I find myself to sometimes have to convert one encoding to the other.</p>
<p>For string objects, this is trivial:</p>
<p>.encode()<br>
.force_encoding()</p>
<p>For reading in a file via File.readlines(), this is also<br>
simple because of stuff like:</p>
<p>File.readlines('test.txt', :encoding => 'ascii-8bit')</p>
<p>For Array and Hashes, however, this is a bit annoying for me.</p>
<p>I'd love to have an .encode method as well.</p>
<p>This method should try to convert all elements on an Array<br>
or a Hash to another encoding IF they are a string object.</p>
<p>I'd like to be able to treat Array and Hashes in the same<br>
way, so that I can e. g. convert a hash dictionary from<br>
one encoding to the other quickly.</p>
<p>It already is possible of course, with some extra lines<br>
of code, but I'd love to have a way to do so with just<br>
one method call.</p>
<p>:</p> Ruby master - Feature #9909 (Open): why shouldn't constant lookup check the nesting of module's namehttps://bugs.ruby-lang.org/issues/99092014-06-06T14:43:18Zrits (First Last)
<p>module A<br>
module B<br>
end<br>
end</p>
<p>above, B will have access to A's constants<br>
but below, it won't</p>
<p>module A::B<br>
end</p>
<p>is there a reason why the nesting of the name should not be part of the constant resolution algorithm?</p>
<p>when adding or reopening (deeply) nested modules/classes the :: syntax would be preferable, but you lose constant resolution</p> Ruby master - Misc #9724 (Open): Warnings in Ruby: allow per-file directives to i.e. suppress war...https://bugs.ruby-lang.org/issues/97242014-04-10T18:21:31Zshevegen (Robert A. Heiler)shevegen@gmail.com
<p>Hi,</p>
<p>A bit of intro.</p>
<p>I usually run all my ruby code with -w. I feel that it gives me some more security if the<br>
ruby parser does not have to think about ambiguous code.</p>
<p>Now this works perfect for my own code - I know what I have written, I know how to fix it,<br>
so my code runs fine.</p>
<p>Problem is other people who do not use the -w switch, and in doing so their stuff outputs<br>
a lot of warnings if I require their project and use them.</p>
<p>This is somewhat annoying and there is no real good way to fix it as far as I know.</p>
<p>Modifying $VERBOSE and setting it to nil is of no real help because it works globally.<br>
But I'd rather want something to be used on a per-file basis.</p>
<p>Would it be possible to enable something that could be used on a per file<br>
basis? Kernel.no_warnings, or Kernel.be_silent or something like this?</p> Ruby master - Feature #9613 (Open): Warn about unsafe ossl ciphershttps://bugs.ruby-lang.org/issues/96132014-03-08T03:04:48Zzzak (zzak _)
<p>As of r45274, we now have sane whitelist of available OpenSSL ciphers. However, this patch breaks backwards compatibility for any apps that use any ciphers not whitelisted.</p>
<a name="Solution"></a>
<h2 >Solution<a href="#Solution" class="wiki-anchor">¶</a></h2>
<ul>
<li>Implement a new class: OpenSSL::SSL::Ciphers
<ul>
<li>This class defines a constant for every whitelisted cipher used by DEFAULT_PARAMS[:ciphers]</li>
<li>Any constant not found within this class should raise a warning and report to the user</li>
</ul>
</li>
<li>Add an OpenSSL::SSL::Configuration class
<ul>
<li>Designed to default to no compression, and no sslv2/v3</li>
<li>Used by DEFAULT_PARAMS[:options]</li>
<li>This class may contain helper methods such as: #compression_enabled?</li>
</ul>
</li>
</ul>
<a name="Pros"></a>
<h2 >Pros<a href="#Pros" class="wiki-anchor">¶</a></h2>
<ul>
<li>We don't break anything, without warning users first</li>
<li>Maintaining future whitelist ciphers is easier</li>
<li>Future unsupported/blacklist ciphers are already dismissed</li>
<li>Users are able to extend cipher lists to support their needs (by adding a constant to OpenSSL::SSL::Ciphers)</li>
</ul>
<a name="Concerns"></a>
<h2 >Concerns<a href="#Concerns" class="wiki-anchor">¶</a></h2>
<p>I have discussed this with Martin, and we'd like to open up this discussion for feedback. We're particularly concerned about backporting r45274 as it breaks compatibility. We should also consider:</p>
<ul>
<li>Do we backport both patches or just the warning?</li>
<li>Should we bother backporting deprecation warnings?
<ul>
<li>Since r45274 is not a security fix, do we consider this a bug?</li>
<li>Rails only introduces deprecation notices in new minor releases (ie: Ruby-2.2.0)</li>
</ul>
</li>
<li>r45274 is a major change that could break existing apps, even considering security</li>
</ul> Ruby master - Feature #9401 (Open): Yet another syntax for literal anonymous functions (lambdas)https://bugs.ruby-lang.org/issues/94012014-01-12T10:44:54Zalexeymuranov (Alexey Muranov)
<p>Please do not be angry at me and just close this proposal if it does not look interesting. It comes from my aesthetic dissatisfaction with the <code>->(x){ ... }</code> literal anonymous function notation and from my amateurish interest in lambda calculus.</p>
<p>Here is a yet another syntax for literal anonymous functions (lambdas) that i propose:</p>
<pre><code>f = {\ x => x*x }
f[1] # => 1
f[2] # => 4
</code></pre>
<p>It looks a bit like a hash on purpose: i think that a hash is a "function in extension" and a lambda is a "function in intension" (see, for example, in <a href="http://www.classes.cs.uchicago.edu/archive/2004/spring/15300-1/docs/lambda-intro.pdf" class="external">these notes</a>). The backslash stands for "lambda", like in Haskell.</p> Ruby master - Feature #9174 (Open): value receiving block for Hash#has_key?https://bugs.ruby-lang.org/issues/91742013-11-29T06:33:11Zrits (First Last)
<p>Seems useful to be able to check for presence (as opposed to falsyness) and receive the value</p>
<p>class Hash<br>
def has_key?(key, &block)<br>
val = fetch(key){return false}<br>
block.(val) if block<br>
true<br>
end<br>
end</p>
<p>if h.has_key? :key do |val|</p>
<h1></h1>
<p>end; else</p>
<h1></h1>
<p>end</p> Ruby master - Feature #8404 (Open): virtual, hooked or read only global variabels for ruby only c...https://bugs.ruby-lang.org/issues/84042013-05-14T21:19:29ZHanmac (Hans Mackowiak)hanmac@gmx.de
<p>currently pure virtual or hooked global variables can only be defined with cFunctions like rb_define_virtual_variable</p>
<p>i think it would be cool if this would be possible in Ruby code too</p> Ruby master - Feature #8272 (Open): Transfer feature tracking to CommonRubyhttps://bugs.ruby-lang.org/issues/82722013-04-16T05:45:34Zheadius (Charles Nutter)headius@headius.com
<p>If my proposal in <a class="issue tracker-2 status-2 priority-4 priority-default" title="Feature: Proposal for moving to a more visible, formal process for feature requests (Assigned)" href="https://bugs.ruby-lang.org/issues/8271">#8271</a> is accepted, we'll need to:</p>
<ol>
<li>
<p>Document in appropriate places that CommonRuby is the place to file and track feature changes. Examples of such places: bugs.ruby-lang.org top-level page, pages for the existing "trunk" and version-specific Redmine projects, ruby-lang.org pages that describe how to file bugs.</p>
</li>
<li>
<p>Decide how to handle the "feature" flag in the current trackers. This may include solutions like removing it entirely (perhaps infeasible if existing features are not migrated to CommonRuby), adding a warning or error when "feature" is selected to encourage users to file under CommonRuby instead, or automatically putting "feature" issues under CommonRuby at submission time.</p>
</li>
<li>
<p>(optional) Migrate existing open features to CommonRuby.</p>
</li>
</ol> Ruby master - Feature #8061 (Open): 重複するキーワードをエラーにするhttps://bugs.ruby-lang.org/issues/80612013-03-10T09:53:22Ztadf (tadayoshi funaba)
<p>重複するキーワードをエラーにする。</p>
<p>def m(a:1, b:2)<br>
p [a, b]<br>
end</p>
<p>m(a:8, a:9)</p> Ruby master - Feature #7788 (Open): YAML Tag Schema Supporthttps://bugs.ruby-lang.org/issues/77882013-02-06T05:05:55Ztrans (Thomas Sawyer)
<p>=begin<br>
I have endeavoured to add proper Schema support to Psych (see ((<YAML Spec|URL:<a href="http://www.yaml.org/spec/1.2/spec.html#Schema%3E" class="external">http://www.yaml.org/spec/1.2/spec.html#Schema></a>)) on Schemas). The primary reasons for supporting schemas are two fold: security and global tag conflict. The first is well known b/c of recent events. The second is less realized, but consider is it same problem as using global variables. Different apps have different tags; two identical local tags may have different meanings and thus cause conflict.</p>
<p>The API works like this:</p>
<pre><code>class Foo
end
foo_schema = YAML::Schema.new do |s|
s.tag '!foo', Foo
end
YAML.load('foo.yml', :schema=>foo_schema)
</code></pre>
<p>This code would allow only failsafe and json schema tags (core defaults), plus the specifically defined !foo tag.<br>
Also, %TAG prefix is supported:</p>
<pre><code>foo_schema = YAML::Schema.new(:prefix=>{'!'=>'tag:foo.org/'}) do |s|
s.tag '!foo', Foo
end
</code></pre>
<p>This will add tag 'tag:foo.org/foo<code>instead of local</code>!foo` tag.</p>
<p>To properly support schema, object's must store the tag with which they were loaded in order to ensure correct round tripping. For this there is <code>tag_uri</code> attribute.<br>
(Note: I am not sure if it best to store as instance variable, which it currently is, or to store in global table. Need feedback.)</p>
<p>In the process of adding schema support I was able to clean up and generalize loading code. For immutable types and class factories, adding (({ClassName.new_with(coder)})) can be used to instantiate class.</p>
<p>Implementation is close to complete, I believe this is all that remains:</p>
<ol>
<li>ScalarScanner needs to respect schema (basically if failsafe and/or json schemas are not used).</li>
<li>Dumping needs to take :schema option to limit it to schema tags.</li>
<li>Dumping needs to look to tag_uri for tag by default.</li>
<li>There is one bug I have yet to figure out (test_spec_builtin_map).</li>
<li>I have questions about Coder, b/c it seems more complex than it needs to be.</li>
</ol>
<p>I am also considering refactoring Schemas as modules that can be included into other schema. Currently they are classes/objects that can be subclassed or merged via <code>+</code>, e.g.</p>
<pre><code>LEGACY_SCHEMA = CORE_SCHEMA + RUBY_SCHEMA + OBJECT_SCHEMA + SYCK_SCHEMA
</code></pre>
<p>Of course, as with any new code, there's sure to be corner cases to work out. Having other pound on it for a while would be very helpful. Oh, and I should also mention I am documenting as much of the code as can.</p>
<p>Feel free to ask me any questions for more details about the code. You can find the branch here: <a href="https://github.com/trans/psych/tree/isotag" class="external">https://github.com/trans/psych/tree/isotag</a><br>
=end</p>