mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
cbe5f8820b
commit
aff9dff46d
6 changed files with 39 additions and 9 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Sat Dec 15 23:08:56 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||
|
||||
* 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.
|
||||
|
||||
Sat Dec 15 18:24:21 2012 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* rational.c (f_round_common): should check overflow.
|
||||
|
|
2
gc.c
2
gc.c
|
@ -574,7 +574,7 @@ init_heap(rb_objspace_t *objspace)
|
|||
/* altstack of another threads are allocated in another place */
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
void *tmp = th->altstack;
|
||||
th->altstack = malloc(ALT_STACK_SIZE);
|
||||
th->altstack = malloc(rb_sigaltstack_size());
|
||||
free(tmp); /* free previously allocated area */
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -252,6 +252,7 @@ VALUE rb_reg_check_preprocess(VALUE);
|
|||
|
||||
/* signal.c */
|
||||
int rb_get_next_signal(void);
|
||||
int rb_sigaltstack_size(void);
|
||||
|
||||
/* strftime.c */
|
||||
#ifdef RUBY_ENCODING_H
|
||||
|
|
23
signal.c
23
signal.c
|
@ -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. */
|
||||
|
|
2
vm.c
2
vm.c
|
@ -1834,7 +1834,7 @@ th_init(rb_thread_t *th, VALUE self)
|
|||
/* allocate thread stack */
|
||||
#ifdef USE_SIGALTSTACK
|
||||
/* altstack of main thread is reallocated in another place */
|
||||
th->altstack = malloc(ALT_STACK_SIZE);
|
||||
th->altstack = malloc(rb_sigaltstack_size());
|
||||
#endif
|
||||
th->stack_size = RUBY_VM_THREAD_STACK_SIZE;
|
||||
th->stack = thread_recycle_stack(th->stack_size);
|
||||
|
|
|
@ -456,12 +456,6 @@ struct rb_unblock_callback {
|
|||
|
||||
struct rb_mutex_struct;
|
||||
|
||||
#ifdef MINSIGSTKSZ
|
||||
#define ALT_STACK_SIZE (MINSIGSTKSZ*2)
|
||||
#else
|
||||
#define ALT_STACK_SIZE (4*1024)
|
||||
#endif
|
||||
|
||||
struct rb_thread_struct;
|
||||
typedef struct rb_thread_list_struct{
|
||||
struct rb_thread_list_struct *next;
|
||||
|
|
Loading…
Add table
Reference in a new issue