зеркало из https://github.com/github/ruby.git
* vm_core.c (rb_thread_struct): add a field for sigaltstack.
* thread_pthread.c (thread_start_func_1): initialize machine stack information. * thread.c (thread_start_func_2): set sigaltstack for each sub thread. [ruby-core:24540] [ruby-core:30207] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a22df39467
Коммит
50587316b8
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Fri May 14 01:17:10 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* vm_core.c (rb_thread_struct): add a field for sigaltstack.
|
||||||
|
|
||||||
|
* thread_pthread.c (thread_start_func_1): initialize machine stack
|
||||||
|
information.
|
||||||
|
|
||||||
|
* thread.c (thread_start_func_2): set sigaltstack for each sub thread.
|
||||||
|
[ruby-core:24540] [ruby-core:30207]
|
||||||
|
|
||||||
Thu May 13 21:40:39 2010 Tanaka Akira <akr@fsij.org>
|
Thu May 13 21:40:39 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* missing/ffs.c (ffs): fixed for non-zero values.
|
* missing/ffs.c (ffs): fixed for non-zero values.
|
||||||
|
|
19
signal.c
19
signal.c
|
@ -420,10 +420,6 @@ static struct {
|
||||||
#define sighandler_t sh_t
|
#define sighandler_t sh_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
|
|
||||||
#define USE_SIGALTSTACK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef RETSIGTYPE (*sighandler_t)(int);
|
typedef RETSIGTYPE (*sighandler_t)(int);
|
||||||
#ifdef USE_SIGALTSTACK
|
#ifdef USE_SIGALTSTACK
|
||||||
typedef void ruby_sigaction_t(int, siginfo_t*, void*);
|
typedef void ruby_sigaction_t(int, siginfo_t*, void*);
|
||||||
|
@ -442,18 +438,17 @@ typedef RETSIGTYPE ruby_sigaction_t(int);
|
||||||
#define ALT_STACK_SIZE (4*1024)
|
#define ALT_STACK_SIZE (4*1024)
|
||||||
#endif
|
#endif
|
||||||
/* alternate stack for SIGSEGV */
|
/* alternate stack for SIGSEGV */
|
||||||
static void
|
void
|
||||||
register_sigaltstack(void)
|
rb_register_sigaltstack(rb_thread_t *th)
|
||||||
{
|
{
|
||||||
static void *altstack = 0;
|
|
||||||
stack_t newSS, oldSS;
|
stack_t newSS, oldSS;
|
||||||
|
|
||||||
if (altstack) return;
|
if (th->altstack) return;
|
||||||
|
|
||||||
newSS.ss_sp = altstack = malloc(ALT_STACK_SIZE);
|
newSS.ss_sp = th->altstack = malloc(ALT_STACK_SIZE);
|
||||||
if (newSS.ss_sp == NULL)
|
if (newSS.ss_sp == NULL)
|
||||||
/* should handle error */
|
/* should handle error */
|
||||||
rb_bug("register_sigaltstack. malloc error\n");
|
rb_bug("rb_register_sigaltstack. malloc error\n");
|
||||||
newSS.ss_size = ALT_STACK_SIZE;
|
newSS.ss_size = ALT_STACK_SIZE;
|
||||||
newSS.ss_flags = 0;
|
newSS.ss_flags = 0;
|
||||||
|
|
||||||
|
@ -737,7 +732,7 @@ default_handler(int sig)
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
func = (sighandler_t)sigsegv;
|
func = (sighandler_t)sigsegv;
|
||||||
# ifdef USE_SIGALTSTACK
|
# ifdef USE_SIGALTSTACK
|
||||||
register_sigaltstack();
|
rb_register_sigaltstack(GET_THREAD());
|
||||||
# endif
|
# endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1130,7 +1125,7 @@ Init_signal(void)
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGSEGV
|
#ifdef SIGSEGV
|
||||||
# ifdef USE_SIGALTSTACK
|
# ifdef USE_SIGALTSTACK
|
||||||
register_sigaltstack();
|
rb_register_sigaltstack(GET_THREAD());
|
||||||
# endif
|
# endif
|
||||||
install_sighandler(SIGSEGV, (sighandler_t)sigsegv);
|
install_sighandler(SIGSEGV, (sighandler_t)sigsegv);
|
||||||
#endif
|
#endif
|
||||||
|
|
5
thread.c
5
thread.c
|
@ -417,6 +417,11 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
|
||||||
rb_thread_t *join_th;
|
rb_thread_t *join_th;
|
||||||
rb_thread_t *main_th;
|
rb_thread_t *main_th;
|
||||||
VALUE errinfo = Qnil;
|
VALUE errinfo = Qnil;
|
||||||
|
# ifdef USE_SIGALTSTACK
|
||||||
|
void rb_register_sigaltstack(rb_thread_t *th);
|
||||||
|
|
||||||
|
rb_register_sigaltstack(th);
|
||||||
|
# endif
|
||||||
|
|
||||||
ruby_thread_set_native(th);
|
ruby_thread_set_native(th);
|
||||||
|
|
||||||
|
|
|
@ -344,6 +344,7 @@ thread_start_func_1(void *th_ptr)
|
||||||
rb_thread_t *th = th_ptr;
|
rb_thread_t *th = th_ptr;
|
||||||
VALUE stack_start;
|
VALUE stack_start;
|
||||||
|
|
||||||
|
native_thread_init_stack(th);
|
||||||
/* run */
|
/* run */
|
||||||
thread_start_func_2(th, &stack_start, rb_ia64_bsp());
|
thread_start_func_2(th, &stack_start, rb_ia64_bsp());
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,10 @@
|
||||||
#define va_init_list(a,b) va_start(a)
|
#define va_init_list(a,b) va_start(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
|
||||||
|
#define USE_SIGALTSTACK
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
/* configuration */
|
/* configuration */
|
||||||
/*****************/
|
/*****************/
|
||||||
|
@ -473,6 +477,9 @@ typedef struct rb_thread_struct
|
||||||
/* misc */
|
/* misc */
|
||||||
int method_missing_reason;
|
int method_missing_reason;
|
||||||
int abort_on_exception;
|
int abort_on_exception;
|
||||||
|
#ifdef USE_SIGALTSTACK
|
||||||
|
void *altstack;
|
||||||
|
#endif
|
||||||
} rb_thread_t;
|
} rb_thread_t;
|
||||||
|
|
||||||
/* iseq.c */
|
/* iseq.c */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче