Commit graph

93002 commits

Author SHA1 Message Date
Samuel Williams
64f508ade8
Support cause: in Thread#raise and Fiber#raise. (#13967)
* Add support for `cause:` argument to `Fiber#raise` and `Thread#raise`.

The implementation behaviour is consistent with `Kernel#raise` and
`Exception#initialize` methods, allowing the `cause:` argument to be
passed to `Fiber#raise` and `Thread#raise`. This change ensures that
the `cause:` argument is handled correctly, providing a more consistent
and expected behavior when raising exceptions in fibers and threads.

[Feature #21360]

* Shared specs for Fiber/Thread/Kernel raise.

---------

Co-authored-by: Samuel Williams <samuel.williams@shopify.com>
2025-07-24 14:45:43 +12:00
Stan Lo
2e0a782936 ZJIT: Run zjit-check on CI for faster test_zjit.rb feedback 2025-07-23 19:52:59 -04:00
Stan Lo
f27e8b11cb ZJIT: Add multiple exclude targets 2025-07-23 19:52:59 -04:00
Stan Lo
3504eba9b8 ZJIT: Start testing againt /test 2025-07-23 19:52:59 -04:00
John Hawthorn
9256442615 Cleanup M_TBL workarounds and comments
Previously we had an assertion that the method table was only set on
young objects, and a comment stating that was how it needed to be used.
I think that confused the complexity of the write barriers that may be
needed here.

* Setting an empty M_TBL never needs a write barrier
* T_CLASS and T_MODULE should always fire a write barrier to newly added
  methods
* T_ICLASS only needs a write barrier to methods when
  RCLASSEXT_ICLASS_IS_ORIGIN(x) && !RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(x)

We shouldn't assume that the object being young is sufficient, because
we also need write barriers for incremental marking and it's unreliable.
2025-07-23 14:33:55 -07:00
John Hawthorn
d67eb07f75 Fix missing write barrier through M_TBL
When creating a new origin in ensure_origin, we need to fire a write
barrier after RCLASS_WRITE_ORIGIN. rb_class_set_super allocates, so GC
could happen there, either incrementally marking or promoting the newly
allocated class, and only after RCLASS_WRITE_ORIGIN will origin mark
object in the M_TBL.
2025-07-23 14:33:55 -07:00
BurdetteLamar
54a578e72a [DOC] Tweaks for String#encoding 2025-07-23 17:09:33 -04:00
Burdette Lamar
56572baa4c
[DOC] Tweaks for String#each_grapheme_cluster (#13981) 2025-07-23 17:07:25 -04:00
Burdette Lamar
e3d36fff8f
[DOC] Tweaks for String#empty? 2025-07-23 17:06:44 -04:00
Stan Lo
78820e86c7 Update doc for ObjectSpace.memsize_of 2025-07-23 15:49:04 -04:00
BurdetteLamar
7816a04d97 [DOC] Tweaks for String#each_line 2025-07-23 15:48:35 -04:00
BurdetteLamar
17eee25c66 [DOC] Tweaks for String#each_codepoint 2025-07-23 15:36:32 -04:00
BurdetteLamar
cd9b74638c [DOC] Tweaks for String#each_char 2025-07-23 15:35:28 -04:00
Alan Wu
41149a96ef ZJIT: Fix clobbering register for self in gen_entry_params()
Previously, for 8+ params we wound up clobbering the self param when
putting the last param in memory in the JIT entry point:

    # ZJIT entry point: a@../test.rb:5
    <snip>
    ldur x0, [x19, #0x18]
    # set method params: 8
    ldur x1, [x21, #-0x58]
    ldur x2, [x21, #-0x50]
    ldur x3, [x21, #-0x48]
    ldur x4, [x21, #-0x40]
    ldur x5, [x21, #-0x38]
    ldur x11, [x21, #-0x30]
    ldur x12, [x21, #-0x28]
    ldur x0, [x21, #-0x20]
    stur x0, [sp, #-0x20]
    bl #0x11e17018c

Doing the memcpys for parameters in memory first avoids this clobbering.

    # set method params: 8
    ldur x0, [x21, #-0x20]
    stur x0, [sp, #-0x20]
    ldur x12, [x21, #-0x28]
    ldur x11, [x21, #-0x30]
    ldur x5, [x21, #-0x38]
    ldur x4, [x21, #-0x40]
    ldur x3, [x21, #-0x48]
    ldur x2, [x21, #-0x50]
    ldur x1, [x21, #-0x58]
    ldur x0, [x19, #0x18]
2025-07-23 13:29:03 -04:00
tomoya ishida
5e5cec1b86
Fix bigand_int edgecase returning false (#13987) 2025-07-24 02:12:12 +09:00
Peter Zhu
93be578691 Remove global symbol locks for rb_intern 2025-07-23 10:07:11 -04:00
Peter Zhu
33a849e385 Remove global symbol lock for rb_gc_free_dsymbol 2025-07-23 10:07:11 -04:00
André Luiz Tiago Soares
85221800ca
Add comments to autogen script 2025-07-23 11:23:38 +00:00
Yusuke Endoh
7e64a68252 Prevent a warning: old-style function definition
ipsocket.c:57:1: warning: old-style function definition [-Wold-style-definition]
   57 | current_clocktime()
      | ^~~~~~~~~~~~~~~~~
2025-07-23 16:46:01 +09:00
Naoto Ono
fbaad485db
Launchable: Remove launchable subset command (#13969)
I've enabled the [Predictive Test Selection](https://www.launchableinc.com/docs/features/predictive-test-selection/) feature, which let machine-learning model selects the appropriate tests to reduce CI execution time in https://github.com/ruby/ruby/pull/12617.

However, I noticed that there are some problems for enabling PTS in Ruby CI after several experiments. Until fixing the problem, I'll disable this feature by removing `launchable subset` command.
2025-07-23 11:18:11 +09:00
André Luiz Tiago Soares
61b5d3cf89
[DOC] Fix 'hexadecimal' spelling on encodings docs
Fix typo
2025-07-23 10:10:56 +09:00
Alan Wu
33363030e1 ZJIT: Use rb_vm_env_write() for hir::Insn::SetLocal
We weren't firing write barriers before when writing to imemo/env
objects. Wbcheck caught this with test/ruby/test_refinement.rb:

    ruby -v: ruby 3.5.0dev (2025-07-22T17:05:58Z wbcheck 2569a80954) +ZJIT dev +PRISM +GC[wbcheck] [x86_64-linux]
    WBCHECK ERROR: Missed write barrier detected!
      Parent object: 0x558de9f4e6e0 (wb_protected: true)
        rb_obj_info_dump: 0x0000558de9f4e6e0 T_IMEMO/<env>
      Reference counts - snapshot: 3, writebarrier: 0, current: 4, missed: 1
      Missing reference to: 0x558decf37c30
        rb_obj_info_dump: 0x0000558decf37c30 method/UnboundMethod method

    WBCHECK SUMMARY: Found 1 objects with missed write barriers (1 total violations)
2025-07-22 18:04:28 -04:00
BurdetteLamar
465b1696ad [DOC] Tweaks for String#each_byte 2025-07-22 17:55:06 -04:00
BurdetteLamar
7ca3b38a95 [DOC] Tweak for String#dump 2025-07-22 17:54:04 -04:00
Allison Cretel
45e65f55bc Fix typos in documentation_guide.md 2025-07-22 12:52:45 -04:00
Allison Cretel
02aee1b724 Change TESTOPS to TESTOPTS 2025-07-22 12:52:45 -04:00
Jun Aruga
7bb48f87f3 [ruby/openssl] ssl: add SSLSocket#sigalg, #peer_sigalg, #group
These methods are useful to test post-quantum cryptography (PQC) cases.

434ef74452
2025-07-22 16:51:02 +00:00
John Hawthorn
41ec0f5b97 Update misc/tsan_suppressions.txt
* Add gc_enable/disable to TSAN suppressions
* Remove deleted methods from tsan suppressions
* Remove TSAN errors we've fixed
* Add another two inline cache suppressions
* Improve comments
2025-07-22 09:37:13 -07:00
John Hawthorn
973e6770d5 Fix TSAN data race in gc_start
objspace->flags.immediate_sweep shares the same word as
objspace->flags.during_incremental_marking. So in gc_start we need to
assign it after gc_enter() so that we hold the VM lock and have issued a
barrier, as rb_gc_impl_writebarrier is reading
objspace->flags.during_incremental_marking.
2025-07-22 09:37:13 -07:00
Aaron Patterson
a1403fb7cb Interpolated strings must not be frozen
Strings concatenated with backslash may end up being frozen when they
shouldn't be.  This commit fixes the issue.  It required a change
upstream in Prism, but also a change to the Prism compiler in CRuby.

  https://github.com/ruby/prism/pull/3606

[Bug #21187]
2025-07-22 08:10:55 -07:00
Kunshan Wang
0f408602cb Fix missing increment of deleted_entries
When `rb_concurrent_set_foreach_with_replace` deletes entries from a
concurrent set, it should increment the `deleted_entries` field, too.
2025-07-22 10:05:24 -04:00
Jean Boussier
8541dec8c4 encoding.c: check for autoload before checking index
Otherwise we may be checking the index while the encoding
is being autoloaded by another ractor.
2025-07-22 12:58:49 +02:00
Hiroshi SHIBATA
4dec4fbdfa
[rubygems/rubygems] Define dummy module for mise plugin
64bdff1e1e
2025-07-22 18:41:57 +09:00
git
af718aaf4b Update bundled gems list as of 2025-07-22 2025-07-22 07:07:16 +00:00
Alan Wu
e77eee96a3 ZJIT: Load return value before frame teardown
Or else the following returns garbage since it loads after
moving SP. Prior bad disassembly:

    def a(n1,n2,n3,n4,n5,n6,n7,n8) = n8
    a(1,1,1,1,1,1,1,0)

    # Block: bb0(v0, v1, v2, v3, v4, v5, v6, v7, v8)
    stp x29, x30, [sp, #-0x10]!
    mov x29, sp
    # bump C stack pointer
    sub sp, sp, #0x10
    # Insn: v10 Return v8
    # pop stack frame
    adds x19, x19, #0x38
    stur x19, [x20, #0x10]
    # restore C stack pointer
    add sp, sp, #0x10
    mov sp, x29
    ldp x29, x30, [sp], #0x10
    ldur x0, [sp]
    ret
2025-07-21 23:09:42 -04:00
David Rodríguez
9f961a4b30 [rubygems/rubygems] Workaround RVM issue when using Bundler <= 2.5.22
Old versions of BUndler need a workaround to support nested `bundle
exec` invocations by overriding `Gem.activate_bin_path`. However,
RubyGems now uses this new `Gem.activate_and_load_bin_path` helper in
binstubs, which is of course not overridden in those Bundler versions
since it didn't exist at the time.

So, include the override here to workaround that.

e5ed95e242
2025-07-22 10:01:28 +09:00
Hiroshi SHIBATA
ba6a2717f4
Skip test_ln_sr(FileUtilsSingletonTest) ib rbs tests
https://github.com/ruby/fileutils/pull/139
4641428778
2025-07-22 09:56:47 +09:00
Hiroshi SHIBATA
7dbd9c2636
Revert "[ruby/prism] Clear flags on interpolated strings"
This reverts commit a495e6a44c.

This break extension builds:

```
/Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:321:in 'String#replace': can't modify frozen String: "$(SDKROOT)$(prefix)/include" (FrozenError)
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:321:in 'RbConfig.expand'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:314:in 'block in RbConfig.expand'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:307:in 'String#gsub'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:307:in 'RbConfig.expand'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:314:in 'block in RbConfig.expand'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:307:in 'String#gsub'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:307:in 'RbConfig.expand'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:314:in 'block in RbConfig.expand'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:307:in 'String#gsub'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:307:in 'RbConfig.expand'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:325:in 'block in <module:RbConfig>'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:324:in 'Hash#each_value'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:324:in '<module:RbConfig>'
        from /Users/hsbt/Documents/github.com/ruby/ruby/rbconfig.rb:11:in '<top (required)>'
        from ./ext/extmk.rb:42:in 'Kernel#require'
        from ./ext/extmk.rb:42:in '<main>'
make[1]: *** [ext/configure-ext.mk:70: ext/json/exts.mk] Error 1
```
2025-07-22 09:07:04 +09:00
Aaron Patterson
a495e6a44c [ruby/prism] Clear flags on interpolated strings
When inner strings aren't frozen, we need to clear the flags on
interpolated string nodes so that we don't emit wrong instructions.

The compiler is currently incorrectly emitting frozen strings because
the parser is erroneously declaring interpolated strings as "frozen".
We need to fix this behavior in the parser so we can fix the compiler in
CRuby.  This patch is a partial fix for [this bug](https://bugs.ruby-lang.org/issues/21187)

eda693f056
2025-07-21 23:04:42 +00:00
Peter Zhu
21c78cb0f7 [DOC] Docs for String#dump 2025-07-21 17:07:39 -04:00
Alan Wu
3bbdcf0848 ZJIT: Remove no-op movs after register allocation
Previously `no_dead_mov_from_vreg` generated:

    0x0: ldur x0, [x0]
    0x4: mov x0, x0
    0x8: ret

Because of phase ordering. Split couldn't recognize that the no-op mov
because at that point it sees a `VReg`.
2025-07-21 13:51:44 -04:00
Alan Wu
495e3f642b ZJIT: Trim disassembly output from capstone-rs
It has a bad habit of leaving a trailing space, for example for ARM
`ret`.
2025-07-21 13:51:44 -04:00
Peter Zhu
6b0e5de4e6 Don't rehash on retry in concurrent set
Since the hash should never change, we only need to calculate it once.
2025-07-21 10:58:30 -04:00
Peter Zhu
66349692f0 Introduce free function to rb_concurrent_set_funcs
If we create a key but don't insert it (due to other Ractor winning the
race), then it would leak memory if we don't free it. This introduces a
new function to free that memory for this case.
2025-07-21 10:58:30 -04:00
Peter Zhu
061224f3cb Remove lock for dynamic symbol
Benchmark:

    ARGV[0].to_i.times.map do
      Ractor.new do
        1_000_000.times do |i|
          "hello#{i}".to_sym
        end
      end
    end.map(&:value)

Results:

| Ractor count | Branch (s) | Master (s) |
|--------------|------------|------------|
| 1            | 0.364      | 0.401      |
| 2            | 0.555      | 1.149      |
| 3            | 0.583      | 3.890      |
| 4            | 0.680      | 3.288      |
| 5            | 0.789      | 5.107      |
2025-07-21 10:58:30 -04:00
Peter Zhu
efc232241e Don't call cmp on garbage objects
If the object is garbage, then calling cmp on it may crash.
2025-07-21 10:58:30 -04:00
Peter Zhu
a2e165e8a0 Remove dsymbol_fstr_hash
We don't need to delay the freeing of the fstr for the symbol if we store
the hash of the fstr in the dynamic symbol and we use compare-by-identity
for removing the dynamic symbol from the sym_set.
2025-07-21 10:58:30 -04:00
Peter Zhu
2bcb155b49 Convert global symbol table to concurrent set 2025-07-21 10:58:30 -04:00
Peter Zhu
f05ee26a1f Add rb_concurrent_set_find 2025-07-21 10:58:30 -04:00
Peter Zhu
9ef482bd13 Add rb_concurrent_set_size 2025-07-21 10:58:30 -04:00