From 86efaded7fe10816cdbd35215bf7e0ce7156869c Mon Sep 17 00:00:00 2001 From: Suraj N. Kurapati Date: Sat, 24 Oct 2009 11:21:19 -0700 Subject: [PATCH] make SET_STACK_END macro respect rb_thread_t.machine_stack_maxsize --- cont.c | 2 +- gc.c | 4 ++-- gc.h | 6 ++++++ thread.c | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cont.c b/cont.c index 9021333..c9e0dc7 100644 --- a/cont.c +++ b/cont.c @@ -229,7 +229,7 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont) size_t size; rb_thread_t *sth = &cont->saved_thread; - SET_MACHINE_STACK_END(&th->machine_stack_end); + SET_THREAD_MACHINE_STACK_END(th); #ifdef __ia64 th->machine_register_stack_end = rb_ia64_bsp(); #endif diff --git a/gc.c b/gc.c index ddfe39b..deaf4b6 100644 --- a/gc.c +++ b/gc.c @@ -1162,9 +1162,9 @@ rb_objspace_data_type_name(VALUE obj) } #ifdef __ia64 -#define SET_STACK_END (SET_MACHINE_STACK_END(&th->machine_stack_end), th->machine_register_stack_end = rb_ia64_bsp()) +#define SET_STACK_END (SET_THREAD_MACHINE_STACK_END(th), th->machine_register_stack_end = rb_ia64_bsp()) #else -#define SET_STACK_END SET_MACHINE_STACK_END(&th->machine_stack_end) +#define SET_STACK_END SET_THREAD_MACHINE_STACK_END(th) #endif #define STACK_START (th->machine_stack_start) diff --git a/gc.h b/gc.h index 82fbcb5..9c15682 100644 --- a/gc.h +++ b/gc.h @@ -10,6 +10,12 @@ NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p)); #define USE_CONSERVATIVE_STACK_END #endif +#define SET_THREAD_MACHINE_STACK_END(th) SET_MACHINE_STACK_END(&th->machine_stack_end);\ +/* keep machine stack pointer within the maximum size limit */\ +if (th->machine_stack_end && th->machine_stack_start - th->machine_stack_end > th->machine_stack_maxsize) {\ + th->machine_stack_end = th->machine_stack_start + th->machine_stack_maxsize;\ +} + /* for GC debug */ #ifndef RUBY_MARK_FREE_DEBUG diff --git a/thread.c b/thread.c index 8d7d67b..64b4b6e 100644 --- a/thread.c +++ b/thread.c @@ -2598,7 +2598,7 @@ rb_gc_set_stack_end(VALUE **stack_end_p) void rb_gc_save_machine_context(rb_thread_t *th) { - SET_MACHINE_STACK_END(&th->machine_stack_end); + SET_THREAD_MACHINE_STACK_END(th); FLUSH_REGISTER_WINDOWS; #ifdef __ia64 th->machine_register_stack_end = rb_ia64_bsp(); -- 1.6.5.1