ruby-changes:20702
From: kosaki <ko1@a...>
Date: Sat, 30 Jul 2011 10:58:34 +0900 (JST)
Subject: [ruby-changes:20702] kosaki:r32750 (ruby_1_9_3): merge revision(s) 32749:
kosaki 2011-07-30 10:58:21 +0900 (Sat, 30 Jul 2011) New Revision: 32750 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32750 Log: merge revision(s) 32749: * vm.c (th_init): preallocate alternative stack. NoMemoryError is better than rb_bug, of course. Patch by Eric Wong. [ruby-core:38572][ruby-core:38594]. * signal.c (rb_register_sigaltstack): ditto. * vm_core.h: moved ALT_STACK_SIZE definition from signal.c. * vm.c (thread_free): use xfree() instead of free(). Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/signal.c branches/ruby_1_9_3/vm.c branches/ruby_1_9_3/vm_core.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 32749) +++ ruby_1_9_3/ChangeLog (revision 32750) @@ -1,3 +1,14 @@ +Sat Jul 30 10:58:10 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * vm.c (th_init): preallocate alternative stack. + NoMemoryError is better than rb_bug, of course. + Patch by Eric Wong. [ruby-core:38572][ruby-core:38594]. + + * signal.c (rb_register_sigaltstack): ditto. + + * vm_core.h: moved ALT_STACK_SIZE definition from signal.c. + * vm.c (thread_free): use xfree() instead of free(). + Sat Jul 30 07:20:49 2011 Tanaka Akira <akr@f...> * ext/socket/lib/socket.rb (udp_server_sockets): unused variable Index: ruby_1_9_3/vm_core.h =================================================================== --- ruby_1_9_3/vm_core.h (revision 32749) +++ ruby_1_9_3/vm_core.h (revision 32750) @@ -383,6 +383,12 @@ struct rb_mutex_struct; +#ifdef SIGSTKSZ +#define ALT_STACK_SIZE (SIGSTKSZ*2) +#else +#define ALT_STACK_SIZE (4*1024) +#endif + typedef struct rb_thread_struct { VALUE self; rb_vm_t *vm; Index: ruby_1_9_3/vm.c =================================================================== --- ruby_1_9_3/vm.c (revision 32749) +++ ruby_1_9_3/vm.c (revision 32750) @@ -1754,7 +1754,7 @@ else { #ifdef USE_SIGALTSTACK if (th->altstack) { - free(th->altstack); + xfree(th->altstack); } #endif ruby_xfree(ptr); @@ -1826,6 +1826,9 @@ th->self = self; /* allocate thread stack */ +#ifdef USE_SIGALTSTACK + th->altstack = xmalloc(ALT_STACK_SIZE); +#endif th->stack_size = RUBY_VM_THREAD_STACK_SIZE; th->stack = thread_recycle_stack(th->stack_size); Index: ruby_1_9_3/signal.c =================================================================== --- ruby_1_9_3/signal.c (revision 32749) +++ ruby_1_9_3/signal.c (revision 32750) @@ -423,29 +423,22 @@ #ifdef POSIX_SIGNAL #ifdef USE_SIGALTSTACK -#ifdef SIGSTKSZ -#define ALT_STACK_SIZE (SIGSTKSZ*2) -#else -#define ALT_STACK_SIZE (4*1024) -#endif /* alternate stack for SIGSEGV */ void rb_register_sigaltstack(rb_thread_t *th) { stack_t newSS, oldSS; - if (th->altstack) return; + if (!th->altstack) + rb_bug("rb_register_sigaltstack: th->altstack not initialized\n"); - newSS.ss_sp = th->altstack = malloc(ALT_STACK_SIZE); - if (newSS.ss_sp == NULL) - /* should handle error */ - rb_bug("rb_register_sigaltstack. malloc error\n"); + newSS.ss_sp = th->altstack; newSS.ss_size = ALT_STACK_SIZE; newSS.ss_flags = 0; sigaltstack(&newSS, &oldSS); /* ignore error. */ } -#endif +#endif /* USE_SIGALTSTACK */ static sighandler_t ruby_signal(int signum, sighandler_t handler) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/