Issue #19562 has been reported by larskanis (Lars Kanis).
----------------------------------------
Bug #19562: Setting default_(in|ex)ternal encoding after running an Ractor freezes ruby
https://bugs.ruby-lang.org/issues/19562
* Author: larskanis (Lars Kanis)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
The following command blocks infinitely and must be killed with "kill -9"
```
ruby -e "Ractor.new{}.take; Encoding.default_external = Encoding::ISO8859_2"
```
Backtrace is:
```
#0 futex_wait (private=0, expected=2, futex_word=0x55555555abd0) at ../sysdeps/nptl/futex-internal.h:146
#1 __GI___lll_lock_wait (futex=futex@entry=0x55555555abd0, private=0) at ./nptl/lowlevellock.c:49
#2 0x00007ffff760a082 in lll_mutex_lock_optimized (mutex=0x55555555abd0) at ./nptl/pthread_mutex_lock.c:48
#3 ___pthread_mutex_lock (mutex=mutex@entry=0x55555555abd0) at ./nptl/pthread_mutex_lock.c:93
#4 0x00007ffff7c5a40d in rb_native_mutex_lock (lock=lock@entry=0x55555555abd0) at ruby-3.2.1/thread_pthread.c:556
#5 0x00007ffff7cc5376 in vm_lock_enter (cr=0x55555555deb0, vm=0x55555555aba0, locked=locked@entry=false, no_barrier=no_barrier@entry=false, lev=0x55555555ac00) at vm_sync.c:56
#6 0x00007ffff7cc5747 in rb_vm_lock_body () at vm_sync.c:175
#7 0x00007ffff7bc02c2 in rb_vm_lock (line=1829, file=0x7ffff7e209cb "ractor.c") at ruby-3.2.1/vm_sync.h:57
#8 ractor_check_blocking (remained_thread_cnt=<optimized out>, file=0x7ffff7e209cb "ractor.c", line=1865, cr=0x55555555deb0) at ractor.c:1829
#9 ractor_check_blocking (line=1865, file=0x7ffff7e209cb "ractor.c", remained_thread_cnt=<optimized out>, cr=0x55555555deb0) at ractor.c:1811
#10 rb_ractor_blocking_threads_inc (cr=0x55555555deb0, file=file@entry=0x7ffff7e29b04 "thread.c", line=line@entry=1488) at ractor.c:1865
#11 0x00007ffff7c60977 in blocking_region_begin (th=0x55555555d070, region=0x7fffffffd220, ubf=0x7ffff7c5b300 <ubf_select>, arg=0x55555555d070, fail_if_interrupted=<optimized out>) at thread.c:1488
#12 0x00007ffff7c61edf in rb_nogvl (func=0x7ffff7ac66e0 <no_gvl_stat>, data1=0x7fffffffd2a0, ubf=<optimized out>, data2=0x55555555d070, flags=<optimized out>) at thread.c:1548
#13 0x00007ffff7acdfbc in stat_without_gvl (st=0x7fffffffd2b0, path=0x7ffff27dfe88 "ruby-3.2.1/lib/ruby/3.2.0/x86_64-linux/enc/iso_8859_2.so") at file.c:1171
#14 rb_check_realpath_internal (basedir=basedir@entry=4, path=path@entry=140737261984200, origenc=0x555555565030, mode=mode@entry=RB_REALPATH_STRICT) at file.c:4491
#15 0x00007ffff7acebaa in rb_realpath_internal (basedir=basedir@entry=4, path=path@entry=140737261984200, strict=strict@entry=1) at file.c:4536
#16 0x00007ffff7b2cdd4 in require_internal (ec=0x55555555e1f0, fname=<optimized out>, exception=1, warn=<optimized out>) at load.c:1195
#17 0x00007ffff7aa0a17 in load_encoding (name=0x5555556049b0 "ISO-8859-2") at encoding.c:779
#18 0x00007ffff7aa2ef8 in check_encoding (enc=0x5555556049d0) at encoding.c:191
#19 enc_check_encoding (obj=140737335533800) at encoding.c:202
#20 rb_to_encoding (enc=enc@entry=140737335533800) at encoding.c:307
#21 0x00007ffff7aa4049 in enc_set_default_encoding (name=0x7ffff7de6287 "external", encoding=140737335533800, def=0x7ffff7fb00c0 <default_external>) at encoding.c:1563
#22 rb_enc_set_default_external (encoding=140737335533800) at encoding.c:1637
#23 0x00007ffff7aa411f in set_default_external (klass=<optimized out>, encoding=140737335533800) at encoding.c:1658
#24 0x00007ffff7c99037 in vm_call_cfunc_with_frame (ec=0x55555555e1f0, reg_cfp=0x7ffff6f7df90, calling=<optimized out>) at ruby-3.2.1/vm_insnhelper.c:3268
#25 0x00007ffff7ca9564 in vm_sendish (method_explorer=<optimized out>, block_handler=<optimized out>, cd=<optimized out>, reg_cfp=<optimized out>, ec=<optimized out>)
at ruby-3.2.1/vm_callinfo.h:367
#26 vm_exec_core (ec=0x55555555e1f0, initial=128) at ruby-3.2.1/insns.def:820
#27 0x00007ffff7caee93 in rb_vm_exec (ec=0x55555555e1f0, jit_enable_p=true) at vm.c:2374
#28 0x00007ffff7abfbf1 in rb_ec_exec_node (ec=ec@entry=0x55555555e1f0, n=n@entry=0x7ffff796c2c0) at eval.c:289
#29 0x00007ffff7ac60b3 in ruby_run_node (n=0x7ffff796c2c0) at eval.c:330
#30 0x0000555555555187 in rb_main (argv=0x7fffffffdb98, argc=3) at ./main.c:38
#31 main (argc=<optimized out>, argv=<optimized out>) at ./main.c:57
```
When the encoding was already loaded before running `Ractor.new`, then it works and doesn't block:
```
ruby -e "''.encode(Encoding::ISO8859_2); Ractor.new{}.take; Encoding.default_internal = Encoding::ISO8859_2"
```
When the encoding is not assigned as default encoding, but used otherwise, it works too:
```
ruby -e "Ractor.new{}.take; ''.encode(Encoding::ISO8859_2)"
```
--
https://bugs.ruby-lang.org/
Issue #19545 has been reported by hurricup (Alexandr Evstigneev).
----------------------------------------
Bug #19545: lp/hp logic parsing inconsistency
https://bugs.ruby-lang.org/issues/19545
* Author: hurricup (Alexandr Evstigneev)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
As far as i get it, low precedence logic should behave the same as high precedence. But:
This is ok:
```
puts(false || !false)
```
And this is not:
```
puts(false or not false)
```
Feels like in latter case there is some mess with comma precedence.
--
https://bugs.ruby-lang.org/
Issue #19441 has been reported by stac47 (Laurent Stacul).
----------------------------------------
Bug #19441: Closing an IO#dup behaviour
https://bugs.ruby-lang.org/issues/19441
* Author: stac47 (Laurent Stacul)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-darwin20]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
Hello amazing ruby folks!
I classified that ticket as a "Bug" although it is perhaps something I did not understand.
Here is a ruby session:
``` ruby
irb(main):001:0> file = Tempfile.new
=> #<File:/var/folders/m2/bljzrgq160vbf0vk466k_7gw0000gn/T/20230216-39664-davfmj>
irb(main):002:0> file.fileno
=> 9
irb(main):003:0> dup = file.dup
=> #<File:/var/folders/m2/bljzrgq160vbf0vk466k_7gw0000gn/T/20230216-39664-davfmj>
irb(main):004:0> dup.fileno
=> 10
irb(main):005:0> dup.close
=> nil
irb(main):006:0> dup.closed?
=> false
irb(main):007:0> file.closed?
=> true
```
The two last lines are unexpected to me. I would have expected the converse:
```ruby
irb(main):006:0> dup.closed?
=> true
irb(main):007:0> file.closed?
=> false
```
I tried this scenario in latest ruby but also in ruby 2.7.
Thanks in advance for helping me to understand this behaviour.
--
https://bugs.ruby-lang.org/
Issue #19548 has been reported by hurricup (Alexandr Evstigneev).
----------------------------------------
Bug #19548: Ambiguous and confusing syntax for alias/undef arguments
https://bugs.ruby-lang.org/issues/19548
* Author: hurricup (Alexandr Evstigneev)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
This was introduced in https://bugs.ruby-lang.org/issues/8851 and looks really confusing at least because of bare `/`.
Here are 3 semantically similar methods, but feels like first two should not be valid:
```
def method1
undef :*,<<,/,[]
alias :* /
end
def method2
undef :*,
<<,
/,
[]
alias :*
/
end
def method3
undef :*
undef :<<
undef :/
undef :[]
alias :* :/
end
puts RubyVM::InstructionSequence.of(method :method1).disasm
puts RubyVM::InstructionSequence.of(method :method2).disasm
puts RubyVM::InstructionSequence.of(method :method3).disasm
```
--
https://bugs.ruby-lang.org/
Issue #19555 has been reported by p8 (Petrik de Heus).
----------------------------------------
Feature #19555: Allow passing default options to `Data.define`
https://bugs.ruby-lang.org/issues/19555
* Author: p8 (Petrik de Heus)
* Status: Open
* Priority: Normal
----------------------------------------
Defining a subclass of `Data` with default attributes can currently be implemented by overriding `intialize`:
```ruby
class Point < Data.define(:x, :y, :z)
def initialize(x:, y:, z: 0) = super
end
p Point.new(1, 2)
#=> #<data Point x=1, y=2, z=0>
```
It would be nice if we could do it in `define` as well:
```ruby
Point = Data.define(:x, :y, z: 0)
```
--
https://bugs.ruby-lang.org/
Issue #19565 has been reported by rubyFeedback (robert heiler).
----------------------------------------
Feature #19565: Ignore lower-case/upper-case Proposal
https://bugs.ruby-lang.org/issues/19565
* Author: rubyFeedback (robert heiler)
* Status: Open
* Priority: Normal
----------------------------------------
So, first april is on the horizon and in-before-we-go (nobu tends
to make quick first april proposals, so let's hurry up!)
It is here proposed to ignore case, that is, lower-case, and upper-case,
at the least for method calls. This could be for variables too, but I
don't care so much about variables.
Rationale for the proposal:
Given a method such as
primary_link
I typoed and wrote:
primary_LINK
Of course ruby complains and insists it must be written "primary_link".
(I use that method for ad-hoc HTML hyperreferences in a webpage.)
Wouldn't it be nice if we are able to ignore this, and simply assume
that, at the least for method names, ruby would ignore the case,
that is, whether it is downcased/lowercased or upper cased?
Granted, the proposal is about 85% meant as a jest and joke, but the
15% is that this MAY be useful in SOME situations. Kind of like
we had in oldschool evil.rb; I distinctly remember we could even
change object identities at runtime too (I don't know what happened
to evil.rb, but I distinctly remember we had it during the ruby
1.8.x era or so).
I actually only propose this to be used on a per-file basis, to
simplify it.
So, for instance, you have a .rb file, and in that .rb file you
need to tell ruby that you want to ignore the case.
This could perhaps be via some configuration-call, such as:
RbConfig.ignore_case
Or something similar. Or more similar to IRB where we treat
RbConfig as a Hash via [] e. g.
RbConfig[:ignore_case] = true
Or something similar like that. Right now there is no method
defined on RbConfig, so this should not cause backwards
incompatibility issues.
Of course one can reason that this is 100% a rubbish proposal.
That's ok. Easier to suggest it when it is close to the first
april. :)
PHP works like this if I recall correctly. Windows also ignores
cases of e. g. binaries and directories if I recall correctly.
So while this proposal may be rubbish, and as stated more of a
joke, I believe there may be a few potential use cases of this
too. Kind of like the ruby user telling ruby "ruby, I know by
default you look at the case of characters, but for this
specific file or project, I want you to ignore the case".
(We could extend this to a whole namespace, e. g. per-module
and per-class, but for this proposal I want to keep it simpler
and just focus on a per-file basis, that is, on a per .rb
basis. We could also add more magic comments such as it was
with "# frozen_string_literal: true", but I think the ruby core
team does not want to add more meta-meaning, so this probably
would have zero chance to be implemented. So the focus on a
per .rb file basis just seemed simpler to me for this proposal
here.)
--
https://bugs.ruby-lang.org/
Issue #19554 has been reported by peterzhu2118 (Peter Zhu).
----------------------------------------
Bug #19554: Invalid memory access detected by Valgrind when using Fibers
https://bugs.ruby-lang.org/issues/19554
* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
This issue was originally reported here: https://github.com/Shopify/ruby_memcheck/issues/14
Running the script shown below using `valgrind --trace-children=yes --num-callers=500 ruby test.rb` outputs a lot of invalid memory access errors. I've shown a few sample errors below.
I am able to reproduce this issue on the master branch (commit [1e9a218ade](https://github.com/ruby/ruby/commit/1e9a218ade3af90c18f42e3fea0…), 3.2, 3.1, 3.0.
```ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "graphql"
end
module Example
class FooType < GraphQL::Schema::Object
field :id, ID, null: false
end
class FooSource < GraphQL::Dataloader::Source
def fetch(ids)
ids
end
end
class QueryType < GraphQL::Schema::Object
field :foo, Example::FooType do
argument :foo_id, GraphQL::Types::ID, required: false, loads: Example::FooType
end
def foo(foo: nil); end
end
class Schema < GraphQL::Schema
query Example::QueryType
use GraphQL::Dataloader
def self.object_from_id(id, ctx)
ctx.dataloader.with(Example::FooSource).request(id)
end
end
end
Example::Schema.execute(<<-GRAPHQL)
{
foo(fooId: "Other") {
id
}
}
GRAPHQL
```
```
==203957== Use of uninitialised value of size 8
==203957== at 0x3453FD: vm_exec_core (vm.inc:4411)
==203957== by 0x357EFB: rb_vm_exec (vm.c:2366)
==203957== by 0x354E44: invoke_block (vm.c:1384)
==203957== by 0x355759: invoke_iseq_block_from_c (vm.c:1440)
==203957== by 0x355759: invoke_block_from_c_proc (vm.c:1538)
==203957== by 0x355759: vm_invoke_proc (vm.c:1568)
==203957== by 0x355DF4: rb_vm_invoke_proc (vm.c:1589)
==203957== by 0x48F695: rb_fiber_start (cont.c:2513)
==203957== by 0x48CCF8: fiber_entry (cont.c:831)
==203957==
==203957== Invalid write of size 8
==203957== at 0x48C407: fiber_pool_stack_reset (cont.c:325)
==203957== by 0x48C4E9: fiber_pool_vacancy_reset (cont.c:364)
==203957== by 0x48CBB0: fiber_pool_stack_release (cont.c:752)
==203957== by 0x48CECF: fiber_stack_release (cont.c:874)
==203957== by 0x48FC9F: fiber_switch (cont.c:2726)
==203957== by 0x4901F9: fiber_resume_kw (cont.c:2906)
==203957== by 0x490235: rb_fiber_resume_kw (cont.c:2912)
==203957== by 0x4903B7: rb_fiber_m_resume (cont.c:2973)
==203957== by 0x3337D6: ractor_safe_call_cfunc_m1 (vm_insnhelper.c:3166)
==203957== by 0x33440A: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3357)
==203957== by 0x3345E1: vm_call_cfunc_with_frame (vm_insnhelper.c:3385)
==203957== by 0x3398E5: vm_sendish (vm_insnhelper.c:5225)
==203957== by 0x341203: vm_exec_core (insns.def:835)
==203957== by 0x357EFB: rb_vm_exec (vm.c:2366)
==203957== by 0x354E44: invoke_block (vm.c:1384)
==203957== by 0x355759: invoke_iseq_block_from_c (vm.c:1440)
==203957== by 0x355759: invoke_block_from_c_proc (vm.c:1538)
==203957== by 0x355759: vm_invoke_proc (vm.c:1568)
==203957== by 0x355DF4: rb_vm_invoke_proc (vm.c:1589)
==203957== by 0x48F695: rb_fiber_start (cont.c:2513)
==203957== by 0x48CCF8: fiber_entry (cont.c:831)
==203957== Address 0x9bad008 is in a rw- anonymous segment
```
--
https://bugs.ruby-lang.org/
Issue #19558 has been reported by ikaronen-relex (Ilmari Karonen).
----------------------------------------
Bug #19558: str.dump.undump crashes when str contains both Unicode and ASCII control characters
https://bugs.ruby-lang.org/issues/19558
* Author: ikaronen-relex (Ilmari Karonen)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-03-29T10:20:29Z master 02ecdf85c5) [x86_64-darwin21]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
Recently, as a result of a question I asked on Stack Overflow (https://stackoverflow.com/q/75866159), I learned about the existence of String#dump and String#undump. However, I also found what seems like a bug in them, in that apparently dumping and then undumping a string containing a sufficiently diverse selection of characters (such as at least one ASCII C0 control character and at least one non-ASCII Unicode character) causes the undump to raise a RuntimeError.
Specifically, evaluating e.g. any of the following expressions:
"\u0000\uFFFF".dump.undump
"\u0001\uABCD".dump.undump
"\u007F\u0080".dump.undump
raises a RuntimeError with the message "hex escape and Unicode escape are mixed". This contradicts the documentation of String#undump, which says that it "does the inverse of String#dump."
The behavior is the same on all Ruby versions I have tested this on, including master (3.3.0), 2.6.10 and JRuby 9.3.10.0.
The obvious fix would be to simply remove the check for mixed hex and Unicode escape sequences, essentially reverting https://github.com/ruby/ruby/commit/05d1d29d1f4a87620371463d8c7942e170be031f. However, as I don't understand why the check is there in the first place, I'm also not sure if removing it could somehow have some unwanted consequences.
--
https://bugs.ruby-lang.org/
Issue #17290 has been updated by sawa (Tsuyoshi Sawada).
I withdraw this proposal. Please close it. I came up with a better idea #19559.
----------------------------------------
Feature #17290: Syntax sugar for boolean keyword argument
https://bugs.ruby-lang.org/issues/17290#change-102585
* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
----------------------------------------
We frequently use keyword arguments just to pass `true` value out of the truthy/falsy options given. And in many such cases, the falsy option is set as the default, and only the truthy value is ever passed explicitly. I propose to have a syntax sugar to omit the value of a keyword argument. When omitted, it should be interpreted with value `true`.
```ruby
gets(chomp:)
CSV.parse(" foo var ", strip:)
```
should be equivalent to
```ruby
gets(chomp: true)
CSV.parse(" foo var ", strip: true)
```
Additionally, we may also extend this to pragmas.
```ruby
# frozen_string_literal:
```
to be equivalent to:
```ruby
# frozen_string_literal: true
```
--
https://bugs.ruby-lang.org/