From: nobu.nokada@... Date: 2002-05-27T23:52:18+09:00 Subject: Re: possible bug: stack dump with <<-String, #{...} and large loops Hi, At Mon, 27 May 2002 21:00:57 +0900, ts wrote: > "#{a = 12}" > eval "x = 12" > > after NODE_DSTR, ruby_dyna_vars != NULL ==> `x' is a dynamic variable Another approach. Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.295 diff -u -2 -p -r1.295 eval.c --- eval.c 2002/05/21 05:39:18 1.295 +++ eval.c 2002/05/27 14:34:52 @@ -841,4 +841,5 @@ static NODE *top_cref; #define POP_CREF() ruby_cref = ruby_cref->nd_next +#define scope_node super.klass #define PUSH_SCOPE() do { \ volatile int _vmode = scope_vmode; \ @@ -2784,4 +2785,5 @@ rb_eval(self, n) ruby_frame->cbase = node->nd_rval; } + ruby_scope->scope_node = (VALUE)node; if (node->nd_tbl) { VALUE *vars = ALLOCA_N(VALUE, node->nd_tbl[0]+1); @@ -3077,4 +3079,14 @@ rb_eval(self, n) ruby_sourcefile, ruby_sourceline); + if (ruby_scope->local_tbl) { + NODE *body = (NODE *)ruby_scope->scope_node; + if (body && + (!body->nd_tbl || + body->nd_tbl != ruby_scope->local_tbl && + (free(body->nd_tbl), 1))) { + ruby_scope->local_vars[-1] = + (VALUE)(body->nd_tbl = ruby_scope->local_tbl); + } + } ruby_eval_tree = 0; ruby_in_eval--; @@ -3414,4 +3426,5 @@ module_setup(module, n) PUSH_VARS(); + ruby_scope->scope_node = (VALUE)node; if (node->nd_tbl) { VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1); @@ -4553,4 +4566,5 @@ rb_call0(klass, recv, id, argc, argv, bo ruby_frame->cbase = body->nd_rval; } + ruby_scope->scope_node = (VALUE)body; if (body->nd_tbl) { local_vars = TMP_ALLOC(body->nd_tbl[0]+1); -- Nobu Nakada