1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_insnhelper.c (vm_callee_setup_arg_complex, vm_yield_setup_block_args):

clear keyword arguments to prevent GC bug which occurs
  while marking VM stack.
  [ruby-dev:47729] [Bug #8964]

* test/ruby/test_keyword.rb: tests for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ktsj 2013-09-29 09:50:24 +00:00
parent 202cc8e615
commit 94f5787130
3 changed files with 37 additions and 0 deletions

View file

@ -1,3 +1,12 @@
Sun Sep 29 18:45:05 2013 Kazuki Tsujimoto <kazuki@callcc.net>
* vm_insnhelper.c (vm_callee_setup_arg_complex, vm_yield_setup_block_args):
clear keyword arguments to prevent GC bug which occurs
while marking VM stack.
[ruby-dev:47729] [Bug #8964]
* test/ruby/test_keyword.rb: tests for the above.
Sat Sep 28 23:25:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* math.c (math_log, math_log2, math_log10): fix for Bignum argument.

View file

@ -396,4 +396,23 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal([{}, {}], a.new.foo({}))
assert_equal([{}, {:bar=>"x"}], a.new.foo({}, bar: "x"))
end
def test_gced_object_in_stack
bug8964 = '[ruby-dev:47729] [Bug #8964]'
assert_normal_exit %q{
def m(a: [])
end
GC.stress = true
tap { m }
GC.start
tap { m }
}, bug8964
assert_normal_exit %q{
prc = Proc.new {|a: []|}
GC.stress = true
tap { prc.call }
GC.start
tap { prc.call }
}, bug8964
end
end

View file

@ -1226,6 +1226,11 @@ vm_callee_setup_arg_complex(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t
/* keyword argument */
if (iseq->arg_keyword != -1) {
int i;
int arg_keywords_end = iseq->arg_keyword - (iseq->arg_block != -1);
for (i = iseq->arg_keywords; 0 < i; i--) {
orig_argv[arg_keywords_end - i] = Qnil;
}
orig_argv[iseq->arg_keyword] = keyword_hash;
}
@ -2302,6 +2307,10 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq,
/* keyword argument */
if (iseq->arg_keyword != -1) {
int arg_keywords_end = iseq->arg_keyword - (iseq->arg_block != -1);
for (i = iseq->arg_keywords; 0 < i; i--) {
argv[arg_keywords_end - i] = Qnil;
}
argv[iseq->arg_keyword] = keyword_hash;
}