diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-15 14:20:12 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-15 14:20:12 +0000 |
commit | aff9dff46d79181d143697d7b9e76735788e45cc (patch) | |
tree | 004b41af951802cd8638800184cd4633cee21590 /signal.c | |
parent | cbe5f8820b71e0e9a214ae86e9264712e5580413 (diff) |
* signal.c (rb_sigaltstack_size): new. calculate stack size for
sigsegv handler. enlarge value when x86 or x86_64 on Linux.
Linux has very small MINSIGSTKSZ size (2048 bytes) and
our sigsegv routine need 5KiB at least. [Bug #7141]
* internal.h: add declaration of rb_sigaltstack_size().
* vm_core.h: remove ALT_STACK_SIZE definition.
* signal.c (rb_register_sigaltstack): replace ALT_STACK_SIZE with
rb_sigaltstack_size();
* gc.c (Init_heap): ditto.
* vm.c (th_init): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r-- | signal.c | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -447,6 +447,27 @@ typedef RETSIGTYPE ruby_sigaction_t(int); #endif #ifdef USE_SIGALTSTACK +int rb_sigaltstack_size(void) +{ + /* XXX: BSD_vfprintf() uses >1500KiB stack and x86-64 need >5KiB stack. */ + int size = 8192; + +#ifdef MINSIGSTKSZ + if (size < MINSIGSTKSZ) + size = MINSIGSTKSZ; +#endif +#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) + { + int pagesize; + pagesize = sysconf(_SC_PAGE_SIZE); + if (size < pagesize) + size = pagesize; + } +#endif + + return size; +} + /* alternate stack for SIGSEGV */ void rb_register_sigaltstack(rb_thread_t *th) @@ -457,7 +478,7 @@ rb_register_sigaltstack(rb_thread_t *th) rb_bug("rb_register_sigaltstack: th->altstack not initialized\n"); newSS.ss_sp = th->altstack; - newSS.ss_size = ALT_STACK_SIZE; + newSS.ss_size = rb_sigaltstack_size(); newSS.ss_flags = 0; sigaltstack(&newSS, &oldSS); /* ignore error. */ |