[前][次][番号順一覧][スレッド一覧]

ruby-changes:46238

From: nobu <ko1@a...>
Date: Fri, 14 Apr 2017 22:00:06 +0900 (JST)
Subject: [ruby-changes:46238] nobu:r58353 (trunk): signal.c: unblock signal

nobu	2017-04-14 21:59:59 +0900 (Fri, 14 Apr 2017)

  New Revision: 58353

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58353

  Log:
    signal.c: unblock signal
    
    * signal.c (raise_stack_overflow): unblock the received signal, to
      receive the same signal again.  [ruby-core:79285] [Bug #13164]

  Modified files:
    trunk/signal.c
Index: signal.c
===================================================================
--- signal.c	(revision 58352)
+++ signal.c	(revision 58353)
@@ -772,9 +772,22 @@ NORETURN(void ruby_thread_stack_overflow https://github.com/ruby/ruby/blob/trunk/signal.c#L772
 # elif defined __FreeBSD__
 #   define USE_UCONTEXT_REG 1
 # endif
+NORETURN(static void raise_stack_overflow(int sig, rb_thread_t *th));
+static void
+raise_stack_overflow(int sig, rb_thread_t *th)
+{
+    sigset_t mask;
+    clear_received_signal();
+    sigemptyset(&mask);
+    sigaddset(&mask, sig);
+    if (sigprocmask(SIG_UNBLOCK, &mask, NULL))
+	rb_bug_errno("sigprocmask:set", errno);
+    ruby_thread_stack_overflow(th);
+}
+
 # ifdef USE_UCONTEXT_REG
 static void
-check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx)
+check_stack_overflow(int sig, const uintptr_t addr, const ucontext_t *ctx)
 {
     const DEFINE_MCONTEXT_PTR(mctx, ctx);
 # if defined __linux__
@@ -826,30 +839,28 @@ check_stack_overflow(const uintptr_t add https://github.com/ruby/ruby/blob/trunk/signal.c#L839
 	     * place. */
 	    th->tag = th->tag->prev;
 	}
-	clear_received_signal();
-	ruby_thread_stack_overflow(th);
+	raise_stack_overflow(sig, th);
     }
 }
 # else
 static void
-check_stack_overflow(const void *addr)
+check_stack_overflow(int sig, const void *addr)
 {
     int ruby_stack_overflowed_p(const rb_thread_t *, const void *);
     rb_thread_t *th = ruby_current_thread;
     if (ruby_stack_overflowed_p(th, addr)) {
-	clear_received_signal();
-	ruby_thread_stack_overflow(th);
+	raise_stack_overflow(sig, th);
     }
 }
 # endif
 # ifdef _WIN32
-#   define CHECK_STACK_OVERFLOW() check_stack_overflow(0)
+#   define CHECK_STACK_OVERFLOW() check_stack_overflow(sig, 0)
 # else
 #   define FAULT_ADDRESS info->si_addr
 #   ifdef USE_UCONTEXT_REG
-#     define CHECK_STACK_OVERFLOW() check_stack_overflow((uintptr_t)FAULT_ADDRESS, ctx)
+#     define CHECK_STACK_OVERFLOW() check_stack_overflow(sig, (uintptr_t)FAULT_ADDRESS, ctx)
 #   else
-#     define CHECK_STACK_OVERFLOW() check_stack_overflow(FAULT_ADDRESS)
+#     define CHECK_STACK_OVERFLOW() check_stack_overflow(sig, FAULT_ADDRESS)
 #   endif
 #   define MESSAGE_FAULT_ADDRESS " at %p", FAULT_ADDRESS
 # endif

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]