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

11748 Коммитов

Автор SHA1 Сообщение Дата
Alan Wu c06ddfee87
str_duplicate: Don't share with a frozen shared string
This is a follow up for 3f9562015e.
Before this commit, it was possible to create a shared string which
shares with another shared string by passing a frozen shared string
to `str_duplicate`.

Such string looks like:

```
 --------                    -----------------
 | root | ------ owns -----> | root's buffer |
 --------                    -----------------
     ^                             ^   ^
 -----------                       |   |
 | shared1 | ------ references -----   |
 -----------                           |
     ^                                 |
 -----------                           |
 | shared2 | ------ references ---------
 -----------
```

This is bad news because `rb_fstring(shared2)` can make `shared1`
independent, which severs the reference from `shared1` to `root`:

```c
/* from fstr_update_callback() */
str = str_new_frozen(rb_cString, shared2);  /* can return shared1 */
if (STR_SHARED_P(str)) { /* shared1 is also a shared string */
    str_make_independent(str);  /* no frozen check */
}
```

If `shared1` was the only reference to `root`, then `root` can be
reclaimed by the GC, leaving `shared2` in a corrupted state:

```
 -----------                         --------------------
 | shared1 | -------- owns --------> | shared1's buffer |
 -----------                         --------------------
      ^
      |
 -----------                         -------------------------
 | shared2 | ------ references ----> | root's buffer (freed) |
 -----------                         -------------------------
```

Here is a reproduction script for the situation this commit fixes.

```ruby
a = ('a' * 24).strip.freeze.strip
-a
p a
4.times { GC.start }
p a
```

 - string.c (str_duplicate): always share with the root string when
   the original is a shared string.
 - test_rb_str_dup.rb: specifically test `rb_str_dup` to make
   sure it does not try to share with a shared string.

[Bug #15792]

Closes: https://github.com/ruby/ruby/pull/2159
2019-05-09 10:04:19 +09:00
NARUSE, Yui f1486fea46 require 'stringio' 2019-05-09 09:23:44 +09:00
Takashi Kokubun a95ca6d5e9
Trim MJIT output from TestHideSkip
to prevent failure like
https://app.wercker.com/ruby/ruby/runs/mjit-test1/5cd28aa6ab79a30008ee819b?step=5cd28b2403f44600070db083
with --jit-verbose=1.
2019-05-08 17:30:15 +09:00
Jean Boussier 7d805e67f3
Avoid triggering autoload in Module#const_defined?(String)
[Bug #15780]
2019-05-07 21:20:01 +09:00
Jeremy Evans 0c0ed1cee8
Fix use of numbered parameter inside proc that is default value of optarg
This allows cases such as:

```ruby
m ->(a = ->{@1}) {a}
m.call.call(1)

m2 ->(a: ->{@1}) {a}
m2.call.call(2)
```

Previously, this would cause a syntax error.

[Bug#15789]
2019-05-05 15:33:10 +09:00
Jeremy Evans b8f3be295b
Fix a case where numbered parameters should not be allowed
Because `proc{|| @1}` is a syntax error, the following should
also be syntax errors:

```ruby
proc { |
| @1}
```

```ruby
proc { |; a| @1 }
```

This fixes both cases.

[Bug #15825]
2019-05-05 14:46:39 +09:00
Nobuyoshi Nakada ff21e75d32
parse.y: duplicated when clause warning
* parse.y (case_args): moved "duplicated when clause" warning from
  compile phase, so that `ruby -wc` shows them.
2019-05-05 00:29:12 +09:00
Masatoshi SEKI 848edb03f8 ignore test_RangeError 2019-05-04 23:32:13 +09:00
Masatoshi SEKI 8980b53a48 add DRb::WeakIdConv (Bug #15711) 2019-05-04 19:28:57 +09:00
Nobuyoshi Nakada 71952440ad
Silence a (probable) debug print 2019-05-01 20:55:08 +09:00
NAKAMURA Usaku dcb6a6ae3e
Windows simply causes an error to open invalid path 2019-05-01 17:38:45 +09:00
manga_osyo 4e88e86928 Add exception support in `Range#first`.
Closes: https://github.com/ruby/ruby/pull/2163
2019-05-01 00:03:30 +09:00
NAKAMURA Usaku 830e40ee05
Skip on Windows now when using reline because it causes hang of whole tests 2019-04-30 19:45:44 +09:00
aycabta 94b740b249 Use Ripper for IRB
The debug option of IRB is deleted because it's just for IRB's pure Ruby
parser.
2019-04-30 14:40:06 +09:00
aycabta 567cb1ae1d Use Encoding::UTF_8 if RELINE_TEST_ENCODING doesn't exist 2019-04-30 12:53:24 +09:00
aycabta 319eee0f4a Use Encoding::UTF_8 if Encoding.default_external is Encoding::IBM437 2019-04-30 12:33:24 +09:00
aycabta 17350c7e55 Add Reline as a fallback library for Readline
* lib/reine.rb, lib/reline/*: Reline is a readline stdlib compatible
  library.
* lib/readline.rb: Readline uses a fallback to Reline when ext/readline
  doesn't exist.
* tool/sync_default_gems.rb: add ruby/reline as a default gem.
* appveyor.yml: add "set RELINE_TEST_ENCODING=Windows-31J" for test suit
  of Reline, and add "--exclude readline" to "nmake test-all" on Visual
  Studio builds because of strange behavior.
* spec/ruby/library/readline/spec_helper.rb: skip Reline as with
  RbReadline.
2019-04-30 11:44:20 +09:00
Nobuyoshi Nakada 1432471a75
Disallow also CR in here-doc identifier
* parse.y (heredoc_identifier): CR in here-document identifier
  might or might not result in a syntax error, by the EOL code.
  make a syntax error regardless of the EOL code.
2019-04-29 13:47:20 +09:00
Nobuyoshi Nakada 23375c8b81
Make only `mesg` can be assigned with default `fname` 2019-04-29 13:42:50 +09:00
Nobuyoshi Nakada 330b376133
parse.y: fix here-doc identifier with newline
* parse.y (heredoc_identifier): quoted here-document identifier
  must end within the same line.

  the only corner case that here-document identifier can contain a
  newline is that the closing qoute is placed at the beginning of
  the next line, and has been warned since 2.4.

  ```ruby
  <<"EOS
  " # warning: here document identifier ends with a newline
  EOS
  ```
2019-04-29 12:49:59 +09:00
Yusuke Endoh 6bedbf4625 numeric.c: Extend Integer#[] to support range arguments
````
0b01001101[2, 4]  #=> 0b0011
0b01001100[2..5]  #=> 0b0011
0b01001100[2...6] #=> 0b0011
    ^^^^
````

[Feature #8842]
2019-04-28 23:40:57 +09:00
Yusuke Endoh cb55024613 test/ruby/test_integer.rb: Add a sane test for Integer#[] 2019-04-28 23:23:00 +09:00
Takashi Kokubun f2d7ba6a74
make sync-default-gems GEM=irb
from e8e79d569e.

This colorizes Range object on IRB inspect.
2019-04-28 21:51:37 +09:00
Takashi Kokubun 8711f77a26
make sync-default-gems GEM=irb
from 96f05e7268.

Just syncing newer test changes so that conflicts do not happen when trunk is
modified and we need to backport that to ruby/irb.
2019-04-28 20:34:11 +09:00
Takashi Kokubun 588f212c26
make sync-default-gems GEM=irb
from 44301d3827.

This includes some fixes for string interpolation highlight fixes.
2019-04-28 20:18:45 +09:00
David Rodríguez d0a5467320 Update rubygems with latest upstream changes
Closes: https://github.com/ruby/ruby/pull/2154
2019-04-28 11:07:45 +09:00
Jeremy Evans a15f7dd1fb
Always mark the string returned by File.realpath as tainted
This string can include elements that were not in either string
passed to File.realpath, even if one of the strings is an
absolute path, due to symlinks:

```ruby
Dir.mkdir('b') unless File.directory?('b')
File.write('b/a', '') unless File.file?('b/a')
File.symlink('b', 'c') unless File.symlink?('c')
path = File.realpath('c/a'.untaint, Dir.pwd.untaint)
path # "/home/testr/ruby/b/a"
path.tainted? # should be true, as 'b' comes from file system
```

[Bug #15803]
2019-04-28 10:47:51 +09:00
git ed4f331879 * remove trailing spaces. 2019-04-28 02:02:30 +09:00
Takashi Kokubun cae0b73214
make sync-default-gems GEM=irb
from 89e9add06d.

This adds syntax highlight support for Module on inspect.

In addition to that, I'm adding a trailing space in test_color.rb for
testing ruby-commit-hook's auto-style.
2019-04-28 02:01:04 +09:00
Takashi Kokubun 9348643575
make sync-default-gems GEM=irb
Synced from 5feb361ed8.
This includes a support to colorize named Class instance on IRB inspect.
2019-04-27 22:01:11 +09:00
Nobuyoshi Nakada 3f9562015e
Get rid of indirect sharing
* string.c (str_duplicate): share the root shared string if the
  original string is already sharing, so that all shared strings
  refer the root shared string directly.  indirect sharing can
  cause a dangling pointer.

[Bug #15792]
2019-04-27 21:26:42 +09:00
Takashi Kokubun 5f6ba669ff
Isolate TestGCCompact from JIT testing
Wercker seems to randomly fail
https://app.wercker.com/ruby/ruby/runs/mjit-test1/5cc3c1c423fcb70008db9b64?step=5cc3c46a03f4460007da0659

To help debugging, let me isolate the impact from GC.compact in the JIT
testing on Wercker.
2019-04-27 12:28:52 +09:00
Takashi Kokubun 569c1ef6f1
make sync-default-gems GEM=irb
Backport changes from ruby/irb.
2019-04-27 11:42:40 +09:00
naruse 782e487260
suppress warning in test/irb
https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos7/ruby-trunk/log/20190421T040003Z.fail.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Re-committing 7f09b5e9da
2019-04-27 11:31:30 +09:00
Takashi Kokubun a429b3601f
Revert "Class instance should be also colorable on IRB"
This reverts commit 6669c966d2.

It seems to make tests fail... let me fix this later.
2019-04-26 18:46:43 +09:00
Takashi Kokubun 6669c966d2
Class instance should be also colorable on IRB
inspect.

Change is made with: `$ make -C .ruby sync-default-gems GEM=irb`
2019-04-26 18:42:51 +09:00
Takashi Kokubun 52cfb17086
make sync-default-gems GEM=irb
from e6739d8c66
2019-04-26 18:28:57 +09:00
Nobuyoshi Nakada 54eac83b2a
Hide internal IDs
* parse.y (internal_id): number the ID serial for internal use by
  counting down from the neary maximum value, not to accidentally
  match permanent IDs.

[Bug #15768]
2019-04-26 09:33:48 +09:00
Takashi Kokubun 0408b8b390
Syntax-highlight yield in IRB 2019-04-26 01:43:14 +09:00
Takashi Kokubun 5fe99aefd3
Support highlighting Regexp in inspect 2019-04-26 01:15:30 +09:00
Takashi Kokubun 0c54d2e2c7
Force IRB::Color to recognize TERM
Closes: https://github.com/ruby/ruby/pull/2150
2019-04-26 00:47:43 +09:00
Takashi Kokubun b55201dd09
Colorize IRB's inspect result
Closes: https://github.com/ruby/ruby/pull/2150
2019-04-26 00:47:40 +09:00
Takashi Kokubun 94af6cd383
Colorize IRB's code_around_binding
Closes: https://github.com/ruby/ruby/pull/2150
2019-04-26 00:47:39 +09:00
Masatoshi SEKI 68e3f8192b add DRbObject dereference test (Preparation for investigation of Bug #15711) 2019-04-25 01:08:54 +09:00
Kazuhiro NISHIYAMA dd5b6c71c6
Fix typos [ci skip] 2019-04-25 00:52:16 +09:00
Nobuyoshi Nakada f1a52d96a5
Defer setting gc_stress until inits done
[Bug #15784]
2019-04-24 13:02:01 +09:00
Aaron Patterson 75061f46ae
Fix complex hash keys to work with compaction
For example when an array containing objects is a hash key, the contents
of the array may move which can cause the hash value for the array to
change.   This commit makes the default `hash` value based off the
object id, so the hash value will remain stable.

Fixes test/shell/test_command_processor.rb
2019-04-23 14:21:15 -07:00
Nobuyoshi Nakada f4f66bd11c
Revert "IRB is improved with Reline and RDoc, take 2"
Accidentally merged when 89271d4a37
"Adjusted indents".
2019-04-23 21:55:29 +09:00
aycabta f2cd4f4cd0
IRB is improved with Reline and RDoc, take 2 2019-04-23 20:08:02 +09:00
Seiei Miyagi 6ca9e7cc07
Disallow numbered parameter as the default value of optional argument
[Fix GH-2139] [Bug #15783]
2019-04-23 12:16:15 +09:00