summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2024-12-17[PRISM] Recurse use_deconstructed_cache in Alternation NodesMatt Valentine-House
This fixes the behavioural difference between Prism and parse.y when evaluating the following code ```ruby 1 in [1 | [1]] ``` Fixes [Bug #20956] Notes: Merged: https://github.com/ruby/ruby/pull/12370
2024-12-16Freeze `Random::Formatter::ALPHANUMERIC` and its elementsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12356
2024-12-15[Bug #20927] Fix compile_shareable_literal_constant for hash with keyword splattompng
Compilation of NODE_HASH in compile_shareable_literal_constant does not support hash that contains keyword splat. If there is a keyword splat, fallback to default case. Notes: Merged: https://github.com/ruby/ruby/pull/12338
2024-12-13Fix use-after-free in ep in Proc#dup for ifunc procsPeter Zhu
[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. Notes: Merged: https://github.com/ruby/ruby/pull/12319
2024-12-12[Feature #20884] Reserve "Ruby" toplevel nameNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12315
2024-12-10[Bug #20924] Fix reading with delimiter in wide character encodingsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12304
2024-12-10[Bug #20936] Fix #size for Range#reverse_eachKouhei Yanagita
Notes: Merged: https://github.com/ruby/ruby/pull/12301
2024-12-06[Bug #20929] Win32: Encode timezone name in UTF-8Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12269
2024-12-06[Bug #20929] Fix `assert_zone_encoding`Nobuyoshi Nakada
The default internal encoding is not taken into account to encode timezone name. Notes: Merged: https://github.com/ruby/ruby/pull/12269
2024-12-05Standardize on the name "modular GC"Peter Zhu
We have name fragmentation for this feature, including "shared GC", "modular GC", and "external GC". This commit standardizes the feature name to "modular GC" and the implementation to "GC library". Notes: Merged: https://github.com/ruby/ruby/pull/12261
2024-11-29Warn when redefining __id__ as well as object_idJohn Hawthorn
[Feature #20912] Notes: Merged: https://github.com/ruby/ruby/pull/12177
2024-11-29[Bug #20915] Fix SEGV with `TracePoint#parameters` and aliased C methodviralpraxis
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`. Notes: Merged: https://github.com/ruby/ruby/pull/12186
2024-11-29Avoid illegal pointerYusuke Endoh
When loading a crafted marshal data of Random, a pointer to an illegal address was created. I don't think there is any harm since the data is normalized before access, but just to be safe, I add a check to make it an error. Notes: Merged: https://github.com/ruby/ruby/pull/12200
2024-11-26Optimize instructions when creating an array just to call `include?` (#12123)Randy Stauner
* Add opt_duparray_send insn to skip the allocation on `#include?` If the method isn't going to modify the array we don't need to copy it. This avoids the allocation / array copy for things like `[:a, :b].include?(x)`. This adds a BOP for include? and tracks redefinition for it on Array. Co-authored-by: Andrew Novoselac <andrew.novoselac@shopify.com> * YJIT: Implement opt_duparray_send include_p Co-authored-by: Andrew Novoselac <andrew.novoselac@shopify.com> * Update opt_newarray_send to support simple forms of include?(arg) Similar to opt_duparray_send but for non-static arrays. * YJIT: Implement opt_newarray_send include_p --------- Co-authored-by: Andrew Novoselac <andrew.novoselac@shopify.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2024-11-26Many of Oniguruma functions need valid encoding stringsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12169
2024-11-26Check negative integer underflowNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12169
2024-11-25Prevent a warning: setting Encoding.default_externalYusuke Endoh
2024-11-20Fix a bug in rb_include_module that stops nested inclusion into module ↵Jeremy Evans
subclasses This bug was present since the code was originally added by me in 3556a834a2847e52162d1d3302d4c64390df1694. Fixes [Bug #20871] Notes: Merged: https://github.com/ruby/ruby/pull/12125
2024-11-19Remove deprecated method Refinement#refined_classShugo Maeda
[Feature #20901] Notes: Merged: https://github.com/ruby/ruby/pull/12115
2024-11-19[Bug #20900] Warn deprecated constant when removingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12114
2024-11-14rb_raise when attempting to set the GC implementation nameMatt Valentine-House
Instead of silently ignoring the key, we should raise to clearly tell the user that this key is read-only. Notes: Merged: https://github.com/ruby/ruby/pull/11872
2024-11-14Include the currently active GC in RUBY_DESCRIPTIONMatt Valentine-House
This will add +MOD_GC to the version string and Ruby description when Ruby is compiled with shared gc support. When shared GC support is compiled in and a GC module has been loaded using RUBY_GC_LIBRARY, the version string will include the name of the currently active GC as reported by the rb_gc_active_gc_name function in the form +MOD_GC[gc_name] [Feature #20794] Notes: Merged: https://github.com/ruby/ruby/pull/11872
2024-11-14Expose GC.config[:implementation], to query the currently active GCMatt Valentine-House
And a default and readonly key to the GC.config hash that names the current GC implementation. This is provided by each implementation by the API function rb_gc_impl_active_gc_name Notes: Merged: https://github.com/ruby/ruby/pull/11872
2024-11-13Move Array#map to RubyTakashi Kokubun
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/12074
2024-11-11Fix regex timeout double-free after stack_doubleJohn Hawthorn
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] Notes: Merged: https://github.com/ruby/ruby/pull/12030
2024-11-08Fix race condition in test_self_stopKJ Tsanaktsidis
This test was relying on a sleep to synchronise the parent and child processes. By having the child be the process that stops itself with SIGSTOP, instead of the parent, we can actually properly wait for that using waitpid2 and be notified of the stop. This use of sleep to synchronise processes is potentially flaky and caused failures under rr's `--chaos` mode. Notes: Merged: https://github.com/ruby/ruby/pull/12042
2024-11-08Fix update_coderange for binary stringsJohn Hawthorn
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> Notes: Merged: https://github.com/ruby/ruby/pull/12029
2024-11-08Fix memory leak in prism when syntax error in iseq compilationPeter Zhu
If there's a syntax error during iseq compilation then prism would leak memory because it would not free the pm_parse_result_t. This commit changes pm_iseq_new_with_opt to have a rb_protect to catch when an error is raised, and return NULL and set error_state to a value that can be raised by calling rb_jump_tag after memory has been freed. For example: 10.times do 10_000.times do eval("/[/=~s") rescue SyntaxError end puts `ps -o rss= -p #{$$}` end Before: 39280 68736 99232 128864 158896 188208 217344 246304 275376 304592 After: 12192 13200 14256 14848 16000 16000 16000 16064 17232 17952 Notes: Merged: https://github.com/ruby/ruby/pull/12036
2024-11-08Avoid calculating large powersYusuke Endoh
... for slow CI machines like macOS.
2024-11-08Do not round `a**b` to infinityYusuke Endoh
... instead, just calculate the value unless it is too big. Also, this change raises an ArgumentError if it is expected to exceed 16 GB in a 64-bit environment. (It is possible to calculate it straightforward, but it would likely be out-of-memory, so I didn't think it would make sense.) [Feature #20811] Notes: Merged: https://github.com/ruby/ruby/pull/12033
2024-11-07[Bug #20869] Discard read buffer and encoding converters at seekingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12023
2024-11-07[Bug #20802] Copy encodings at reopen as wellNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12022
2024-11-07Prevent method redefinition warnings in testYusuke Endoh
2024-11-06io_buffer.c: Allow copies between overlapping buffers with #copy and ↵Kasumi Hanazuki
#set_string (#11640) The current implementation of `IO::Buffer#copy` and `#set_string` has an undefined behavior when the source and destination memory overlaps, due to the underlying use of the `memcpy` C function. This patch guarantees the methods to be safe even when copying between overlapping buffers by replacing `memcpy` with `memmove`, Fixes: [Bug #20745] Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2024-11-06[Bug #20868] Fix Method#hash to not change after compactionPeter Zhu
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 Notes: Merged: https://github.com/ruby/ruby/pull/12004
2024-11-06Fix flakiness in TestGc#test_thrashing_for_young_objectsKJ Tsanaktsidis
I caught a reproduction of this test failing under rr, and was able to replay it to isolate the failure. The call to `before_stat_heap = GC.stat_heap` is itself allocating a hash, which in unlucky circumstances can result in a new page being allocated and thus `before_stats[:heap_allocated_pages]` no longer equals `after_stats[:heap_allocated_pages]`. The solution is to use the form of GC.stat/stat_heap which takes a hash as an argument, and thus needs to perform no Ruby allocations itself. Notes: Merged: https://github.com/ruby/ruby/pull/11997
2024-11-06macOS 15 is the stable version todayHiroshi SHIBATA
2024-11-06[Bug #20873] Consider `-FIXNUM_MIN` overflowNobuyoshi Nakada
`-FIXNUM_MIN` is usually greater than `FIXNUM_MAX` on platforms using two's complement representation. Notes: Merged: https://github.com/ruby/ruby/pull/12011
2024-11-06`Warning[:strict_unused_block]`Koichi Sasada
to show unused block warning strictly. ```ruby class C def f = nil end class D def f = yield end [C.new, D.new].each{|obj| obj.f{}} ``` In this case, `D#f` accepts a block. However `C#f` doesn't accept a block. There are some cases passing a block with `obj.f{}` where `obj` is `C` or `D`. To avoid warnings on such cases, "unused block warning" will be warned only if there is not same name which accepts a block. On the above example, `C.new.f{}` doesn't show any warnings because there is a same name `D#f` which accepts a block. We call this default behavior as "relax mode". `strict_unused_block` new warning category changes from "relax mode" to "strict mode", we don't check same name methods and `C.new.f{}` will be warned. [Feature #15554] Notes: Merged: https://github.com/ruby/ruby/pull/12005
2024-11-04YJIT: Replace Array#each only when YJIT is enabled (#11955)Takashi Kokubun
* YJIT: Replace Array#each only when YJIT is enabled * Add comments about BUILTIN_ATTR_C_TRACE * Make Ruby Array#each available with --yjit as well * Fix all paths that expect a C location * Use method_basic_definition_p to detect patches * Copy a comment about C_TRACE flag to compilers * Rephrase a comment about add_yjit_hook * Give METHOD_ENTRY_BASIC flag to Array#each * Add --yjit-c-builtin option * Allow inconsistent source_location in test-spec * Refactor a check of BUILTIN_ATTR_C_TRACE * Set METHOD_ENTRY_BASIC without touching vm->running Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2024-11-04Fix Dir.mktmpdir argumentNobuyoshi Nakada
The temporary directory is the second argument.
2024-11-02Skip TestProc#test_hash_does_not_change_after_compaction if compaction is ↵Peter Zhu
not supported Notes: Merged: https://github.com/ruby/ruby/pull/11980
2024-11-01Improve coverage of TestProc#test_hash_uniquenessPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11966
2024-11-01Add TestProc#test_hash_equalPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11966
2024-11-01Rename test_hash to test_hash_uniquenessPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11966
2024-11-01[Bug #20853] Fix Proc#hash to not change after compactionPeter Zhu
The hash value of a Proc must remain constant after a compaction, otherwise it may not work as the key in a hash table. Notes: Merged: https://github.com/ruby/ruby/pull/11966
2024-11-01`alias` should not set `defined_class` for ModulesKoichi Sasada
`me->defined_class` should be 0 for method entries of Modules. This patch checks this condition and fix https://github.com/ruby/ruby/pull/11965#issuecomment-2448291790 Notes: Merged: https://github.com/ruby/ruby/pull/11968
2024-10-31Fix assertion when envval of proc is QundefPeter Zhu
The following code crashes with assertions enabled because envval could be Qundef: {}.to_proc.dup Notes: Merged: https://github.com/ruby/ruby/pull/11970
2024-10-31Fix indentation in TestProc#test_hash [ci skip]Peter Zhu
2024-10-21Show where mutated chilled strings were allocatedÉtienne Barrié
[Feature #20205] The warning now suggests running with --debug-frozen-string-literal: ``` test.rb:3: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information) ``` When using --debug-frozen-string-literal, the location where the string was created is shown: ``` test.rb:3: warning: literal string will be frozen in the future test.rb:1: info: the string was created here ``` When resurrecting strings and debug mode is not enabled, the overhead is a simple FL_TEST_RAW. When mutating chilled strings and deprecation warnings are not enabled, the overhead is a simple warning category enabled check. Co-authored-by: Jean Boussier <byroot@ruby-lang.org> Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Jean Boussier <byroot@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/11893