The id2ref table could contain dead entries which should not be passed
into rb_gc_location. Also, we already update references in gc_update_references
using rb_gc_vm_weak_table_foreach so we do not need to update it again.
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>
The `ractor_wakeup` function takes an optional `th` argument, so it can be NULL.
There is a macro call to RUBY_DEBUG_LOG that dereferences `th` without checking
if it's NULL first. To fix this, we never dereference `th` in this macro call.
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.
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.
Superclasses can't be modified by user code, so do not need namespace
indirection. For example Object.superclass is always BasicObject, no
matter what modules are included onto it.
The FL_PROMOTED flag was not copied when moving objects, causing assertions
to fail when an old object is moved:
gc/default/default.c:834: Assertion Failed: RVALUE_AGE_SET:age <= RVALUE_OLD_AGE
Co-Authored-By: Luke Gruber <luke.gruber@shopify.com>
The current implementation of the visitor pattern in Prism uses
a single method (`visit_child_nodes`) to handle all node types. This can lead to performance issues since the `node` argument will end up being polymorphic, and will prevent effective use of inline caches, which in CRuby are monomorphic.
This commit generates an inlined version of the previous code for each node type, thus making the calls inside visitor methods monomorphic. This should improve performance, especially in cases where the visitor is called frequently.
https://github.com/ruby/prism/commit/60d324a701
Currently, this can be reproduced by:
r = Ractor.new do
a = [1, 2, 3]
a.object_id
a.dup # this frees the generic ivar for `object_id` on the copied object
:done
end
r.take
In debug builds, this hits an assertion failure without this 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}
```
`ext` is newly allocated so it shouldn't need an assertion. The class
ext (which is always from the module) that we're passing to
`class_duplicate_iclass_classext` could legitimately have instance
variables on it. We just want to avoid copying them.
The assertion was making this crash:
```
$ RUBY_NAMESPACE=1 ./miniruby -e1
```