mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
signal.c: unblock signal
* signal.c (raise_stack_overflow): unblock the received signal, to receive the same signal again. [ruby-core:79285] [Bug #13164] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d005ada1b8
commit
1e1a585300
1 changed files with 20 additions and 9 deletions
29
signal.c
29
signal.c
|
@ -772,9 +772,22 @@ NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th));
|
||||||
# elif defined __FreeBSD__
|
# elif defined __FreeBSD__
|
||||||
# define USE_UCONTEXT_REG 1
|
# define USE_UCONTEXT_REG 1
|
||||||
# endif
|
# 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
|
# ifdef USE_UCONTEXT_REG
|
||||||
static void
|
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);
|
const DEFINE_MCONTEXT_PTR(mctx, ctx);
|
||||||
# if defined __linux__
|
# if defined __linux__
|
||||||
|
@ -826,30 +839,28 @@ check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx)
|
||||||
* place. */
|
* place. */
|
||||||
th->tag = th->tag->prev;
|
th->tag = th->tag->prev;
|
||||||
}
|
}
|
||||||
clear_received_signal();
|
raise_stack_overflow(sig, th);
|
||||||
ruby_thread_stack_overflow(th);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
static void
|
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 *);
|
int ruby_stack_overflowed_p(const rb_thread_t *, const void *);
|
||||||
rb_thread_t *th = ruby_current_thread;
|
rb_thread_t *th = ruby_current_thread;
|
||||||
if (ruby_stack_overflowed_p(th, addr)) {
|
if (ruby_stack_overflowed_p(th, addr)) {
|
||||||
clear_received_signal();
|
raise_stack_overflow(sig, th);
|
||||||
ruby_thread_stack_overflow(th);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
# define CHECK_STACK_OVERFLOW() check_stack_overflow(0)
|
# define CHECK_STACK_OVERFLOW() check_stack_overflow(sig, 0)
|
||||||
# else
|
# else
|
||||||
# define FAULT_ADDRESS info->si_addr
|
# define FAULT_ADDRESS info->si_addr
|
||||||
# ifdef USE_UCONTEXT_REG
|
# 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
|
# else
|
||||||
# define CHECK_STACK_OVERFLOW() check_stack_overflow(FAULT_ADDRESS)
|
# define CHECK_STACK_OVERFLOW() check_stack_overflow(sig, FAULT_ADDRESS)
|
||||||
# endif
|
# endif
|
||||||
# define MESSAGE_FAULT_ADDRESS " at %p", FAULT_ADDRESS
|
# define MESSAGE_FAULT_ADDRESS " at %p", FAULT_ADDRESS
|
||||||
# endif
|
# endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue