Permalink
Browse files

* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@11964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 457515a commit 36ee4b72ac1734ffffa4da61b7d56e72e6ea9eb1 @knu knu committed Mar 3, 2007
Showing with 19 additions and 3 deletions.
  1. +13 −0 ChangeLog
  2. +1 −0 env.h
  3. +2 −1 eval.c
  4. +1 −1 gc.c
  5. +2 −1 parse.y
View
13 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
View
1 env.h
@@ -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;
View
3 eval.c
@@ -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 */
View
2 gc.c
@@ -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
3 parse.y
@@ -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();
}

0 comments on commit 36ee4b7

Please sign in to comment.