62634 Commits

Author SHA1 Message Date
Kasumi Hanazuki
5d71eed1a7 rb_str_{partition,rpartition}_m: Handle /\K/ in pattern
When the pattern given to String#partition and String#rpartition
contain a /\K/ (lookbehind) operator, the methods return strings
sliced at incorrect positions.

```
# without patch
"abcdbce".partition(/b\Kc/)  # => ["a", "c", "cdbce"]
"abcdbce".rpartition(/b\Kc/)  # => ["abcd", "c", "ce"]
```

This patch fixes the problem by using BEG(0) instead of the return
value of rb_reg_search.

```
# with patch
"abcdbce".partition(/b\Kc/)  # => ["ab", "c", "dbce"]
"abcdbce".rpartition(/b\Kc/)  # => ["abcdb", "c", "e"]
```

As a side-effect this patch makes String#partition 2x faster when the
pattern is a costly Regexp by performing Regexp search only once,
which was unexpectedly done twice in the original implementation.

Fixes [Bug #17119]
2020-08-13 20:50:50 +09:00
卜部昌平
69b5241c36 ruby_debug_log: suppress warning
Old gcc (< 5 maybe?) warns that this variable is not initialized:

    debug.c: In function 'ruby_debug_log':
    debug.c:441:13: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
                 ^

I don't know if that is true, but adding "= 0" here must harm no one.
2020-08-13 10:14:20 +09:00
卜部昌平
1f9e25cd02 MAYBE_UNUSED should just suffice
This reverts commit c355fa72d4e356378a8b03a67432b52bafcc308b.
2020-08-13 10:14:20 +09:00
Jeremy Evans
4fc6cfbeae Revert "Improve performance of partial backtraces"
This reverts commit f2d7461e85053cb084e10999b0b8019b0c29e66e.

Some CI machines are reporting issues with backtrace_mark, so I'm
going to revert this for now.
2020-08-12 11:43:11 -07:00
git
6dfd7ad4f5 * 2020-08-13 [ci skip] 2020-08-13 03:03:49 +09:00
Jeremy Evans
f2d7461e85 Improve performance of partial backtraces
Previously, backtrace_each fully populated the rb_backtrace_t with all
backtrace frames, even if caller only requested a partial backtrace
(e.g. Kernel#caller_locations(1, 1)).  This changes backtrace_each to
only add the requested frames to the rb_backtrace_t.

To do this, backtrace_each needs to be passed the starting frame and
number of frames values passed to Kernel#caller or #caller_locations.

backtrace_each works from the top of the stack to the bottom, where the
bottom is the current frame.  Due to how the location for cfuncs is
tracked using the location of the previous iseq, we need to store an
extra frame for the previous iseq if we are limiting the backtrace and
final backtrace frame (the first one stored) would be a cfunc and not
an iseq.

To limit the amount of work in this case, while scanning until the start
of the requested backtrace, for each iseq, store the cfp.  If the first
backtrace frame we care about is a cfunc, use the stored cfp to find the
related iseq.  Use a function pointer to handle the storage of the cfp
in the iteration arg, and also store the location of the extra frame
in the iteration arg.

backtrace_each needs to return int instead of void in order to signal
when a starting frame larger than backtrace size is given, as caller
and caller_locations needs to return nil and not the empty array in
these cases.

To handle cases where a range is provided with a negative end, and the
backtrace size is needed to calculate the result to pass to
rb_range_beg_len, add a backtrace_size static function to calculate
the size, which copies the logic from backtrace_each.

As backtrace_each only adds the backtrace lines requested,
backtrace_to_*_ary can be simplified to always operate on the entire
backtrace.

Previously, caller_locations(1,1) was about 6.2 times slower for an
800 deep callstack compared to an empty callstack.  With this new
approach, it is only 1.3 times slower. It will always be somewhat
slower as it still needs to scan the cfps from the top of the stack
until it finds the first requested backtrace frame.

Fixes [Bug #17031]
2020-08-12 11:03:22 -07:00
Peter Zhu
166cacc505
Fix corruption in ARGF.inplace
Extension string stored in `ARGF.inplace` is created using an api
designed for C string constants to create a Ruby string that
points at another Ruby string. When the original string is swept,
the extension string gets corrupted.

Reproduction script (on MacOS):

```ruby
#!/usr/bin/ruby -pi.bak

BEGIN {
  GC.start(full_mark: true)
  arr = []
  1000000.times do |x|
    arr << "fooo#{x}"
  end
}

puts "hello"
```

Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com>
2020-08-12 17:54:09 +09:00
Kasumi Hanazuki
e79cdcf61b string.c(rb_str_split_m): Handle /\K/ correctly
Use BEG(0) instead of the result of rb_reg_search to handle the cases
when the separator Regexp contains /\K/ (lookbehind) operator.

Fixes [Bug #17113]
2020-08-12 10:01:39 +09:00
git
66efe37311 * 2020-08-12 [ci skip] 2020-08-12 01:02:18 +09:00
Alan Wu
7930a352a5 Test out fix for OpenSSL test flakiness
`OpenSSL::TestX509Store#test_verify` has been failing intermittently on
CI about once a day:
  - http://ci.rvm.jp/results/trunk-random2@phosphorus-docker/3121244
  - http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3117661
  - http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3111684

According to the test:
 > OpenSSL uses time(2) while Time.now uses clock_gettime(CLOCK_REALTIME),
 > and there may be difference.

This difference is could be the cause for the flaky failures. Let's see
if giving the certificate more room solves the problem.

In any case, I will revert this in a week. I think changes to these
should go to https://github.com/ruby/openssl/?
2020-08-11 12:01:51 -04:00
Takashi Kokubun
42725e3ab4
Enable s390x invokebuiltin JIT test again 2020-08-11 06:49:04 -07:00
Nobuyoshi Nakada
7806b2e28b
Use colorize.rb for non-capable terminals 2020-08-11 18:35:08 +09:00
Nobuyoshi Nakada
2e7fe3b687
Add default color for each instance 2020-08-11 18:35:07 +09:00
卜部昌平
5af983af4f template/prelude.c.tmpl: suppress clang-12 warning
Clang 12 warns "suspicious concatenation of string literals in an array
initialization", which is rather annoying than useful in this context.
2020-08-11 16:51:07 +09:00
卜部昌平
ef2b785b2d .github/workflows/compilers.yml: clang-12
LLVM made release/11.x branch.  Its master is now version 12.
2020-08-11 16:51:07 +09:00
卜部昌平
acd8ee8dbc tool/prelude.c.tmpl: use RubyVM::CEscape
Do not repeat yourself.
2020-08-11 16:51:07 +09:00
卜部昌平
b0eb5aa344 RubyVM::CEscape#rstring2cstr: do not escape '
A single quote "is representable either by itself or by the escape
sequence", according to ISO/IEC 9899 (checked all versions).  So this is
not a bug fix.  But the generated output is a bit readable without
backslashes.
2020-08-11 16:51:07 +09:00
Jeremy Evans
d43e99b722
Add Method Documentation Guide (#3399)
This documents how methods for core classes and classes in the
standard library should be documented.

Co-authored-by: Eric Hodel <drbrain@segment7.net>
2020-08-10 12:47:31 -07:00
git
404bff567d * 2020-08-11 [ci skip] 2020-08-11 01:33:54 +09:00
Burdette Lamar
c303e21d52
Enhanced RDoc for Array (#3400)
Methods:

    drop
    drop_while
    any?
    all?
    none?
    one?
2020-08-10 11:33:31 -05:00
Nobuyoshi Nakada
0ca6b973e8
Removed non-ASCII code to suppress warnings by localized compilers 2020-08-10 19:46:13 +09:00
Nobuyoshi Nakada
17d869c7d6
Check if C-sources are US-ASCII
Encoding of C-sources can not be determined, and non-ASCII code
are often warned by localized compilers.
2020-08-10 19:46:13 +09:00
Nobuyoshi Nakada
187c164d71
Suppress unused-variable warning
`key` is not used outside this assertion.
2020-08-10 17:49:08 +09:00
Nobuyoshi Nakada
c355fa72d4
Suppress unused-function warnings
Calls with a constant argument should be optimized away.
2020-08-10 17:47:34 +09:00
git
9260b0aece * 2020-08-10 [ci skip] 2020-08-10 16:36:35 +09:00
Nobuyoshi Nakada
fac62f094e
Adjust indent 2020-08-10 16:35:42 +09:00
git
b4b702dd4f * 2020-08-08 [ci skip] 2020-08-08 02:08:56 +09:00
Burdette Lamar
4126a979ae
Enhanced RDoc for Array#take and Array#take_while (#3398) 2020-08-07 12:08:36 -05:00
Burdette Lamar
615b7fa557
Enhanced RDoc for Array#product (#3395) 2020-08-07 06:52:37 -05:00
卜部昌平
504e632a15
sync NDEBUG, RUBY_DEBUG, and RUBY_NDEBUG (#3327)
- When NDEBUG is defined that shall be honoured.
- When RUBY_DEBUG is defined that shall be honoured.
- When both are defined and they conflict, warnings shall be rendered.
- When nothing is specified, nothing shall happen.
2020-08-07 14:01:13 +09:00
Hiroshi SHIBATA
8a99f820ce
Use zlib provided by vcpkg in mswin CI (#3397)
* Revert "mswin build - install src zlib files after checkout"

This reverts commit b6175c9e4fe25b978252d8998fe791d65d998fc5.

* Revert "mswin build - install src zlib files"

This reverts commit bf758ef8b4e2895bf71a611a7ab2a4f236e260ea.
2020-08-07 12:28:39 +09:00
git
429efce4ed * 2020-08-07 [ci skip] 2020-08-07 00:17:15 +09:00
Kazuhiro NISHIYAMA
fcdda2f8a1
Add more debug info to test_verify
http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3111684
2020-08-07 00:16:06 +09:00
Kazuhiro NISHIYAMA
99e4852766
Add verbose message to random failed assertion
for example:
http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3111251
http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3109195
2020-08-06 22:04:39 +09:00
Nguyễn Quang Minh
1819652578
[Feature #16513] TracePoint#inspect returns "... file:line" (#3391)
* Fix debug documents to match Thread#to_s change (Feature #16412 ticket)

* TracePoint#inspect returns "... file:line" (Feature #16513)

* Guard older version of Ruby in Tracepoint inspection tests

* Focus on current thread only when running TracePoint inspection test
2020-08-06 11:56:24 +09:00
Jun Aruga
bbbec4b87c Apply timeout-scale to test_thr_kill. 2020-08-06 08:36:53 +09:00
git
77cfd2e0a1 * 2020-08-06 [ci skip] 2020-08-06 04:58:36 +09:00
Burdette Lamar
e0bc436d9c
Enhanced documentation for Array#repeated_combination (#3392)
* Enhanced documentation for Array#repeated_combination

* Enhanced documentation for Array#repeated_combination
2020-08-05 14:58:16 -05:00
Burdette Lamar
2498334614
Enhanced documentation for Array#repeated_permutation (#3390)
* Enhanced documentation for Array#repeated_permutation

* Enhanced documentation for Array#repeated_permutation
2020-08-05 09:42:58 -05:00
Hiroshi SHIBATA
8f71bb0e4f
Fixed the inconsistency gemspec location with net-* gems. 2020-08-05 20:01:03 +09:00
git
c87043283e * 2020-08-05 [ci skip] 2020-08-05 08:05:19 +09:00
S-H-GAMELINKS
9db5d63ece [DOC] Use oracle url instead of sun url
[ci skip]
2020-08-05 08:04:58 +09:00
Aaron Patterson
e8edc34f0a Remove unused struct member
I accidentally added this in 35ba2783fe6b3316a6bbc6f00bf975ad7185d6e0,
and it's making the size of RVALUE be too big. I'm sorry! orz
2020-08-03 17:01:13 -07:00
git
d8e7885012 * 2020-08-04 [ci skip] 2020-08-04 04:28:22 +09:00
Aaron Patterson
3dc313a239 Don't pin objects if we're just walking the heap
Walking the heap can inadvertently pin objects.  Only mark the object's
pin bit if the mark_func_data pointer is NULL (similar to the mark bits)
2020-08-03 12:28:00 -07:00
Hiroshi SHIBATA
1d637b1f5e [ruby/weakref] Use Gemfile instead of Gem::Specification#add_development_dependency.
https://github.com/ruby/weakref/commit/10d547ba12
2020-08-03 19:46:39 +09:00
Hiroshi SHIBATA
9e93596d7b [ruby/ostruct] Drop to Ruby 2.4
https://github.com/ruby/ostruct/commit/00e8fe3df2
2020-08-03 19:42:06 +09:00
Jeremy Evans
85dc570893 [ruby/net-http] Fix SSL session reuse test with LibreSSL 3.2+
https://github.com/ruby/net-http/commit/5ae9620fbc
2020-08-03 18:56:14 +09:00
Jeremy Evans
20eb9e98b6 [ruby/net-http] Switch invalid server name format
invalid_servername is not a valid name in an SSL request due to
the use of the underscore, and LibreSSL 3.2.0 will raise an
exception for this.  These tests are not testing the allowed
characters in the server name, but how net/http handles cases where
the server name provided does not match the IP address you are
trying to connect to, so I think it's better to just modify the
tests to use a correct format.

While here, fix a typo in a test name, and use better code in the
ensure block so the same test doesn't issue both a failure and an
error.

https://github.com/ruby/net-http/commit/0e8dc91120
2020-08-03 18:55:44 +09:00
Hiroshi SHIBATA
e732d376af [ruby/cgi] Drop to Ruby 2.4
https://github.com/ruby/cgi/commit/8a86536e94
2020-08-03 18:30:19 +09:00