ruby-changes:39411
From: nobu <ko1@a...>
Date: Thu, 6 Aug 2015 02:25:55 +0900 (JST)
Subject: [ruby-changes:39411] nobu:r51492 (trunk): node.c: NODE_ALLOCA for ALLOCV
nobu 2015-08-06 02:25:35 +0900 (Thu, 06 Aug 2015) New Revision: 51492 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51492 Log: node.c: NODE_ALLOCA for ALLOCV * node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations like as builtin alloca. [ruby-core:70251] [Bug #11418] Modified files: trunk/ChangeLog trunk/node.c trunk/string.c trunk/test/ruby/test_process.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 51491) +++ ChangeLog (revision 51492) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Aug 6 02:25:31 2015 Nobuyoshi Nakada <nobu@r...> + + * node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations + like as builtin alloca. [ruby-core:70251] [Bug #11418] + Wed Aug 5 14:37:55 2015 Nobuyoshi Nakada <nobu@r...> * transcode.c (rb_econv_open0): rb_econv_t::source_encoding_name Index: string.c =================================================================== --- string.c (revision 51491) +++ string.c (revision 51492) @@ -1116,22 +1116,6 @@ rb_str_tmp_new(long len) https://github.com/ruby/ruby/blob/trunk/string.c#L1116 return str_new(0, 0, len); } -void * -rb_alloc_tmp_buffer(volatile VALUE *store, long len) -{ - VALUE s = rb_str_tmp_new(len); - *store = s; - return RSTRING_PTR(s); -} - -void -rb_free_tmp_buffer(volatile VALUE *store) -{ - VALUE s = *store; - *store = 0; - if (s) rb_str_clear(s); -} - void rb_str_free(VALUE str) { Index: test/ruby/test_process.rb =================================================================== --- test/ruby/test_process.rb (revision 51491) +++ test/ruby/test_process.rb (revision 51492) @@ -2172,4 +2172,14 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L2172 w.close if w r.close if r end if defined?(fork) + + def test_many_args + bug11418 = '[ruby-core:70251] [Bug #11418]' + assert_in_out_err([], <<-"end;", ["x"]*256, [], bug11418) + bin = "#{EnvUtil.rubybin}" + args = Array.new(256) {"x"} + GC.stress = true + system(bin, "--disable=gems", "-w", "-e", "puts ARGV", *args) + end; + end end Index: node.c =================================================================== --- node.c (revision 51491) +++ node.c (revision 51492) @@ -1075,3 +1075,27 @@ rb_gc_mark_node(NODE *obj) https://github.com/ruby/ruby/blob/trunk/node.c#L1075 } return 0; } + +void * +rb_alloc_tmp_buffer(volatile VALUE *store, long len) +{ + NODE *s = rb_node_newnode(NODE_ALLOCA, 0, 0, 0); + void *ptr = xmalloc(len); + s->u1.node = ptr; + s->u3.cnt = len / sizeof(VALUE); + *store = (VALUE)s; + return ptr; +} + +void +rb_free_tmp_buffer(volatile VALUE *store) +{ + VALUE s = *store; + *store = 0; + if (s) { + void *ptr = RNODE(s)->u1.node; + RNODE(s)->u1.node = 0; + RNODE(s)->u3.cnt = 0; + xfree(ptr); + } +} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/