Commit graph

15017 commits

Author SHA1 Message Date
Takashi Kokubun
b33caa5bbc [ruby/irb] Add a test of find_end for show_source command
68e6ca95a0
2021-10-10 23:23:47 -07:00
aycabta
3112e876a1 [ruby/reline] Add tests for dialog with fullwidth chars and corner cases
35ab5d47a8
2021-10-11 14:10:35 +09:00
Jeremy Evans
9a321dd9b2
[ruby/ipaddr] Make IPAddr#include? consider range of argument
It would be nice to use Range#cover? here, but it doesn't work
correctly before Ruby 2.6. Switch to manual checks of the beginning
of end of the ranges.

Fixes Ruby Bug 14119

f45630da31
2021-10-11 13:50:54 +09:00
Nobuyoshi Nakada
b9f7286fe9
[ruby/io-console] Skip Interrupt test on Solaris too
48db3616da
2021-10-11 11:33:15 +09:00
David Rodríguez
bbcf8f87ac [ruby/rubygems] Check safety of packaged symlinks
If we explicitly disallow the creation of symlinks that point to files
outside of the destination directory, we can avoid any other safety
checks while creating directories, because we can be sure they will
always fall under the destination directory as well.

555692b8de
2021-10-10 23:12:47 +09:00
David Rodríguez
05e3d7b967 [ruby/rubygems] Explicit check file not created outside of destination
1e363dbbcb
2021-10-10 23:12:21 +09:00
David Rodríguez
48e4dea4cd [ruby/rubygems] Refactor symlink attack specs
9180b390aa
2021-10-10 23:12:15 +09:00
aycabta
d0f2c4d053 [ruby/reline] Fix tests to show dialog to the right edge
6a0d0ada94
2021-10-09 23:23:14 +09:00
aycabta
bf1f6a696f [ruby/reline] Add a test for full-width scrollbar
cff83e68f8
2021-10-09 23:23:07 +09:00
Masataka Pocke Kuwabara
d03d122ba1 [rubygems/rubygems] Improve performance of Specification#missing_extensions?
90c1919f94
2021-10-09 08:04:08 +09:00
Jeremy Evans
08759edea8
Remove autoload for constant if the autoload fails
Previously, if an autoload failed (the file was loaded, but the
constant was not defined by the autoloaded file). Ruby will try
to autoload again if you delete the autoloaded file from
$LOADED_FEATURES.  With this change, the autoload and the
constant itself are removed as soon as it fails.

To handle cases where multiple threads are autoloading, when
deleting an autoload, handle the case where another thread
already deleted it.

Fixes [Bug #15790]
2021-10-08 14:54:26 -07:00
Nobuyoshi Nakada
78ff9b719c
Add tests for the edge caces of String#end_with?
Also, check if a suffix is empty, to guarantee the assumption of
`onigenc_get_left_adjust_char_head` that `*s` is always accessible,
even in the case of `SHARABLE_MIDDLE_SUBSTRING`.
2021-10-08 14:08:03 +09:00
aycabta
1251edd1db [ruby/irb] Add tests for truncated show doc dialog
But pending them now because they need dummy document data to show doc.

ac471ee14e
2021-10-08 10:34:20 +09:00
aycabta
36bf378363 [ruby/reline] Add a test for narrow screen without scrollbar
44cd35e65d
2021-10-08 10:33:27 +09:00
aycabta
374b15a84a [ruby/reline] Cut off the excess on narrow screen
972cc993ca
2021-10-08 10:33:22 +09:00
Aaron Patterson
217df51f0e 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]
2021-10-07 15:39:47 -07:00
Nobuyoshi Nakada
8057129da6
Remove duplicate value checks on mrhs which always has the value 2021-10-08 00:11:22 +09:00
Jeremy Evans
bd6e1a0f08
[ruby/ipaddr] Support zone identifiers in IPv6 addresses
These are supported by Ruby's socket library if the operating system
supports zone indentifiers, so they should be supported by ipaddr.
See RFCs 4007 and 6874 for additional information.

Implements Ruby Feature #10911

09a6408fb2
2021-10-07 18:22:43 +09:00
Bogdan Irimie
74ed881e10
[ruby/ipaddr] Add netmask method that returns net mask as string.
283d16f3a3
2021-10-07 18:22:43 +09:00
Jeremy Evans
abad5e10e8
[ruby/ipaddr] Disallow leading zeros in mask
f49d2d49a4
2021-10-07 18:22:43 +09:00
Nobuyoshi Nakada
38da84296c
[ruby/ipaddr] Raise if extra slashes follow
https://bugs.ruby-lang.org/issues/15832

de9805d6fa
2021-10-07 18:22:42 +09:00
Espartaco Palma
b23fba91ae [ruby/ipaddr] Removing superfluos assingments & return
Also adding test for ntop

0ba16cca10
2021-10-07 17:46:00 +09:00
Yusuke Endoh
273673aeaf test/ruby/test_process (test_no_curdir): tentatively skipped on Solaris
The test gets stuck on Solaris CI.

20211006T050007Z.fail.html.gz#test-all
```
[14558/21042] TestProcess#test_no_curdirtimeout: output interval exceeds 1800.0 seconds.
timeout: the process group 3857 is alive.
```

Related to ee89543e09
2021-10-07 10:40:40 +09:00
Jean Boussier
afcbb501ac marshal.c Marshal.load accepts a freeze: true option.
Fixes [Feature #18148]

When set, all the loaded objects are returned as frozen.

If a proc is provided, it is called with the objects already frozen.
2021-10-05 18:34:56 +02:00
aycabta
dc8fa2691b [ruby/reline] Reduce window size so that it can be displayed in my desktop
22359d50ab
2021-10-05 22:33:13 +09:00
aycabta
2c2a017fe8 [ruby/reline] Cyrillic chars are now forced to be displayed in full-width on Windows
So testing is no longer necessary.

c59589548b
2021-10-05 22:33:02 +09:00
Nobuyoshi Nakada
1f544d6715
Show the last line at unexpected end-of-input error 2021-10-05 16:44:43 +09:00
Jeremy Evans
ee89543e09 Fix regression on Solaris after change to use realpath on loaded features
After the change to use realpath on loaded features, Solaris CI
started failing in test_no_curdir (which tests behavior for running
ruby without a working directory).

I was able to trace the problem to the following call chain:

rb_call_inits->Init_Thread->Init_thread_sync->rb_provide->
get_loaded_features_index->rb_check_realpath->rb_dir_getwd_ospath->
ruby_getcwd

This will throw an exception, but because Ruby hasn't been fully
initialized at the point the exception is thrown, it just exits
with a status of 1.

The bug here is that rb_check_realpath should not raise an
exception, it should return nil.  This bug is hit on Solaris
because Solaris uses the realpath emulation instead of native
realpath, and the realpath emualation raised instead of
returning nil if the mode was RB_REALPATH_CHECK. Use rb_rescue
in the realpath emulation if the mode is RB_REALPATH_CHECK, and
swallow any exceptions raised and return nil.
2021-10-04 19:30:01 -09:00
Jeremy Evans
e4d85d3a2d Revert rescue around internal realpath call on Solaris
Solaris CI still has a problem even with these commits, so it doesn't
appear to fix the issue.  Reverting both 84e8e2a39b
and bfd2f159f0.
2021-10-04 10:51:52 -07:00
Jeremy Evans
3381fa5458 Only rescue realpath calls during require on Solaris
Remove temporary skip of test_no_curdir to see if this fixes the
problem.
2021-10-04 07:43:24 -09:00
Nobuyoshi Nakada
28392d3045
The same warning for static symbol literal 2021-10-04 12:16:31 +09:00
Nobuyoshi Nakada
da139317a5
Fix the warning message for dynamic symbol literal in condition 2021-10-04 12:16:31 +09:00
Nobuyoshi Nakada
19f9d9cf73 Remove extraneous conversion to float [Bug #18236] 2021-10-03 22:06:31 +09:00
aycabta
64e96d6b41 [ruby/reline] Re-calc the scroll pos when the content in dialog is shortened
12ea63e6e0
2021-10-03 21:51:02 +09:00
Nobuyoshi Nakada
ea64e742f5
Revert "mkmf.rb: try linking at try_var" [Bug #18235]
This reverts commit 524513be39,
which can return false positive by existing but unusable symbol,
including functions.
2021-10-03 18:23:39 +09:00
aycabta
d31279fe6f [ruby/reline] Add a test for rerendering arg prompt after pasting
5414a42b0e
2021-10-03 14:53:19 +09:00
aycabta
2a3d0fbe17 [ruby/reline] Add newlines for readability
2a60aacebb
2021-10-03 14:09:03 +09:00
aycabta
7c6ef27d6c [ruby/reline] Stop using Ctrl+j to test on Windows
Because Ctrl+j and Enter are the same on Windows.

fa885ed449
2021-10-03 14:08:38 +09:00
Jeremy Evans
4f65e6ce2a Temporarily skip test_no_curdir test to avoid CI failures on Solaris 2021-10-02 15:55:13 -07:00
Jeremy Evans
79a4484a07 Do not load file with same realpath twice when requiring
This fixes issues with paths being loaded twice in certain cases
when symlinks are used.

It took me multiple attempts to get this working.  My original
attempt tried to convert paths to realpaths before adding them
to $LOADED_FEATURES.  Unfortunately, this doesn't work well
with the loaded feature index, which is based off load paths
and not realpaths. While I was able to get require working, I'm
fairly sure the loaded feature index was not being used as
expected, which would have significant performance implications.
Additionally, I was never able to get that approach working with
autoload when autoloading a non-realpath file. It also broke
some specs.

This takes a more conservative approach. Directly before loading the
file, if the file with the same realpath has been required, the
loading of the file is skipped. The realpaths are stored as
fstrings in a hidden hash.

When rebuilding the loaded feature index, the hash of realpaths
is also rebuilt.  I'm guessing this makes rebuilding process
slower, but I don think that is a hot path. In general, modifying
loaded features is only done when reloading, and that tends to be
in non-production environments.

Change test_require_with_loaded_features_pop test to use 30 threads
and 300 iterations, instead of 4 threads and 1000 iterations.
I saw only sporadic failures with 4/1000, but consistent failures
30/300 threads. These failures were due to the fact that the
concurrent deletions from $LOADED_FEATURES in other threads can
result in rb_ary_entry returning nil when rebuilding the loaded
features index.

To avoid concurrency issues when rebuilding the loaded features
index, the building of the index itself is left alone, and
afterwards, a separate loop is done on a copy of the loaded feature
snapshot in order to rebuild the realpaths hash.

Fixes [Bug #17885]
2021-10-02 05:51:29 -09:00
manga_osyo
b8327fb8b1 [ruby/reline] Refactoring Reline::Key.match? and add test.
90e8999ae4
2021-10-02 19:58:41 +09:00
Jeremy Evans
abc0304cb2 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]
2021-10-01 19:50:19 -09:00
Nobuyoshi Nakada
d087214658 Restore Hash#compare_by_identity mode [Bug #18171] 2021-10-02 11:43:35 +09:00
Nobuyoshi Nakada
60d0421ca8 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.
2021-10-01 20:28:44 +09:00
Jeremy Evans
1f5f8a187a
Make Array#min/max optimization respect refined methods
Pass in ec to vm_opt_newarray_{max,min}. Avoids having to
call GET_EC inside the functions, for better performance.

While here, add a test for Array#min/max being redefined to
test_optimization.rb.

Fixes [Bug #18180]
2021-09-30 15:18:14 -07:00
Jean byroot Boussier
529fc204af
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.
2021-09-30 16:50:31 +02:00
aycabta
5eb8b6d1bd [ruby/reline] Support ed_argument_digit by M+num
The vi mode can handle "argument number" before an operator or a motion,
such as, "3x" (equals "xxx"), and "3l" (equals "lll"). In the emacs
mode, GNU Readline can handle argument number with meta key, like
"Meta+3 x" (equals "xxx").

9183cc2e8b
2021-09-29 22:07:49 +09:00
Yusuke Endoh
be51f4ce83 [ruby/did_you_mean] Disable error_highlight when testing did_you_mean
Fixes #160

93df310873
2021-09-28 17:48:57 +09:00
Ellen Marie Dash
fcaa918445 [rubygems/rubygems] Only disallow FIXME/TODO for first word of gemspec description
7890c98 matched the start of each line, whereas this matches the start
of the entire string.

432de7b819
2021-09-28 17:43:42 +09:00
Jeremy Evans
f9f7f3a75e [ruby/date] Make %v strftime flag use uppercase month
%v is supposed to be the VMS date, and VMS date format uses an
uppercase month.

Ruby 1.8 used an uppercase month for %v, but the behavior was
changed without explanation in r31672.

Time#strftime still uses an uppercase month for %v, so this change
makes Date#strftime consistent with Time#strftime.

Fixes [Bug #13810]

56c489fd7e
2021-09-28 17:34:26 +09:00