From d33ccac173969a3cb96b72d835a965bfa6decc3e Mon Sep 17 00:00:00 2001 From: kosaki Date: Thu, 11 Aug 2011 12:28:41 +0000 Subject: * backport r32815 from trunk. * gc.c (init_heap): allocate sigaltstack after heaps are allocated. [ruby-dev:44315] [Bug #5139] * vm.c (thread_free): use free because objspace is not ready. * vm.c (th_init): use malloc because objspace is not ready. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ gc.c | 8 ++++++++ vm.c | 5 +++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab3e05dc47..16f648292f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Tue Aug 2 22:04:46 2011 NARUSE, Yui + + * backport r32815 from trunk. + + * gc.c (init_heap): allocate sigaltstack after heaps are allocated. + [ruby-dev:44315] [Bug #5139] + + * vm.c (thread_free): use free because objspace is not ready. + + * vm.c (th_init): use malloc because objspace is not ready. + Thu Aug 11 19:04:38 2011 Hiroshi Nakamura * backport r32931 from trunk. diff --git a/gc.c b/gc.c index 8c33323e9b..fb74b0623a 100644 --- a/gc.c +++ b/gc.c @@ -1085,6 +1085,14 @@ static void init_heap(rb_objspace_t *objspace) { add_heap_slots(objspace, HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT); +#ifdef USE_SIGALTSTACK + { + /* altstack of another threads are allocated in another place */ + rb_thread_t *th = GET_THREAD(); + free(th->altstack); /* free previously allocated area */ + th->altstack = xmalloc(ALT_STACK_SIZE); + } +#endif heaps_inc = 0; objspace->profile.invoke_time = getrusage_time(); diff --git a/vm.c b/vm.c index 3f2b52420f..c627a91bcf 100644 --- a/vm.c +++ b/vm.c @@ -1761,7 +1761,7 @@ thread_free(void *ptr) else { #ifdef USE_SIGALTSTACK if (th->altstack) { - xfree(th->altstack); + free(th->altstack); } #endif ruby_xfree(ptr); @@ -1834,7 +1834,8 @@ th_init(rb_thread_t *th, VALUE self) /* allocate thread stack */ #ifdef USE_SIGALTSTACK - th->altstack = xmalloc(ALT_STACK_SIZE); + /* altstack of main thread is reallocated in another place */ + th->altstack = malloc(ALT_STACK_SIZE); #endif th->stack_size = RUBY_VM_THREAD_STACK_SIZE; th->stack = thread_recycle_stack(th->stack_size); -- cgit v1.2.3