Граф коммитов

14622 Коммитов

Автор SHA1 Сообщение Дата
NARUSE, Yui 46655156dc Add Thread#native_thread_id [Feature #17853] 2021-05-26 15:14:11 +09:00
Hiroshi SHIBATA 88e3848fca
RSS library is the bundled gems now 2021-05-26 11:39:01 +09:00
Hiroshi SHIBATA e54bef92d5
Ignore lib/irb/ext/tracer.rb with TestRequireLib because tracer library was removed from ruby repo 2021-05-26 10:04:24 +09:00
Aaron Patterson fc832ffbfa Disable compaction on platforms that can't support it
Manual compaction also requires a read barrier, so we need to disable
even manual compaction on platforms that don't support mprotect.

[Bug #17871]
2021-05-25 17:37:21 -07:00
Hiroshi SHIBATA edcc29dcff Removed gdbm from ruby repo 2021-05-25 20:04:54 +09:00
Hiroshi SHIBATA 55cd3e4ebf Removed dbm from ruby repo 2021-05-25 15:18:31 +09:00
Hiroshi SHIBATA ab3266ea5c Removed tracer from ruby repo 2021-05-25 13:13:52 +09:00
aycabta f57968e329 Set USE_COLORIZE to the default value in a test 2021-05-24 12:13:46 +09:00
jethrodaniel d06d4560a1 [ruby/irb] update test/irb/test_init.rb to avoid useless eval
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

https://github.com/ruby/irb/commit/2dfdc031ec
2021-05-24 11:56:05 +09:00
Mark Delk b8ffb1c46f [ruby/irb] respect NO_COLOR environment variable
When `NO_COLOR` is set to any non-nil value, output is not colorized.

See https://no-color.org/

https://github.com/ruby/irb/commit/401d0916fe
2021-05-24 11:55:58 +09:00
aycabta c264d30261 Use YAML.safe_load to use the permitted_classes option 2021-05-21 21:45:03 +09:00
Nobuyoshi Nakada c4162a4cb8
Refined portability of test for [Bug #17739]
The order of arguments to callback of qsort is not defined.
That means `a` may not be 3 at all.
2021-05-22 14:34:23 +09:00
Jeremy Evans 8b00bfb7c2
Do not allow array modifications after freeze inside sort!
If freezing an array inside sort!, previously the array could be
modified after the freeze.  This checks whether the receiver is
frozen after every yield and potential call to #> or #<,
preventing modifications if the receiver is frozen inside the
block or by the #> or #< call.

Fixes [Bug #17739]
2021-05-21 18:33:56 -07:00
Alan Wu b2fc592c30
Build CDHASH properly when loading iseq from binary
Before this change, CDHASH operands were built as plain hashes when
loaded from binary. Without setting up the hash with the correct
st_table type, the hash can sometimes be an ar_table. When the hash is
an ar_table, lookups can call the `eql?` method on keys of the hash,
which makes the `opt_case_dispatch` instruction not "leaf" as it
implicitly declares.

The following script trips the stack canary for checking the leaf
attribute for `opt_case_dispatch` on VM_CHECK_MODE > 0 (enabled by
default with RUBY_DEBUG).

    rb_vm_iseq = RubyVM::InstructionSequence

    iseq = rb_vm_iseq.compile(<<-EOF)
      case Class.new(String).new("foo")
      when "foo"
        42
      end
    EOF

    puts rb_vm_iseq.load_from_binary(iseq.to_binary).eval

This commit changes the binary loading logic to build CDHASH with the
right st_table type. The dumping logic and the dump format stays the
same
2021-05-21 12:13:55 -04:00
Alan Wu 636d4f7eb9 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]
2021-05-21 12:12:31 -04:00
Nobuyoshi Nakada 50a534a152 ripper: wrap endless method in bodystmt [Bug #17869] 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada 050bb06e66 ripper: assertions for rescue/ensure in method body 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada e9974a466a
Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-21 18:26:07 +09:00
Koichi Sasada 817764bd82 simple rescue+while+break should not use `throw`
609de71f04 fixes the issue by using
`throw` insn if `ensure` is used. However, that patch introduce
additional `throw` even if it is not needed. This patch solves
the issue.

This issue is pointed by @mame.
2021-05-21 18:12:14 +09:00
Nobuyoshi Nakada 59b327aa58
[ruby/rdoc] Drop support for Ruby 2.4
https://github.com/ruby/rdoc/commit/f480b970cc
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada f18a0b7654
[ruby/rdoc] Follow-up rubygems
Use test-unit assertions instead of minitest.

https://github.com/ruby/rdoc/commit/d6a6209d7f
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada 10e63f3f56
[ruby/rdoc] Vertical-bar is disallowed in path names on Windows
No risk of remote code execution, when the file cannot be created.

https://github.com/ruby/rdoc/runs/2565343916?check_suite_focus=true#step:5:58
```
Error: test_remove_unparseable_CVE_2021_31799(TestRDocRDoc): Errno::EINVAL: Invalid argument @ utime_failed - | touch evil.txt && echo tags
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1142:in `utime'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1142:in `block in touch'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1139:in `each'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1139:in `touch'
D:/a/rdoc/rdoc/test/rdoc/test_rdoc_rdoc.rb:463:in `block (2 levels) in test_remove_unparseable_CVE_2021_31799'
     460:     temp_dir do
     461:       file_list = ['| touch evil.txt && echo tags']
     462:       file_list.each do |f|
  => 463:         FileUtils.touch f
     464:       end
     465:
     466:       assert_equal file_list, @rdoc.remove_unparseable(file_list)
```

https://github.com/ruby/rdoc/commit/a7df7dc8fa
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada a298bdf860
[ruby/rdoc] Dir.children is 2.5+
RDoc seems still supporting outdated 2.4.

https://github.com/ruby/rdoc/runs/2565344070?check_suite_focus=true#step:5:64
```
Error: test_remove_unparseable_CVE_2021_31799(TestRDocRDoc): NoMethodError: undefined method `children' for Dir:Class
/home/runner/work/rdoc/rdoc/test/rdoc/test_rdoc_rdoc.rb:467:in `block in test_remove_unparseable_CVE_2021_31799'
     464:       end
     465:
     466:       assert_equal file_list, @rdoc.remove_unparseable(file_list)
  => 467:       assert_equal file_list, Dir.children('.')
     468:     end
     469:   end
     470:
```

https://github.com/ruby/rdoc/commit/5a4a64dc0f
2021-05-21 15:53:34 +09:00
aycabta b1c73f239f [ruby/rdoc] Use File.open to fix the OS Command Injection vulnerability in CVE-2021-31799
https://github.com/ruby/rdoc/commit/a7f5d6ab88
2021-05-21 13:42:24 +09:00
Nobuyoshi Nakada c711093559 Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-20 21:56:58 +09:00
Yusuke Endoh 5026f9a5d5 compile.c: stop the jump-jump optimization if the second has any event
Fixes [Bug #17868]
2021-05-20 19:13:39 +09:00
Hiroshi SHIBATA adcbae8d49
Removed minitest/mock 2021-05-19 14:24:01 +09:00
Yusuke Endoh ceea1ea8af test/rubygems/test_gem_commands_open_command.rb: prevent a warning
http://rubyci.s3.amazonaws.com/debian9/ruby-master/log/20210518T093002Z.log.html.gz
```
[ 9396/21186] TestGemCommandsOpenCommand#test_execute-e:1: warning: possibly useless use of a literal in void context
 = 0.06 s
```
2021-05-18 19:06:48 +09:00
Yusuke Endoh 837cbea64b test/psych/test_coder.rb: Suppress non-parenthesis warnings
http://rubyci.s3.amazonaws.com/debian9/ruby-master/log/20210518T093002Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20210518T093002Z/ruby/test/psych/test_coder.rb:277: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator
```
2021-05-18 19:01:27 +09:00
Nobuyoshi Nakada 34bc8210ed
test/irb/test_raise_no_backtrace_exception.rb: fix test file path
Create a file for test under the temporary directory.
2021-05-18 16:04:37 +09:00
Jeremy Evans 2579593a56 [ruby/fiddle] Do not use a libdir for glibc, it breaks Linux PPC64 (#70)
Fixes [Bug #12666]

https://github.com/ruby/fiddle/commit/a267a40be7
2021-05-18 12:48:40 +09:00
Sutou Kouhei ab5212b3c9 [ruby/fiddle] Add support for "const" in type
GitHub: fix #68

Reported by kojix2. Thanks!!!

https://github.com/ruby/fiddle/commit/d7322c234a
2021-05-18 12:48:40 +09:00
Sutou Kouhei 881b2dc898 [ruby/fiddle] closure: add support for const char *
GitHub: fix GH-62

Reported by Cody Krieger. Thanks!!!

https://github.com/ruby/fiddle/commit/284b820f2d
2021-05-18 12:48:40 +09:00
Sutou Kouhei b2de5999d8 [ruby/fiddle] closure: accept symbol as type
https://github.com/ruby/fiddle/commit/dc2da6633e
2021-05-18 12:48:40 +09:00
Hiroshi SHIBATA e36da7ba18
Revert an accidentally commits at df86a13cc1 2021-05-17 15:28:47 +09:00
Yusuke Endoh 31a757a442 Make the test pass with the old libyaml
I have no idea what result is right, but it fails with libyaml 0.1.7
(bundled with Ubuntu 18.04) anyway.
2021-05-17 14:31:34 +09:00
Yusuke Endoh f367b4ffe7 assert_equal accepts an expected value as the first argument 2021-05-17 14:31:34 +09:00
Yusuke Endoh ffdf0232ef lib/rdoc/rdoc.rb: Allow only RDoc::Options in .rdoc_options
Follow-up of d8fd92f620. Instead of using
unsafe_load blindly, RDoc::Options is only supposed to be allowed.
2021-05-17 12:53:42 +09:00
Hiroshi SHIBATA d8fd92f620
Workaround with fbb4e3f96c in rdoc 2021-05-17 12:04:40 +09:00
Hiroshi SHIBATA 8e91b969df
Workaround with fbb4e3f96c 2021-05-17 12:00:05 +09:00
Yusuke Endoh da5b283963 test/ostruct/test_ostruct.rb: Use YAML.unsafe_load instead of YAML.load
Follow-up of fbb4e3f96c
2021-05-17 11:36:16 +09:00
Aaron Patterson 42b20bdbfe
[ruby/psych] remove deprecated interface
https://github.com/ruby/psych/commit/0767227051
2021-05-17 11:20:46 +09:00
Aaron Patterson c7c2ad5749
[ruby/psych] Introduce `Psych.unsafe_load`
In future versions of Psych, the `load` method will be mostly the same
as the `safe_load` method.  In other words, the `load` method won't
allow arbitrary object deserialization (which can be used to escalate to
an RCE).  People that need to load *trusted* documents can use the
`unsafe_load` method.

This commit introduces the `unsafe_load` method so that people can
incrementally upgrade.  For example, if they try to upgrade to 4.0.0 and
something breaks, they can downgrade, audit callsites, change to
`safe_load` or `unsafe_load` as required, and then upgrade to 4.0.0
smoothly.

https://github.com/ruby/psych/commit/cb50aa8d3f
2021-05-17 11:20:45 +09:00
Hiroshi SHIBATA bcaa6aecea
[ruby/psych] Removed needless platform detection
https://github.com/ruby/psych/commit/57d704fd63
2021-05-17 11:20:45 +09:00
Hiroshi SHIBATA df86a13cc1
[ruby/psych] Import test assertions from ruby/ruby
https://github.com/ruby/psych/commit/01dda86681
2021-05-17 11:20:45 +09:00
Jean Boussier a3ceed50b8
[ruby/psych] Fix symabolize_name with non-string keys
https://github.com/ruby/psych/commit/1c5c29e81f
2021-05-17 11:20:45 +09:00
Jeremy Ebler 830778db95
[ruby/psych] feat: allow scalars and sequences to be styled when dumped
https://github.com/ruby/psych/commit/546154ddb7
2021-05-17 11:20:45 +09:00
Gabriel Nagy 229cb0fcdb
[Win32] long path name support [Bug #12551]
Implement long path support on Windows by applying Microsoft's
recommended application manifest.

To make this work on both Visual C++ and MinGW, include the manifest as
a resource when generating the resource files. This way it will be
embedded into the executables generated by both compilers.

It's important for the manifest resource to have ID 1, otherwise GCC
will embed a default manifest.

Note that in addition to this, the user needs to have [long paths enabled]
either by modifying the registry or by enabling a group policy.

[long paths enabled]: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-05-17 08:33:08 +09:00
Yusuke Endoh f210d456a8 test/objspace/test_objspace.rb: check stderr before stdout
When `require "objspace/trace"` fails, previously the failure says:
```
  1) Failure:
TestObjSpace#test_objspace_trace [/tmp/ruby/v3/src/trunk-mjit/test/objspace/test_objspace.rb:621]:
<3> expected but was
<0>.
```
but this is hard to debug.
2021-05-14 18:07:58 +09:00
Yusuke Endoh 702961a88b test/ruby/test_refinement.rb: prevent "assigned but unused variable" 2021-05-14 15:44:13 +09:00
Yusuke Endoh cf1e1879f1 ext/objspace/lib/objspace/trace.rb: Added
This file, when require'ed, starts tracing the object allocations, and
redefines `Kernel#p` to show the allocation site.

This commit is experimental; the library name and APIs may change.

[Feature #17762]
2021-05-14 13:40:32 +09:00
Nobuyoshi Nakada 110f242ef9
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.
2021-05-13 12:54:56 +09:00
Jeremy Evans 9ce29c94d8 Avoid improper optimization of case statements mixed integer/rational/complex
Fixes [Bug #17857]
2021-05-12 19:30:05 -07:00
Jeremy Evans 11ae581a4a Fix handling of control/meta escapes in literal regexps
Ruby uses a recursive algorithm for handling control/meta escapes
in strings (read_escape).  However, the equivalent code for regexps
(tokadd_escape) in did not use a recursive algorithm.  Due to this,
Handling of control/meta escapes in regexp did not have the same
behavior as in strings, leading to behavior such as the following
returning nil:

```ruby
/\c\xFF/ =~ "\c\xFF"
```

Switch the code for handling \c, \C and \M in literal regexps to
use the same code as for strings (read_escape), to keep behavior
consistent between the two.

Fixes [Bug #14367]
2021-05-12 18:55:43 -07:00
Yusuke Endoh 9484f9ebdf [rubygems/rubygems] Use `Time.stub :now` to avoid a random failure
Essentially this reverts 45464bfcbdf9f9cfb440950bc57a27d237627a17.
The commit removed a mock of Time.now, which caused a random failure.

http://rubyci.s3.amazonaws.com/ubuntu1804/ruby-master/log/20210512T123004Z.fail.html.gz
```
  1) Failure:
TestGemPackageTarWriter#test_add_file_signer [/home/chkbuild/chkbuild/tmp/build/20210512T123004Z/ruby/test/rubygems/test_gem_package_tar_writer.rb:117]:
Field mtime of the tar header differs..
<"14046746312\u0000"> expected but was
<"14046746311\x00">.
```

Object#stub is defined at f1af59fe02ef2cc58f13e2742e4cc6cf8c2a1a20, so
now `Time.stub :now` works.

https://github.com/rubygems/rubygems/commit/85f60a9ed0
2021-05-13 09:26:13 +09:00
Yusuke Endoh 31794d2e73 parse.y: Allow "command" syntax in endless method definition
This change allows `def hello = puts "Hello"` without parentheses.

Note that `private def hello = puts "Hello"` does not parse for
technical reason.

[Feature #17398]
2021-05-13 00:14:50 +09:00
git 81513c9dab * remove trailing spaces. [ci skip] 2021-05-12 17:40:52 +09:00
Koichi Sasada 523a6998dd Use another class for the comparison.
`memsize_of(Object.new)` can be changed with past ivar creation
history for Object instances (another Object instance has 4 or
more ivars, next created Object instance has the area for the
ivars). So use antoher class for the comparison.
2021-05-12 17:40:31 +09:00
Hiroshi SHIBATA 81720b947a Use assert_raise instead of assert_raises 2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA cdcfe1082c Revert 924ce2c5ba4d1c1dc781a6a06682204d358421bb
Because test-unit didn't provide the benchmark test. And This test
  is fragile with the several environments.
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA bef49e6e8d [rubygems/rubygems] Added begin-end block for java platform
Because pend of test-unit raises exception.

https://github.com/rubygems/rubygems/commit/b5e2d0855a
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA d33888bf96 [rubygems/rubygems] Replace skip to pend
https://github.com/rubygems/rubygems/commit/0b145135c7
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 129bc04ab7 [rubygems/rubygems] util/rubocop -a
https://github.com/rubygems/rubygems/commit/a10ff97830
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 00f5b4b546 [rubygems/rubygems] Don't use Minitest::Mock
https://github.com/rubygems/rubygems/commit/d3fa893597
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 3456335a9c [rubygems/rubygems] Removed minitest/mock from test/rubygems/test_gem_remote_fetcher.rb
https://github.com/rubygems/rubygems/commit/f1af59fe02
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA ff3f990499 [rubygems/rubygems] Removed minitest/mock from test_gem_package_tar_writer.rb
https://github.com/rubygems/rubygems/commit/45464bfcbd
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 7b3b48549b [rubygems/rubygems] capture_output will return empty string, not nil
https://github.com/rubygems/rubygems/commit/3fa93f6144
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 9b5e4ce611 [rubygems/rubygems] Fixed variable scope at test_silent_system
https://github.com/rubygems/rubygems/commit/bfcdf79657
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA cd375e455e [rubygems/rubygems] Rewrite with capture_output
https://github.com/rubygems/rubygems/commit/a091004ded
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 5ed9d3f16f [rubygems/rubygems] Use capture_output instead of capture_io
https://github.com/rubygems/rubygems/commit/c46185abe3
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA c30594bb0c [rubygems/rubygems] Use assert_raise instead of assert_raises
https://github.com/rubygems/rubygems/commit/769e87f011
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 2c0072dec5 [rubygems/rubygems] Use dummy assertion for assert_https
https://github.com/rubygems/rubygems/commit/64d843fe17
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA a1c416460b [rubygems/rubygems] Use capture_output instead of assert_silent
https://github.com/rubygems/rubygems/commit/3225aab7f8
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 958f9d425a [rubygems/rubygems] Use capture_output instead of capture_io for test-unit
https://github.com/rubygems/rubygems/commit/ab9c80d4cb
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 3948be3503 [rubygems/rubygems] Use assert_path_exist and assert_path_not_exist instead of assert_path_exists and refute_path_exists
https://github.com/rubygems/rubygems/commit/a7c93558c3
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 81d793a921 [rubygems/rubygems] Extract assert_output to assert_empty and assert_equal with capture_output
https://github.com/rubygems/rubygems/commit/f6759440a4
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 183174475c [rubygems/rubygems] Use Regexp with refute_match
https://github.com/rubygems/rubygems/commit/51fdbe53bc
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 3c9633acfc [rubygems/rubygems] Also use capture_output instead of capture_io
https://github.com/rubygems/rubygems/commit/229858ea56
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 26cbda8dc9 [rubygems/rubygems] Use capture_output instead of capture_io.
https://github.com/rubygems/rubygems/commit/ad9206d4d0
2021-05-12 17:24:43 +09:00
Koichi Sasada 5a6af44e20 skip test for debug.
test_memsize_of_iseq fails on repeat tests and it seems to difficult
to solve immediately. Now this test is skipped.

It seems that the result of `memsize_of(Object.new)` are increased.
Why...?
2021-05-12 12:57:53 +09:00
Koichi Sasada 3df7c967bb suppress warnings on repeat tests.
Constant definitions are affect on outer namespace of an anonymous
module. To define constants on the anonymous module, this patch
uses Module#class_eval(str).
2021-05-12 12:53:14 +09:00
卜部昌平 6911b4bc82 test_cdhash: refactor change class
It is now strange to test Complex in a class named Rational_Test.
2021-05-12 10:30:46 +09:00
卜部昌平 cc0dc67bbb cdhash_cmp: can also take complex
There are complex literals `123i`, which can also be a case condition.
2021-05-12 10:30:46 +09:00
卜部昌平 d0e6c6e682 cdhash_cmp: rational literals with fractions
Nobu kindly pointed out that rational literals can have fractions.
2021-05-12 10:30:46 +09:00
卜部昌平 2bc293e899 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]
2021-05-12 10:30:46 +09:00
Takashi Kokubun cc1ea6e023
Run nmake check on Actions (#4487)
* Run nmake check on Actions

* Skip tests not working in mswin GitHub Actions

* Override TEMP

* Revert "Skip tests not working in mswin GitHub Actions"

This reverts commit 544d2575fcdf23ae63cd25aa03fce10c28b259f2.

* Revert "Revert "Skip tests not working in mswin GitHub Actions""

This reverts commit e1f8ad7862c9c4be52dc6e1031a004621eb07e6e.

* Fix timeouts

* Skip some more broken tests

* Update windows.yml

* Add a guard for rbasic_spec

* Revert "Update windows.yml"

This reverts commit bc9694b6b3b9594d406378d15ca11723fb052bc8.

* Skip the ensure clause

* Simplify the ensure
2021-05-11 15:18:44 -07:00
Alan Wu 39a2ba5cc5
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]
2021-05-11 12:05:06 -04:00
Yusuke Endoh 1b61cdd5e0 test/irb/test_raise_no_backtrace_exception.rb: Set LC_MESSAGES as UTF-8 2021-05-11 19:38:06 +09:00
Takashi Kokubun 66ca6ede16 [ruby/irb] Skip test_raise_exception_with_invalid_byte_sequence
on Windows for now. It seems like we haven't figured this out yet.

https://github.com/ruby/irb/commit/ecf5a1ace1
2021-05-11 14:46:33 +09:00
Takashi Kokubun afa70d079f
Explicitly specify encoding for another test as well
Same as e2ccc3301e
https://ci.appveyor.com/project/ruby/ruby/builds/39102539/job/k8m1yrrjesxbgvtq
2021-05-10 21:41:36 -07:00
Yusuke Endoh e2ccc3301e test/irb/test_raise_no_backtrace_exception.rb: UTF-8 is expected
... for the output of assert_in_out_err.

This will fix the following failure on many CI machines

http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20210511T030005Z.fail.html.gz
```
  1) Failure:
TestIRB::TestRaiseNoBacktraceException#test_raise_exception_with_different_encoding_containing_invalid_byte_sequence [/home/chkbuild/chkbuild/tmp/build/20210511T030005Z/ruby/test/irb/test_raise_no_backtrace_exception.rb:41]:
pid 221531 exit 0.

1. [1/2] Assertion for "stdout"
   | invalid byte sequence in US-ASCII.
```
2021-05-11 13:30:28 +09:00
Takashi Kokubun bb54361057 [ruby/irb] Skip the new IRB test on Windows for now
It's not passing from the beginning
https://github.com/ruby/ruby/runs/2550929220
https://ci.appveyor.com/project/ruby/ruby/builds/39100747

https://github.com/ruby/irb/commit/71fc180018
2021-05-11 13:01:38 +09:00
David Rodríguez 5b0abba931 Sync bundler & rubygems 2021-05-11 11:29:41 +09:00
aycabta 774cc32b4d [ruby/irb] Treat encodings in exception correctly
https://github.com/ruby/irb/commit/4452adbe04
2021-05-11 09:32:08 +09:00
Jean Boussier c110ade0d2
[ruby/psych] Fix custom marshalization with symbolize_names: true
https://github.com/ruby/psych/commit/ee26f26ab5
2021-05-10 19:17:32 +09:00
Hiroshi SHIBATA ab785b28e2 [ruby/psych] Use assert_raise instead of assert_raises
https://github.com/ruby/psych/commit/e6ad12b4e1
2021-05-10 19:09:43 +09:00
Hiroshi SHIBATA bae9a21e40 [ruby/psych] Use pend instead of skip
https://github.com/ruby/psych/commit/efd2a62c9a
2021-05-10 18:53:56 +09:00
Hiroshi SHIBATA 53c5a4bbe1 [ruby/psych] Fixed test-case for NaN
https://github.com/ruby/psych/commit/f85a008263
2021-05-10 18:53:49 +09:00
Hiroshi SHIBATA 230d559f6b [ruby/psych] Use Ractor constant for ignoreing condition
https://github.com/ruby/psych/commit/cc5f957327
2021-05-10 18:53:41 +09:00
Hiroshi SHIBATA ce67549c50 [ruby/psych] Use test-unit instead of minitest
https://github.com/ruby/psych/commit/01e7310dd3
2021-05-10 18:53:33 +09:00
Jeremy Evans 406ae7fb03 Fix Math.cbrt(0.0) on glibc
This should return 0, but on glibc it returned NaN.

Fixes [Bug #17804]
2021-05-08 14:45:30 -07:00
Nobuyoshi Nakada c7601fb9ed [ruby/irb] Deal with different screen sizes
https://github.com/ruby/irb/commit/7118b3322f
2021-05-08 15:29:36 +09:00
Masataka Pocke Kuwabara de96ae9b71 [ruby/irb] Dump ancestors' methods by ls command
https://github.com/ruby/irb/commit/73edff287c
2021-05-08 14:00:40 +09:00
Hiroshi SHIBATA f2d6fa16e1 Use assert_ractor for separating test processes 2021-05-06 19:02:10 +09:00
Jeremy Evans 33b5e179a8 [ruby/timeout] Make Timeout::Error#exception with multiple arguments not ignore arguments
This makes:

  raise(Timeout::Error.new("hello"), "world")

raise a TimeoutError instance with "world" as the message instead
of "hello", for consistency with other Ruby exception classes.

This required some internal changes to keep the tests passing.

Fixes [Bug #17812]

https://github.com/ruby/timeout/commit/952154dbf9
2021-05-06 16:49:26 +09:00
Kenichi Kamiya 564ccd095a [ruby/strscan] Fix segmentation fault of `StringScanner#charpos` when `String#byteslice` returns non string value [Bug #17756] (#20)
https://github.com/ruby/strscan/commit/92961cde2b
2021-05-06 16:20:38 +09:00
Hiroshi SHIBATA 822eb94563
Import from https://github.com/ruby/strscan/pull/19
* Use Gemfile instead of Gem::Specification#add_development_dependency.

* Use pend instead of skip for test-unit.
2021-05-06 16:18:58 +09:00
Kazuki Yamaguchi 364044e090 [ruby/net-http] Do not require stringio
It is not used in net/http library code since commit 15ccd0118c13
(r36473 in ruby svn trunk, 2012).

require's in test suite are also cleaned up.

https://github.com/ruby/net-http/commit/996d18a43f
2021-05-06 15:58:41 +09:00
nicholas a. evans 337c0e312b
[ruby/net-imap] Move UTF7 & datetime formatting to net/imap/data_encoding
Partially implements #10.

https://github.com/ruby/net-imap/commit/0d43c5e856
2021-05-06 15:20:34 +09:00
nicholas a. evans 912f39b2c3
[ruby/net-imap] Update AUTH=PLAIN to be a little closer to RFC4616
* Add authzid support
* must not contain NULL chars
* improve rdoc

https://github.com/ruby/net-imap/commit/a587fc71b7
2021-05-06 15:20:34 +09:00
MSP-Greg 370949aad6 test/net/ftp/test_ftp.rb - fix intermittent MinGW failure
Fixes intermittent error as below:

[242/838] 5316=test_ftp
#<Thread:0x0000020aa8733f20 D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:2532 run> terminated with exception (report_on_exception is true):
D:/a/ruby/ruby/src/tool/lib/minitest/unit.rb:199:in `assert': Expected #<Errno::ECONNRESET: An existing connection was forcibly closed by the remote host.> to be nil. (MiniTest::Assertion)
	from D:/a/ruby/ruby/src/tool/lib/test/unit/core_assertions.rb:504:in `assert'
	from D:/a/ruby/ruby/src/tool/lib/minitest/unit.rb:299:in `assert_nil'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:430:in `ensure in block in test_list_read_timeout_exceeded'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:431:in `block in test_list_read_timeout_exceeded'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:2539:in `block in create_ftp_server'
D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:426:in `write': An existing connection was forcibly closed by the remote host. (Errno::ECONNRESET)
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:426:in `print'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:426:in `block (2 levels) in test_list_read_timeout_exceeded'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:420:in `each'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:420:in `each_with_index'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:420:in `block in test_list_read_timeout_exceeded'
	from D:/a/ruby/ruby/src/test/net/ftp/test_ftp.rb:2539:in `block in create_ftp_server'
2021-05-05 08:49:16 +12:00
Yusuke Endoh 113ddf4d1d test/net/imap/test_imap.rb: wait a moment before socket is closed
to try to suppress a failure on Solaris. This is the same as
19504d115d

http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20210504T070007Z.fail.html.gz
```
  1) Error:
IMAPTest#test_idle_done_not_during_idle:
Errno::EINVAL: Invalid argument - connect(2) for [::1]:33839
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:1214:in `__connect_nonblock'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:1214:in `connect_nonblock'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:56:in `connect_internal'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:137:in `connect'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:642:in `block in tcp'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:227:in `each'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:227:in `foreach'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/.ext/common/socket.rb:632:in `tcp'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/lib/net/imap.rb:1223:in `tcp_socket'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/lib/net/imap.rb:1180:in `initialize'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/test/net/imap/test_imap.rb:289:in `new'
    /export/home/chkbuild/chkbuild-sunc/tmp/build/20210504T070007Z/ruby/test/net/imap/test_imap.rb:289:in `test_idle_done_not_during_idle'
```
2021-05-04 19:03:26 +09:00
MSP-Greg 5a42ef496a Fix test/net/http/test_https.rb host naming for Windows 2021-05-04 08:53:58 +09:00
Nobuyoshi Nakada 14ee263505
Workaround failures on Windows 2021-05-04 00:59:29 +09:00
Yusuke Endoh 19504d115d test/net/smtp/test_smtp.rb: wait a moment before socket is closed
On Solaris, Socket.tcp seems to fail with EINVAL if the server closes
the connection immediately after accpeted. I think this is a bug of
Socket.tcp, but seems difficult to fix soon.

http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20210429T100007Z.fail.html.gz
```
  1) Failure:
Net::TestSMTP#test_eof_error_backtrace [/export/home/chkbuild/chkbuild-sunc/tmp/build/20210429T100007Z/ruby/test/net/smtp/test_smtp.rb:193]:
[ruby-core:78550] [Bug #13018].
[EOFError] exception expected, not #<Net::ReadTimeout: Net::ReadTimeout>.
```
2021-04-30 01:36:04 +09:00
Hiroshi SHIBATA f985dafee7
Guard for < Ruby 3.0 2021-04-28 17:58:12 +09:00
Alexander Popov 2afbe7113a
[ruby/optparse] Add EditorConfig file
More info here: https://editorconfig.org/

For example, `ruby/ruby` has it: https://github.com/ruby/ruby/blob/05ebaee/.editorconfig

Also fix some offenses.

https://github.com/ruby/optparse/commit/29402e7e0e
2021-04-28 11:56:15 +09:00
Lukas Eipert 842f00f452 [ruby/net-http] Decode user and password from env configured proxy
If someone sets an env variable defining a http_proxy, containing a
username / password with percent-encoded characters, then the resulting
base64 encoded auth header will be wrong.

For example, suppose a username is `Y\X` and the password is `R%S] ?X`.
Properly URL encoded the proxy url would be:

    http://Y%5CX:R%25S%5D%20%3FX@proxy.example:8000

The resulting proxy auth header should be: `WVxYOlIlU10gP1g=`, but the
getters defined by ruby StdLib `URI` return a username `Y%5CX` and
password `R%25S%5D%20%3FX`, resulting in `WSU1Q1g6UiUyNVMlNUQlMjAlM0ZY`.
As a result the proxy will deny the request.

Please note that this is my first contribution to the ruby ecosystem, to
standard lib especially and I am not a ruby developer.

References:

- https://gitlab.com/gitlab-org/gitlab/-/issues/289836
- https://bugs.ruby-lang.org/projects/ruby-master/repository/trunk/revisions/58461
- https://bugs.ruby-lang.org/issues/17542

https://github.com/ruby/net-http/commit/e57d4f38aa
2021-04-28 11:01:23 +09:00
Yusuke Endoh 734557498f test/net/ftp/test_ftp.rb: Use RubyVM::JIT instead of RubyVM::MJIT 2021-04-28 09:10:58 +09:00
Yusuke Endoh 8e2ac2140d test/net/ftp/test_ftp.rb: reduce the size of a long response
"9" * 999999999 (about 1 GB) was too large for some CI servers.
This commit changes the size to 999999 (about 1 MB).

http://rubyci.s3.amazonaws.com/scw-9d6766/ruby-master/log/20210427T141707Z.fail.html.gz
http://rubyci.s3.amazonaws.com/raspbian10-aarch64/ruby-master/log/20210427T145408Z.fail.html.gz
2021-04-28 03:12:48 +09:00
Yusuke Endoh fe11031b67 test/net/ftp/test_ftp.rb: remove unused variable 2021-04-28 02:27:58 +09:00
Yusuke Endoh 99eebf8260 test/ruby/test_fiber.rb: reduce the count of object creation to cause GC
... on Solaris. This is the same as 547887138f.

http://rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20210427T160003Z.fail.html.gz
```
[ 7667/20965] TestFiber#test_fork_from_fiber/export/home/users/chkbuild/cb-gcc/tmp/build/20210427T160003Z/ruby/test/ruby/test_fiber.rb:397:in `transfer': can't alloc machine stack to fiber (1 x 139264 bytes): Not enough space (FiberError)
	from /export/home/users/chkbuild/cb-gcc/tmp/build/20210427T160003Z/ruby/test/ruby/test_fiber.rb:397:in `block (6 levels) in test_fork_from_fiber'
	from /export/home/users/chkbuild/cb-gcc/tmp/build/20210427T160003Z/ruby/test/ruby/test_fiber.rb:396:in `times'
	from /export/home/users/chkbuild/cb-gcc/tmp/build/20210427T160003Z/ruby/test/ruby/test_fiber.rb:396:in `block (5 levels) in test_fork_from_fiber'
	from /export/home/users/chkbuild/cb-gcc/tmp/build/20210427T160003Z/ruby/test/ruby/test_fiber.rb:392:in `fork'
	from /export/home/users/chkbuild/cb-gcc/tmp/build/20210427T160003Z/ruby/test/ruby/test_fiber.rb:392:in `block (4 levels) in test_fork_from_fiber'
 = 0.88 s

...

  1) Failure:
TestFiber#test_fork_from_fiber [/export/home/users/chkbuild/cb-gcc/tmp/build/20210427T160003Z/ruby/test/ruby/test_fiber.rb:409]:
[ruby-core:41456].
<0> expected but was
<1>.
```
2021-04-28 02:13:32 +09:00
Benoit Daloze 3a3b19b2bb Fix Monitor to lock per Fiber, like Mutex [Bug #17827] 2021-04-27 18:42:50 +02:00
Shugo Maeda 2670509ebb [ruby/net-ftp] Add test cases
https://github.com/ruby/net-ftp/commit/865232bb2a
2021-04-27 21:22:42 +09:00
Shugo Maeda 4ae27d8075
[ruby/net-ftp] Reduce resource cosumption of Net::FTP::TIME_PARSER
Reported by Alexandr Savca as a DoS vulnerability, but Net::FTP is a
client library and the impact of the issue is low, so I have decided
to fix it as a normal issue.
Based on patch by nobu.

https://github.com/ruby/net-ftp/commit/a93af636f8
2021-04-27 21:21:33 +09:00
Jeremy Evans 990baec411 [ruby/net-ftp] Close the passive connection data socket if there is an error setting up the transfer
Previously, the connection leaked in this case.  This uses
begin/ensure and checking for an error in the ensure block.

An alternative approach would be to not even perform the
connection until after the RETR (or other) command has been
sent.  However, I'm not sure all FTP servers support that.
The current behavior is:

* Send (PASV/EPSV)
* Connect to the host/port returned in 227/229 reply
* Send (RETR/other command)

Changing it to connect after the RETR could break things.
FTP servers might expect that the client has already
connected before sending the RETR.  The alternative
approach is more likely to introduce backwards compatibility
issues, compared to the begin/ensure approach taken here.

Fixes Ruby Bug 17027

https://github.com/ruby/net-ftp/commit/6e8535f076
2021-04-27 21:21:00 +09:00
Hiroshi SHIBATA fb819d9331 [ruby/net-ftp] Re-apply 827e471d438fdec1ae329afb5912b8e06d534823
https://github.com/ruby/net-ftp/commit/3ca80368c4
2021-04-27 21:19:14 +09:00
Hiroshi SHIBATA ac739f42eb [ruby/matrix] Guard for < Ruby 3.0
https://github.com/ruby/matrix/commit/1ef660c627
2021-04-27 21:07:17 +09:00
Yusuke Endoh ea88f49a76 test/ruby/test_exception.rb: suppress "warning: statement not reached" 2021-04-27 17:07:44 +09:00
Yusuke Endoh 2c7d3b3a72 node.c (rb_ast_new): imemo_ast is WB-unprotected
Previously imemo_ast was handled as WB-protected which caused a segfault
of the following code:

    # shareable_constant_value: literal
    M0 = {}
    M1 = {}
    ...
    M100000 = {}

My analysis is here: `shareable_constant_value: literal` creates many
Hash instances during parsing, and add them to node_buffer of imemo_ast.
However, the contents are missed because imemo_ast is incorrectly
WB-protected.

This changeset makes imemo_ast as WB-unprotected.
2021-04-26 22:46:51 +09:00
Nobuyoshi Nakada 5219b4ddb4 [ruby/irb] Added setup and teardown to TestIRB::TestInit
Not to be affected by existing rc files in all tests.

https://github.com/ruby/irb/commit/bf434892b4
2021-04-26 21:15:06 +09:00
Nobuyoshi Nakada 8fdc45c894 [ruby/irb] Added `colorable` keyword option
Currently `IRB::Color.colorize` and `IRB::Color.colorize_code`
refer `$stdin.tty?` internally.
This patch adds `colorable` keyword option which overrides it.

https://github.com/ruby/irb/commit/402e3f1907
2021-04-26 21:14:52 +09:00
Nobuyoshi Nakada 687ab5dcad [ruby/irb] Assertions on non-tty
https://github.com/ruby/irb/commit/ede12890d2
2021-04-26 21:14:44 +09:00
Nobuyoshi Nakada 75f1ad8cb3 [ruby/irb] Added test_colorize
https://github.com/ruby/irb/commit/10e290fc3a
2021-04-26 21:14:37 +09:00
Nobuyoshi Nakada 6ddaad606e [ruby/irb] Added assert_equal_with_term
https://github.com/ruby/irb/commit/b690da96d8
2021-04-26 21:14:31 +09:00
Kazuhiro NISHIYAMA 2b487d36f0
Remove test of removed reverse VM instruction
since 5512353d97
2021-04-26 11:07:53 +09:00
Ryuta Kamizono 33f2ff3bab Fix some typos by spell checker 2021-04-26 10:07:41 +09:00
Alan Wu dee58d7ae7
Add back checks for empty kw splat with tests (#4405)
This reverts commit a224ce8150.
Turns out the checks are needed to handle splatting an array with an
empty ruby2 keywords hash.
2021-04-23 22:17:20 -04:00
Jeremy Evans 4b36a597f4 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]
2021-04-23 16:31:18 -07:00
Yusuke Endoh 71ee05c936 test/ruby/test_assignment.rb: Avoid "assigned but unused variable" 2021-04-23 22:11:01 +09:00
Hiroshi SHIBATA 3ea2a40713
Suppress warnings for unsued variable 2021-04-23 10:35:29 +09:00
Jeremy Evans 3e27ca6047 [ruby/uri] Add tests for URI::RFC{2396,3986}_Parser#inspect
https://github.com/ruby/uri/commit/d47dae2f8e
2021-04-22 14:54:37 +09:00
Lukas Zapletal c46a4b8c7f [ruby/uri] Optimize URI#hostname and URI#hostname=
https://github.com/ruby/uri/commit/3b7ccfd835
2021-04-22 14:54:28 +09:00
Hiroshi SHIBATA 674760316c
Merge net-imap-0.2.0 2021-04-22 14:37:45 +09:00
Hiroshi SHIBATA 01f131457f
Separate test used by test_ractor for Ractor in test_time.rb 2021-04-22 13:35:30 +09:00
Keith Bennett 4f39a35b60
[ruby/benchmark] Add comment about terminating newline in captions; fix test method name.
https://github.com/ruby/benchmark/commit/02ce298d3e
2021-04-22 11:51:37 +09:00
Jeremy Evans f818b1ed2b
[ruby/cgi] Add test for escapeHTML/unescapeHTML invalid encoding fix in pure ruby version
Also, remove pointless assert_nothing_raised(ArgumentError) while
here.

https://github.com/ruby/cgi/commit/c05edf5608
2021-04-22 11:51:36 +09:00
Kir Shatrov 53d153e42c
[ruby/time] Make Time friendly to Ractor
https://github.com/ruby/time/commit/c784e4f166
2021-04-22 11:51:36 +09:00
Koichi Sasada 609de71f04 fix raise in exception with jump
add_ensure_iseq() adds ensure block to the end of
jump such as next/redo/return. However, if the rescue
cause are in the body, this rescue catches the exception
in ensure clause.

  iter do
    next
  rescue
    R
  ensure
    raise
  end

In this case, R should not be executed, but executed without this patch.

Fixes [Bug #13930]
Fixes [Bug #16618]

A part of tests are written by @jeremyevans https://github.com/ruby/ruby/pull/4291
2021-04-22 11:33:39 +09:00
Jeremy Evans 50c54d40a8
Evaluate multiple assignment left hand side before right hand side
In regular assignment, Ruby evaluates the left hand side before
the right hand side.  For example:

```ruby
foo[0] = bar
```

Calls `foo`, then `bar`, then `[]=` on the result of `foo`.

Previously, multiple assignment didn't work this way.  If you did:

```ruby
abc.def, foo[0] = bar, baz
```

Ruby would previously call `bar`, then `baz`, then `abc`, then
`def=` on the result of `abc`, then `foo`, then `[]=` on the
result of `foo`.

This change makes multiple assignment similar to single assignment,
changing the evaluation order of the above multiple assignment code
to calling `abc`, then `foo`, then `bar`, then `baz`, then `def=` on
the result of `abc`, then `[]=` on the result of `foo`.

Implementing this is challenging with the stack-based virtual machine.
We need to keep track of all of the left hand side attribute setter
receivers and setter arguments, and then keep track of the stack level
while handling the assignment processing, so we can issue the
appropriate topn instructions to get the receiver.  Here's an example
of how the multiple assignment is executed, showing the stack and
instructions:

```
self                                      # putself
abc                                       # send
abc, self                                 # putself
abc, foo                                  # send
abc, foo, 0                               # putobject 0
abc, foo, 0, [bar, baz]                   # evaluate RHS
abc, foo, 0, [bar, baz], baz, bar         # expandarray
abc, foo, 0, [bar, baz], baz, bar, abc    # topn 5
abc, foo, 0, [bar, baz], baz, abc, bar    # swap
abc, foo, 0, [bar, baz], baz, def=        # send
abc, foo, 0, [bar, baz], baz              # pop
abc, foo, 0, [bar, baz], baz, foo         # topn 3
abc, foo, 0, [bar, baz], baz, foo, 0      # topn 3
abc, foo, 0, [bar, baz], baz, foo, 0, baz # topn 2
abc, foo, 0, [bar, baz], baz, []=         # send
abc, foo, 0, [bar, baz], baz              # pop
abc, foo, 0, [bar, baz]                   # pop
[bar, baz], foo, 0, [bar, baz]            # setn 3
[bar, baz], foo, 0                        # pop
[bar, baz], foo                           # pop
[bar, baz]                                # pop
```

As multiple assignment must deal with splats, post args, and any level
of nesting, it gets quite a bit more complex than this in non-trivial
cases. To handle this, struct masgn_state is added to keep
track of the overall state of the mass assignment, which stores a linked
list of struct masgn_attrasgn, one for each assigned attribute.

This adds a new optimization that replaces a topn 1/pop instruction
combination with a single swap instruction for multiple assignment
to non-aref attributes.

This new approach isn't compatible with one of the optimizations
previously used, in the case where the multiple assignment return value
was not needed, there was no lhs splat, and one of the left hand side
used an attribute setter.  This removes that optimization. Removing
the optimization allowed for removing the POP_ELEMENT and adjust_stack
functions.

This adds a benchmark to measure how much slower multiple
assignment is with the correct evaluation order.

This benchmark shows:

* 4-9% decrease for attribute sets
* 14-23% decrease for array member sets
* Basically same speed for local variable sets

Importantly, it shows no significant difference between the popped
(where return value of the multiple assignment is not needed) and
!popped (where return value of the multiple assignment is needed)
cases for attribute and array member sets.  This indicates the
previous optimization, which was dropped in the evaluation
order fix and only affected the popped case, is not important to
performance.

Fixes [Bug #4443]
2021-04-21 10:49:19 -07:00
Yusuke Endoh fb04c69418
array.c (rb_ary_zip): take only as many as needed from an Enumerator (#4389)
[Bug #17814]
2021-04-21 13:02:29 +09:00
Travis Hunter 55d91a096a Add Array#intersect? 2021-04-16 16:06:36 +09:00
Hiroshi SHIBATA 96741765d8 Merge the master branch of RubyGems 2021-04-15 15:36:15 +09:00
Yusuke Endoh 582f4bc188 test/ruby/test_gc_compact.rb: Use assert_separately for debugging
... the following timeout failure.

http://rubyci.s3.amazonaws.com/rhel_zlinux/ruby-master/log/20210408T213303Z.fail.html.gz
```
[ 8871/21204] TestGCCompact#test_ast_compactstimeout: output interval exceeds 600.0 seconds.
timeout: the process group 28416 is alive.
PSOUT  PGID   PID     ELAPSED %CPU    VSZ COMMAND         COMMAND
PSOUT 28416 28416       12:46  0.0 108120 gmake           gmake TESTS=--hide-skip -v RUBYOPT=-w test-all
PSOUT 28416 28423       12:46 88.2 1446124 ruby           ./test/runner.rb: TestGCCompact#test_ast_compacts
timeout: INT signal sent.
timeout: INT signal sent.
timeout: TERM signal sent.
timeout: TERM signal sent.
timeout: KILL signal sent.
```

This error repeatedly occurs on RHEL s390x.

This change sends SEGV when timeout occurs so that it should dump the backtrace.
2021-04-09 13:59:46 +09:00
aycabta 5543695a19
[ruby/reline] Separate keystrokes each editing mode
https://github.com/ruby/reline/commit/ee23e6f3f8
2021-04-08 21:41:00 +09:00
Yusuke Endoh ee372aa873 test/zlib/test_zlib.rb: Set binmode to test output file
Seems like the test `TestZlibGzipFile#test_gzip_reader_zcat` fails when
the timestamp has `\n\n`.

https://ci.appveyor.com/project/ruby/ruby/builds/38597932
```
  1) Error:
TestZlibGzipFile#test_gzip_reader_zcat:
Zlib::DataError: invalid distance too far back
    C:/projects/ruby/test/zlib/test_zlib.rb:522:in `initialize'
    C:/projects/ruby/test/zlib/test_zlib.rb:522:in `new'
    C:/projects/ruby/test/zlib/test_zlib.rb:522:in `zcat'
    C:/projects/ruby/test/zlib/test_zlib.rb:522:in `block (2 levels) in test_gzip_reader_zcat'
    C:/projects/ruby/test/zlib/test_zlib.rb:521:in `open'
    C:/projects/ruby/test/zlib/test_zlib.rb:521:in `block in test_gzip_reader_zcat'
    C:/projects/ruby/lib/tempfile.rb:358:in `create'
    C:/projects/ruby/test/zlib/test_zlib.rb:510:in `test_gzip_reader_zcat'
```

The test time is around 2021-04-08 04:40 +0900. Maybe the following time
should trigger the bug.

```
irb(main):001:0> Time.at(1617824266)
=> 2021-04-08 04:37:46 +0900
irb(main):002:0> [1617824266].pack("V")
=> "\n\nn`"
```
2021-04-08 14:26:42 +09:00
Peter Zhu d8a13e5049 [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
c60aaed185 as part of bug #17130.
2021-04-07 15:16:58 -04:00
Yusuke Endoh fbbc37dc1d test/drb/test_drb.rb: Specify the host of DRbServer
to try fixing the following error.

http://rubyci.s3.amazonaws.com/opensuseleap/ruby-master/log/20210407T063004Z.log.html.gz
```
[  605/21105] DRbTests::TestDRbSSLAry#test_06_next/home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/lib/drb/drb.rb:1138:in `method_missing': undefined method `regist' for [1, 2, "III", 4, "five", 6]:Array (NoMethodError)
	from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/lib/drb/extserv.rb:21:in `block in initialize'
	from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/.ext/common/monitor.rb:202:in `synchronize'
	from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/.ext/common/monitor.rb:202:in `mon_synchronize'
	from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/lib/drb/extserv.rb:20:in `initialize'
	from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/test/drb/ut_array_drbssl.rb:35:in `new'
	from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/test/drb/ut_array_drbssl.rb:35:in `<main>'
 = 100.05 s
```

Here is my analysis:
The test of drb used both `druby://:0` and `druby://localhost:0` for
DRbServer. However, the former listens on IPv4, and the latter does on
IPv6, depending on environments. The port 0 is automatically assigned,
but sometimes the same port is used to both because they are different
protocols (IPv4 and IPv6). In this case, their URIs are resolved to the
completely same one (`druby://localhost:port`), which confuses the
method `DRb.here?` which determines the DRbObject is remote or local.

This changeset uses `druby://localhost:0` consistently.
2021-04-07 16:34:19 +09:00
Kazuhiro NISHIYAMA 31ba817887
Try to fix Leaked file descriptor
https://github.com/ruby/ruby/runs/2274767991?check_suite_focus=true#step:15:118
```
Leaked file descriptor: DRbTests::TestDRbTCP#test_immediate_close: 7 : #<TCPServer:fd 7, AF_INET, 0.0.0.0, 42451>
Leaked file descriptor: DRbTests::TestDRbTCP#test_immediate_close: 9 : #<IO:fd 9>
Leaked file descriptor: DRbTests::TestDRbTCP#test_immediate_close: 10 : #<IO:fd 10>
```
2021-04-06 16:03:20 +09:00
Nobuyoshi Nakada 856a9701fd
Get rid of multibyte prefix to tmpdir 2021-04-05 21:20:51 +09:00
Nobuyoshi Nakada 4b6fa03a72
[ruby/tmpdir] Make usable chars more strict
Remove other than alphanumeric and some punctuations considered
filesystem-safe, instead of removing some unsafe chars only.

https://hackerone.com/reports/1131465

https://github.com/ruby/tmpdir/commit/adf294bc2d
2021-04-05 21:08:57 +09:00
Nobuyoshi Nakada 4b92633043 [ruby/irb] Suppress verbose messages in the parallel test
`:VERBOSE` flag needs to be set prior to `IRB::Irb.new`.

https://github.com/ruby/irb/commit/0dbe292979
2021-04-05 14:00:21 +09:00
Yusuke Endoh 2fcae4f90a test/ruby/test_lambda.rb: Remove "warning: assigned but unused variable" 2021-04-04 15:26:09 +09:00
Nobuyoshi Nakada 64b991b0cd [ruby/rdoc] Links to document texts without "rdoc-ref:" prefix
While links to generated HTML from RDoc file needs to be prefixed
by "rdoc-ref:" currently, in case of explicit references this
seems just redundant.

Also GitHub RDoc support does not work with this prefix.

This patch lets links to such document texts (".rb", ".rdoc" and
".md" now) refer URLs generated by `RDoc::TopLevel#http_url`
without the prefix.

https://github.com/ruby/rdoc/commit/f18b27b69d
2021-04-03 01:22:09 +09:00
Nobuyoshi Nakada a6948329f8 [ruby/rdoc] Clarify that dots in URL are replaced
The dots in all path components from the document root are
replaced with underscores, not only in the basename.

https://github.com/ruby/rdoc/commit/7a3417ea4c
2021-04-03 01:22:00 +09:00
aycabta 61e1cf23ac [ruby/rdoc] Treat emphasis tags as excluding other notations
And exclusive notations don't exclude other exclusive notations.

https://github.com/ruby/rdoc/commit/b8baa9a435
2021-04-03 01:21:50 +09:00
aycabta e84d275fe6 [ruby/rdoc] Treat other tags as word boundaries
https://github.com/ruby/rdoc/commit/8222f85a17
2021-04-03 01:21:38 +09:00
aycabta 54aa11efa8 [ruby/rdoc] Disable other notations in <code> tags
https://github.com/ruby/rdoc/commit/0cd3b55210
2021-04-03 01:21:12 +09:00
aycabta ab89c45b90 [ruby/irb] Evaluate each toplevel statement
https://github.com/ruby/irb/commit/bc1b1d8bc3
2021-04-03 01:17:08 +09:00
aycabta 254cd937c2 [ruby/irb] Add test for multiline paste
https://github.com/ruby/irb/commit/e93c9cb54d
2021-04-03 01:15:46 +09:00
aycabta 0eb1491957 [ruby/irb] Add yamatanooroti test example
https://github.com/ruby/irb/commit/279155fcee
2021-04-03 01:14:31 +09:00
aycabta 7e93917458 [ruby/reline] Reset @rest_height when clear screen
https://github.com/ruby/reline/commit/3a7019b0d5
2021-04-02 17:33:48 +09:00
Takashi Kokubun 9e336f73fb [ruby/irb] Add show_source command
https://github.com/ruby/irb/commit/108cb04352
2021-04-02 16:40:06 +09:00
Nobuyoshi Nakada 79af8ce6d7 [ruby/irb] Colorize `__END__` as keyword
https://github.com/ruby/irb/commit/9b84018311
2021-04-02 10:52:53 +09:00
Koichi Sasada ecfa8dcdba fix return from orphan Proc in lambda
A "return" statement in a Proc in a lambda like:
  `lambda{ proc{ return }.call }`
should return outer lambda block. However, the inner Proc can become
orphan Proc from the lambda block. This "return" escape outer-scope
like method, but this behavior was decieded as a bug.
[Bug #17105]

This patch raises LocalJumpError by checking the proc is orphan or
not from lambda blocks before escaping by "return".

Most of tests are written by Jeremy Evans
https://github.com/ruby/ruby/pull/4223
2021-04-02 09:25:33 +09:00
Koichi Sasada 1ac68bba4e [ruby/irb] SIGINT should raise Interrupt after IRB session
https://github.com/ruby/irb/commit/5832cfe75b
2021-04-02 01:57:44 +09:00
Nobuyoshi Nakada ccb0b7ab7d [ruby/irb] Suppress verbose messages in the parallel test
`:VERBOSE` flag needs to be set prior to `IRB::Irb.new`.

https://github.com/ruby/irb/commit/78604682d9
2021-04-02 01:47:58 +09:00
Nobuyoshi Nakada 2a02b61fae
Use EnvUtil.under_gc_stress 2021-03-31 22:14:15 +09:00
Koichi Sasada 1fac99afda skip marking for uninitialized imemo_env.
RUBY_INTERNAL_EVENT_NEWOBJ can expose uninitialized imemo_env
objects and marking it will cause critical error. This patch
skips marking on uninitialized imemo_env.

See: http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20210329T183003Z.fail.html.gz

Shortest repro-code is provided by mame-san.
2021-03-31 19:18:32 +09:00
Kazuki Yamaguchi e2bf3659e1 [ruby/openssl] pkcs7: keep private key when duplicating PKCS7_SIGNER_INFO
ASN1_dup() will not copy the 'pkey' field of a PKCS7_SIGNER_INFO object
by design; it is a temporary field kept until the PKCS7 structure is
finalized. Let's bump reference counter of the pkey in the original
object and use it in the new object, too.

This commit also removes PKCS7#add_signer's routine to add the
content-type attribute as a signed attribute automatically. This
behavior was not documented or tested. This change should not break any
working user code since the method was completely useless without the
change above.

https://github.com/ruby/openssl/commit/20ca7a27a8
2021-03-31 18:05:07 +09:00
Nobuyoshi Nakada 5cdf99f64e
mkmf: fixed install directories of header files in extension libraries [Bug #17761]
When installing an extension library which provides a header, that
header should be installed under site_ruby (or vendor_ruby when
"--vendor" option was given to extconf.rb).  However, currently
this file is about to be installed in the core include directory.
2021-03-30 23:28:49 +09:00
Samuel Williams 611e711085 Test incorrect behaviour of `rb_io_wait_readable/writable`. 2021-03-30 23:16:59 +13:00
Samuel Williams 92449e0e99 Fix handling of timeout accessing scheduler outside of non-blocking context. 2021-03-30 18:38:42 +13:00
Samuel Williams af1c587546 Improve timeout tests. 2021-03-30 18:38:42 +13:00
Samuel Williams 511acba4ae Update method name and add documentation. 2021-03-30 18:38:42 +13:00
Samuel Williams 4c53dc970b Add hook for `Timeout.timeout`. 2021-03-30 18:38:42 +13:00
Jeremy Evans 62e66aedb0 Add more tests for defined? with method calls 2021-03-29 07:45:15 -07:00
Nobuyoshi Nakada e8317d90b0
[ruby/optparse] Fixed error message of unparsed non-option
Close https://github.com/ruby/optparse/issues/3

https://github.com/ruby/optparse/commit/94c5cf4032
2021-03-29 19:37:24 +09:00
Jeremy Evans eca8ffaa0b
[ruby/optparse] Add OptionParser#require_exact accessor
This allows you to disable allowing abbreviations of long options
and using short options for long options.

Implements Ruby Feature #11523

https://github.com/ruby/optparse/commit/dfefb2d2e2
2021-03-29 15:55:41 +09:00
aycabta a1938ec308 [ruby/irb] Always add input method when calling Irb.new in tests
When passes input method as nil to Context.new through Irb.new,
ReidlineInputMethod.new is executed and the global internal state of Reline is
rewritten, therefore other tests are failed in the Ruby repository. This
commit changes to use TestInputMethod.

https://github.com/ruby/irb/commit/010dce9210
2021-03-29 05:10:08 +09:00
Kenichi Kamiya 9af57eeed6
[ruby/pathname] Fix segfault of Pathname#split
Fix segmentation fault of Pathname#split when File.split returns
non array value [Bug #17755]

https://github.com/ruby/pathname/commit/e29b49e3b1
https://github.com/ruby/pathname/commit/1db7479a74
2021-03-28 14:04:10 +09:00
Hiroshi SHIBATA 447e095413
[ruby/pathname] Support Ruby 3.0
Update test/pathname/test_pathname.rb

https://github.com/ruby/pathname/commit/29645187e0
https://github.com/ruby/pathname/commit/78584864de

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-03-28 14:03:42 +09:00
Kenichi Kamiya 31e0382723
Keep non evaluated keys in `Hash#transform_keys!` [Bug #17735] 2021-03-28 09:14:57 +09:00
Kenichi Kamiya 0a544c0c35
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
2021-03-28 08:47:42 +09:00
Kenichi Kamiya aceb8c0b4b
Fix Enumerable#tally with some arguments pattern [Feature #17744]
* Add test cases for Enumerable#tally with hash argument

* Add ruby/spec for Enumerable#tally with hash argument

* Fix Enumerable#tally does not update given frozen hash

* Add test cases for Enumerable#tally with hash convertible arguments

* Fix SEGV when Enumerable#tally takes non Hash convertible

* FIx cosmetic damage enum.c
2021-03-27 12:55:46 +09:00
Nobuyoshi Nakada 8a89dd2a6c
No codesign in tests 2021-03-27 10:15:01 +09:00
Nobuyoshi Nakada 9143d21b1b
Enumerable#tally with the resulting hash [Feature #17744] 2021-03-26 16:29:21 +09:00
aycabta ad8842c06d [ruby/irb] Cache completion files to require
https://github.com/ruby/irb/commit/612ebcb311
2021-03-25 18:54:02 +09:00
Peter Zhu b25361f731 Change heap walking to be safe for object allocation 2021-03-24 14:31:10 -04:00
Jeremy Evans f9f13a4f6d 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>
2021-03-24 11:15:00 -07:00