Actions
Bug #4911
closedtimer_thread_function() が thead unsafe
Bug #4911:
timer_thread_function() が thead unsafe
Description
どうして、これを先月気づかなかったのだろう。という罪悪感があるのですが、
target 1.9.x で起票します。
timer_thread_function()で vm->running_thread にアクセスするのは
thread unsafe な気がします
0.スレッドAがrunning_threadである
1.タイマースレッドがvm->running_threadをレジスタにのせる
(レジスタにスレッドAのアドレスがのっかる)
2.コンテキストスイッチ
3.スレッドAが終了。スレッドBがrunning_threadになる
4.スレッドAの rb_thead_t がfreeされる
5.コンテキストスイッチ
6.そんなkとはつゆしらず、タイマースレッドはスレッドAの
アドレスに対して th->interrupt_flag |= 1; するのでメモリ破壊
static void
timer_thread_function(void *arg)
{
rb_vm_t vm = GET_VM(); / TODO: fix me for Multi-VM */
/* for time slice */
RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread); ※ここ
/* check signal */
rb_threadptr_check_signal(vm->main_thread);
}
Actions