summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2025-12-15Skip test_crash_report_pipe with macOS 15Hiroshi SHIBATA
2025-12-15macOS 15 is the stable version todayHiroshi SHIBATA
2025-12-15Add predicates for platformsNobuyoshi Nakada
2025-12-15Pend some tests because these are not working with macOS 15 beta and Xcode ↵Hiroshi SHIBATA
16 beta
2025-11-30merge revision(s) f4f728b319086eea3db6e9909fb9c849c276f813: [Backport #21680]nagachika
[PATCH] [Bug #21680] Fix (base**power_of_two).digits(base) bug (#15144) Fix wrong condition in base multiplying loop.
2025-11-29merge revision(s) c5bd4acd30320a8e180ce9fcb24acdab4e10c73a: [Backport #21666]nagachika
[PATCH] [Bug #21666] Get rid of use of unspecified values
2025-11-29merge revision(s) a4dff09be79b52288a47658964d25e5aa84fc960: [Backport #21673]nagachika
[PATCH] [Bug #21673] Fix resolving refined module-defined method A method defined in a module has no `defined_class`, use the ICLASS for it as the `defined_class`.
2025-11-02Fix initialization of the table for quick searchK.Takata
This fixes k-takata/Onigmo#120. The commit k-takata/Onigmo@9c13de8d0684ebde97e3709d7693997c81ca374b was insufficient. https://github.com/k-takata/Onigmo/commit/1de602ddff140d91419e3f86dd35c81d7bd2d8e7
2025-11-02[Bug #13671] Fix that "ss" in look-behind causes syntax errorK.Takata
Fixes k-takata/Onigmo#92. This fix was ported from oniguruma: https://github.com/kkos/oniguruma/commit/257082dac8c6019198b56324012f0bd1830ff4ba https://github.com/k-takata/Onigmo/commit/b1a5445fbeba97b3e94a733c2ce11c033453af73
2025-10-18merge revision(s) e94a2f691d67ad98be9036e76c765fcfa7d22552: [Backport #21638]nagachika
[PATCH] [Bug #21638] Mark ractor-local `$VERBOSE` and `$DEBUG` https://github.com/sampersand/blog/blob/master/the%20-s%20flag.md#the-segfault
2025-10-11merge revision(s) 7ae67e8f6ad6e7fd0677b28a7a10961f79d55495: [Backport #21568]nagachika
[PATCH] load.c: Fix dest and src of MEMMOVE When multiple files with the same name are required, the features_index hash stores the indexes in `$LOADED_FEATURES` array into a darray. The dest and src arguments for `MEMMOVE` were wrongly reversed when inserting a new index in the darray. [Bug #21568]
2025-10-05merge revision(s) 62430c19c9f1ab49429cebe65f30588472648c95: [Backport #21342]nagachika
Message not found for revision: 62430c19c9f1ab49429cebe65f30588472648c95
2025-09-14merge revision(s) 928fea3bfa86053c0bc6f7a5bf7559b115a676b5: [Backport #21567]nagachika
Fix crash when $LOADED_FEATURES is modified during require [Bug #21567] When we require an object that is not a string, it will attempt to convert it to a string by calling to_str on it. If we modify the $LOADED_FEATURES array while it calls to_str, Ruby can crash because it can end up inserting the string in the wrong index in the array. For example, the following script crashes: require "tempfile" class MyString def initialize(path) @path = path end def to_str $LOADED_FEATURES.clear @path end def to_path = @path end def create_ruby_file = Tempfile.create(["test", ".rb"]).path require MyString.new(create_ruby_file) $LOADED_FEATURES.unshift(create_ruby_file) $LOADED_FEATURES << MyString.new(create_ruby_file) require create_ruby_file Crash log: test.rb:21: [BUG] Segmentation fault at 0x0000000000000004 ruby 3.5.0dev (2025-09-09T09:29:35Z master ce94add7fb) +PRISM [arm64-darwin24] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0003 p:---- s:0011 e:000010 CFUNC :require c:0002 p:0076 s:0006 e:000005 EVAL test.rb:21 [FINISH] c:0001 p:0000 s:0003 E:0001b0 DUMMY [FINISH] -- Ruby level backtrace information ---------------------------------------- test.rb:21:in '<main>' test.rb:21:in 'require' -- Threading information --------------------------------------------------- Total ractor count: 1 Ruby thread count for this ractor: 1 -- Machine register context ------------------------------------------------ x0: 0x0000000000000004 x1: 0x000000000000c800 x2: 0x0000000000000000 x3: 0x0000000000000000 x4: 0x0000000000000205 x5: 0x0000000000000000 x6: 0x0000000000000000 x7: 0x0000000000000001 x18: 0x0000000000000000 x19: 0x0000000209dfc0b0 x20: 0x0000000209dfc018 x21: 0x000000016ee8ab58 x22: 0x0fffffff0009d71d x23: 0x0000000209dfc018 x24: 0x0000000209dfc150 x25: 0x000000016ee8acc0 x26: 0x0000000000000000 x27: 0x0000000000000000 x28: 0x0000000000000000 lr: 0x0000000101244140 fp: 0x000000016ee887f0 sp: 0x000000016ee887d0 -- C level backtrace information ------------------------------------------- miniruby(rb_print_backtrace+0x24) [0x101317b08] vm_dump.c:843 miniruby(rb_print_backtrace) (null):0 miniruby(rb_vm_bugreport+0x26c) [0x101317d94] vm_dump.c:1175 miniruby(rb_bug_for_fatal_signal+0xa4) [0x10105ddac] error.c:1130 miniruby(sig_do_nothing+0x0) [0x1012278c0] signal.c:948 miniruby(sigsegv) (null):0 /usr/lib/system/libsystem_platform.dylib(_sigtramp+0x38) [0x19c1216a4] miniruby(rb_str_new_frozen+0x1c) [0x101244140] string.c:1495 miniruby(rb_check_realpath_internal+0x68) [0x101077804] file.c:4679 miniruby(rb_check_realpath+0x2c) [0x101077aa4] file.c:4765 miniruby(get_loaded_features_index+0x37c) [0x1010f9c94] load.c:467 miniruby(rb_feature_p+0xd0) [0x1010f8174] load.c:582 miniruby(search_required+0xac) [0x1010f6ad4] load.c:1193 miniruby(require_internal+0x274) [0x1010f7518] load.c:1424 miniruby(rb_require_string_internal+0x94) [0x1010f6830] load.c:1571 miniruby(rb_require_string+0x58) [0x1010f66e8] load.c:1557 miniruby(rb_f_require+0x1c) [0x1010f6684] load.c:1150 miniruby(ractor_safe_call_cfunc_1+0x38) [0x101306c28] vm_insnhelper.c:3696 miniruby(vm_call_cfunc_with_frame_+0x250) [0x1012f857c] vm_insnhelper.c:3873 miniruby(vm_call_cfunc_with_frame+0x6c) [0x1012f8834] vm_insnhelper.c:3919 miniruby(vm_sendish+0x1a8) [0x1012c990c] vm_insnhelper.c:6087 miniruby(vm_exec_core+0x4050) [0x1012cfb48] insns.def:900 miniruby(vm_exec_loop+0x80) [0x1012e5448] vm.c:2666 miniruby(rb_vm_exec+0x134) [0x1012c9b40] vm.c:2645 miniruby(rb_iseq_eval_main+0x34) [0x1012e5628] vm.c:2919 miniruby(rb_ec_exec_node+0xe4) [0x10106d094] eval.c:282 miniruby(ruby_run_node+0x94) [0x10106cf64] eval.c:320 miniruby(rb_main+0x40) [0x100f7499c] main.c:42 miniruby(main+0x60) [0x100f74928] main.c:62
2025-09-14merge revision(s) ce849d565bf6aae8e0179fffb04eb1f665f17347, ↵nagachika
acb29f7fa1497463ed3bdd65549ef20b61beda64: [Backport #21402] ruby2_keywords warnings: Quote non-UTF8 method names fully It used to quote only part of the method name because NUL byte in the method terminates the C string: ``` (irb)> "abcdef".encode("UTF-16LE").bytes => [97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0] ``` ``` expected: /abcdef/ actual: warning: Skipping set of ruby2_keywords flag for a (method not defined in Ruby)\n". ``` Do not respect ruby2_keywords on method/proc with post arguments Previously, ruby2_keywords could be used on a method or proc with post arguments, but I don't think the behavior is desired: ```ruby def a(*c, **kw) [c, kw] end def b(*a, b) a(*a, b) end ruby2_keywords(:b) b({foo: 1}, bar: 1) ``` This changes ruby2_keywords to emit a warning and not set the flag on a method/proc with post arguments. While here, fix the ruby2_keywords specs for warnings, since they weren't testing what they should be testing. They all warned because the method didn't accept a rest argument, not because it accepted a keyword or keyword rest argument.
2025-08-29Backport GH-13617 for s390x (#13757)Hiroshi SHIBATA
2025-07-19merge revision(s) 097d742a1ed53afb91e83aef01365d68b763357b: [Backport #20009]nagachika
[Bug #20009] Support marshaling non-ASCII name class/module
2025-07-19Fix generic_ivar_set_shape_ivptr for table rebuildJohn Hawthorn
[Bug #21438] Previously GC could trigger a table rebuild of the generic ivar st_table in the middle of calling the st_update callback. This could cause entries to be reallocated or rearranged and the update to be for the wrong entry. This commit adds an assertion to make that case easier to detect, and replaces the st_update with a separate st_lookup and st_insert. Also free after insert in generic_ivar_set_shape_ivptr Previously we were performing a realloc and then inserting the new value into the table. If the table was flagged as requiring a rebuild, this could trigger GC work and marking within that GC could access the ivptr freed by realloc. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2025-07-02Partly picked from https://github.com/ruby/ruby/pull/10073Hiroshi SHIBATA
2025-06-29merge revision(s) 2e7e78cd590d20aa9d41422e96302f3edd73f623: [Backport #21440]nagachika
[Bug #21440] Stop caching member list in frozen Data/Struct class
2025-06-15merge revision(s) fa85d23ff4a02985ebfe0716b0ff768f5b4fe13d: [Backport #21380]nagachika
[Bug #21380] Prohibit modification in String#split block Reported at https://hackerone.com/reports/3163876
2025-05-24merge revision(s) 056497319658cbefe22351c6ec5c9fa6e4df72bd: [Backport #21357]nagachika
[Bug #21357] Fix crash in Hash#merge with block Prior to https://github.com/ruby/ruby/commit/49b306ecb9e2e9e06e0b1590bacc5f4b38169c3c 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-24merge revision(s) 49b306ecb9e2e9e06e0b1590bacc5f4b38169c3c: [Backport #21333]nagachika
[Bug #21333] Prohibit hash modification inside Hash#update block
2025-05-18merge revision(s) b959263b58e26ef630c085f9f7ddc04373a998c7: [Backport #21344]nagachika
Fix Exception#detailed_message for GC compaction Before this commit, the test fails with RGENGC_CHECK_MODE enabled: TestException#test_detailed_message_under_gc_compact_stress [test/ruby/test_exception.rb:1466]: <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1mbar\e[m\n" + "\e[1mbaz\e[m"> expected but was <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1m\x00\x00\x00\x00\x00\x00\x00\e[m">.
2025-05-17merge revision(s) 7793b59c8d2a13c124fe276e11723db23facce04: [Backport #21331]nagachika
[Bug #21331] Prohibit hash modification during stlike loop
2025-04-07merge revision(s) 3a7b9ca93b91dcc086b9ac8b9957e59268f9493b: [Backport #21217]nagachika
Fix `Integer.sqrt` to never exceed actual value `Integer.sqrt` uses `sqrt(3)` from libm for small values. This method must return a value less than or equal to the actual integer square root, but libm's sqrt does not always guarantee that. This change corrects that by decrementing the result if necessary. Fixes [Bug #21217]
2025-04-02merge revision(s) d78ff6a767ca813ac5fa178dd7611f20a993c191: [Backport #20984]nagachika
[Bug #20984] Fix test with locale encoding
2025-03-30merge revision(s) 5f77f9bea61fb4cc8447a76e191fdfb28f076862: [Backport #21195]nagachika
Fix handling of `error`/`errno` in `io_internal_wait`. (#12961) [Bug #21195]
2025-03-29merge revision(s) f69ad0e810e1fdc18dc12f77bbecfa49999ef3bf: [Backport #21094]nagachika
[Bug #21094] Update nested module names when setting temporary name
2025-03-29merge revision(s) 1acfb29015dbc38fd345d8786aa78aad59f7dcd1: [Backport #21186]nagachika
[Bug #21186] multibyte char literal should be a single letter word
2025-03-29merge revision(s) 9459bedd84d479bb1d7d3d40bada1cecb4701c37: [Backport #19841]nagachika
[Bug #19841] Refine error on marshaling recursive USERDEF
2025-03-16merge revision(s) f423f6e10c0c226dfed98e7cb7a5d489191dfa35: [Backport #21131]nagachika
Ensure IO.copy_stream buffer is an independent string Otherwise, changes to the buffer by the destination write method could result in data changing for supposedly independent strings. Fixes [Bug #21131]
2025-03-16merge revision(s) 931ac960b6d11937364b6c4e847fdd575ee67980: [Backport #21159]nagachika
[Bug #21159] module names should not be modifiable
2025-03-08Replace 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 <alanwu@ruby-lang.org>
2025-01-14merge revision(s) b176d4f52e4af67654814dab3e9c5f4bf9170e54: [Backport #21008]Takashi Kokubun
[Bug #21008] Normalize before sum to float After switching to `Float`-mode when summing `Numeric` objects, normalization for `Float` is still needed.
2025-01-14merge revision(s) 8034e9c3d001ca3dff124ab42972684eac8af2ae: [Backport #20995]Takashi Kokubun
[Bug #20995] Protect `IO.popen` block from exiting by exception
2025-01-14merge revision(s) 19c39e4cfaa467e69b9848c9c5496d7f50d39c7f: [Backport #20984]Takashi Kokubun
[Bug #20984] ENV.inspect should be encoding aware
2025-01-14merge revision(s) e0d600ec190c64aff76cfcbd6009cffb927da166: [Backport #21012]Takashi Kokubun
Avoid opt_aset_with optimization inside multiple assignment Previously, since the opt_aset_with optimization was introduced, use of the opt_aset_with optimization inside multiple assignment would result in a segfault or incorrect instructions. Fixes [Bug #21012] Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
2025-01-14merge revision(s) 92dd9734a967c20e628c8f77c5ce700058dcd58c: [Backport #20950]Takashi Kokubun
Fix use-after-free in ep in Proc#dup for ifunc procs [Bug #20950] ifunc proc has the ep allocated in the cfunc_proc_t which is the data of the TypedData object. If an ifunc proc is duplicated, the ep points to the ep of the source object. If the source object is freed, then the ep of the duplicated object now points to a freed memory region. If we try to use the ep we could crash. For example, the following script crashes: p = { a: 1 }.to_proc 100.times do p = p.dup GC.start p.call rescue ArgumentError end This commit changes ifunc proc to also duplicate the ep when it is duplicated.
2025-01-14merge revision(s) e90b447655dd39ad1eb645cdaae450efd605db00: [Backport #20924]Takashi Kokubun
[Bug #20924] Fix reading with delimiter in wide character encodings
2025-01-14merge revision(s) 660b995365f719fa59ed6f2809bb1527e6470d14: [Backport #20915]Takashi Kokubun
[Bug #20915] Fix SEGV with `TracePoint#parameters` and aliased C method The following snippet results with a SEGV: ```ruby C = Class.new do alias_method :new_to_s, :to_s end TracePoint.new(:c_call, &:parameters).enable { C.new.new_to_s } ``` at MRI 3.3.6 and ruby 3.4.0dev The root cause of the issue lies in the `rb_tracearg_parameters` function within the `RUBY_EVENT_C_RETURN` branch. Specifically, when the invoked method is an alias for a C function, `rb_method_entry_without_refinements(..., trace_arg->called_id, ...)` may return NULL. In that case we can fallback to `trace_arg->id`.
2025-01-14merge revision(s) 02b70256b5171d4b85ea7eeab836d3d7cfb3dbfc, ↵Takashi Kokubun
6b4f8945d600168bf530d21395da8293fbd5e8ba: [Backport #20909] Check negative integer underflow Many of Oniguruma functions need valid encoding strings
2025-01-14merge revision(s) 3b7892b6e4d1a1a5d6019987f9b46ed443dd104f: [Backport #20871]Takashi Kokubun
Fix a bug in rb_include_module that stops nested inclusion into module subclasses This bug was present since the code was originally added by me in 3556a834a2847e52162d1d3302d4c64390df1694. Fixes [Bug #20871]
2025-01-14merge revision(s) d71be7274bd2623bb521be72c245c08fc38d6ae4: [Backport #20873]Takashi Kokubun
[Bug #20873] Consider `-FIXNUM_MIN` overflow `-FIXNUM_MIN` is usually greater than `FIXNUM_MAX` on platforms using two's complement representation.
2025-01-14merge revision(s) 56ecc243e230e8e99761ec0ffc5116601f094bb0: [Backport #20868]Takashi Kokubun
[Bug #20868] Fix Method#hash to not change after compaction The hash value of a Method must remain constant after a compaction, otherwise it may not work as the key in a hash table. For example: def a; end # Need this method here because otherwise the iseq may be on the C stack # which would get pinned and not move during compaction def get_hash method(:a).hash end puts get_hash # => 2993401401091578131 GC.verify_compaction_references(expand_heap: true, toward: :empty) puts get_hash # => -2162775864511574135
2025-01-14merge revision(s) 773d140f65c1c8b726e107915bc003c186f38677: [Backport #20787]Takashi Kokubun
[Bug #20787] Check the separator in `IO#readline` as well as 3.2
2024-11-20Revert "Skip tests that suddenly started failing for MinGW"Hiroshi SHIBATA
This reverts commit f72eb702f29574b85889d3ea6447efa29c8a8789.
2024-11-12[Bug #20886] Avoid double-free in regex timeout after stack_double (#12063)John Hawthorn
Fix regex timeout double-free after stack_double As of 10574857ce167869524b97ee862b610928f6272f, it's possible to crash on a double free due to `stk_alloc` AKA `msa->stack_p` being freed twice, once at the end of match_at and a second time in `FREE_MATCH_ARG` in the parent caller. Fixes [Bug #20886]
2024-11-09[Bug #20883] Fix coderange for sprintf on binary strings (#12040)John Hawthorn
Fix update_coderange for binary strings Although a binary (aka ASCII-8BIT) string will never have a broken coderange, it still has to differentiate between "valid" and "7bit". On Ruby 3.4/trunk this problem is masked because we now clear the coderange more agressively in rb_str_resize, and we happened to always be strinking this string, but we should not assume that. On Ruby 3.3 this created strings where `ascii_only?` was true in cases it shouldn't be as well as other problems. Fixes [Bug #20883] Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> Co-authored-by: Matthew Draper <matthew@trebex.net>
2024-11-04Skip tests that suddenly started failing for MinGWTakashi Kokubun
These test failures first appeared on irrelevant changes. It probably came from changes in GitHub Actions instead of CRuby's. Until we figure out how to fix these tests, let's skip them to make the CI usable.
2024-11-04merge revision(s) 29c480dd6fca993590c82078ba797e2c4e876ac7: [Backport #20853]Takashi Kokubun
[Bug #20853] Fix Proc#hash to not change after compaction The hash value of a Proc must remain constant after a compaction, otherwise it may not work as the key in a hash table.