96501 Commits

Author SHA1 Message Date
Luke Gruber
7e81bf5c0c
Fix sleep spurious wakeup from sigchld (#15802)
When sleeping with `sleep`, currently the main thread can get woken up from sigchld
from any thread (subprocess exited). The timer thread wakes up the main thread when this
happens, as it checks for signals. The main thread then executes the ruby sigchld handler
if one is registered and is supposed to go back to sleep immediately. This is not ideal but
it's the way it's worked for a while. In commit 8d8159e7d8 I added writes to `th->status`
before and after `wait_running_turn` in `thread_sched_to_waiting_until_wakeup`, which is
called from `sleep`. This is usually the right way to set the thread's status, but `sleep`
is an exception because the writes to `th->status` are done in `sleep_forever`. There's a
loop that checks `th->status` in `sleep_forever`. When the main thread got woken up from
sigchld it saw the changed `th->status` and continued to run the main thread instead of
going back to sleep.

The following script shows the error. It was returning instead of sleeping forever.

```ruby
t = Thread.new do
  sleep 0.3
  `echo hello`  # Spawns subprocess
  puts "Subprocess exited"
end

puts "Main thread sleeping..."
result = sleep  # Should block forever
puts "sleep returned: #{result.inspect}"
```

Fixes [Bug #21812]
2026-01-05 12:18:47 -05:00
Brandon Zylstra
c65a5548a8 Update box.md
"Code" (when used to refer to what we create in Ruby or any other programming language) is an abstract non-count noun, so it cannot be pluralized.  ("Codes" would be used when referring to specific countable things like PIN codes, which is a different use of the word "code".)

This is somewhat confusing because English allows converting count nouns into non-count nouns, and converting non-count nouns into count nouns, and because many words have both forms.

For an example of converting a non-count noun to a count noun, "water" is normally a non-count noun:

> The world is covered with water.

but people who work in restaurants often use the word as a count noun, as a shorthand for "cup of water":

> I need 7 waters on the big table by the window.

For an example of the opposite conversion, "worm" is normally a count noun:

> There are lots of worms in the puddle.

but someone might use it as a non-count noun when talking about non-distinct remains of worms:

> You have worm all over the bottom of your shoe!

So although a given noun can be flexible enough to be used in either way—even when it is unconventional—there is a definite change of meaning when using a word as a count noun or a non-count noun.
2026-01-05 17:11:06 +09:00
Nobuyoshi Nakada
3267460610 Update bindgen 2026-01-05 16:47:14 +09:00
Nobuyoshi Nakada
28b0e5125f [Bug #18433] Remove unneeded declaration
This `rb_cObject` declaration was only for `rb_cData()` that was
removed at 7c738ce5e649b82bdc1305d5c347e81886ee759a.
2026-01-05 16:47:14 +09:00
Hiroshi SHIBATA
d3ecd9d2ab [ruby/rubygems] Lock minitest ~> 5.1
https://github.com/ruby/rubygems/commit/7b9bfb4e18
2026-01-05 07:22:11 +00:00
Hiroshi SHIBATA
b87b6edf2e [ruby/rubygems] Update vendored net-http to 0.9.1
https://github.com/ruby/rubygems/commit/12072e8d23
2026-01-05 07:22:10 +00:00
Hiroshi SHIBATA
8c8561adbc [ruby/rubygems] Update vendored connection_pool to 2.5.5
https://github.com/ruby/rubygems/commit/4c1eb2b274
2026-01-05 07:22:10 +00:00
Hiroshi SHIBATA
05f791bf41 [ruby/rubygems] rake update
https://github.com/ruby/rubygems/commit/aa7632161e
2026-01-05 07:22:09 +00:00
Tsutomu Katsube
99bd18b5b8 Unskip RBS test on Windows for NoMemoryError workaround
test-unit 3.7.7 has been fixed this problem.

See also:
https://github.com/test-unit/test-unit/releases/tag/3.7.7
2026-01-05 13:48:29 +09:00
Shugo Maeda
e6762d23cb
[DOC] Fix a typo and trim trailing whitespace per .editorconfig 2026-01-05 11:49:48 +09:00
Hiroshi SHIBATA
01e8b38f60
Use RUBY_VERSION in specs instead of hardcoded 'Ruby 4.0.0' to make tests version-independent 2026-01-05 11:32:42 +09:00
Jeremy Evans
699813b65f [ruby/rubygems] Remove date require from rebuild command
As far as I can see, this isn't used.

https://github.com/ruby/rubygems/commit/67c97e7180
2026-01-05 00:58:13 +00:00
Peter Zhu
7d5c0247eb Dump fstr and frozen status in rb_raw_obj_info_buitin_type 2026-01-04 12:26:06 -05:00
Benoit Daloze
6eadc01cda Fix condition for UTF-8 default in magic_comment_spec.rb 2026-01-04 18:13:08 +01:00
Benoit Daloze
9888a3e8bd UNIXSocket#recvfrom only returns the path on Linux
* Notably it does not on BSD, macOS and Windows.
2026-01-04 18:10:42 +01:00
Benoit Daloze
2bf9543053 Remove assertion which does not hold
* https://github.com/ruby/ruby/actions/runs/20694508956/job/59407571754
  1)
  UNIXSocket.pair emulates unnamed sockets with a temporary file with a path FAILED
  Expected "C:\\a\\_temp\\102424668889-2384.($)".match? /\\AppData\\Local\\Temp\\\d+-\d+\.\(\$\)\z/
  to be truthy but was false
2026-01-04 16:04:02 +01:00
Benoit Daloze
e79f8974b5 Get better error if UNIXSocket.socketpair spec fails 2026-01-04 15:39:31 +01:00
Benoit Daloze
29e7973e05 Update to ruby/spec@94dbd55 2026-01-04 15:36:02 +01:00
Peter Zhu
6939f03f4c Add field handle_weak_references to TypedData
This commit adds a field handle_weak_references to rb_data_type_struct for
the callback when handling weak references. This avoids TypedData objects
from needing to expose their rb_data_type_struct and weak references function.
2026-01-04 09:02:40 -05:00
Benoit Daloze
1b3382cbab Update to ruby/spec@f54296d 2026-01-04 14:53:24 +01:00
Nobuyoshi Nakada
18672b392b
[DOC] Add base-url to ChangeLog by default
It is used to expand repository references to URL.
2026-01-04 16:01:27 +09:00
Augustin Gottlieb
912cf819b9 [ruby/openssl] Improve Argument Error Message in EC:Group.new
Before, passing the wrong number of arguments (e.g., 2) to
OpenSSL::PKey::EC::Group.new raised a generic "wrong number of
arguments"
error.

This change updates it to show the actual argument count and the
expected
options (1 or 4), making debugging easier for the user.

Example:
ArgumentError: wrong number of arguments (given 2, expected 1 or 4)

I hope it helps!

https://github.com/ruby/openssl/commit/783c99e6c7
2026-01-04 06:56:57 +00:00
Koichi ITO
ca0fece56a [DOC] Tweak an example in language/box.md
Although the example code comments indicate that it returns `false`,
a non-matching result for `=~` is actually `nil`.

```ruby
Foo.foo.blank? #=> false
"foo".blank?   #=> false
```

https://github.com/ruby/ruby/blob/v4.0.0-preview3/doc/language/box.md?plain=1#L115-L122

This PR replaces `=~` with `match?` so that it returns the expected `false`.
Since this makes the result a boolean, it also aligns with the expected behavior of
a predicate method name like `blank?`.
2026-01-04 12:53:42 +09:00
Koichi ITO
d8d41d7441 [DOC] Use Ruby::Box#require_relative in box.md examples
Based on the example, it appears that `foo.rb` and `main.rb` are expected to be in the same directory.
Since Ruby 1.9, the current directory is not included in `$LOAD_PATH` by default.
As a result, running `box.require('foo')` as shown in the sample code raises a `LoadError`:

```console
main.rb:2:in `Ruby::Box#require': cannot load such file -- foo (LoadError)
        from main.rb:2:in `<main>'
```

To avoid this, it seems simplest to show either `box.require('./foo')` or `box.require_relative('foo')`.
In this PR, `box.require('foo')` is replaced with `box.require_relative('foo')` to make the intention of
using a relative path explicit.

This should reduce the chance that users trying Ruby Box will run into an unexpected error.
2026-01-04 12:52:40 +09:00
Peter Zhu
5064af7ed1 [ruby/mmtk] Process obj_free candidates in parallel
Redos commit 544770d which seems to have accidentally been undone in b27d935.
2026-01-04 10:26:54 +09:00
Peter Zhu
a0c483fcfb Also output GC thread backtrace in rb_mmtk_gc_thread_bug 2026-01-03 10:43:24 -05:00
Peter Zhu
5b87294d2f Add rb_gc_print_backtrace 2026-01-03 10:43:24 -05:00
Shannon Skipper
65f9c4a06a Drop memberless Data/Struct#inspect trailing space
Anonymous memberless Structs and Data were returning `#<struct >` and
`#<data >` with a trailing space. Now they return `#<struct>` and
`#<data>` to match attrless class behavior and look a bit more compact.
2026-01-03 18:12:44 +09:00
Scott Myron
b6463d59e7 [ruby/json] Directly write to the output buffer when converting UTF32 to UTF8.
https://github.com/ruby/json/commit/a51317c949
2026-01-03 08:30:20 +00:00
Nobuyoshi Nakada
d7a6ff8224
[Bug #21819] Data objects without members should also be frozen 2026-01-03 15:03:57 +09:00
Nobuyoshi Nakada
a8a989b6f6
Test net-imap with ruby/net-imap#593
Delete test/net/imap/test_data_lite.rb, because the target of this
test file has been deleted by [ruby/net-imap#543].

[ruby/net-imap#543]: https://github.com/ruby/net-imap/pull/593
2026-01-03 13:28:58 +09:00
Peter Zhu
2f4119eaea [ruby/mmtk] Use rb_mmtk_gc_thread_bug for rb_mmtk_call_object_closure
https://github.com/ruby/mmtk/commit/308936296a
2026-01-03 00:02:22 +00:00
Peter Zhu
60d9b10dab [ruby/mmtk] Propagate crash of GC thread to mutator thread
This allows the mutator thread to dump its backtrace when a GC thread crashes.

https://github.com/ruby/mmtk/commit/40ff9ffee7
2026-01-03 00:02:22 +00:00
Jean Boussier
16feb46fa2 Convert Queue and SizedQueue to rb builtin
A large part of `thread_sync.c` was migrated already, might as well
go all the way. It also allow to remove a bunch of Rdoc commands.
2026-01-03 00:07:44 +01:00
Peter Zhu
e7695ba3d9 [ruby/mmtk] Check for T_NONE during marking
https://github.com/ruby/mmtk/commit/c3e338bb25
2026-01-02 20:42:11 +00:00
Peter Zhu
31fb970c18 [ruby/mmtk] Assert target is not pinned during normal tracing
https://github.com/ruby/mmtk/commit/58210c88ed
2026-01-02 17:58:49 +00:00
Jean Boussier
c47a8052f6 Add a test case for complex argument forward reference
Using `eval` it's possible to reference a later argument, and
this requires careful initialization of the stack.
2026-01-02 16:59:00 +01:00
Jean Boussier
1596853428 Skip initializing optional arguments to nil
They are optional because they have a default value, so I don't
understand why we'd need to initialize them to nil.
2026-01-02 16:59:00 +01:00
Peter Zhu
b9819ad06c Register a dupped identity hash as pinning 2026-01-02 08:54:56 -05:00
Jean Boussier
177949c8b2 Speedup Queue initialization
Rather than to push items one by one we can directly memcpy.
2026-01-02 13:51:36 +01:00
dependabot[bot]
11165495f4 [ruby/rubygems] Bump the rb-sys group across 2 directories with 1 update
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).

Updates `rb-sys` from 0.9.117 to 0.9.123
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.117...v0.9.123)

Updates `rb-sys` from 0.9.117 to 0.9.123
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.117...v0.9.123)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-version: 0.9.123
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
- dependency-name: rb-sys
  dependency-version: 0.9.123
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
...

Signed-off-by: dependabot[bot] <support@github.com>

https://github.com/ruby/rubygems/commit/551c665b6b
2026-01-02 08:43:54 +00:00
git
0ec5678cd5 Update bundled gems list as of 2026-01-02 2026-01-02 06:55:45 +00:00
Nobuyoshi Nakada
dd34d6273a
Extract git version only
The version message may contain other info such as the distribution.
e.g.:
```console
$ /usr/bin/git --version
git version 2.50.1 (Apple Git-155)
```
2026-01-02 13:13:40 +09:00
Nobuyoshi Nakada
0e9d698930
Prefer dedicated assertions 2026-01-02 11:40:27 +09:00
Peter Zhu
acda63debc [ruby/mmtk] Format imports to be each on a new line
https://github.com/ruby/mmtk/commit/42adba630e
2026-01-01 14:03:49 +00:00
Benoit Daloze
26a5bcd6de [ruby/prism] Fix spacing in the generated #each_child_node
https://github.com/ruby/prism/commit/91f60cb736
2026-01-01 12:30:20 +00:00
Jean Boussier
8ce61f90ba Thread::Queue use a ring buffer
Thread::Queue spends a significant amount of time in array functions,
checking for invariants we know aren't a problem, and whether the backing
array need to reordered.

By using a ring buffer we can remove a lot of overhead (~23% faster).

```
$ hyperfine './miniruby --yjit /tmp/q.rb' './miniruby-qrb --yjit /tmp/q.rb'
Benchmark 1: ./miniruby --yjit /tmp/q.rb
  Time (mean ± σ):      1.050 s ±  0.191 s    [User: 0.988 s, System: 0.004 s]
  Range (min … max):    0.984 s …  1.595 s    10 runs

Benchmark 2: ./miniruby-qrb --yjit /tmp/q.rb
  Time (mean ± σ):     844.2 ms ±   3.1 ms    [User: 840.4 ms, System: 2.8 ms]
  Range (min … max):   838.6 ms … 848.9 ms    10 runs

Summary
  ./miniruby-qrb --yjit /tmp/q.rb ran
    1.24 ± 0.23 times faster than ./miniruby --yjit /tmp/q.rb
```

```
q = Queue.new([1, 2, 3, 4, 5, 6, 7, 8])
i = 2_000_000
while i > 0
  i -= 1
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
  q.push(q.pop)
end
```
2026-01-01 10:20:08 +01:00
Peter Zhu
4129256214 Use STR_SET_SHARED in str_duplicate_setup_heap
str_duplicate_setup_heap is missing a call to rb_gc_register_pinning_obj
that STR_SET_SHARED correctly calls.
2025-12-31 21:57:01 -05:00
Nobuyoshi Nakada
ea05c23ee8 Extract RBIMPL_TYPEDDATA_PRECONDITION 2026-01-01 10:00:33 +09:00
Peter Zhu
7cf6cc83f3 Register imemo_ment as a pinning object
It sometimes pins itself when it is in the overloaded_cme table.
2025-12-31 12:47:43 -05:00