summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2021-11-23merge revision(s) e83c02a768af61cd0890a75e90bcae1119d8bd93: [Backport #18289]nagachika
Delegate keywords from Enumerable#to_a to #each Fixes [Bug #18289] --- enum.c | 2 +- test/ruby/test_enum.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
2021-11-23merge revision(s) 84202963c52e02cecad3e6b2fad478bfbeee1bc7: [Backport #18329]nagachika
[Bug #18329] Fix crash when calling non-existent super method The cme is NULL when a method does not exist, so check it before accessing the callcache. --- test/ruby/test_super.rb | 31 +++++++++++++++++++++++++++++++ vm_insnhelper.c | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-)
2021-11-06merge revision(s) a4d5ee4f31bf3ff36c1a8c8fe3cda16aa1016b12: [Backport #18264]nagachika
[Bug #18264] Fix memory leak in TracePoint TracePoint leaks memory because it allocates a `rb_tp_t` struct without ever freeing it (it is created with `RUBY_TYPED_NEVER_FREE`). --- test/ruby/test_settracefunc.rb | 10 ++++++++++ vm_trace.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
2021-10-31test_gc.rb: relax criterionnagachika
2021-10-16merge revision(s) 217df51f0e5d9824ed712a4d175f555d932e44d8: [Backport #18232]nagachika
Dump outer variables tables when dumping an iseq to binary This commit dumps the outer variables table when dumping an iseq to binary. This fixes a case where Ractors aren't able to tell what outer variables belong to a lambda after the lambda is loaded via ISeq.load_from_binary [Bug #18232] [ruby-core:105504] --- compile.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- test/ruby/test_iseq.rb | 10 +++++++++ 2 files changed, 64 insertions(+), 1 deletion(-)
2021-10-09merge revision(s) abc0304cb28cb9dcc3476993bc487884c139fd11: [Backport #17507]nagachika
Avoid race condition in Regexp#match In certain conditions, Regexp#match could return a MatchData with missing captures. This seems to require at the least, multiple threads calling a method that calls the same block/proc/lambda which calls Regexp#match. The race condition happens because the MatchData is passed from indirectly via the backref, and other threads can modify the backref. Fix the issue by: 1. Not reusing the existing MatchData from the backref, and always allocating a new MatchData. 2. Passing the MatchData directly to the caller using a VALUE*, instead of indirectly through the backref. It's likely that variants of this issue exist for other Regexp methods. Anywhere that MatchData is passed implicitly through the backref is probably vulnerable to this issue. Fixes [Bug #17507] --- re.c | 46 +++++++++++++++++++--------------------------- test/ruby/test_regexp.rb | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 27 deletions(-)
2021-10-09merge revision(s) ↵nagachika
60d0421ca861944459f52292d65dbf0ece26e38a,b6534691a16d751d59fc572d5dddebcaeb21f007,409dbc951b9875d27bd73748c88e15386473cffb,842b0008c132dd587f09766a228041afb7fed24f: [Backport #18191] Fix the encoding of loaded feature names [Bug #18191] The feature names loaded from the default load paths should also be in the file system encoding. --- ruby.c | 12 +++++++++++- test/ruby/test_require.rb | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) Copy path strings as interned strings --- ruby.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) Replace expanded load path only when modified --- ruby.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) Skip broken strings as the locale encoding --- internal/string.h | 1 + ruby.c | 11 +++++++---- string.c | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-)
2021-10-09merge revision(s) ↵nagachika
89242279e61b023a81c58065c62a82de8829d0b3,529fc204af84f825f98f83c34b004acbaa802615: [Backport #18141] Marshal.load: do not call the proc until strings have their encoding Ref: https://bugs.ruby-lang.org/issues/18141 --- marshal.c | 7 +++- spec/ruby/core/marshal/shared/load.rb | 62 +++++++++++++++++++++++------------ test/ruby/test_marshal.rb | 17 ++++++++++ 3 files changed, 64 insertions(+), 22 deletions(-) marshal.c: don't call the proc with partially initialized objects. (#4866) For cyclic objects, it requires to keep a st_table of the partially initialized objects. --- marshal.c | 75 ++++++++++++++++++++--------------- spec/ruby/core/marshal/shared/load.rb | 75 ++++++++++++++++++++--------------- test/ruby/test_marshal.rb | 12 ++++++ 3 files changed, 97 insertions(+), 65 deletions(-)
2021-10-03merge revision(s) ↵nagachika
7c0230b05d0978958f89434c84ddd9c82419c1a5,552728a23aeab0df598b356b19a573259e297d14,49af9012a20a824542cf588e55e5488895553e09: [Backport #18184] Check the entire name as `ruby2_keywords_flag` [Bug #18184] --- marshal.c | 2 +- test/ruby/test_marshal.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) Check the encoding of `ruby2_keywords_flag` [Bug #18184] --- marshal.c | 1 + test/ruby/test_marshal.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) Prohibit invalid encoding symbols [Bug #18184] --- marshal.c | 8 +++++++- test/ruby/test_marshal.rb | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-)
2021-10-03merge revision(s) ddb32e66160ab50849419ef7c7ac584913b79c34: [Backport #18173]nagachika
[Bug #18173] Update loaded_features_index If $LOADED_FEATURES is changed in the just required file, also the index table needs to be updated before loaded_features_snapshot is reset. If the snapshot is reset without updating the table, the name of the added feature will not be found. --- load.c | 1 + test/ruby/test_require.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
2021-09-18merge revision(s) 99d8c4832a7133ca52578d015e3ddcfd94820f4a: [Backport #18160]nagachika
Preserve the encoding of the argument in IndexError [Bug #18160] --- re.c | 20 ++++++++++---------- test/ruby/test_regexp.rb | 7 ++++++- 2 files changed, 16 insertions(+), 11 deletions(-)
2021-09-18merge revision(s) 13939d61b4b69bd109c5f41303c79868d639fa44: [Backport #17661]nagachika
Check if closed after each yield [Bug #17661] --- io.c | 4 +++- test/ruby/test_io.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)
2021-09-11merge revision(s) 5d815542815fe8b939239750bba7f8f0b79c97d6: [Backport #18154]nagachika
[Bug #18154] Fix memory leak in String#initialize String#initialize can leak memory when called on a string that is marked with STR_NOFREE because it does not unset the STR_NOFREE flag. --- string.c | 2 +- test/ruby/test_string.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
2021-09-05merge revision(s) ↵nagachika
cd4f5b13228879d954fa97b6aa479c4a5ef4fb0a,8db269edb3550a85dfab9b193ea115ca36912ced,ab63f6d8543903f177c46634f38e5428655f003b: [Backport #18140] Guard array when appending This prevents early collection of the array. The GC doesn't see the array on the stack when Ruby is compiled with optimizations enabled [ruby-core:105099] [Bug #18140] --- array.c | 1 + test/ruby/test_array.rb | 6 ++++++ 2 files changed, 7 insertions(+) Guard array when appending This prevents early collection of the array. The GC doesn't see the array on the stack when Ruby is compiled with optimizations enabled Thanks @jhaberman for the test case [ruby-core:105099] [Bug #18140] --- ext/-test-/array/concat/depend | 321 ++++++++++++++++++++++++++++++++ ext/-test-/array/concat/extconf.rb | 2 + ext/-test-/array/concat/to_ary_conact.c | 64 +++++++ test/-ext-/array/test_to_ary_concat.rb | 20 ++ 4 files changed, 407 insertions(+) create mode 100644 ext/-test-/array/concat/depend create mode 100644 ext/-test-/array/concat/extconf.rb create mode 100644 ext/-test-/array/concat/to_ary_conact.c create mode 100644 test/-ext-/array/test_to_ary_concat.rb Refined test [Bug #18140] --- ext/-test-/array/concat/to_ary_conact.c | 48 +++++++-------------------------- test/ruby/test_array.rb | 5 +++- 2 files changed, 13 insertions(+), 40 deletions(-)
2021-08-29merge revision(s) ↵nagachika
d43279edacd09edf3a43e02d62f5be475e7c3bcb,5dc36ddcd00fc556c04c15ce9770c5a84d7d43dc,523bf31564f160f899f8cf9f73540d6a6f687f17: [Backport #18138] Fix length calculation for Array#slice! Commit 4f24255 introduced a bug which allows a length to be passed to rb_ary_new4 which is too large, resulting in invalid memory access. For example: (1..1000).to_a.slice!(-2, 1000) --- array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Add out of range tests for Array#slice! --- test/ruby/test_array.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) Add negative position tests [Bug #18138] --- test/ruby/test_array.rb | 4 ++++ 1 file changed, 4 insertions(+)
2021-08-08Fix multiple bugs in partial backtrace optimizationJeremy Evans
This fixes multiple bugs found in the partial backtrace optimization added in 3b24b79. These bugs occurs when passing a start argument to caller where the start argument lands on a iseq frame without a pc. Before this commit, the following code results in the same line being printed twice, both for the #each method. ``` def a; [1].group_by { b } end def b; puts(caller(2, 1).first, caller(3, 1).first) end a ``` After this commit and in Ruby 2.7, the lines are different, with the first line being for each and the second for group_by. Before this commit, the following code can either segfault or result in an infinite loop: ``` def foo caller_locations(2, 1).inspect # segfault caller_locations(2, 1)[0].path # infinite loop end 1.times.map { 1.times.map { foo } } ``` After this commit, this code works correctly. In terms of the implementation, this correctly skips iseq frames without pc that occur before the number of frames the caller requested to skip. This rewrites the algorithm used for handling the partial backtraces. It scans from the current frame outward to the earliest frame, until it has found the desired number of frames. It records that frame as the start frame. If needed, it continues scanning backwards until arg->prev_cfp is set, as that is needed to set the location of the first frame. Due to the fact that arg is a void pointer, it's not possible to check this directly, but this calls the iter_skip function in a situation where it knows it will set arg->prev_cfp, and then breaks out of the loop. Fixes [Bug #18053]
2021-07-18merge revision(s) ↵nagachika
391abc543cea118a9cd7d6310acadbfa352668ef,e86c1f6fc53433ef5c82ed2b7a4cc9a12c153e4c,f6539202c52a051a4e6946a318a1d9cd29002990: [Backport #12052] Scan the coderange in the given encoding --- ext/-test-/string/enc_str_buf_cat.c | 14 ++++++++++++++ string.c | 32 ++++++++++++++++++++++--------- test/-ext-/string/test_enc_str_buf_cat.rb | 9 +++++++++ 3 files changed, 46 insertions(+), 9 deletions(-) Work around issue transcoding issue with non-ASCII compatible encodings and xml escaping When using a non-ASCII compatible source and destination encoding and xml escaping (the :xml option to String#encode), the resulting string was broken, as it used the correct non-ASCII compatible encoding, but contained data that was ASCII-compatible instead of compatible with the string's encoding. Work around this issue by detecting the case where both the source and destination encoding are non-ASCII compatible, and transcoding the source string from the non-ASCII compatible encoding to UTF-8. The xml escaping code will correctly handle the UTF-8 source string and the return the correctly encoded and escaped value. Fixes [Bug #12052] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> --- test/ruby/test_transcode.rb | 19 +++++++++++++++++++ transcode.c | 6 ++++++ 2 files changed, 25 insertions(+) =?UTF-8?q?-=20add=20regression=20tests=20for=20U+6E7F=20(?= =?UTF-8?q?=E6=B9=BF)=20in=20ISO-2022-JP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ISO-2022-JP, the bytes use to code are the same as those for "<>". This adds regression tests to make sure that these bytes, when representing 湿, are NOT escaped with encode("ISO-2022-JP, xml: :text) or similar. These are additional regression tests for #12052. --- test/ruby/test_transcode.rb | 3 +++ 1 file changed, 3 insertions(+)
2021-07-03Revert "merge revision(s) ↵nagachika
e86c1f6fc53433ef5c82ed2b7a4cc9a12c153e4c,f6539202c52a051a4e6946a318a1d9cd29002990: [Backport #1205]" This reverts commit e62cccaeb0986d43480bccbd365cb20056bda4d7.
2021-07-03merge revision(s) ↵nagachika
e86c1f6fc53433ef5c82ed2b7a4cc9a12c153e4c,f6539202c52a051a4e6946a318a1d9cd29002990: [Backport #1205] Work around issue transcoding issue with non-ASCII compatible encodings and xml escaping When using a non-ASCII compatible source and destination encoding and xml escaping (the :xml option to String#encode), the resulting string was broken, as it used the correct non-ASCII compatible encoding, but contained data that was ASCII-compatible instead of compatible with the string's encoding. Work around this issue by detecting the case where both the source and destination encoding are non-ASCII compatible, and transcoding the source string from the non-ASCII compatible encoding to UTF-8. The xml escaping code will correctly handle the UTF-8 source string and the return the correctly encoded and escaped value. Fixes [Bug #12052] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> --- test/ruby/test_transcode.rb | 19 +++++++++++++++++++ transcode.c | 6 ++++++ 2 files changed, 25 insertions(+) =?UTF-8?q?-=20add=20regression=20tests=20for=20U+6E7F=20(?= =?UTF-8?q?=E6=B9=BF)=20in=20ISO-2022-JP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ISO-2022-JP, the bytes use to code are the same as those for "<>". This adds regression tests to make sure that these bytes, when representing 湿, are NOT escaped with encode("ISO-2022-JP, xml: :text) or similar. These are additional regression tests for #12052. --- test/ruby/test_transcode.rb | 3 +++ 1 file changed, 3 insertions(+)
2021-07-03merge revision(s) ↵nagachika
0846c2da457e7523819236ac7da492029b3ef73d,6c7cb00c094332a208cf36e5cd723a9ba60c41b8: [Backport #16376] Check backref number buffer overrun [Bug #16376] --- regcomp.c | 21 ++++++++++++--------- test/ruby/test_regexp.rb | 6 ++++++ 2 files changed, 18 insertions(+), 9 deletions(-) test/ruby/test_regexp.rb: Avoid "ambiguity between regexp and two divisions" --- test/ruby/test_regexp.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
2021-05-29merge revision(s) 636d4f7eb9f3fcb088e1a44af4181c4aa36789b4: [Backport #17822]nagachika
Avoid setting the visibility of refinement method entries Since refinement search is always performed, these entries should always be public. The method entry that the refinement search returns decides the visibility. Fixes [Bug #17822] --- test/ruby/test_refinement.rb | 22 ++++++++++++++++++++++ vm_method.c | 15 ++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-)
2021-05-29merge revision(s) 39a2ba5cc559900c30c3143da32446c2f20a7484: [Backport #17806]nagachika
Method cache: fix refinement entry handling To invalidate some callable method entries, we replace the entry in the class. Most types of method entries are on the method table of the origin class, but refinement entries without an orig_me are housed in the method table of the class itself. They are there because refinements take priority over prepended methods. By unconditionally inserting a copy of the refinement entry into the origin class, clearing the method cache created situations where there are refinement entry duplicates in the lookup chain, leading to infinite loops and other problems. Update the replacement logic to use the right class that houses the method entry. Also, be more selective about cache invalidation when moving refinement entries for prepend. This avoids calling clear_method_cache_by_id_in_class() before refinement entries are in the place it expects. [Bug #17806] --- class.c | 4 +++- test/ruby/test_refinement.rb | 49 ++++++++++++++++++++++++++++++++++++++++++++ vm_method.c | 13 ++++++++++-- 3 files changed, 63 insertions(+), 3 deletions(-)
2021-05-29merge revision(s) 4b36a597f48c857aa5eb9ed80fec0d02f6284646: [Backport #17519]nagachika
Fix setting method visibility for a refinement without an origin class If a class has been refined but does not have an origin class, there is a single method entry marked with VM_METHOD_TYPE_REFINED, but it contains the original method entry. If the original method entry is present, we shouldn't skip the method when searching even when skipping refined methods. Fixes [Bug #17519] --- test/ruby/test_module.rb | 110 ++++++++++++++++++++++++++++++++++++++++++++++- vm_method.c | 3 +- 2 files changed, 111 insertions(+), 2 deletions(-)
2021-05-29merge revision(s) fd8991f797c145615820b4c76e6b7ac5a71339ea: [Backport #17889]nagachika
Fix lazy enumerator with index size Fixes [Bug #17889] --- enumerator.c | 7 ++++++- test/ruby/test_lazy_enumerator.rb | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)
2021-05-23merge revision(s) cfd162d535c7a4f8b1f95255cc6be696a8b75557: [Backport #17467]nagachika
Make String#{strip,lstrip}{,!} strip leading NUL bytes The documentation already specifies that they strip whitespace and defines whitespace to include null. This wraps the new behavior in the appropriate guards in the specs, but does not specify behavior for previous versions, because this is a bug that could be backported. Fixes [Bug #17467] --- spec/ruby/core/string/lstrip_spec.rb | 18 ++++++++++++------ spec/ruby/core/string/strip_spec.rb | 22 ++++++++++------------ string.c | 4 ++-- test/ruby/test_string.rb | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 20 deletions(-)
2021-05-23merge revision(s) ↵nagachika
e019dd24df4ed7063ad80d4c2e4070141793f598,7954bb056be30e86c419fe3792064d28990a4999,7d3fdfb27dac456827b004d9e66a44b15f8cd762: [Backport #17736] Ensure the receiver is modifiable before shrinking [Bug #17736] * Ensure the receiver is modifiable before shinking [Bug #17736] * Assert the receivers are not modified --- array.c | 1 + test/ruby/test_array.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) Some Hash destructive methods ensure the receiver modifiable [Bug #17736] refs: * https://bugs.ruby-lang.org/issues/17736 * https://github.com/ruby/ruby/pull/4296 This commit aims to cover following methods * Hash#select! * Hash#filter! * Hash#keep_if * Hash#reject! * Hash#delete_if I think these are not all. --- * Ensure the receiver is modifiable or not * Assert the receiver is not modified --- hash.c | 2 ++ test/ruby/test_hash.rb | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) Hash#transform_values! ensures receiver modifiable in block [Bug #17736] --- hash.c | 1 + test/ruby/test_hash.rb | 9 +++++++++ 2 files changed, 10 insertions(+)
2021-05-23merge revision(s) d8a13e504992a45d52063f7c925408d7aad3595a: [Backport #17780]nagachika
[Bug #17780] Fix Method#super_method for module alias Method#super_method crashes for aliased module methods because they are not defined on a class. This bug was introduced in c60aaed1856b2b6f90de0992c34771830019e021 as part of bug #17130. --- proc.c | 2 +- test/ruby/test_method.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
2021-05-22merge revision(s) ↵nagachika
2bc293e899c9d32dcd794a73de8925c49ecf8f15,d0e6c6e682b9ba2b0309a5177933a0628e8ef316,cc0dc67bbbe1951ff90004bc987f78545625d772,e1eff837cf12a8e813de9d4ff2db50c9b68b86b5,0ab0b86c8491d639b9ff1335ddf35e341ecd867e,6911b4bc82889860ff7da4ecf975504cdc3e5314: [Backport #17854] cdhash_cmp: can take rational literals Rational literals are those integers suffixed with `r`. They tend to be a part of more complex expressions like `123/456r`, but in theory they can live alone. When such "bare" rational literals are passed to case-when branch, we have to take care of them. Fixes [Bug #17854] --- common.mk | 1 + compile.c | 7 +++++++ internal/rational.h | 1 + rational.c | 13 ++++++++++--- test/ruby/test_rational.rb | 7 +++++++ 5 files changed, 26 insertions(+), 3 deletions(-) cdhash_cmp: rational literals with fractions Nobu kindly pointed out that rational literals can have fractions. --- compile.c | 5 +++-- test/ruby/test_rational.rb | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) cdhash_cmp: can also take complex There are complex literals `123i`, which can also be a case condition. --- compile.c | 15 +++++++++++---- complex.c | 12 +++++++++--- internal/complex.h | 1 + test/ruby/test_rational.rb | 4 ++++ 4 files changed, 25 insertions(+), 7 deletions(-) cdhash_cmp: recursively apply For instance a rational's numerator can be a bignum. Comparison using C's == can be insufficient. --- compile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) cdhash_cmp: should use || cf: https://github.com/ruby/ruby/pull/4469#discussion_r628386707 --- compile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) test_cdhash: refactor change class It is now strange to test Complex in a class named Rational_Test. --- test/ruby/test_rational.rb | 15 --------------- test/ruby/test_syntax.rb | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-)
2021-05-22merge revision(s) 110f242ef9b495037f59e4972ee102a8b8b372d5: [Backport #17861]nagachika
Also `\U` after control/meta is invalid [Bug #17861] As well as `\u`, `\U` should be invalid there too. And highlight including `u`/`U` not only the backslash before it. --- parse.y | 12 ++++++++++-- test/ruby/test_parse.rb | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-)
2021-05-22merge revision(s) 5026f9a5d5012248729a0052cd6cec811748291b: [Backport #17868]nagachika
compile.c: stop the jump-jump optimization if the second has any event Fixes [Bug #17868] --- compile.c | 3 ++- test/ruby/test_settracefunc.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
2021-04-29merge revision(s) ↵nagachika
87c546b5fa97e6e226cce4daf417617a1143f642,7a3322a0fd660d676f1918bd7c4a37676b44e1c2: Avoid using inconsistent coding style Other `_mjit_compile_*.erb` files don't use goto. These files'd better be consistent for readability. --- tool/ruby_vm/views/_mjit_compile_getinlinecache.erb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) Fix broken JIT of getinlinecache e7fc353f04 reverted vm_ic_hit_p's signature change made in 53babf35ef, which broke JIT compilation of getinlinecache. To make sure it doesn't happen again, I separated vm_inlined_ic_hit_p to make the intention clear. --- test/ruby/test_jit.rb | 12 +++++++++++ .../ruby_vm/views/_mjit_compile_getinlinecache.erb | 2 +- vm_insnhelper.c | 25 ++++++++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-)
2021-04-15merge revision(s) ↵nagachika
31e0382723bfb35cffe3ca485dd0577668cafa07,5e5fb72f99701dc27c66ab148471893f14e6d6f0,fb6ebe55d91187d9635e0183d47dbf38e95b1141,522d4cd32f7727886f4fcbc28ed29c08d361ee20: [Backport #17735] Keep non evaluated keys in `Hash#transform_keys!` [Bug #17735] --- hash.c | 6 +++++- spec/ruby/core/hash/transform_keys_spec.rb | 12 +++++++++++- test/ruby/test_hash.rb | 8 ++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) Clear an intermediate hash [Bug #17735] --- hash.c | 1 + 1 file changed, 1 insertion(+) Hide an intermediate array --- hash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Force recycle intermediate collection in Hash#transform_keys! [Bug #17735] * Force recycle intermediate hash * Force recycle intermediate array too https://github.com/ruby/ruby/pull/4329#issuecomment-808840718 --- hash.c | 2 ++ 1 file changed, 2 insertions(+)
2021-04-05Get rid of multibyte prefix to tmpdirv3_0_1Nobuyoshi Nakada
2021-04-02merge revision(s) 0a544c0c35f7445d69402d7c53d825384c728017: [Backport #17754]NARUSE, Yui
Fix segmentation fault when `Module#name` returns non string value [Bug #17754] * Add test for NoMethodError#to_s does not segfault * Ensure no segfault even if Module#name is overridden --- error.c | 4 +++- test/ruby/test_nomethod_error.rb | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
2021-04-02merge revision(s) f9f13a4f6d8be706b17efc089c28f7bc617ef549: [Backport #17746]NARUSE, Yui
Ensure that caller respects the start argument Previously, if there were ignored frames (iseq without pc), we could go beyond the requested start frame. This has two changes: 1) Ensure that we don't look beyond the start frame by using last_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(last_cfp) until the desired start frame is reached. 2) To fix the failures caused by change 1), which occur when a limited number of frames is requested, scan the VM stack before allocating backtrace frames, looking for ignored frames. This is complicated if there are ignored frames before and after the start, in which case we need to scan until the start frame, and then scan backwards, decrementing the start value until we get to the point where start will result in the number of requested frames. This fixes a Rails test failure. Jean Boussier was able to to produce a failing test case outside of Rails. Co-authored-by: Jean Boussier <jean.boussier@gmail.com> --- test/ruby/test_backtrace.rb | 16 ++++++++++++++ vm_backtrace.c | 52 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-)
2021-04-02merge revision(s) a85ed626f18d1014d09fb37eb0a703976c3d2b53: [Backport #17731]NARUSE, Yui
Fix Enumerable#inject with high negative fixnums [Bug #17731] --- enum.c | 2 +- test/ruby/test_enum.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
2021-04-02merge revision(s) f748b911c9157a0bb86f38280ddfba72a55049b6: [Backport #17729]NARUSE, Yui
Fix infinite loop at illegal sequence [Bug #17729] As mblen returns -1 on failure, skip the first byte and try the succeeding bytes in that case. Close https://github.com/ruby/ruby/pull/4281 --- eval_intern.h | 11 ++++++++++- test/ruby/test_rubyoptions.rb | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-)
2021-04-02merge revision(s) 58660e943488778563b9e41005a601e9660ce21f: [Backport #17519]NARUSE, Yui
Skip refined method when exporting methods with changed visibility Previously, attempting to change the visibility of a method in a singleton class for a class/module that is prepended to and refined would raise a NoMethodError. Fixes [Bug #17519] --- test/ruby/test_module.rb | 23 +++++++++++++++++++++++ vm_method.c | 14 +++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-)
2021-03-02merge revision(s) 87437326214e4587a41946c8937e11418d983acd: [Backport #17581]NARUSE, Yui
Fix backtrace to not skip frames with iseq without pc Previously, frames with iseq but no pc were skipped (even before the refactoring in 3b24b7914c16930bfadc89d6aff6326a51c54295). Because the entire backtrace was procesed before the refactoring, this was handled by using later frames instead. However, after the refactoring, we need to handle those frames or they get lost. Keep two iteration counters when iterating, one for the desired backtrace size (so we generate the desired number of frames), and one for the actual backtrace size (so we don't process off the end of the stack). When skipping over an iseq frame with no pc, decrement the counter for the desired backtrace, so it will continue to process the expected number of backtrace frames. Fixes [Bug #17581] --- test/ruby/test_backtrace.rb | 12 ++++++++++++ vm_backtrace.c | 16 +++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-)
2021-02-16merge revision(s) a681c484a3c5b9235c84bc5c253b4406e498e8cf: [Backport #17626]NARUSE, Yui
Fixed codepage for utime [Bug #17626] Should use the given codepage argument. Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org> --- test/ruby/test_file_exhaustive.rb | 7 +++++++ win32/win32.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
2021-02-02merge revision(s) 1b89b99941548fdb65305dd9a412082e7fdba45a: [Backport #17534]NARUSE, Yui
Mark pattern labels as unremoveable Peephole optimization doesn't play well with find pattern at least. The only case when a pattern matching could have unreachable patterns is when we have lasgn/dasgn node, which shouldn't happen in real-life. Fixes https://bugs.ruby-lang.org/issues/17534 --- compile.c | 2 +- test/ruby/test_pattern_matching.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
2021-02-02merge revision(s) 8dfae85adb96cf3da84bf38f2103969d4a7aed3f: [Backport #17575]NARUSE, Yui
Warn the defined location as deprecation as well as the main message [Bug #17575] --- test/ruby/test_defined.rb | 17 +++++++++++++++++ vm_method.c | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-)
2021-02-02merge revision(s) ↵NARUSE, Yui
9efd590a13d1e8b8a141c46eabb48c2a1c286d2b,a55eb9a2af7950d180d9d31ffde2bce66710f44f: [Backport #17572] Rationalize floats in coerce [Bug #17572] --- rational.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) Make reciprocal properly of non-integral rational [Bug #17572] --- rational.c | 2 +- test/ruby/test_rational.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
2021-02-02merge revision(s) eeacdcb9a073c7d8ad703e0dc9faf229a5ebbe3c: [Backport #17558]NARUSE, Yui
Fixed premature return After setting ruby2_keywords for bmethod, the rest of arguments had been ignored. [Bug #17558] --- test/ruby/test_keyword.rb | 9 +++++++++ vm_method.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-)
2021-02-01merge revision(s) ↵NARUSE, Yui
efcdf68e6443ab70fbff1703b9dabbfc5090df31,5e26619660f20272a53c7f839dde36cce034bb35: [Backport #17539] Guard callinfo Callinfo was being written in to an array and the GC would not see the reference on the stack. `new_insn_send` creates a new callinfo object, then it calls `new_insn_core`. `new_insn_core` allocates a new INSN linked list item, which can end up calling `xmalloc` which will trigger a GC: https://github.com/ruby/ruby/blob/70cd351c7c71c48ee18d7c01e851a89614086f8f/compile.c#L968-L969 Since the callinfo object isn't on the stack, the GC won't see it, and it can get collected. This patch just refactors `new_insn_send` to keep the object on the stack Co-authored-by: John Hawthorn <john@hawthorn.email> --- compile.c | 7 +++++-- test/ruby/test_gc.rb | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) Fix WB for callinfo The WB for callinfo needs to be executed *after* the reference is written. Otherwise we get a WB miss. --- compile.c | 1 + 1 file changed, 1 insertion(+)
2021-02-01merge revision(s) 0036648a420f945624898568bb82bc5f83195d12: [Backport #17533]NARUSE, Yui
Capture to reserved name variables if already defined [Bug #17533] --- parse.y | 5 +++-- test/ruby/test_regexp.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
2021-02-01merge revision(s) 6f6dfdcc685077f0f85dcdd63843ecfc0f6fbfb6: [Backport #17523]NARUSE, Yui
Make warning values consistent [Bug #17523] They should be affected, as well as `$VERBOSE`, by `-w`/`-W` options, not only in the main script but in scripts loaded by `-r` option too. --- ruby.c | 4 ++-- test/ruby/test_rubyoptions.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
2021-02-01merge revision(s) 85b5d4c8bf4cdcba4f1af65f2bc0c8ac716cb795: [Backport #17509]NARUSE, Yui
Revert "[Bug #11213] let defined?(super) call respond_to_missing?" This reverts commit fac2498e0299f13dffe4f09a7dd7657fb49bf643 for now, due to [Bug #17509], the breakage in the case `super` is called in `respond_to?`. --- internal/vm.h | 2 +- test/ruby/test_defined.rb | 33 --------------------------------- vm_insnhelper.c | 4 ++-- vm_method.c | 12 +++++++----- 4 files changed, 10 insertions(+), 41 deletions(-)
2021-02-01merge revision(s) f4be7a510eebbe6507ba41d138d7d252f4a68e90:NARUSE, Yui
Added tests for Time#getlocal with UTC offset --- test/ruby/test_time.rb | 8 ++++++++ 1 file changed, 8 insertions(+)
2021-01-13Make any hash values fixable [Bug #17488]Nobuyoshi Nakada
As hnum is an unsigned st_index_t, the result of RSHIFT may not be in the fixable range. Co-authored-by: NeoCat <neocat@neocat.jp>