Issue #19416 has been reported by herwin (Herwin W).
----------------------------------------
Bug #19416: Inconsistent behaviour for Struct.new without any member_names
https://bugs.ruby-lang.org/issues/19416
* Author: herwin (Herwin W)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
When I simply declare a Struct without any arguments, I get an error:
```
irb(main):001:0> Struct.new
(irb):1:in `new': wrong number of arguments (given 0, expected 1+) (ArgumentError)
from (irb):1:in `<main>'
```
But Struct has an option to pass a class name as the first argument, which will create the struct as a constant in the Struct namespace. If this argument is given, there is no ArgumentError
```
irb(main):002:0> Struct.new('Foo')
=> Struct::Foo
```
This results in a rather pointless class
```
irb(main):003:0> Struct::Foo.new(1)
(irb):3:in `initialize': struct size differs (ArgumentError)
from (irb):3:in `new'
irb(main):004:0> Struct::Foo.new
=> #<struct Struct::Foo>
```
This behaviour is not documented in the Struct class, but I would guess this is not how it is intended to be.
--
https://bugs.ruby-lang.org/
Issue #19467 has been reported by tompng (tomoya ishida).
----------------------------------------
Bug #19467: Some linear_time regexp does not match in linear time
https://bugs.ruby-lang.org/issues/19467
* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-02-17T18:10:16Z master c3bae033eb) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
`Regexp.linear_time?(/\A.*a.*x\z/) #=> true` but it does not match in linear time
~~~ruby
Regexp.linear_time? /\A(.*a.*)x\z/ #=> true
/\A(.*a.*)x\z/ =~ 'a'*100000+'y' #=> nil, processing time: 0.016995s
Regexp.linear_time? /\A.*a.*x\z/ #=> true
/\A.*a.*x\z/ =~ 'a'*100000+'y' #=> nil, processing time: 21.479335s
~~~
--
https://bugs.ruby-lang.org/
Issue #19445 has been reported by hsbt (Hiroshi SHIBATA).
----------------------------------------
Bug #19445: Segmentation fault with Numeric#step
https://bugs.ruby-lang.org/issues/19445
* Author: hsbt (Hiroshi SHIBATA)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
The following commands will cause a segmentation fault.
```
curl -s 'https://cache.ruby-lang.org/pub/misc/ci_versions/all.json' -o ruby_versions.json
ruby -rjson -e "min = JSON.parse(File.read('ruby_versions.json')).sort.first; p 2.2.step(by: 0.1, to: min).map{|v| v.round(1).to_s }"
```
Note: above code is working with `min.to_f` instead of `min` in `Numeric#step`.
--
https://bugs.ruby-lang.org/
Issue #19415 has been reported by fxn (Xavier Noria).
----------------------------------------
Bug #19415: Incorrect circularity warning for concurrent requires
https://bugs.ruby-lang.org/issues/19415
* Author: fxn (Xavier Noria)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
This script performs 5 concurrent `require` calls to the same file:
```ruby
threads = []
5.times do
threads << Thread.new {
p require 'bar'
}
end
threads.each(&:join)
```
The file `bar.rb` is simply
```ruby
sleep 0.1
```
Now, if you execute the main script with warnings enabled:
```
ruby -W2 -I. foo.rb
```
you'll see one `true` and four `false` as expected. But also four warnings:
```
circular require considered harmful - /Users/fxn/tmp/bar.rb
```
As you see, there isn't really a circular `require` going on, so the warning itself is incorrect. On the other hand, concurrent `require` calls for the same file is something routinely happening and supported.
I'd suggest that script should issue no warning.
--
https://bugs.ruby-lang.org/
Issue #19403 has been reported by jcouball(a)yahoo.com (James Couball).
----------------------------------------
Bug #19403: Unable to Build Native Gems on Mac with Ruby 3.1.0+
https://bugs.ruby-lang.org/issues/19403
* Author: jcouball(a)yahoo.com (James Couball)
* Status: Open
* Priority: Normal
* ruby -v: 3.2.0
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
# Unable to Build Native Gems on Mac with Ruby 3.1.0+
## Problem
In Ruby 3.1 and later installed by `rvm` or `asdf` on a Mac, `require 'mkmf'` aborts
the script and reports the following error (the reported path is different depending
on the Ruby install manager and the version of Ruby):
```text
mkmf.rb can't find header files for ruby at /Users/couballj/.asdf/installs/ruby/3.2.0/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
```
and `RbConfig::CONFIG["rubyhdrdir"]` is set to an incorrect path:
```text
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Users/couballj/.asdf/installs/ruby/3.2.0/include/ruby-3.2.0"
```
## Expected Behavior
Running `require 'mkmf'` should not abort and for my system/user using `asdf` installed
Ruby 3.2.0 `RbConfig::CONFIG["rubyhdrdir"]` should be set to:
```text
"/Users/couballj/.asdf/installs/ruby/3.2.0/include/ruby-3.2.0"
```
## Details
In Ruby 3.1 and later I can no longer build native gems (like nokoguru or redcarpet)
on my Mac.
I have tried this by installing Ruby with both `rvm` and `asdf`, both which have
the same results.
I receive the following error when trying to install (and build) these gems. For
example, here is the error message when I try to run `gem install redcarpet`:
```text
mkmf.rb can't find header files for ruby at /Users/couballj/.asdf/installs/ruby/3.2.0/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
```
I found that this error could be triggered just by running a Ruby script that requires
`mkmf`. If `test.rb` contains this:
```ruby
require 'mkmf'
```
Running this script:
`ruby test.rb`
Results in this output:
```text
mkmf.rb can't find header files for ruby at /Users/couballj/.asdf/installs/ruby/3.2.0/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
```
Curiously, the reported directory does not exist. On my system, the path to `ruby.h`
is `/Users/couballj/.asdf/installs/ruby/3.2.0/include/ruby-3.2.0/ruby.h`
I found where in the Ruby code this error is reported in [mkmf.rb line 233](https://github.com/ruby/ruby/blob/master/lib/mkmf.rb#L224-L233).
This code is trying to find `ruby.h` based on the value of `RbConfig::CONFIG["rubyhdrdir"]`.
On my system, this value is:
```ruby
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Users/couballj/.asdf/installs/ruby/3.2.0/include/ruby-3.2.0"
```
This value is a concatenation of `ENV['SDKROOT']` (which on my system is `/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk`)
and the correct include directory path `/Users/couballj/.asdf/installs/ruby/3.2.0/include/ruby-3.2.0`.
When I run the same code with Ruby 2.7.7, `RbConfig::CONFIG["rubyhdrdir"]` is set to the correct path:
```ruby
"/Users/couballj/.asdf/installs/ruby/3.2.0/include/ruby-3.2.0"
```
## Possible Cause
I have found a possible cause in [commit fd97862](https://github.com/ruby/ruby/commit/fd978621ccbc9519afc05ad031ba25…
in line 127 of mkconfig.rb. This change prepends `ENV['SDKROOT']` to the include directory that
is used to build `RbConfig::CONFIG["rubyhdrdir"]`.
While there may have been good reason for that change, in my case this change causes
`require 'mkmf'` to fail in my use case.
## Work Around
I have been able to work around this issue by creating a symbolic link from
`/Users /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Users` to `/Users`
with the following command:
```shell
sudo ln -s /Users /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Users
```
This change will works for both `rvm` and `asdf` no matter what version of Ruby is
installed.
--
https://bugs.ruby-lang.org/
Issue #19398 has been reported by peterzhu2118 (Peter Zhu).
----------------------------------------
Bug #19398: Memory leak in WeakMap
https://bugs.ruby-lang.org/issues/19398
* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
Pull request: https://github.com/ruby/ruby/pull/7223
There's a memory leak in ObjectSpace::WeakMap due to not freeing the `struct weakmap`. It can be seen in the following script:
```ruby
100.times do
10000.times do
ObjectSpace::WeakMap.new
end
# Output the Resident Set Size (memory usage, in KB) of the current Ruby process
puts `ps -o rss= -p #{$$}`
end
```
This is the memory usage graph before and after the patch:
![](chart.png)
---Files--------------------------------
chart.png (26.9 KB)
--
https://bugs.ruby-lang.org/
Issue #19284 has been reported by zeke (Zeke Gabrielse).
----------------------------------------
Bug #19284: Integer overflow when using RUBY_GC_HEAP_INIT_SLOTS environment variable
https://bugs.ruby-lang.org/issues/19284
* Author: zeke (Zeke Gabrielse)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-darwin19]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
If you set the environment variable `RUBY_GC_HEAP_INIT_SLOTS` to anything other than `0`, an integer overflow runtime error occurs:
```ruby
RUBY_GC_HEAP_INIT_SLOTS=2 ruby -e 'puts "hello, world!"'
# => integer overflow: 3689348814741910508 * 8 > 18446744073709551615 (RuntimeError)
```
At this time, I'm not sure if this is platform-specific.
--
https://bugs.ruby-lang.org/
Issue #19320 has been reported by peterzhu2118 (Peter Zhu).
----------------------------------------
Bug #19320: Crash during compaction while traversing the stack
https://bugs.ruby-lang.org/issues/19320
* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
Fix PR: https://github.com/ruby/ruby/pull/7081
Applying the following patch to test/erb/test_erb.rb and running that file will cause Ruby to crash on my machine (macOS 13.1 on M1 Pro):
```diff
--- a/test/erb/test_erb.rb
+++ b/test/erb/test_erb.rb
@@ -7,6 +7,12 @@
class TestERB < Test::Unit::TestCase
class MyError < RuntimeError ; end
+ def setup
+ GC.auto_compact = true
+ GC.stress = true
+ GC.verify_compaction_references(expand_heap: true, toward: :empty)
+ end
+
```
It crashes with the following log:
```
/Users/peter/src/ruby/lib/erb/compiler.rb:276: [BUG] Segmentation fault at 0x00000001083a8690
...
-- C level backtrace information -------------------------------------------
...
/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
/Users/peter/src/ruby/build/ruby(check_stack_for_moved+0x2c) [0x104b272a4] ../gc.c:5512
/Users/peter/src/ruby/build/ruby(gc_compact_finish) ../gc.c:5534
/Users/peter/src/ruby/build/ruby(gc_sweep_compact) ../gc.c:8653
/Users/peter/src/ruby/build/ruby(gc_sweep) ../gc.c:6196
/Users/peter/src/ruby/build/ruby(has_sweeping_pages+0x0) [0x104b19c54] ../gc.c:9568
/Users/peter/src/ruby/build/ruby(gc_rest) ../gc.c:9570
```
This crash happens because it's reading the VALUE at sp. But since sp points to the top of the stack, it's reading the VALUE above the top of the stack, which is causing this segfault.
I can repro this crash in Ruby 3.2.0, but looking at the code I think it can happen in Ruby 3.1 and 3.0 as well.
--
https://bugs.ruby-lang.org/