Bug #3354

エンコードを指定してread中にCtrl-Cで落ちる

Added by Makoto Kishimoto about 5 years ago. Updated over 4 years ago.

[ruby-dev:41435]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:ruby 1.9.3dev (2010-05-27 trunk 28032) [x86_64-freebsd8.0] Backport:

Description

=begin

=end

bug-3354.patch Magnifier (614 Bytes) Motohiro KOSAKI, 05/27/2010 08:49 PM

History

#1 Updated by Motohiro KOSAKI about 5 years ago

=begin
直接的な原因はGVLのデッドロックなんだけど

static int
garbage_collect_with_gvl(rb_objspace_t objspace)
{
if (dont_gc) return TRUE;
if (ruby_thread_has_gvl_p()) {
return garbage_collect(objspace);
}
else {
if (ruby_native_thread_p()) {
return (int)(VALUE)rb_thread_call_with_gvl(gc_with_gvl, (void *)objspace);
}
else {
/
no ruby thread */
fprintf(stderr, "[FATAL] failed to allocate memory\n");
exit(EXIT_FAILURE);
}
}
}

のようにGVLをもってないことを確認してから、GVLを取りに行っているのに
pthread_mutex_lock が EDEADLK を返したので大混乱。と。
そういうバグなわけだな(たぶん)

=end

#2 Updated by Motohiro KOSAKI about 5 years ago

=begin
ここかな?

#define blocking_region_begin(th, region, func, arg) \
do { \
(region)->prev_status = (th)->status; \
(th)->blocking_region_buffer = (region); \ ☆ ここでruby_thread_has_gvl_p()が偽を返すようになる
set_unblock_function((th), (func), (arg), &(region)->oldubf); \ ★ ここでシグナルをチェックしてしまうのでSIGINTが見つかると rb_interrupt() が呼ばれてしまう
(th)->status = THREAD_STOPPED; \
thread_debug("enter blocking region (%p)\n", (void *)(th)); \
RB_GC_SAVE_MACHINE_CONTEXT(th); \
native_mutex_unlock(&(th)->vm->global_vm_lock); \ ☆ ここで実際のGVLのアンロック
} while (0)

=end

#3 Updated by Motohiro KOSAKI about 5 years ago

=begin
親切な人がレビューしてくれないかなー(チラッチラッ
と修正パッチ(案)を添付します
=end

#4 Updated by Motohiro KOSAKI about 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r28055.
Makoto, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF