Commit graph

20692 commits

Author SHA1 Message Date
John Hawthorn
f483befd90 Add shape_id to RBasic under 32 bit
This makes `RBobject` `4B` larger on 32 bit systems
but simplifies the implementation a lot.

[Feature #21353]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2025-05-26 10:31:54 +02:00
dependabot[bot]
874469e7ce
[rubygems/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.111 to 0.9.115
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.111...v0.9.115)

Updates `rb-sys` from 0.9.111 to 0.9.115
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.111...v0.9.115)

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

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

a7c0ff5641
2025-05-26 11:46:13 +09:00
Jean Boussier
f171a263f7
[ruby/json] Fix: generate_json_float to reserve enough memory for large negative floats.
Fix: https://github.com/ruby/json/issues/807

Since https://github.com/ruby/json/pull/800, `fpconv_dtoa` can actually
generate up to 28 chars.

d73ae93d3c
2025-05-26 11:46:12 +09:00
Étienne Barrié
2a951f62e1 Change test to avoid stack overflow with MN threads
When using MN threads (such as running the test in a ractor), this test
failed because it was raising a SystemStackError: stack level too deep.

This is because the machine stack is smaller under MN threads than on
the native main thread.
2025-05-23 21:28:16 +02:00
Luke Gruber
f64c89f18d Fix 'require' from a ractor when the required file raises an error
If you catch an error that was raised from a file you required in
a ractor, that error did not have its belonging reset from the main
ractor to the current ractor, so you hit assertion errors in debug
mode.
2025-05-23 21:13:23 +02:00
Koichi Sasada
64c520fc25 skip the test now we couldn't fix
The following error is reported repeatedly on my riscv64-linux machine, so just skipt it.
I hope someone investigate it.

```
  1) Error:
TestStruct::SubStruct#test_named_structs_are_not_rooted:
Test::Unit::ProxyError: execution of Test::Unit::CoreAssertions#assert_no_memory_leak expired timeout (10 sec)
pid 1113858 killed by SIGTERM (signal 15)
| ruby 3.5.0dev (2025-05-22T21:05:12Z master 9583b7af8f) +PRISM [riscv64-linux]
|
| [7;1m1096282:1747967727.622:d70f:[mSTART={peak:453828608,size:453763072,lck:0,pin:0,hwm:9601024,rss:9601024,data:445943808,stk:135168,exe:4096,lib:7450624,pte:77824,swap:0}
| [7;1m1096282:1747967727.622:d70f:[mFINAL={peak:457502720,size:457498624,lck:0,pin:0,hwm:13312000,rss:13312000,data:449679360,stk:135168,exe:4096,lib:7450624,pte:86016,swap:0}
```
2025-05-23 15:03:10 +09:00
Samuel Williams
73c9d6ccaa
Allow IO#close to interrupt IO operations on fibers using fiber_interrupt hook. (#12839) 2025-05-23 14:55:05 +09:00
Daniel Colson
0564973196 [Bug #21357] Fix crash in Hash#merge with block
Prior to 49b306ecb9
the `optional_arg` passed from `rb_hash_update_block_i` to `tbl_update`
was a hash value (i.e. a VALUE). After that commit it changed to an
`update_call_args`.

If the block sets or changes the value, `tbl_update_modify` will set the
`arg.value` back to an actual value and we won't crash. But in the case
where the block returns the original value we end up calling
`RB_OBJ_WRITTEN` with the `update_call_args` which is not expected and
may crash.

`arg.value` appears to only be used to pass to `RB_OBJ_WRITTEN` (others
who need the `update_call_args` get it from `arg.arg`), so I don't think
it needs to be set to anything upfront. And `tbl_update_modify` will set
the `arg.value` in the cases we need the write barrier.
2025-05-22 12:25:55 +09:00
John Hawthorn
7b10660974 Use rb_inspect for Ractor error
Previously the object was used directly, which calls `to_s` if defined.
We should use rb_inspect to get a value suitable for display to the
programmer.
2025-05-21 12:23:14 -07:00
Richard Böhme
9a41d76b83 Fix one-by-one error of numbered parameter ID 2025-05-21 22:12:34 +09:00
Nathan Ladd
3ac239f790 [rubygems/rubygems] Copy prerelease attribute to dependency resolver sets
5956e7f8e5
2025-05-21 11:33:32 +09:00
Aaron Patterson
1c66124273 Make Addrinfo objects Ractor shareable
Allow Addrinfo objects to be shared among Ractors.  Addrinfo objects are
already immutable, so I think it's safe for us to tag them as
RUBY_TYPED_FROZEN_SHAREABLE shareable too.
2025-05-20 18:04:37 -07:00
Jeremy Evans
c52f4eea56 Remove SortedSet autoload and set/sorted_set
Implements [Feature #21287]
2025-05-20 13:34:31 +09:00
Grant Birkinbine
dc69bebde7
[ruby/json] Update json_encoding_test.rb
0ac54a8161
2025-05-19 11:19:17 +09:00
Cody Horton
3468811ed1
[ruby/json] fix for pretty_generate throwing wrong number of arguments error
8433571dcf
2025-05-19 11:19:17 +09:00
Samuel Giddins
4be199e435 [rubygems/rubygems] Simplify Gem::Platform#initialize
Based on PR feedback

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>

562d7aa087
2025-05-19 11:15:29 +09:00
Samuel Giddins
eb48418b40 [rubygems/rubygems] Ensure that Gem::Platform parses strings to a fix point
The issue was that the property that

```ruby
platform = Gem::Platform.new $string
platform == Gem::Platform.new(platform.to_s)
```

was not always true.

This property (of acchieving a fix point) is important,
since `Gem::Platform` gets serialized to a string and
then deserialized back to a `Gem::Platform` object.
If it doesn't deserialize to the same object, then
different platforms are used for the initial serialization
than subsequent runs.

I used https://github.com/segiddins/Scratch/blob/main/2025/03/rubygems-platform.rb
to find the failing cases and then fixed them.
With this patch, the prop check test now passes.

313fb4bcec
2025-05-19 11:15:28 +09:00
Jean Boussier
ec8900e3eb rb_gc_impl_copy_finalizer: generate a new object id
Fix a regression introduced by: https://github.com/ruby/ruby/pull/13155
2025-05-16 20:16:52 +02:00
Jean Boussier
a294427017 Add missing lock to rb_gc_impl_copy_finalizer 2025-05-16 20:16:52 +02:00
Daniel Colson
eead83160b
Prevent enabling yjit when zjit enabled (GH-13358)
`ruby --yjit --zjit` already warns and exits, but it was still possible
to enable both with `ruby --zjit -e 'RubyVM:YJIT.enable`.

This commit prevents that with a warning and an early return. (We could
also exit, but that seems a bit unfriendly once we're already running
the program.)

Co-authored-by: ywenc <ywenc@github.com>
2025-05-16 17:31:43 +00:00
Nick Dower
c5c252c067 Add a test case for it in a regex.
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-05-17 00:17:21 +09:00
Nick Dower
4921845b61 [Bug #21313] Handle it in rescue and ensure blocks.
The following is crashing for me:

```shell
ruby --yjit --yjit-call-threshold=1 -e '1.tap { raise rescue p it }'

ruby: YJIT has panicked. More info to follow...
thread '<unnamed>' panicked at ./yjit/src/codegen.rs:2402:14:
...
```

It seems `it` sometimes points to the wrong value:

```shell
ruby -e '1.tap { raise rescue p it }'
false

ruby -e '1.tap { begin; raise; ensure; p it; end } rescue nil'
false
```

But only when `$!` is set:

```shell
ruby -e '1.tap { begin; nil; ensure; p it; end }'
1

ruby -e '1.tap { begin; nil; rescue; ensure; p it; end }'
1

ruby -e '1.tap { begin; raise; rescue; ensure; p it; end }'
1
```
2025-05-17 00:17:21 +09:00
Nobuyoshi Nakada
097d742a1e [Bug #20009] Support marshaling non-ASCII name class/module 2025-05-16 21:22:33 +09:00
Hiroya Fujinami
35000ac2ed
Prevent double free for too big repetition quantifiers (#13332)
Prevent double free for too big repetition quantifiers

The previous implementation calls `free(node)` twice (on parsing and compiling a
regexp) when it has an error, so it leads to a double-free issue. This
commit enforces `free(node)` once by introducing a temporal pointer to hold
parsing nodes.
2025-05-16 10:14:26 +09:00
Aaron Patterson
55c9c75b47 Maintain same behavior regardless of tracepoint state
Always use opt_new behavior regardless of tracepoint state.
2025-05-15 14:19:48 -07:00
Samuel Chiang
0b9644c252 [ruby/openssl] AWS-LC has support for parsing ber constructed strings now
cdfc08db50
2025-05-15 16:40:42 +00:00
Jean Boussier
ed632cd0ba Add missing lock in rb_gc_impl_undefine_finalizer
The table is global so accesses must be synchronized.
2025-05-15 13:32:08 +02:00
Samuel Williams
87261c2d95
Ensure that forked process do not see invalid blocking operations. (#13343) 2025-05-15 15:50:15 +09:00
Nobuyoshi Nakada
49b306ecb9 [Bug #21333] Prohibit hash modification inside Hash#update block 2025-05-15 15:39:15 +09:00
David Rodríguez
a89460a8a0
[rubygems/rubygems] Reenable skipped specs in truffleruby since they should be fixed
a7cbec95c1
2025-05-14 15:13:45 +09:00
Nobuyoshi Nakada
7793b59c8d
[Bug #21331] Prohibit hash modification during stlike loop 2025-05-14 10:37:59 +09:00
Nobuyoshi Nakada
b66c5c3b1b
Revert "[Bug #21331] Prohibit modification during stlike loop"
This reverts commit bb180b87b4, which
caused "malloc during GC" error on wasm.
2025-05-14 10:23:16 +09:00
Nobuyoshi Nakada
bb180b87b4 [Bug #21331] Prohibit modification during stlike loop 2025-05-13 23:16:58 +09:00
Samuel Williams
425fa0aeb5
Make waiting_fd behaviour per-IO. (#13127)
- `rb_thread_fd_close` is deprecated and now a no-op.
- IO operations (including close) no longer take a vm-wide lock.
2025-05-13 19:02:03 +09:00
Jean Boussier
a6435befa7 variable.c: Refactor rb_obj_field_* to take shape_id_t 2025-05-13 10:35:34 +02:00
Jean Boussier
cd7495a1d0 [ruby/json] Further improve parsing errors
Report EOF when applicable instead of an empty fragment.

Also stop fragment extraction on first whitespace.

cc1daba860
2025-05-13 14:12:22 +09:00
Jean Boussier
50ef208369 [ruby/json] parser.c: include line and column in error messages
30e35b9ba5
2025-05-13 14:12:22 +09:00
Jeremy Evans
18d395e078 [ruby/stringio] Do not issue warning when calling set_encoding if string is chilled
StringIO does not warn for unchilled unfrozen string or for frozen
string, so it should not warn for chilled string.

4ac33b8c70
2025-05-13 03:20:09 +00:00
John Hawthorn
b0502e8f90 Remove respond_to check from Class#bind_call 2025-05-12 14:10:29 -07:00
Earlopain
0c94ae048a [ruby/psych] Fix dumping StringIO (and potentially others) on Ruby <= 2.7
In Ruby < 3.0, the superclass of StringIO was actually already `Data`,
but it doesn't have the expected shape. So, on these earlier versions it errors:
> NoMethodError: undefined method `members' for #<StringIO:0x00005641dd5f2880>
>    vendor/bundle/ruby/2.6.0/gems/psych-5.2.5/lib/psych/visitors/yaml_tree.rb:170:in `visit_Data'

This test doesn't fail on 2.7, presumably because it can pull in a newer `stringio` version.

0f40f56268
2025-05-12 16:19:38 +00:00
Takashi Kokubun
53a27f114a
YJIT: Split the block on optimized getlocal/setlocal (#13282) 2025-05-12 09:03:46 -07:00
Jean Boussier
131ba059ca test_object_id.rb: use better randomness
When the test is repeated 20 or more times in the same process
it's not that unlikely for `rand(100_000)` to return the same thing
twice, causing `TestObjectIdTooComplexClass` to fail.

```
  1) Failure:
TestObjectIdTooComplexClass#test_dup_with_id_and_ivar [/tmp/ruby/src/trunk-repeat20-asserts/test/ruby/test_object_id.rb:172]:
Expected #<struct RubyVM::Shape
 id=6783,
 parent_id=6774,
 edge_name=:@___26417,
 next_field_index=2,
 heap_index=0,
 type=1,
 capacity=7> to be too_complex?.
```
2025-05-12 09:49:59 +02:00
Jean Boussier
af79914002 [ruby/json] Favor decimal notation over scientific notation for floats
e.g.
```
JSON.dump(1746861937.7842371)
```

master:
```
"1.7468619377+9"
```

This branch and older json versions:
```
1746861937.7842371
```

In the end it's shorter, and according to `canada.json` benchmark
performance is the same.

866f72a437
2025-05-12 11:09:11 +09:00
Jean Boussier
f2e5f6dbb6 Allow T_CLASS and generic types to be too_complex
The intial complex shape implementation never allowed objects
other than T_OBJECT to become too complex, unless we run out of
shapes.

I don't see any reason to prevent that.

Ref: https://github.com/ruby/ruby/pull/6931
2025-05-11 19:35:58 +02:00
Satoshi Tagomori
b132322e94 Skip mmtk/i686 tests for a while 2025-05-11 23:32:50 +09:00
Satoshi Tagomori
f24ba27d6d avoid calling ZALLOC after NEWOBJ_OF for RClass: need to return RClass not promoted 2025-05-11 23:32:50 +09:00
Satoshi Tagomori
382645d440 namespace on read 2025-05-11 23:32:50 +09:00
OrenGitHub
e2f5e233b5 [ruby/psych] exception tests
1e9b79f699
2025-05-09 17:53:18 +00:00
OrenGitHub
42328d4ef4 [ruby/psych] more special cases
b33bf8b060
2025-05-09 17:53:18 +00:00
OrenGitHub
451e1dcf31 [ruby/psych] duplicate more tests
a3be6429bf
2025-05-09 17:53:17 +00:00