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

340 Коммитов

Автор SHA1 Сообщение Дата
k0kubun e38a0b4606 revisit more MJIT test skips
r65308 passed both trunk-mjit and trunk-mjit-wait CIs. MJIT copy job
looks working fine. Then this commit skips 5 more tests. Some of them
were skipped in a very early stage and may still need to be skipped, but
I want to confirm them since they haven't been changed for a long time.

And this prefers having inline information on `RubyVM::MJIT.enabled?`.
This commit makes it easier to confirm whether there's suspicious test
skip by RubyVM::MJIT.enabled? or not.

After this commit, tentatively we're not skipping tests for MJIT other
than `assert_no_memory_leak` ones.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22 15:49:22 +00:00
k0kubun e91be25644 revert revert of r65285
because CI was actually hitting another one.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 23:20:32 +00:00
k0kubun cfa7e2707e revert r65285
because it didn't work. Partially leaving "sometimes fail" tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 23:07:18 +00:00
k0kubun e6202c41b5 try to remove some test skips for MJIT
Eric Wong made some effort to keep compatibility around fd with MJIT.
Also I'm hoping r65279 (and r65280) eliminates major MJIT bugs, so I
want to start solely testing MJIT. Other test skips branched by MJIT
enablement seemed reasonable to me.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 15:54:50 +00:00
svn 02cb9c932a * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-21 06:41:09 +00:00
ko1 ac4b2d990c escape all env properly.
* vm_backtrace.c (rb_debug_inspector_open): escape all env using
  `rb_vm_stack_to_heap()` before making bindings.
  [Bug #15105]

  There is a complicated story of this issue:
  Without this patch, IFUNC frame does not escaped. A IFUNC frame
  points to CFUNC ep as previous ep. However, CFUNC ep can be escaped
  because of making bindings of Ruby level frames.
  IFUNC's ep can points to invalidated ep and `rb_iter_break()` will
  fail. This is why `any?` fails.

* test/-ext-/debug/test_debug.rb: add a test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-21 06:41:07 +00:00
kazu b8eb530979 Add more assertions for NotImplementedError of instance method
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-21 14:57:56 +00:00
nobu 37279d1546 non-symbol keys in kwargs
* class.c (separate_symbol): [EXPERIMENTAL] non-symbol key in keyword
  arguments hash causes an exception now.
  c.f. https://twitter.com/yukihiro_matz/status/1022287578995646464

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-14 11:58:17 +00:00
usa f0d20684d2 Add some tests for *method_defined?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 14:29:21 +00:00
kazu 0381ec5164 Fix test bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 13:50:48 +00:00
kazu 984ba3da62 Add test for method_defined?(notimplement)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 13:27:49 +00:00
k0kubun 8ef27ac192 test_iseq_load.rb: reduce timeout of test_stressful_roundtrip
We should increase RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE for slow
environments, and we configured some CI machines.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-11 13:31:10 +00:00
k0kubun 886bed6eb8 test_iseq_load.rb: increase timeout
It's timed out on CI like this
https://gist.github.com/ko1/33df53d78fbec9e4156c017eeae023bb.

I'm not sure how long it would take (it finishes immediately on my machine),
so I chose 600s because r64271 says it took 635s on mswinci. (probably
it's improved by the commit, though.)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10 23:32:32 +00:00
naruse d561eb665d Use assert_separately in TestIseqLoad#test_stressful_roundtrip
It takes 635 seconds on mswinci
http://mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20180810T061315Z.log.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10 09:22:13 +00:00
normal 8f78430da6 test/-ext-/gvl/test_last_thread.rb: skip under MJIT
Spurious wakeup is unavoidable with MJIT; and any real
code must be able to deal with spurious wakeup anyways.

[ruby-core:87882] https://bugs.ruby-lang.org/issues/14901

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-20 22:30:39 +00:00
tenderlove 7aab72f736 Fix crash when loading iseq from an array
Objects loaded during iseq deserialization using arrays need to be added
to the compile time mark array so that they stay alive until iseqs
finish loading.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-09 17:47:37 +00:00
yui-knk 9e1bb6ed5a Move a test file
* test/-ext-/ast/test_ast.rb: This test file
  has not depended C extension since r63534,
  so move to 'test/ruby/'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-05 00:18:29 +00:00
yui-knk 46463af983 Define AST module under RubyVM [experimental]
* ext/-test-/ast/ast.c: Rename to ast.c
  and define AST module under RubyVM.
* common.mk: compile ast.c.
* ext/-test-/ast/extconf.rb: Don't need this file anymore.
* inits.c (rb_call_inits): Call Init_ast to setup AST module.
* test/-ext-/ast/test_ast.rb: Follow up the namespace change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-31 06:13:06 +00:00
normal b6f9a60586 test_wait_for_single_fd.rb: remove with_pipe helper
IO.pipe natively accepts a block, nowadays.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-14 23:51:39 +00:00
normal 863e24b2b1 test_wait_for_single_fd: ensure this works with kqueue
Regardless of future features, this needs to work with
kqueue descriptors across platforms.

Today this will be useful for 3rd-party libraries using
kqueue.  In the future, Ruby may use kqueue natively
and we shall ensure we can wait on it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-14 23:51:35 +00:00
normal baaf3ba189 test_wait_for_single_fd.rb: relax test for newer FreeBSD
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-14 23:42:10 +00:00
k0kubun acacd7a1d3 test_bug_reporter.rb: make it work with --jit
test_rubyoptions.rb: replace gsub with sub because it's suboptimal for
this

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-28 09:02:56 +00:00
tenderlove c03f86b389 Revert "Fix use of `rb_profile_frames` start parameter"
This reverts commit r63265.

ko1 said I should not have committed this! I'm sorry!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-27 00:13:51 +00:00
tenderlove d676ad1050 Fix use of `rb_profile_frames` start parameter
rb_profile_frames was always behaving as if the value given for the
start parameter was 0.

The reason for this was that it would check if (start > 0) { then
continue without updating the control frame pointer or anything other
than decrementing start.

[ruby-core:86147] [Bug #14607]

Co-authored-by: Dylan Thacker-Smith <Dylan.Smith@shopify.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-26 22:49:00 +00:00
nobu c05fa459bb quote symbols
* sprintf.c (ruby__sfvextra): quote symbols as identifiers.

* string.c (rb_id_quote_unprintable): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-14 02:35:51 +00:00
nobu dd3851d278 Rename test classes to allow stable test count when running test-all -j
[Fix GH-1763]

From: MSP-Greg <MSP-Greg@users.noreply.github.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 06:29:02 +00:00
k0kubun ed935aa5be mjit_compile.c: merge initial JIT compiler
which has been developed by Takashi Kokubun <takashikkbn@gmail> as
YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>.

This JIT compiler is designed to be a safe migration path to introduce
JIT compiler to MRI. So this commit does not include any bytecode
changes or dynamic instruction modifications, which are done in original
MJIT.

This commit even strips off some aggressive optimizations from
YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still
fairly faster than Ruby 2.5 in some benchmarks (attached below).

Note that this JIT compiler passes `make test`, `make test-all`, `make
test-spec` without JIT, and even with JIT. Not only it's perfectly safe
with JIT disabled because it does not replace VM instructions unlike
MJIT, but also with JIT enabled it stably runs Ruby applications
including Rails applications.

I'm expecting this version as just "initial" JIT compiler. I have many
optimization ideas which are skipped for initial merging, and you may
easily replace this JIT compiler with a faster one by just replacing
mjit_compile.c. `mjit_compile` interface is designed for the purpose.

common.mk: update dependencies for mjit_compile.c.

internal.h: declare `rb_vm_insn_addr2insn` for MJIT.

vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to
compiler. This avoids to include some functions which take a long time
to compile, e.g. vm_exec_core. Some of the purpose is achieved in
transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are
manually resolved for now. Load mjit_helper.h for MJIT header.
mjit_helper.h: New. This is a file used only by JIT-ed code. I'll
refactor `mjit_call_cfunc` later.
vm_eval.c: add some #ifdef switches to skip compiling some functions
like Init_vm_eval.

win32/mkexports.rb: export thread/ec functions, which are used by MJIT.

include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify
that a function is exported only for MJIT.

array.c: export a function used by MJIT.
bignum.c: ditto.
class.c: ditto.
compile.c: ditto.
error.c: ditto.
gc.c: ditto.
hash.c: ditto.
iseq.c: ditto.
numeric.c: ditto.
object.c: ditto.
proc.c: ditto.
re.c: ditto.
st.c: ditto.
string.c: ditto.
thread.c: ditto.
variable.c: ditto.
vm_backtrace.c: ditto.
vm_insnhelper.c: ditto.
vm_method.c: ditto.

I would like to improve maintainability of function exports, but I
believe this way is acceptable as initial merging if we clarify the
new exports are for MJIT (so that we can use them as TODO list to fix)
and add unit tests to detect unresolved symbols.
I'll add unit tests of JIT compilations in succeeding commits.

Author: Takashi Kokubun <takashikkbn@gmail.com>
Contributor: wanabe <s.wanabe@gmail.com>

Part of [Feature #14235]

---

* Known issues
  * Code generated by gcc is faster than clang. The benchmark may be worse
    in macOS. Following benchmark result is provided by gcc w/ Linux.
  * Performance is decreased when Google Chrome is running
  * JIT can work on MinGW, but it doesn't improve performance at least
    in short running benchmark.
  * Currently it doesn't perform well with Rails. We'll try to fix this
    before release.

---

* Benchmark reslts

Benchmarked with:
Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores

- 2.0.0-p0: Ruby 2.0.0-p0
- r62186: Ruby trunk (early 2.6.0), before MJIT changes
- JIT off: On this commit, but without `--jit` option
- JIT on: On this commit, and with `--jit` option

** Optcarrot fps

Benchmark: https://github.com/mame/optcarrot

|         |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:--------|:--------|:--------|:--------|:--------|
|fps      |37.32    |51.46    |51.31    |58.88    |
|vs 2.0.0 |1.00x    |1.38x    |1.37x    |1.58x    |

** MJIT benchmarks

Benchmark: https://github.com/benchmark-driver/mjit-benchmarks
(Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks)

|           |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:----------|:--------|:--------|:--------|:--------|
|aread      |1.00     |1.09     |1.07     |2.19     |
|aref       |1.00     |1.13     |1.11     |2.22     |
|aset       |1.00     |1.50     |1.45     |2.64     |
|awrite     |1.00     |1.17     |1.13     |2.20     |
|call       |1.00     |1.29     |1.26     |2.02     |
|const2     |1.00     |1.10     |1.10     |2.19     |
|const      |1.00     |1.11     |1.10     |2.19     |
|fannk      |1.00     |1.04     |1.02     |1.00     |
|fib        |1.00     |1.32     |1.31     |1.84     |
|ivread     |1.00     |1.13     |1.12     |2.43     |
|ivwrite    |1.00     |1.23     |1.21     |2.40     |
|mandelbrot |1.00     |1.13     |1.16     |1.28     |
|meteor     |1.00     |2.97     |2.92     |3.17     |
|nbody      |1.00     |1.17     |1.15     |1.49     |
|nest-ntimes|1.00     |1.22     |1.20     |1.39     |
|nest-while |1.00     |1.10     |1.10     |1.37     |
|norm       |1.00     |1.18     |1.16     |1.24     |
|nsvb       |1.00     |1.16     |1.16     |1.17     |
|red-black  |1.00     |1.02     |0.99     |1.12     |
|sieve      |1.00     |1.30     |1.28     |1.62     |
|trees      |1.00     |1.14     |1.13     |1.19     |
|while      |1.00     |1.12     |1.11     |2.41     |

** Discourse's script/bench.rb

Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb

NOTE: Rails performance was somehow a little degraded with JIT for now.
We should fix this.
(At least I know opt_aref is performing badly in JIT and I have an idea
 to fix it. Please wait for the fix.)

*** JIT off
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 17
  75: 18
  90: 22
  99: 29
home_admin:
  50: 21
  75: 21
  90: 27
  99: 40
topic_admin:
  50: 17
  75: 18
  90: 22
  99: 32
categories:
  50: 35
  75: 41
  90: 43
  99: 77
home:
  50: 39
  75: 46
  90: 49
  99: 95
topic:
  50: 46
  75: 52
  90: 56
  99: 101

*** JIT on
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 19
  75: 21
  90: 25
  99: 33
home_admin:
  50: 24
  75: 26
  90: 30
  99: 35
topic_admin:
  50: 19
  75: 20
  90: 25
  99: 30
categories:
  50: 40
  75: 44
  90: 48
  99: 76
home:
  50: 42
  75: 48
  90: 51
  99: 89
topic:
  50: 49
  75: 55
  90: 58
  99: 99

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 11:22:28 +00:00
normal 3ce9a14040 ruby.h: relax rb_funcall check on extra args for clang
clang 5.+ (tested clang 7.0.0) seems to be attempting division-by-zero
and giving a very large number for static args to rb_funcall.

* include/ruby/ruby.h (rb_varargs_bad_length): relax check for clang
* ext/-test-/funcall/funcall.c: renamed from passing_block.c
  define extra_args_name function
* test/-ext-/funcall/test_funcall.rb: new test
  [ruby-core:85266] [Bug #14425]

From: Eric Wong <e@80x24.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-30 23:55:49 +00:00
nobu e6883ef688 parse.y: fix overflow
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 03:29:12 +00:00
nobu 2f5a20ce0d test_ast.rb: no base directory name
* test/-ext-/ast/test_ast.rb: exclude base directory name from
  test method names.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-17 06:38:08 +00:00
yui-knk 0f3dcbdf38 Add tests for Node code locations
* test/-ext-/ast/test_ast.rb: Add tests for Node
  code locations. This file tests

  1. There are no Node whose code location is default
     value (#test_not_cared)

  2. There are no Node whose children's code locations
     exceed parent's code location (#test_ranges)

* ext/-test-/ast/ast.c, ext/-test-/ast/extconf.rb:
  Define AST module to help tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 23:43:17 +00:00
nobu 79a2517026 test_console_attr.rb: fix test
* test/-ext-/win32/test_console_attr.rb (reverse_video): fix test
  when reverse video is set.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 12:25:24 +00:00
nobu aee02268bd test_iseq_load.rb: set location
* test/-ext-/iseq_load/test_iseq_load.rb (assert_iseq_roundtrip):
  set path and line number from callers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04 00:26:50 +00:00
eregon 15689ed778 Fix test-all tests to avoid creating report_on_exception warnings
* The warnings are shown by Thread.report_on_exception defaulting to
  true. [Feature #14143] [ruby-core:83979]
* Improves tests by narrowing down the scope where an exception
  is expected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 18:44:49 +00:00
shyouhei b57915eddc Add FrozenError as a subclass of RuntimeError
FrozenError will be used instead of RuntimeError for exceptions
raised when there is an attempt to modify a frozen object. The
reason for this change is to differentiate exceptions related
to frozen objects from generic exceptions such as those generated
by Kernel#raise without an exception class.

From: Jeremy Evans <code@jeremyevans.net>
Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org>


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 00:46:34 +00:00
naruse 7a96d788dc Add test for Bug::String.buf_new
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03 12:06:16 +00:00
nobu a1692f7fdf string.c: fix rb_external_str_new_with_enc
* string.c (rb_external_str_new_with_enc): do not search non-ascii
  by NULL pointer.  [ruby-core:84055] [Bug #14150]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-02 07:09:16 +00:00
hsbt 6693e3e723 Fixed misspelling words.
These are detected by https://github.com/client9/misspell

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 11:27:06 +00:00
kazu 6064132c42 Remove unnecessary `require 'thread'`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-08 07:00:01 +00:00
shirosaki ff6573b696 test_dln.rb: fix path separator on MinGW
* test/-ext-/win32/test_dln.rb (TestDln#test_check_imported):
  RbConfig::CONFIG["PATH_SEPARATOR"] is : which is a separator on
  msys2 shell building ruby. Use File::PATH_SEPARATOR ; on test.
  [Bug #13642] [ruby-core:81623]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-28 13:55:48 +00:00
nobu 6f968cab15 load.c: fix rb_load_protect condition
* load.c (rb_load_protect): fix the condition to load the found
  file.  fixup of r59155.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-24 05:22:23 +00:00
nobu 067d9e9ce9 sprintf.c: NULL as str
* sprintf.c (ruby_vsnprintf, ruby_snprintf): allow NULL as str,
  just count the expected buffer size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-09 09:16:59 +00:00
nobu 9f1994ed5c io.c: shrink read buffer
* io.c (io_setstrbuf): return true if the buffer is newly created.

* io.c (io_set_read_length): shrink the read buffer if it is a new
  object and is too large.  [ruby-core:81370] [Bug #13597]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-31 08:21:46 +00:00
nobu 17b3441ac4 non-keywords hash
* class.c (rb_scan_args), include/ruby/ruby.h (rb_scan_args_set):
  return non-keywords elements only in the last hash when keyword
  arguments are extracted from it, as well as methods defined in
  ruby level.  [ruby-core:82427] [Bug #13830]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-20 06:08:25 +00:00
nobu 3632bd45f5 ruby.h: fix rb_scan_args_trail_idx
* include/ruby/ruby.h (rb_scan_args_trail_idx): fix the case both
  of optional and rest arguments are defined.
  [ruby-core:82427] [Bug #13830]

* include/ruby/ruby.h (rb_scan_args_n_trail): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-19 23:39:03 +00:00
nobu 7a1c10ba08 gc.c: expand sorted pages
* gc.c (heap_page_allocate): expand sorted pages before inserting
  allocated new page.  [Bug #12670]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22 00:59:54 +00:00
ko1 4d932a68ff skip unresolved issue.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-20 05:34:33 +00:00
nobu 263a0f7f16 test for [Bug #12670]
heap corruption by deferred free.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-19 14:36:17 +00:00
normal 27b8ef7ff7 thread.c: avoid busy looping on rb_thread_fd_close
We no longer use it this function, but extensions do, and
we need to ensure it continues to work for them.

* thread.c (rb_thread_fd_close): schedule other threads in loop
* ext/-test-/thread_fd_close/thread_fd_close.c: new file
* ext/-test-/thread_fd_close/depend: ditto
* ext/-test-/thread_fd_close/extconf.rb: ditto
* test/-ext-/thread_fd_close/test_thread_fd_close.rb: new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-07 00:32:02 +00:00
normal b3d126d5de rb_wait_for_single_fd: do not OOM or segfault with invalid FD on select()
Instead, match the poll() implementation used on Linux for now;
as the Linux poll(2) manpage describes using negative FD to
easily ignore an FD in a larger FD set while (sleeping the given
timeout).  I'm not entirely sure if matching poll() behavior
is a good idea for a single FD, but it's better than segfaulting
or NoMemoryError.

* thread.c (init_set_fd): ignore negative FD
* test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb
  (test_wait_for_invalid_fd): check values which may trigger
  segfaults or OOM

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-27 08:26:47 +00:00