Skip to content

Commit

Permalink
* env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a
Browse files Browse the repository at this point in the history
  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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@11964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
knu committed Mar 3, 2007
1 parent 457515a commit 36ee4b7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
@@ -1,3 +1,16 @@
Sat Mar 3 16:23:13 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:07:02 2007 Akinori MUSHA <knu@iDaemons.org>

* object.c (rb_obj_ivar_set): RDoc updated according to a
Expand Down
1 change: 1 addition & 0 deletions env.h
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion eval.c
Expand Up @@ -8553,11 +8553,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 */
Expand Down
2 changes: 1 addition & 1 deletion gc.c
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion parse.y
Expand Up @@ -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();
}
Expand Down

0 comments on commit 36ee4b7

Please sign in to comment.