* env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a

local_tbl region from getting freed many times; submitted by
  Chikanaga Tomoyuki <chikanag AT nippon-control-system.co.jp> in
  [ruby-dev:30460].

* eval.c (proc_invoke): Ditto.

* gc.c (obj_free): Ditto.

* parse.y (top_local_setup_gen): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@11965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2007-03-03 07:30:46 +00:00
parent ff18a5d9ed
commit da9117c9de
5 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,16 @@
Sat Mar 3 16:30:39 2007 Akinori MUSHA <knu@iDaemons.org>
* env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a
local_tbl region from getting freed many times; submitted by
Chikanaga Tomoyuki <chikanag AT nippon-control-system.co.jp> in
[ruby-dev:30460].
* eval.c (proc_invoke): Ditto.
* gc.c (obj_free): Ditto.
* parse.y (top_local_setup_gen): Ditto.
Sat Mar 3 16:09:27 2007 Akinori MUSHA <knu@iDaemons.org>
* object.c (rb_obj_ivar_set): RDoc updated according to a

1
env.h
View File

@ -43,6 +43,7 @@ extern struct SCOPE {
#define SCOPE_MALLOC 1
#define SCOPE_NOSTACK 2
#define SCOPE_DONT_RECYCLE 4
#define SCOPE_CLONE 8
extern int ruby_in_eval;

3
eval.c
View File

@ -8547,11 +8547,12 @@ proc_invoke(proc, args, self, klass)
if (klass) _block.frame.last_class = klass;
_block.frame.argc = RARRAY(tmp)->len;
_block.frame.flags = ruby_frame->flags;
if (_block.frame.argc && (ruby_frame->flags & FRAME_DMETH)) {
if (_block.frame.argc && DMETHOD_P()) {
NEWOBJ(scope, struct SCOPE);
OBJSETUP(scope, tmp, T_SCOPE);
scope->local_tbl = _block.scope->local_tbl;
scope->local_vars = _block.scope->local_vars;
scope->flags |= SCOPE_CLONE;
_block.scope = scope;
}
/* modify current frame */

2
gc.c
View File

@ -1253,7 +1253,7 @@ obj_free(obj)
if (RANY(obj)->as.scope.local_vars &&
RANY(obj)->as.scope.flags != SCOPE_ALLOCA) {
VALUE *vars = RANY(obj)->as.scope.local_vars-1;
if (vars[0] == 0)
if (!(RANY(obj)->as.scope.flags & SCOPE_CLONE) && vars[0] == 0)
RUBY_CRITICAL(free(RANY(obj)->as.scope.local_tbl));
if (RANY(obj)->as.scope.flags & SCOPE_MALLOC)
RUBY_CRITICAL(free(vars));

View File

@ -5727,7 +5727,8 @@ top_local_setup()
rb_mem_clear(ruby_scope->local_vars+i, len-i);
}
if (ruby_scope->local_tbl && ruby_scope->local_vars[-1] == 0) {
xfree(ruby_scope->local_tbl);
if (!(ruby_scope->flags & SCOPE_CLONE))
xfree(ruby_scope->local_tbl);
}
ruby_scope->local_tbl = local_tbl();
}