1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

signal.c: fix stack overflow check on Mac OS X

* signal.c (check_stack_overflow): fix condition to use ucontext
  register, mcontext_t dereference, and its member names, on Mac
  OS X.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-05-25 03:15:32 +00:00
parent a563664e06
commit 55f7a4b726
2 changed files with 11 additions and 4 deletions

View file

@ -1,3 +1,9 @@
Sun May 25 12:15:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* signal.c (check_stack_overflow): fix condition to use ucontext
register, mcontext_t dereference, and its member names, on Mac
OS X.
Sun May 25 11:58:26 2014 Zachary Scott <e@zzak.io>
* enumerator.c: [DOC] Fix example to show Enumerator#peek behavior

View file

@ -700,7 +700,7 @@ rb_get_next_signal(void)
#if defined(USE_SIGALTSTACK) || defined(_WIN32)
NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th));
#if !(defined(HAVE_UCONTEXT_H) && (defined __i386__ || defined __x86_64__))
#if (defined(HAVE_UCONTEXT_H) && (defined __i386__ || defined __x86_64__))
#elif defined __linux__
# define USE_UCONTEXT_REG 1
#elif defined __APPLE__
@ -710,18 +710,19 @@ NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th));
static void
check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx)
{
const mcontext_t *mctx = &ctx->uc_mcontext;
# if defined __linux__
const mcontext_t *mctx = &ctx->uc_mcontext;
# if defined REG_RSP
const greg_t sp = mctx->gregs[REG_RSP];
# else
const greg_t sp = mctx->gregs[REG_ESP];
# endif
# elif defined __APPLE__
const mcontext_t mctx = ctx->uc_mcontext;
# if defined(__LP64__)
const uintptr_t sp = mctx->ss.rsp;
const uintptr_t sp = mctx->__ss.__rsp;
# else
const uintptr_t sp = mctx->ss.esp;
const uintptr_t sp = mctx->__ss.__esp;
# endif
# endif
enum {pagesize = 4096};