summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2022-12-16Unconditionally warn "unknown pack/unpack directive"Yusuke Endoh
[Bug #19150] Notes: Merged: https://github.com/ruby/ruby/pull/6948
2022-12-16Reject keyword arguments given to Enumerator::Product.newAkinori MUSHA
The use of keyword arguments should be reserved for future extension.
2022-12-16fixed encoding tableKoichi Sasada
This reduces global lock acquiring for reading. https://bugs.ruby-lang.org/issues/18949 Notes: Merged: https://github.com/ruby/ruby/pull/6935
2022-12-15YJIT: Fix `obj.send(:call)`Alan Wu
All the method call types need to handle argument shifting in case they're called by `.send`, and we weren't handling that in `OPTIMIZED_METHOD_TYPE_CALL`. Lack of shifting caused the stack size assertion in gen_leave() to fail. Discovered by Rails CI: https://buildkite.com/rails/rails/builds/91705#018516c4-f8f8-469e-bc2d-ddeb25ca8317/1920-2067 Diagnosed with help from `@eileencodes` and `@k0kubun`. Notes: Merged: https://github.com/ruby/ruby/pull/6943 Merged-By: XrXr
2022-12-15Fix Object Movement allocation in GCMatt Valentine-House
When moving Objects between size pools we have to assign a new shape. This happened during updating references - we tried to create a new shape tree that mirrored the existing tree, but based on the root shape of the new size pool. This causes allocations to happen if the new tree doesn't already exist, potentially triggering a GC, during GC. This commit changes object movement to look for a pre-existing new tree during object movement, and if that tree does not exist, we don't move the object to the new pool. This allows us to remove the shape allocation from update references. Co-Authored-By: Peter Zhu <peter@peterzhu.ca> Notes: Merged: https://github.com/ruby/ruby/pull/6938
2022-12-15Transition complex objects to "too complex" shapeJemma Issroff
When an object becomes "too complex" (in other words it has too many variations in the shape tree), we transition it to use a "too complex" shape and use a hash for storing instance variables. Without this patch, there were rare cases where shape tree growth could "explode" and cause performance degradation on what would otherwise have been cached fast paths. This patch puts a limit on shape tree growth, and gracefully degrades in the rare case where there could be a factorial growth in the shape tree. For example: ```ruby class NG; end HUGE_NUMBER.times do NG.new.instance_variable_set(:"@unique_ivar_#{_1}", 1) end ``` We consider objects to be "too complex" when the object's class has more than SHAPE_MAX_VARIATIONS (currently 8) leaf nodes in the shape tree and the object introduces a new variation (a new leaf node) associated with that class. For example, new variations on instances of the following class would be considered "too complex" because those instances create more than 8 leaves in the shape tree: ```ruby class Foo; end 9.times { Foo.new.instance_variable_set(":@uniq_#{_1}", 1) } ``` However, the following class is *not* too complex because it only has one leaf in the shape tree: ```ruby class Foo def initialize @a = @b = @c = @d = @e = @f = @g = @h = @i = nil end end 9.times { Foo.new } `` This case is rare, so we don't expect this change to impact performance of most applications, but it needs to be handled. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/6931
2022-12-15Revert "Fix Object Movement allocation in GC"Peter Zhu
This reverts commit 9c54466e299aa91af225bc2d92a3d7755730948f. We're seeing crashes in Shopify CI after this commit.
2022-12-15Fix Object Movement allocation in GCMatt Valentine-House
When moving Objects between size pools we have to assign a new shape. This happened during updating references - we tried to create a new shape tree that mirrored the existing tree, but based on the root shape of the new size pool. This causes allocations to happen if the new tree doesn't already exist, potentially triggering a GC, during GC. This commit changes object movement to look for a pre-existing new tree during object movement, and if that tree does not exist, we don't move the object to the new pool. This allows us to remove the shape allocation from update references. Co-Authored-By: Peter Zhu <peter@peterzhu.ca> Notes: Merged: https://github.com/ruby/ruby/pull/6926
2022-12-15Disallow mixed usage of ... and */**Shugo Maeda
[Feature #19134] Notes: Merged: https://github.com/ruby/ruby/pull/6934
2022-12-15Remove `require 'io/wait'` where it's no longer necessary. (#6932)Samuel Williams
* Remove `require 'io/wait'` as it's part of core now. * Update ruby specs using version gates. * Add note about why it's conditional. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-12-14Add `Regexp.linear_time?` (#6901)TSUYUSATO Kitsune
Notes: Merged-By: makenowjust <make.just.on@gmail.com>
2022-12-13[Bug #19195] Allow optional newlines before closing parenthesisNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6916
2022-12-12Make absent operator work at the end of the input stringYusuke Endoh
https://bugs.ruby-lang.org/issues/19104#change-100542 Notes: Merged: https://github.com/ruby/ruby/pull/6902
2022-12-10MJIT: Compile methods in batches (#6900)Takashi Kokubun
* MJIT: Compile methods in batches * MJIT: make mjit-bindgen * MJIT: Fix RubyVM::MJIT tests Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-12-10Expose need_major_gc via GC.latest_gc_info (#6791)Mirek Klimos
Notes: Merged-By: peterzhu2118 <peter@peterzhu.ca>
2022-12-10A negative denominator case in the Rational string parsing testNobuyoshi Nakada
2022-12-09YJIT: implement `getconstant` YARV instruction (#6884)Maxime Chevalier-Boisvert
* YJIT: implement getconstant YARV instruction * Constant id is not a pointer * Stack operands must be read after jit_prepare_routine_call Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-12-09Use rb_inspect instead of +PRIsVALUE for Object.inspectMatt Valentine-House
In order to preserve the values when TrueClass, FalseClass or NilClass are stored in ivars Notes: Merged: https://github.com/ruby/ruby/pull/6872
2022-12-08Freeze singleton class, not its originAlan Wu
Previously, when we froze an object, we froze `RCLASS_ORIGIN(object.singleton_class)`, which didn't freeze `object.singleton_class` when it has some prepended modules. Origin iclass are internal objects and users can't interact with them through Kernel#freeze?, Kernel#freeze, or any mutation method that checks the frozen status. So we shouldn't touch the origin iclasses when the frozen status should be visible. [Bug #19169] Notes: Merged: https://github.com/ruby/ruby/pull/6869
2022-12-08Introduce `IO.new(..., path:)` and promote `File#path` to `IO#path`. (#6867)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-12-07Stop transitioning to UNDEF when undefining an instance variableAaron Patterson
Cases like this: ```ruby obj = Object.new loop do obj.instance_variable_set(:@foo, 1) obj.remove_instance_variable(:@foo) end ``` can cause us to use many more shapes than we want (and even run out). This commit changes the code such that when an instance variable is removed, we'll walk up the shape tree, find the shape, then rebuild any child nodes that happened to be below the "targetted for removal" IV. This also requires moving any instance variables so that indexes derived from the shape tree will work correctly. Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com> Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6866
2022-12-07[Bug #19187] Fix for tzdata-2022gNobuyoshi Nakada
2022-12-06add file version check for new Unicode emoji file headerMartin Dürst
The change in the Unicode emoji file header took place at version 14.0.0, but is needed only from version 15.0.0 because in version 14.0.0, another check is still active.
2022-12-03return early if there is no is_entries bufferAaron Patterson
If there is a compilation error, is_entries may not be allocated, but ic_size could be greater than 0. If we don't have a buffer to iterate over, just return early. Otherwise GC could segv [Bug #19173] Notes: Merged: https://github.com/ruby/ruby/pull/6853
2022-12-03UnboundMethod only refer defined_classKoichi Sasada
UnboundMethod records caller's class, like `D` or `E` on the following case: ```ruby class C def foo = :foo end class D < C end class E < C end d = D.instance_method(:foo) e = E.instance_method(:foo) ``` But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't record `D` or `E`. This behavior changes the following methods: * `UnboundMethod#inspect` (doesn't show caller's class) * `UnboundMethod#==` (`d == e` for example) fix https://bugs.ruby-lang.org/issues/18798 Notes: Merged: https://github.com/ruby/ruby/pull/6855
2022-12-02Wait killed threadNobuyoshi Nakada
2022-12-01Module#remove_method: Check frozen on the right objectJean byroot Boussier
Previously, the frozen check happened on `RCLASS_ORIGIN(self)`, which can return an iclass. The frozen check is supposed to respond to objects that users can call methods on while iclasses are hidden from users. Other mutation methods like Module#{define_method,alias_method,public} don't do this. Check frozen status on the module itself. Fixes [Bug #19164] and [Bug #19166]. Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6842 Merged-By: XrXr
2022-12-02[Bug #19087] Disallow successive underscores in Complex stringNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6645
2022-12-01YJIT: Reorder branches for Fixnum opt_case_dispatch (#6841)Takashi Kokubun
* YJIT: Reorder branches for Fixnum opt_case_dispatch Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> * YJIT: Don't support too large values Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-12-02[Feature #19163] Marshal-loaded Data object also should be frozenNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6843
2022-12-02[Feature #19163] Data object should be frozenNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6843
2022-12-01[Bug #19108] Check for the encoding of pack/unpack formatNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6785
2022-12-01[Feature #19138] Add `SyntaxError#path`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6779
2022-11-30Use RTEST and add test for GH-6832Alan Wu
Technically we shouldn't see Qfalse now, but RTEST also compiles down to just one branch anyways. Pretty contrived issue, but easy to fix. Notes: Merged: https://github.com/ruby/ruby/pull/6832
2022-11-30YJIT: Optimize rb_int_equal (#6838)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-12-01Prevent segfault in String#scan with ObjectSpace.each_objectYusuke Endoh
Calling `String#scan` without a block creates an incomplete MatchData object whose `RMATCH(match)->str` is Qfalse. Usually this object is not leaked, but it was possible to pull it by using ObjectSpace.each_object. This change hides the internal MatchData object by using rb_obj_hide. Fixes [Bug #19159] Notes: Merged: https://github.com/ruby/ruby/pull/6836
2022-11-29Add a test case for argument forwardingyui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/6828
2022-11-29Add tests for [Feature #19134]Shugo Maeda
https://bugs.ruby-lang.org/issues/19134?next_issue_id=19133&prev_issue_id=19135#note-4
2022-11-29Allow ** in def foo(...)Shugo Maeda
[Feature #19134] Notes: Merged: https://github.com/ruby/ruby/pull/6818
2022-11-27Make the timeout of test_system_sigpipe longerTakashi Kokubun
https://github.com/ruby/ruby/actions/runs/3562236318/jobs/5983796689
2022-11-27Relax a too strict timeoutTakashi Kokubun
Regexp tests are flaky. http://rubyci.s3.amazonaws.com/s390x/ruby-master/log/20221128T050004Z.fail.html.gz
2022-11-25MJIT: Remove the code to optimize shape transitionTakashi Kokubun
because this code crashes on railsbench. I'll try adding a repro for it later, but I don't know shapes enough to craft it right away.
2022-11-25YJIT: Run test-all tests without requiring RUN_OPTSAlan Wu
Most tests in test_yjit.rb use a sub process, so we can run them even when the parent process is not running with YJIT. Run them so simply running `make check` tests YJIT a bit. [Misc #19149] Notes: Merged: https://github.com/ruby/ruby/pull/6814
2022-11-25Fix autoload status of statically linked extensionsAlan Wu
Previously, for statically-linked extensions, we used `vm->loading_table` to delay calling the init function until the extensions are required. This caused the extensions to look like they are in the middle of being loaded even before they're required. (`rb_feature_p()` returned true with a loading path output.) Combined with autoload, queries like `defined?(CONST)` and `Module#autoload?` were confused by this and returned nil incorrectly. RubyGems uses `defined?` to detect if OpenSSL is available and failed when OpenSSL was available in builds using `--with-static-linked-ext`. Use a dedicated table for the init functions instead of adding them to the loading table. This lets us remove some logic from non-EXTSTATIC builds. [Bug #19115] Notes: Merged: https://github.com/ruby/ruby/pull/6756
2022-11-25[Bug #18971] Add precheck to enumeratorNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6809
2022-11-24Make String#rstrip{,!} raise Encoding::CompatibilityError for broken coderangeJeremy Evans
It's questionable whether we want to allow rstrip to work for strings where the broken coderange occurs before the trailing whitespace and not after, but this approach is probably simpler, and I don't think users should expect string operations like rstrip to work on broken strings. In some cases, this changes rstrip to raise Encoding::CompatibilityError instead of ArgumentError. However, as the problem is related to an encoding issue in the receiver, and due not due to an issue with an argument, I think Encoding::CompatibilityError is the more appropriate error. Fixes [Bug #18931] Notes: Merged: https://github.com/ruby/ruby/pull/6282
2022-11-24Raise TypeError for endless non-numeric range include?Jeremy Evans
Beginless ranges previously raised TypeError for this case, except for string ranges, which had unexpected behavior: ('a'..'z').include?('ww') # false (..'z').include?('ww') # previously true, now TypeError Use of include? with endless ranges could previously result in an infinite loop. This splits off a range_string_cover_internal function from range_include_internal. Fixes [Bug #18580] Notes: Merged: https://github.com/ruby/ruby/pull/6261
2022-11-24Relax the timeout of TestRegexp#test_cache_optimization_squareYusuke Endoh
It fails on riscv (QEmu) http://rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20221124T000021Z.fail.html.gz ``` 1) Error: TestRegexp#test_cache_optimization_square: Regexp::TimeoutError: regexp match timeout /home/rubyci/chkbuild/tmp/build/20221124T000021Z/ruby/test/ruby/test_regexp.rb:1693:in `<main>' /home/rubyci/chkbuild/tmp/build/20221124T000021Z/ruby/test/ruby/test_regexp.rb:1688:in `test_cache_optimization_square' ```
2022-11-22Add Time#deconstruct_keyszverok
Notes: Merged: https://github.com/ruby/ruby/pull/6594
2022-11-22Use dedicated assertions for warningsNobuyoshi Nakada