summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2025-04-01[Bug #21203] Skip TestGc#test_gc_parameter_init_slots since it is flaky (#13025)Naoto Ono
https://bugs.ruby-lang.org/issues/21203 TestGc#test_gc_parameter_init_slots is a flaky test that fails intermittently. Until the issue with flakiness is resolved, I will skip it. Notes: Merged-By: ono-max <[email protected]>
2025-03-31ractor: don't inherit the default thread groupJean Boussier
[Bug #17506] `Thread.current.group` isn't shareable so it shouldn't be inherited by the main thread of a new Ractor. This cause an extra allocation when spawning a ractor, which could be elided with a bit of extra work, but not sure if it's worth the effort. Notes: Merged: https://github.com/ruby/ruby/pull/13013
2025-03-28TestRegexp#test_match_cache_positive_look_ahead_complex: Extend the timeout ↵Yusuke Endoh
limit
2025-03-27Avoid allocation for anonymous positional splat with no argumentsJeremy Evans
Anonymous positional splats cannot be directly accessed, they can only be passed as splats to other methods. So if an anonymous positional splat would be empty, you can use a shared frozen empty array to save an allocation. ```ruby def a(*) end a() ``` This is similar to how anonymous empty keyword splats are optimized, except those use `nil` instead of a shared empty frozen hash. This updates the allocation tests to check that the array allocations are avoided where possible. It also makes a small change to test_iseq.rb to ensure an unfrozen hash is passed as the value of an anonymous splat parameter. Notes: Merged: https://github.com/ruby/ruby/pull/12596
2025-03-27Avoid array allocation for *nil, by not calling nil.to_aJeremy Evans
The following method call: ```ruby a(*nil) ``` A method call such as `a(*nil)` previously allocated an array, because it calls `nil.to_a`, but I have determined this array allocation is unnecessary. The instructions in this case are: ``` 0000 putself ( 1)[Li] 0001 putnil 0002 splatarray false 0004 opt_send_without_block <calldata!mid:a, argc:1, ARGS_SPLAT|FCALL> 0006 leave ``` The method call uses `ARGS_SPLAT` without `ARGS_SPLAT_MUT`, so the returned array doesn't need to be mutable. I believe all cases where `splatarray false` are used allow the returned object to be frozen, since the `false` means to not duplicate the array. The optimization in this case is to have `splatarray false` push a shared empty frozen array, instead of calling `nil.to_a` to return a newly allocated array. There is a slightly backwards incompatibility with this optimization, in that `nil.to_a` is not called. However, I believe the new behavior of `*nil` not calling `nil.to_a` is more consistent with how `**nil` does not call `nil.to_hash`. Also, so much Ruby code would break if `nil.to_a` returned something different from the empty hash, that it's difficult to imagine anyone actually doing that in real code, though we have a few tests/specs for that. I think it would be bad for consistency if `*nil` called `nil.to_a` in some cases and not others, so this changes other cases to not call `nil.to_a`: For `[*nil]`, this uses `splatarray true`, which now allocates a new array for a `nil` argument without calling `nil.to_a`. For `[1, *nil]`, this uses `concattoarray`, which now returns the first array if the second array is `nil`. This updates the allocation tests to check that the array allocations are avoided where possible. Implements [Feature #21047] Notes: Merged: https://github.com/ruby/ruby/pull/12597
2025-03-26Add additional Ractor.make_shareable testsJohn Hawthorn
Notes: Merged: https://github.com/ruby/ruby/pull/12977
2025-03-23Fix handling of `error`/`errno` in `io_internal_wait`. (#12961)Samuel Williams
[Bug #21195] Notes: Merged-By: ioquatix <[email protected]>
2025-03-21Fix regexp when non-ruby thread received the signalNobuyoshi Nakada
A space is added only when the source path is found.
2025-03-21Run cleanup code in `ensure`Nobuyoshi Nakada
2025-03-20Remove leading `nop` from block when we don't need itAaron Patterson
Blocks insert a leading `nop` instruction in order to execute a "block call" tracepoint. Block compilation unconditionally inserts a leading `nop` plus a label after the instruction: https://github.com/ruby/ruby/blob/641f15b1c6bd8921407a1f045573d3b0605f00d3/prism_compile.c#L6867-L6869 This `nop` instruction is used entirely for firing the block entry tracepoint. The label exists so that the block can contain a loop but the block entry tracepoint is executed only once. For example, the following code is an infinite loop, but should only execute the b_call tracepoint once: ```ruby -> { redo }.call ``` Previous to this commit, we would eliminate the `nop` instruction, but only if there were no other jump instructions inside the block. This means that the following code would still contain a leading `nop` even though the label following the `nop` is unused: ```ruby -> { nil if bar } ``` ``` == disasm: #<ISeq:block in <main>@test.rb:1 (1,2)-(1,17)> (catch: FALSE) 0000 nop ( 1)[Bc] 0001 putself [Li] 0002 opt_send_without_block <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0004 branchunless 8 0006 putnil 0007 leave [Br] 0008 putnil 0009 leave [Br] ``` This commit checks to see if the label inserted after the `nop` is actually a jump target. If it's not a jump target, then we should be safe to eliminate the leading `nop`: ``` > build-master/miniruby --dump=insns test.rb == disasm: #<ISeq:<main>@test.rb:1 (1,0)-(1,17)> 0000 putspecialobject 1 ( 1)[Li] 0002 send <calldata!mid:lambda, argc:0, FCALL>, block in <main> 0005 leave == disasm: #<ISeq:block in <main>@test.rb:1 (1,2)-(1,17)> 0000 putself ( 1)[LiBc] 0001 opt_send_without_block <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0003 branchunless 7 0005 putnil 0006 leave [Br] 0007 putnil 0008 leave [Br] ``` We have a test for b_call tracepoints that use `redo` here: https://github.com/ruby/ruby/blob/aebf96f371c8d874398e0041b798892e545fa206/test/ruby/test_settracefunc.rb#L1728-L1736 Notes: Merged: https://github.com/ruby/ruby/pull/12957
2025-03-20[Bug #21026] no singleton method on pseudo variable literalNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12925
2025-03-19A comment for TestRubyOptions::ExpectedStderrList [ci skip]Nobuyoshi Nakada
2025-03-19Source path may or may not existNobuyoshi Nakada
2025-03-19Loosen SEGV message testingYusuke Endoh
Since `rb_bug` does not always take Ruby frame info during SEGV, the source file path may not be output. ``` 1) Failure: TestRubyOptions#test_crash_report_script [/tmp/ruby/src/trunk_gcc11/test/ruby/test_rubyoptions.rb:907]: Expected / bug\.rb:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n /x to match "[BUG] Segmentation fault at 0x000003e900328766\n"+ ``` http://ci.rvm.jp/results/trunk_gcc11@ruby-sp2-noble-docker/5663880
2025-03-18Handle void expressions in defined?Kevin Newton
[Bug #21029] Notes: Merged: https://github.com/ruby/ruby/pull/12949
2025-03-18[Bug #21094] Update nested module names when setting temporary nameNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12947
2025-03-18[Feature #19908] Update Unicode headers to 15.1.0Mari Imaizumi
Notes: Merged: https://github.com/ruby/ruby/pull/12798
2025-03-18Fix case folding in single byte encodingMari Imaizumi
Notes: Merged: https://github.com/ruby/ruby/pull/12889
2025-03-18[Feature #20702] Tests for Array#fetch_valuesNobuyoshi Nakada
2025-03-17[Bug #21186] multibyte char literal should be a single letter wordNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12946
2025-03-17[Bug #21185] Fix Range#overlap? with infinite rangeJérôme Parent-Lévesque
Infinite ranges, i.e. unbounded ranges, should overlap with any other range which wasn't the case in the following example: (0..3).overlap?(nil..nil) Notes: Merged: https://github.com/ruby/ruby/pull/12937
2025-03-14Invoke `inherited` callbacks before `const_added`Jean Boussier
[Misc #21143] Conceptually this makes sense and is more consistent with using the `Name = Class.new(Superclass)` alternative method. However the new class is still named before `inherited` is called. Notes: Merged: https://github.com/ruby/ruby/pull/12927
2025-03-12Have `ast` live longer in ISeq.compile_file to fix GC stress crashAlan Wu
Previously, live range of `ast_value` ended on the call right before rb_ast_dispose(), which led to premature collection and use-after-free. We observed this crashing on -O3, -DVM_CHECK_MODE, with GCC 11.4.0 on Ubuntu. Co-authored-by: Aaron Patterson <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/12898
2025-03-12Fix flaky test_AREF_fstring_keyPeter Zhu
The code between the two ObjectSpace.count_objects could trigger a GC, which could free string objects causing this test to fail. We can see this failure on CI http://ci.rvm.jp/results/trunk-random2@ruby-sp2-noble-docker/5651016 TestHashOnly#test_AREF_fstring_key [test/ruby/test_hash.rb:1991]: <197483> expected but was <129689>. Notes: Merged: https://github.com/ruby/ruby/pull/12916
2025-03-12[Bug #19841] Refine error on marshaling recursive USERDEFNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12914
2025-03-11Fix memory leak in rb_reg_search_set_matchPeter Zhu
https://github.com/ruby/ruby/pull/12801 changed regexp matches to reuse the backref, which causes memory to leak if the original registers of the match is not freed. For example, the following script leaks memory: 10.times do 1_000_000.times do "aaaaaaaaaaa".gsub(/a/, "") end puts `ps -o rss= -p #{$$}` end Before: 774256 1535152 2297360 3059280 3821296 4583552 5160304 5091456 5114256 4980192 After: 12480 11440 11696 11632 11632 11760 11824 11824 11824 11888 Notes: Merged: https://github.com/ruby/ruby/pull/12905
2025-03-12[Bug #21177] Win32: Allow longer path nameNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12901
2025-03-11Fix flaky test_latest_gc_info_need_major_byPeter Zhu
The test could flake because a major GC could be triggered due to allocation for caches or other things, which would cause the test to fail.
2025-03-10Bump tolerance for weak reference test from 1 to 2Peter Zhu
The test fails sometimes with: TestGc#test_latest_gc_info_weak_references_count [test/ruby/test_gc.rb:421]: Expected 2 to be <= 1. Notes: Merged: https://github.com/ruby/ruby/pull/12894
2025-03-08Implement CLASS NODE locationsydah
The following Location information has been added This is the information required for parse.y to be a universal parser: ``` ❯ ruby --parser=prism --dump=parsetree -e "class A < B; end" @ ProgramNode (location: (1,0)-(1,16)) +-- locals: [] +-- statements: @ StatementsNode (location: (1,0)-(1,16)) +-- body: (length: 1) +-- @ ClassNode (location: (1,0)-(1,16)) +-- locals: [] +-- class_keyword_loc: (1,0)-(1,5) = "class" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-- constant_path: | @ ConstantReadNode (location: (1,6)-(1,7)) | +-- name: :A +-- inheritance_operator_loc: (1,8)-(1,9) = "<" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-- superclass: | @ ConstantReadNode (location: (1,10)-(1,11)) | +-- name: :B +-- body: nil +-- end_keyword_loc: (1,13)-(1,16) = "end" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-- name: :A ```
2025-03-07[Bug #21174] [Bug #21175] Fix `Range#max` on beginless integer rangeNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12879
2025-03-07[Bug #21163] Fix hexadecimal float conversionNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12878
2025-03-06Fix flaky failure in TestSetTraceFunc#test_tracepoint_disable (#12854)Naoto Ono
TestSetTraceFunc#test_tracepoint_disable is a flaky and failing intermittently. Here is an example of failure logs. ``` 1) Failure: TestSetTraceFunc#test_tracepoint_disable [/home/runner/work/ruby/ruby/src/test/ruby/test_settracefunc.rb:857]: <[:foo, :disable, :foo, :disable]> expected but was <[:call, :call, :foo, :disable, :foo, :disable]>. ``` https://github.com/ruby/ruby/actions/runs/13619175633/job/38066208546?pr=12585#step:12:875 I printed values of TracePoint objects as follows, and checked the values when failing intermittently. https://github.com/ruby/ruby/blob/7f9a6fc582fb5cfd88ab73a61782f39894a37ba6/test/ruby/test_settracefunc.rb#L848 Here is the log when the TestSetTraceFunc#test_tracepoint_disable failed intermittently. `2025-03-05T09:08:37.4075411Z e: call, f: /home/runner/work/ruby/ruby/src/lib/tempfile.rb, l: 386, i: call, d: Tempfile::FinalizerManager` is an unexpected events. Thus, I modified test code so that we can filter out unexpected trace events. ``` 2025-03-05T09:08:37.4075411Z e: call, f: /home/runner/work/ruby/ruby/src/lib/tempfile.rb, l: 386, i: call, d: Tempfile::FinalizerManager 2025-03-05T09:08:37.4085009Z e: call, f: /home/runner/work/ruby/ruby/src/test/ruby/test_settracefunc.rb, l: 808, i: foo, d: TestSetTraceFunc 2025-03-05T09:08:37.4086042Z e: call, f: <internal:trace_point>, l: 295, i: disable, d: TracePoint 2025-03-05T09:08:37.4115693Z e: call, f: /home/runner/work/ruby/ruby/src/test/ruby/test_settracefunc.rb, l: 808, i: foo, d: TestSetTraceFunc 2025-03-05T09:08:37.4116734Z e: call, f: <internal:trace_point>, l: 295, i: disable, d: TracePoint ``` Notes: Merged-By: ono-max <[email protected]>
2025-03-05Replace tombstone when converting AR to ST hashJohn Hawthorn
[Bug #21170] st_table reserves -1 as a special hash value to indicate that an entry has been deleted. So that that's a valid value to be returned from the hash function, do_hash replaces -1 with 0 so that it is not mistaken for the sentinel. Previously, when upgrading an AR table to an ST table, rb_st_add_direct_with_hash was used which did not perform the same conversion, this could lead to a hash in a broken state where one if its entries which was supposed to exist being marked as a tombstone. The hash could then become further corrupted when the ST table required resizing as the falsely tombstoned entry would be skipped but it would be counted in num entries, leading to an uninitialized entry at index 15. In most cases this will be really rare, unless using a very poorly implemented custom hash function. This also adds two debug assertions, one that st_add_direct_with_hash does not receive the reserved hash value, and a second in rebuild_table_with, which ensures that after we rebuild/compact a table it contains the expected number of elements. Co-authored-by: Alan Wu <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/12852
2025-03-05Add tests for alias locations with special variables $`, $', and $+ydah
Notes: Merged: https://github.com/ruby/ruby/pull/12837
2025-03-04Move in-place interning spec to Ruby's testsJean Boussier
Fix: https://github.com/ruby/spec/issues/1249 JRuby and TruffleRuby can't implement this behavior. While quite a lot of code out there relies on it, if it's not implemented it will simply result in sligthly less efficient code, so not the end of the world. Notes: Merged: https://github.com/ruby/ruby/pull/12850
2025-03-03Allow YJIT `mem-size` and `call-threshold` to be set at runtime via ↵annichai-stripe
`YJIT.enable()` (#12505) * first commit * yjit.rb change * revert formatting * rename mem-size to exec-mem-size for correctness * wip, move setting into rb_yjit_enable directly * remove unused helper functions * add in call threshold * input validation with extensive eprintln * delete test script * exec-mem-size -> mem-size * handle input validation with asserts * add test cases related to input validation * modify test cases * move validation out of rs, into rb * add comments * remove trailing spaces * remove logging Co-authored-by: Takashi Kokubun <[email protected]> * remove helper fn * Update test/ruby/test_yjit.rb Co-authored-by: Takashi Kokubun <[email protected]> * trailing white space --------- Co-authored-by: Alan Wu <[email protected]> Co-authored-by: Takashi Kokubun <[email protected]> Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> Notes: Merged-By: maximecb <[email protected]>
2025-03-03Implement POSTEXE NODE locationsydah
The following Location information has been added This is the information required for parse.y to be a universal parser: ``` ❯ ruby --parser=prism --dump=parsetree -e "END { }" @ ProgramNode (location: (1,0)-(1,8)) +-- locals: [] +-- statements: @ StatementsNode (location: (1,0)-(1,8)) +-- body: (length: 1) +-- @ PostExecutionNode (location: (1,0)-(1,8)) +-- statements: nil +-- keyword_loc: (1,0)-(1,3) = "END" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-- opening_loc: (1,4)-(1,5) = "{" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-- closing_loc: (1,7)-(1,8) = "}" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
2025-02-28Improve tests for small UTF regex with case fold.Maciek Rząsa
Co-authored-by: Nobuyoshi Nakada <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/12787
2025-02-28Use mbuf instead of bitset for character class for small UTF. Fixes #16145Maciej Rzasa
Notes: Merged: https://github.com/ruby/ruby/pull/12787
2025-02-27[Bug #21159] module names should not be modifiableNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12819
2025-02-24[Bug #21153] Add missing op-assign to top const in `command_asgn`Nobuyoshi Nakada
It was defined in `arg` only; moved that pattern to `op_asgn` rule to share it with `command_asgn`.
2025-02-18Ensure IO.copy_stream buffer is an independent stringJeremy Evans
Otherwise, changes to the buffer by the destination write method could result in data changing for supposedly independent strings. Fixes [Bug #21131] Notes: Merged: https://github.com/ruby/ruby/pull/12771
2025-02-18Fix typo in test_gc_compact.rb [ci skip]Peter Zhu
2025-02-18Fix crash for special constants in too complex generic ivarsPeter Zhu
We should skip reference updating for entries in too complex generic ivars that are special constants. This fixes the following crash: MAX_SHAPES = 0x80000 MAX_SHAPES.times do |i| o = [] o.instance_variable_set(:"@foo#{i}", 1) end o = [] o.instance_variable_set(:"@a", 123) GC.compact Notes: Merged: https://github.com/ruby/ruby/pull/12781
2025-02-18Add a test for Binding#local_variable* with numbered parameters and `it`Yusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/12746
2025-02-14Only count VM instructions in YJIT stats buildsAaron Patterson
The instruction counter is slowing multi-Ractor applications. I had changed it to use a thread local, but using a thread local is slowing single threaded applications. This commit only enables the instruction counter in YJIT stats builds until we can figure out a way to gather the information with lower overhead. Co-authored-by: Randy Stauner <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/12670
2025-02-14[Bug #21127] Thread deadlock does not display backtraces (#12721)Masataka Pocke Kuwabara
Previously, Ruby displayed backtraces for each thread on deadlock. However, it has not been shown since Ruby 3.0. It should display the backtrace for debugging. Co-authored-by: Jeremy Evans <[email protected]> Notes: Merged-By: pocke <[email protected]>
2025-02-13[Feature #21116] Extract RJIT as a third-party gemNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12740
2025-02-13Extend timeout with resolv.rb and Windows platform. It's expired with 10sec ↵Hiroshi SHIBATA
sometimes.