[#28687] [Bug #2973] rb_bug - Segmentation fault - error.c:213 — rudolf gavlas <redmine@...>

Bug #2973: rb_bug - Segmentation fault - error.c:213

10 messages 2010/03/16

[#28735] [Bug #2982] Ruby tries to link with both openssl and readline — Lucas Nussbaum <redmine@...>

Bug #2982: Ruby tries to link with both openssl and readline

16 messages 2010/03/18

[#28736] [Bug #2983] Ruby (GPLv2 only) tries to link to with readline (now GPLv3) — Lucas Nussbaum <redmine@...>

Bug #2983: Ruby (GPLv2 only) tries to link to with readline (now GPLv3)

10 messages 2010/03/18

[#28907] [Bug #3000] Open SSL Segfaults — Christian Höltje <redmine@...>

Bug #3000: Open SSL Segfaults

19 messages 2010/03/23

[#28924] [Bug #3005] Ruby core dump - [BUG] rb_sys_fail() - errno == 0 — Sebastian YEPES <redmine@...>

Bug #3005: Ruby core dump - [BUG] rb_sys_fail() - errno == 0

10 messages 2010/03/24

[#28954] [Feature #3010] slow require gems in ruby 1.9.1 — Miao Jiang <redmine@...>

Feature #3010: slow require gems in ruby 1.9.1

15 messages 2010/03/24

[#29179] [Bug #3071] Convert rubygems and rdoc to use psych — Aaron Patterson <redmine@...>

Bug #3071: Convert rubygems and rdoc to use psych

10 messages 2010/03/31

[ruby-core:28931] [Bug #947] Signal handler block is never called when the program is too short

From: Yusuke Endoh <redmine@...>
Date: 2010-03-24 15:20:25 UTC
List: ruby-core #28931
Issue #947 has been updated by Yusuke Endoh.

ruby -v set to ruby 1.9.2dev (2010-03-24 trunk 27033) [i686-linux]

Hi,

2008/12/29 Yuki Sonoda <redmine@ruby-lang.org>:
> Bug #947: Signal handler block is never called when the program is too short
> http://redmine.ruby-lang.org/issues/show/947
>
> Author: Yuki Sonoda
> Status: Open, Priority: Normal
> Assigned to: Koichi Sasada, Category: YARV, Target version: 1.9.1
>
> forked from #727.
>
> % ruby-trunk -e 'Signal.trap(:INT){p :ok}; Process.kill(:INT, $$)'
> => displays nothing


It would be good to check whether signal is delivered or not before
process termination:


diff --git a/eval.c b/eval.c
index a1deab6..2db160c 100644
--- a/eval.c
+++ b/eval.c
@@ -127,6 +127,12 @@ ruby_cleanup(volatile int ex)
     volatile VALUE errs[2];
     rb_thread_t *th = GET_THREAD();
     int nerr;
+    void rb_threadptr_interrupt(rb_thread_t *th);
+    void rb_threadptr_check_signal(rb_thread_t *mth);
+
+    rb_threadptr_interrupt(th);
+    rb_threadptr_check_signal(th);
+    RUBY_VM_CHECK_INTS();
 
     errs[1] = th->errinfo;
     th->safe_level = 0;
diff --git a/thread.c b/thread.c
index a3dfe00..5273dd1 100644
--- a/thread.c
+++ b/thread.c
@@ -290,7 +290,7 @@ reset_unblock_function(rb_thread_t *th, const struct rb_unblock_callback *old)
     native_mutex_unlock(&th->interrupt_lock);
 }
 
-static void
+void
 rb_threadptr_interrupt(rb_thread_t *th)
 {
     native_mutex_lock(&th->interrupt_lock);
@@ -2644,18 +2644,13 @@ rb_gc_save_machine_context(rb_thread_t *th)
 
 int rb_get_next_signal(void);
 
-static void
-timer_thread_function(void *arg)
+void
+rb_threadptr_check_signal(rb_thread_t *mth)
 {
-    rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */
     int sig;
-    rb_thread_t *mth;
 
-    /* for time slice */
-    RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread);
+    /* mth must be main_thread */
 
-    /* check signal */
-    mth = vm->main_thread;
     if (!mth->exec_signal && (sig = rb_get_next_signal()) > 0) {
 	enum rb_thread_status prev_status = mth->status;
 	thread_debug("main_thread: %s, sig: %d\n",
@@ -2665,6 +2660,19 @@ timer_thread_function(void *arg)
 	rb_threadptr_interrupt(mth);
 	mth->status = prev_status;
     }
+}
+
+static void
+timer_thread_function(void *arg)
+{
+    rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */
+    rb_thread_t *mth;
+
+    /* for time slice */
+    RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread);
+
+    /* check signal */
+    rb_threadptr_check_signal(vm->main_thread);
 
 #if 0
     /* prove profiler */

-- 
Yusuke ENDOH <mame@tsg.ne.jp>
----------------------------------------
http://redmine.ruby-lang.org/issues/show/947

----------------------------------------
http://redmine.ruby-lang.org

In This Thread