From 9001cbdfadbc8d797dbca764211775e098bb9068 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 22 Feb 2005 14:57:43 +0000 Subject: [PATCH] * eval.c (rb_thread_start_0): update curr_thread before raising TAG_THREAD. [ruby-dev:25712] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0e776544a..a719c81ece 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,11 @@ Tue Feb 22 23:50:26 2005 Nobuyoshi Nakada * signal.c (ruby_signal, ruby_nativethread_signal): must be valid as expressions, not only statements. +Tue Feb 22 12:54:13 2005 Yukihiro Matsumoto + + * eval.c (rb_thread_start_0): update curr_thread before raising + TAG_THREAD. [ruby-dev:25712] + Tue Feb 22 07:24:57 2005 Nobuyoshi Nakada * parse.y (parser_yylex): identifier after dot must not be a variable. diff --git a/eval.c b/eval.c index 911a10a2f6..860ec0ab12 100644 --- a/eval.c +++ b/eval.c @@ -9941,6 +9941,11 @@ thread_mark(th) } } +static struct { + rb_thread_t thread; + VALUE proc, arg; +} new_thread; + void rb_gc_mark_threads() { @@ -9953,6 +9958,11 @@ rb_gc_mark_threads() FOREACH_THREAD(th) { rb_gc_mark(th->thread); } END_FOREACH(th); + if (new_thread.thread) { + rb_gc_mark(new_thread.thread->thread); + rb_gc_mark(new_thread.proc); + rb_gc_mark(new_thread.arg); + } } static void @@ -11603,11 +11613,6 @@ thread_insert(th) } } -static struct { - rb_thread_t thread; - VALUE proc, arg; -} new_thread; - static VALUE rb_thread_start_0(fn, arg, th) VALUE (*fn)(); @@ -11652,6 +11657,8 @@ rb_thread_start_0(fn, arg, th) new_thread.proc = rb_block_proc(); new_thread.arg = (VALUE)arg; th->anchor = ip; + thread_insert(th); + curr_thread = th; longjmp((prot_tag = ip->tag)->buf, TAG_THREAD); } @@ -11747,8 +11754,6 @@ rb_thread_start_1() enum thread_status status; int state; - thread_insert(th); - ruby_frame = ip->frame; ruby_block = ip->block; ruby_scope = ip->scope; @@ -11762,6 +11767,7 @@ rb_thread_start_1() PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { if (THREAD_SAVE_CONTEXT(th) == 0) { + new_thread.thread = 0; curr_thread = th; th->result = rb_block_pass(rb_thread_yield_0, arg, proc); }