Tachino Nobuhiroさんの <g0fdsjyl.wl / frostrubin.open.nm.fujitsu.co.jp>から > メモリリークはなくなったのですが、下の変なスクリプトを実行すると > assign()がrb_bug("bug in variableassignment")を呼んでコアダンプする > ようになってしまいました。 > > def func > t = Thread.start {} > t.join > yield t > end > > loop do > func {|x| x = 3} > ObjectSpace.garbage_collect > end 以下で、とりあえずメモリリークとコアダンプは なくなるように思います。 (これ以降はruby-devが適当?) --- eval.c.orig Tue Apr 10 15:09:00 2001 +++ eval.c Fri Apr 13 12:40:48 2001 @@ -8081,6 +8081,7 @@ volatile VALUE thread = th->thread; enum thread_status status; int state; + struct BLOCK* saved_block = 0; #if defined(HAVE_SETITIMER) if (!thread_init) { @@ -8096,7 +8097,19 @@ #endif if (ruby_block) { /* should nail down higher scopes */ - blk_copy_prev(ruby_block); + struct BLOCK dummy; + struct BLOCK* p; + struct RVarmap* vars; + + dummy.prev = ruby_block; + blk_copy_prev(&dummy); + saved_block = ruby_block = dummy.prev; + for (p = ruby_block; p; p = p->prev) { + for (vars = p->dyna_vars; vars; vars = vars->next) { + if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break; + FL_SET(vars, DVAR_DONT_RECYCLE); + } + } } scope_dup(ruby_scope); FL_SET(ruby_scope, SCOPE_SHARED); @@ -8123,6 +8136,18 @@ } POP_TAG(); status = th->status; + + if (saved_block) { + struct BLOCK *data = saved_block; + while (data) { + struct BLOCK *tmp = data; + if (data->frame.argc > 0) + free(data->frame.argv); + data = data->prev; + free(tmp); + } + } + if (th == main_thread) ruby_stop(state); rb_thread_remove(th); if (state && status != THREAD_TO_KILL && !NIL_P(ruby_errinfo)) { ---- 小迫@ソフネック 渋谷区恵比寿1-15-1