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

58230 Коммитов

Автор SHA1 Сообщение Дата
Romain Tartière 1c999952e7 Resolve unused local variable reported by LGTM
LGTM reports that the value assigned to local variable 'shared' is never
used:
f319a5d064/files/misc/lldb_cruby.py (x6512c0281581a470):1

This problem was introduced in by the refactoring that took place in
7c496b6624.
2019-10-03 13:44:52 +09:00
git a515e3f99e * 2019-10-03 [ci skip] 2019-10-03 12:48:30 +09:00
git 7e060d5018 * expand tabs. [ci skip]
Tabs were expanded because previously the file did not have any tab indentation.
Please update your editor config, and use misc/expand_tabs.rb in the pre-commit hook.
2019-10-03 12:48:20 +09:00
卜部昌平 eb92159d72 Revert https://github.com/ruby/ruby/pull/2486
This reverts commits: 10d6a3aca7 8ba48c1b85 fba8627dc1 dd883de5ba
6c6a25feca 167e6b48f1 7cb96d41a5 3207979278 595b3c4fdd 1521f7cf89
c11c5e69ac cf33608203 3632a812c0 f56506be0d 86427a3219 .

The reason for the revert is that we observe ABA problem around
inline method cache.  When a cache misshits, we search for a
method entry.  And if the entry is identical to what was cached
before, we reuse the cache.  But the commits we are reverting here
introduced situations where a method entry is freed, then the
identical memory region is used for another method entry.  An
inline method cache cannot detect that ABA.

Here is a code that reproduce such situation:

```ruby
require 'prime'

class << Integer
  alias org_sqrt sqrt
  def sqrt(n)
    raise
  end

  GC.stress = true
  Prime.each(7*37){} rescue nil # <- Here we populate CC
  class << Object.new; end

  # These adjacent remove-then-alias maneuver
  # frees a method entry, then immediately
  # reuses it for another.
  remove_method :sqrt
  alias sqrt org_sqrt
end

Prime.each(7*37).to_a # <- SEGV
```
2019-10-03 12:45:24 +09:00
Jeremy Evans ef697388be
Treat return in block in class/module as LocalJumpError (#2511)
return directly in class/module is an error, so return in
proc in class/module should also be an error.  I believe the
previous behavior was an unintentional oversight during the
addition of top-level return in 2.4.
2019-10-02 07:56:28 -07:00
Koichi Sasada 9759e3c9f0 fix assertion number.
On parallel test, there are additional tests because of implicit
checkers which are enabled on 84cbce3d88.
2019-10-02 17:19:14 +09:00
Nobuyoshi Nakada 4ed51b3956
Fixed failure message for `clean-cache` 2019-10-02 17:03:55 +09:00
Koichi Sasada 84cbce3d88 Enable checkers on parallel test.
parallel test (`make test-all TESTS=-j8`) runs tests on specified
number of processes. However, some test checkers written in
`runner.rb` are not loaded. This fix enable these checkers on
parallel tests.

See also: https://github.com/ruby/ruby/pull/2508
2019-10-02 16:23:00 +09:00
Alan Wu 99d3043bd8 Iseq#to_binary: dump flag for **nil (#2508)
RUBY_ISEQ_DUMP_DEBUG=to_binary and the attached test case was failing.
Dump the flag to make sure `**nil` can round-trip properly.
2019-10-02 16:05:40 +09:00
git 4946d83a1c * 2019-10-02 [ci skip] 2019-10-02 13:00:56 +09:00
NAKAMURA Usaku a61ae414b6 Fix the order of executing `after-update` task 2019-10-02 13:00:17 +09:00
NAKAMURA Usaku 5af2c8735a Should fail if `system` failed 2019-10-02 12:59:59 +09:00
Hiroshi SHIBATA 15606963de expose assert_raise and assert_join_threads 2019-10-01 22:19:18 +09:00
Kazuhiro NISHIYAMA 55de0282da
Remove draft-release.yml [ci skip]
I thought default branch's workflow runs on any tags,
but it does not run for stable branches without draft-release.yml.
So I abandoned, and use workflow in ruby/actions instead.
2019-10-01 21:26:54 +09:00
Yusuke Endoh 3ce238b5f9 WEBrick: prevent response splitting and header injection
This is a follow up to d9d4a28f1c.
The commit prevented CRLR, but did not address an isolated CR or an
isolated LF.

Co-Authored-By: NARUSE, Yui <naruse@airemix.jp>
2019-10-01 19:19:56 +09:00
Nobuyoshi Nakada 36e057e26e Loop with String#scan without creating substrings
Create the substrings necessary parts only, instead of cutting the
rest of the buffer.  Also removed a useless, probable typo, regexp.
2019-10-01 19:19:56 +09:00
Nobuyoshi Nakada a0a2640b39 Fix for wrong fnmatch patttern
* dir.c (file_s_fnmatch): ensure that pattern does not contain a
  NUL character.  https://hackerone.com/reports/449617
2019-10-01 19:19:56 +09:00
Yusuke Endoh a38fe1fbf0 ext/-test-/enumerator_kw/enumerator_kw.c: remove unused variable 2019-10-01 08:57:50 +09:00
git 01e75b6be9 * 2019-10-01 [ci skip] 2019-10-01 01:14:45 +09:00
Koichi Sasada 671ca21254 remove `unused var` warning 2019-10-01 01:14:19 +09:00
Jeremy Evans a8c436d9a1 Issue keyword flag warning even with no arguments
If the keyword flag is set, there should be at least one argument,
if there isn't, that is a sign the keyword flag was passed when it
should not have been.
2019-09-30 07:06:42 -07:00
Jeremy Evans 3073404e74 Add rb_enumeratorize_with_size_kw and related macros
Currently, there is not a way to create a sized enumerator in C
with a different set of arguments than provided by Ruby, and
correctly handle keyword arguments.  This function allows that.

The need for this is fairly uncommon, but it occurs at least in
Enumerator.produce, which takes arugments from Ruby but calls
rb_enumeratorize_with_size with a different set of arguments.
2019-09-30 07:06:42 -07:00
Yusuke Endoh 5ddc2ba13e test/ruby/test_io.rb: supress a "method redefined" warning
by explicitly removing the old definition.
2019-09-30 20:24:26 +09:00
Yusuke Endoh fc66947c61 test/-ext-/string/test_fstring.rb: suppress "possibly useless use of -@"
"in void context" by assigning the result to a dummy variable.
2019-09-30 20:22:29 +09:00
Koichi Sasada 945560008f Revert "introduce debug check."
This reverts commit c3b84f2de8.
Backtrace shows it is before running tests and debug check was
nonsense.
2019-09-30 17:59:10 +09:00
Nobuyoshi Nakada 10d6a3aca7
Fix assertion
callable_method_entry_p is for rb_callable_method_entry_t.
2019-09-30 17:43:11 +09:00
Nobuyoshi Nakada 771fd915a4
Use assert_operator instead of mere assert 2019-09-30 17:39:38 +09:00
Nobuyoshi Nakada 1722c156dd
Now `use_symbol` is always true 2019-09-30 17:38:54 +09:00
Koichi Sasada c3b84f2de8 introduce debug check.
There are random failures:

> lib/rubygems/core_ext/kernel_require.rb:61:in `require':
> wrong number of arguments (given 1, expected 0) (ArgumentError)
http://ci.rvm.jp/results/trunk-jemalloc@silicon-docker/2275159

To check this failure, I added a small check code.
2019-09-30 17:23:36 +09:00
Koichi Sasada 88f38c187e Emulate method_list (chkbuild) on test-all.
chkbuild (CI process) shows methods list before
running tests and sometimes it can fails. This
commit a code part to emulate this method listing
feature.
2019-09-30 15:36:19 +09:00
Koichi Sasada bf8d7d9c1d show RUBY_ISEQ_DUMP_DEBUG envval if given. 2019-09-30 15:35:22 +09:00
Koichi Sasada 8ba48c1b85 rb_method_attr_t::location should be 0 or others.
method_def_location() expects that rb_method_attr_t::location
is 0 (Qfalse) or not.
2019-09-30 14:27:02 +09:00
Jeremy Evans 649a64ae29 Add three more C-API functions for handling keywords
This adds rb_funcall_passing_block_kw, rb_funcallv_public_kw,
and rb_yield_splat_kw.  This functions are necessary to easily
handle cases where rb_funcall_passing_block, rb_funcallv_public,
and rb_yield_splat are currently used and a keyword argument
separation warning is raised.
2019-09-29 18:31:08 -07:00
卜部昌平 fba8627dc1 delete unnecessary branch
At last, not only myself but also your compiler are fully confident
that the method entries pointed from call caches are immutable.  We
don't have to worry about silent updates.  Just delete the branch
that is now always false.

Calculating -------------------------------------
                           ours       trunk
vm2_poly_same_method     2.142M      2.070M i/s -      6.000M times in 2.801148s 2.898994s

Comparison:
             vm2_poly_same_method
                ours:   2141979.2 i/s
               trunk:   2069683.8 i/s - 1.03x  slower
2019-09-30 10:26:38 +09:00
卜部昌平 dd883de5ba refactor constify most of rb_method_entry_t
Now that we have eliminated most destructive operations over the
rb_method_entry_t / rb_callable_method_entry_t, let's make them
mostly immutabe and mark them const.

One exception is rb_export_method(), which destructively modifies
visibilities of method entries.  I have left that operation as is
because I suspect that destructiveness is the nature of that
function.
2019-09-30 10:26:38 +09:00
卜部昌平 6c6a25feca refactor add rb_method_entry_from_template
Tired of rb_method_entry_create(..., rb_method_definition_create(
..., &(rb_method_foo_t) {...})) maneuver.  Provide a function that
does the thing to reduce copy&paste.
2019-09-30 10:26:38 +09:00
卜部昌平 167e6b48f1 refactor reduce METHOD_ENTRY_FLAGS_COPY
Make things more immutable.
2019-09-30 10:26:38 +09:00
卜部昌平 7cb96d41a5 refactor delete rb_method_entry_copy
The deleted function was to destructively overwrite existing method
entries, which is now considered to be a bad idea.  Delete it, and
assign a newly created method entry instead.
2019-09-30 10:26:38 +09:00
卜部昌平 3207979278 refactor delete rb_method_definition_set
Instead of destructively write fields of method entries, create a
new entry and let it overwrite its owner.
2019-09-30 10:26:38 +09:00
卜部昌平 595b3c4fdd refactor rb_method_definition_create take opts
Before this changeset rb_method_definition_create only allocated a
memory region and we had to destructively initialize it later.
That is not a good design so we change the API to return a complete
struct instead.
2019-09-30 10:26:38 +09:00
卜部昌平 1521f7cf89 refactor delete vm_cref_dump
No longer used.
2019-09-30 10:26:38 +09:00
卜部昌平 c11c5e69ac refactor split rb_method_definition_set
Did you know that C functions can return structs?  That has been
true since the beginning, but not that very useful until C99.  Now
that we can write compound literals, this feature is much easier
to use.  By allowing struct-returning functions, some formerly big
functions can be split into smaller ones, like this changeset.

At least GCC is smart enough to inline the split functions back
into one.  No performance penalty is observed.
2019-09-30 10:26:38 +09:00
卜部昌平 cf33608203 refactor constify most of rb_method_definition_t
Most (if not all) of the fields of rb_method_definition_t are never
meant to be modified once after they are stored.  Marking them const
makes it possible for compilers to warn on unintended modifications.
2019-09-30 10:26:38 +09:00
卜部昌平 3632a812c0 refactor add rb_id_table_foreach_with_replace_with_key
This is a pure refactoring to reduce copy & paste.  Also the new
function is made visible from other parts of the interpreter, to
be used later.
2019-09-30 10:26:38 +09:00
卜部昌平 f56506be0d refactor delete ID_TABLE_ITERATOR_RESULT_END
Not used from anywhere.
2019-09-30 10:26:38 +09:00
卜部昌平 86427a3219 refactor delete METHOD_ENTRY_COMPLEMENTED flag
Because rb_method_definition_t tracks its own complemented_count,
we no longer have to check it in rb_method_entry_t side.
2019-09-30 10:26:38 +09:00
Jeremy Evans 6fdd701472 Remove VM_NO_KEYWORDS, replace with RB_NO_KEYWORDS
VM_NO_KEYWORDS was introduced first in vm_core.h, but it is best
to only use a single definition for this.
2019-09-29 16:41:00 -07:00
Jeremy Evans 58dfea0c8d Make direct calls to rb_{obj_instance,mod_module}_{eval,exec} not pass keywords
In general RB_PASS_CALLED_KEYWORDS should only be set if we are
sure the arguments passed come directly from Ruby.  For direct calls
to these C functions, we should not assume that keywords are passed.
Add static *_internal versions of these functions that
Kernel#instance_{eval,exec} and Module#{class,module}_{eval,exec}
call that set RB_PASS_CALLED_KEYWORDS.

Also, change struct.c back to calling rb_mod_module_eval, now that
the call is safe.
2019-09-29 16:28:52 -07:00
Benoit Daloze 59060aadea Run test-unit tests in CI 2019-09-30 00:16:11 +02:00
Benoit Daloze 2740b86905 Update to latest test-unit
* See https://github.com/test-unit/test-unit/issues/165
2019-09-30 00:16:11 +02:00