まつもと ゆきひろです
In message "[ruby-list:2231] [BUG] Thread (Re: ruby 1.0-070220 available)"
on 97/02/20, sinara / blade.nagaokaut.ac.jp <sinara / blade.nagaokaut.ac.jp> writes:
|次のコードで n の値によって、Segmentation fault や
|deadlock を起こします。19日のバージョンからです。
すみませんねえ.二つのバグが絡んでいたので結構大変でした.
ひとつはGCのタイミングが変わったので,今まで隠れていたGCのバ
グが顕在化したもので,もうひとつは割込みのタイミングに関する
問題でした.
|> # 日刊rubyの再来か
|つーことは、夕刊も出るかな。:-)
号外です.^^;;;
--- eval.c.orig Thu Feb 20 18:37:22 1997
+++ eval.c Thu Feb 20 18:38:18 1997
@@ -3835,6 +3835,8 @@
gc_mark(th->result);
- gc_mark_locations(th->stk_ptr, th->stk_ptr+th->stk_len);
+ if (th->stk_ptr) {
+ gc_mark_locations(th->stk_ptr, th->stk_ptr+th->stk_len);
#ifdef THINK_C
- gc_mark_locations(th->stk_ptr+2, th->stk_ptr+th->stk_len+2);
+ gc_mark_locations(th->stk_ptr+2, th->stk_ptr+th->stk_len+2);
#endif
+ }
gc_mark(th->thread);
@@ -4070,8 +4072,8 @@
FOREACH_THREAD(th) {
- if (th->status != THREAD_STOPPED && th->status != THREAD_KILLED) {
- next = th;
- break;
- }
+ if (th->status != THREAD_STOPPED && th->status != THREAD_KILLED) {
+ next = th;
+ break;
+ }
}
- END_FOREACH(th);
+ END_FOREACH(th);
@@ -4147,2 +4149,4 @@
}
+
+ thread_critical = TRUE;
TRAP_BEG;
@@ -4150,2 +4154,3 @@
TRAP_END;
+ thread_critical = FALSE;
if (n > 0) {
@@ -4480,3 +4485,8 @@
}
- thread_stop_method(curr_thread->thread);
+
+ num_waiting_on_timer++;
+ curr_thread->delay = DELAY_INFTY;
+ curr_thread->wait_for |= WAIT_TIME;
+ curr_thread->status = THREAD_STOPPED;
+ thread_schedule();
}
@@ -4697,6 +4707,4 @@
{
+ thread_critical = 0;
thread_ready(main_thread);
- if (main_thread == curr_thread) {
- rb_interrupt();
- }
curr_thread = main_thread;