ruby-changes:24110
From: nobu <ko1@a...>
Date: Thu, 21 Jun 2012 17:21:04 +0900 (JST)
Subject: [ruby-changes:24110] nobu:r36161 (trunk): parse.y: fix GC problem of keyword rest argument
nobu 2012-06-21 17:20:51 +0900 (Thu, 21 Jun 2012) New Revision: 36161 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36161 Log: parse.y: fix GC problem of keyword rest argument * parse.y (new_args_tail_gen): fix GC problem of keyword rest argument. the wrapped struct should be bound to the wrapping node before assignment of child nodes, to get rid of the case the children are referred by only the struct pointer which is not a subject of GC. [ruby-core:45744] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_syntax.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 36160) +++ ChangeLog (revision 36161) @@ -1,3 +1,11 @@ +Thu Jun 21 17:20:44 2012 Nobuyoshi Nakada <nobu@r...> + + * parse.y (new_args_tail_gen): fix GC problem of keyword rest + argument. the wrapped struct should be bound to the wrapping node + before assignment of child nodes, to get rid of the case the + children are referred by only the struct pointer which is not a + subject of GC. [ruby-core:45744] + Thu Jun 21 07:06:52 2012 Koichi Sasada <ko1@a...> * error.c (err_append): rename err_append() to compile_err_append() Index: parse.y =================================================================== --- parse.y (revision 36160) +++ parse.y (revision 36161) @@ -9289,8 +9289,11 @@ int saved_line = ruby_sourceline; struct rb_args_info *args; NODE *kw_rest_arg = 0; + NODE *node; args = ALLOC(struct rb_args_info); + MEMZERO(args, struct rb_args_info, 1); + node = NEW_NODE(NODE_ARGS, 0, 0, args); args->block_arg = b; args->kw_args = k; @@ -9302,7 +9305,7 @@ args->kw_rest_arg = kw_rest_arg; ruby_sourceline = saved_line; - return NEW_NODE(NODE_ARGS, 0, 0, args); + return node; } #endif /* !RIPPER */ Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 36160) +++ test/ruby/test_syntax.rb (revision 36161) @@ -88,6 +88,10 @@ assert_equal({}, o.kw, bug5989) assert_equal({foo: 1}, o.kw(foo: 1), bug5989) assert_equal({foo: 1, bar: 2}, o.kw(foo: 1, bar: 2), bug5989) + EnvUtil.under_gc_stress do + eval("def o.m(k: 0) k end") + end + assert_equal(42, o.m(k: 42), '[ruby-core:45744]') end def test_keyword_splat -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/