mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1054b79609
commit
18bc6c31a1
4 changed files with 25 additions and 12 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Sat Jul 30 10:39:14 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* 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@fsij.org>
|
Sat Jul 30 07:20:49 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/lib/socket.rb (udp_server_sockets): unused variable
|
* ext/socket/lib/socket.rb (udp_server_sockets): unused variable
|
||||||
|
|
15
signal.c
15
signal.c
|
@ -423,29 +423,22 @@ typedef RETSIGTYPE ruby_sigaction_t(int);
|
||||||
#ifdef POSIX_SIGNAL
|
#ifdef POSIX_SIGNAL
|
||||||
|
|
||||||
#ifdef USE_SIGALTSTACK
|
#ifdef USE_SIGALTSTACK
|
||||||
#ifdef SIGSTKSZ
|
|
||||||
#define ALT_STACK_SIZE (SIGSTKSZ*2)
|
|
||||||
#else
|
|
||||||
#define ALT_STACK_SIZE (4*1024)
|
|
||||||
#endif
|
|
||||||
/* alternate stack for SIGSEGV */
|
/* alternate stack for SIGSEGV */
|
||||||
void
|
void
|
||||||
rb_register_sigaltstack(rb_thread_t *th)
|
rb_register_sigaltstack(rb_thread_t *th)
|
||||||
{
|
{
|
||||||
stack_t newSS, oldSS;
|
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);
|
newSS.ss_sp = th->altstack;
|
||||||
if (newSS.ss_sp == NULL)
|
|
||||||
/* should handle error */
|
|
||||||
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;
|
||||||
|
|
||||||
sigaltstack(&newSS, &oldSS); /* ignore error. */
|
sigaltstack(&newSS, &oldSS); /* ignore error. */
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* USE_SIGALTSTACK */
|
||||||
|
|
||||||
static sighandler_t
|
static sighandler_t
|
||||||
ruby_signal(int signum, sighandler_t handler)
|
ruby_signal(int signum, sighandler_t handler)
|
||||||
|
|
5
vm.c
5
vm.c
|
@ -1754,7 +1754,7 @@ thread_free(void *ptr)
|
||||||
else {
|
else {
|
||||||
#ifdef USE_SIGALTSTACK
|
#ifdef USE_SIGALTSTACK
|
||||||
if (th->altstack) {
|
if (th->altstack) {
|
||||||
free(th->altstack);
|
xfree(th->altstack);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ruby_xfree(ptr);
|
ruby_xfree(ptr);
|
||||||
|
@ -1826,6 +1826,9 @@ th_init(rb_thread_t *th, VALUE self)
|
||||||
th->self = self;
|
th->self = self;
|
||||||
|
|
||||||
/* allocate thread stack */
|
/* allocate thread stack */
|
||||||
|
#ifdef USE_SIGALTSTACK
|
||||||
|
th->altstack = xmalloc(ALT_STACK_SIZE);
|
||||||
|
#endif
|
||||||
th->stack_size = RUBY_VM_THREAD_STACK_SIZE;
|
th->stack_size = RUBY_VM_THREAD_STACK_SIZE;
|
||||||
th->stack = thread_recycle_stack(th->stack_size);
|
th->stack = thread_recycle_stack(th->stack_size);
|
||||||
|
|
||||||
|
|
|
@ -383,6 +383,12 @@ struct rb_unblock_callback {
|
||||||
|
|
||||||
struct rb_mutex_struct;
|
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 {
|
typedef struct rb_thread_struct {
|
||||||
VALUE self;
|
VALUE self;
|
||||||
rb_vm_t *vm;
|
rb_vm_t *vm;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue