ruby-changes:34591
From: usa <ko1@a...>
Date: Fri, 4 Jul 2014 00:17:06 +0900 (JST)
Subject: [ruby-changes:34591] usa:r46672 (ruby_2_0_0): revert r46667 and r46669 because they introduced SEGV on CentOS.
usa 2014-07-04 00:16:52 +0900 (Fri, 04 Jul 2014) New Revision: 46672 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46672 Log: revert r46667 and r46669 because they introduced SEGV on CentOS. see [Bug #9454] [Bug #9945] Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/cont.c branches/ruby_2_0_0/gc.c branches/ruby_2_0_0/test/ruby/test_exception.rb branches/ruby_2_0_0/thread.c branches/ruby_2_0_0/thread_pthread.c branches/ruby_2_0_0/thread_win32.c branches/ruby_2_0_0/version.h branches/ruby_2_0_0/vm.c branches/ruby_2_0_0/vm_core.h Index: ruby_2_0_0/thread_win32.c =================================================================== --- ruby_2_0_0/thread_win32.c (revision 46671) +++ ruby_2_0_0/thread_win32.c (revision 46672) @@ -589,8 +589,8 @@ native_thread_init_stack(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_win32.c#L589 size = end - base; space = size / 5; if (space > 1024*1024) space = 1024*1024; - th->machine.stack_start = (VALUE *)end - 1; - th->machine.stack_maxsize = size - space; + th->machine_stack_start = (VALUE *)end - 1; + th->machine_stack_maxsize = size - space; } #ifndef InterlockedExchangePointer @@ -618,7 +618,7 @@ thread_start_func_1(void *th_ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_win32.c#L618 thread_debug("thread created (th: %p, thid: %p, event: %p)\n", th, th->thread_id, th->native_thread_data.interrupt_event); - thread_start_func_2(th, th->machine.stack_start, rb_ia64_bsp()); + thread_start_func_2(th, th->machine_stack_start, rb_ia64_bsp()); w32_close_handle(thread_id); thread_debug("thread deleted (th: %p)\n", th); Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 46671) +++ ruby_2_0_0/ChangeLog (revision 46672) @@ -20,41 +20,6 @@ Thu Jul 3 15:17:22 2014 Koichi Sasada https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L20 move definition of rb_frame_pop() and deprecate it. It doesn't care about `return' events. -Thu Jul 3 15:00:35 2014 Nobuyoshi Nakada <nobu@r...> - - * encoding.c (enc_find): [DOC] never accepted a symbol. - [ruby-dev:48308] [Bug #9966] - -Thu Jul 3 13:23:31 2014 Nobuyoshi Nakada <nobu@r...> - - * thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p): - place get_stack above others to get stack boundary information. - [ruby-core:60113] [Bug #9454] - -Thu Jul 3 13:23:31 2014 Nobuyoshi Nakada <nobu@r...> - - * thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p): - place get_stack above others to get stack boundary information. - [ruby-core:60113] [Bug #9454] - -Thu Jul 3 13:23:31 2014 NARUSE, Yui <naruse@r...> - - * thread_pthread.c: rlimit is only available on Linux. - At least r44712 breaks FreeBSD. - [ruby-core:60113] [Bug #9454] - -Thu Jul 3 13:23:31 2014 Nobuyoshi Nakada <nobu@r...> - - * thread_pthread.c: get current main thread stack size, which may - be expanded than allocated size at initialization, by rlimit(). - [ruby-core:60113] [Bug #9454] - -Thu Jul 3 13:23:31 2014 Nobuyoshi Nakada <nobu@r...> - - * thread_pthread.c: get current main thread stack size, which may - be expanded than allocated size at initialization, by rlimit(). - [ruby-core:60113] [Bug #9454] - Fri Jun 27 17:57:16 2014 Nobuyoshi Nakada <nobu@r...> * string.c (rb_str_substr): need to reset code range for shared Index: ruby_2_0_0/thread_pthread.c =================================================================== --- ruby_2_0_0/thread_pthread.c (revision 46671) +++ ruby_2_0_0/thread_pthread.c (revision 46672) @@ -520,9 +520,6 @@ size_t pthread_get_stacksize_np(pthread_ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L520 # define MAINSTACKADDR_AVAILABLE 0 # endif #endif -#if MAINSTACKADDR_AVAILABLE && !defined(get_main_stack) -# define get_main_stack(addr, size) get_stack(addr, size) -#endif #ifdef STACKADDR_AVAILABLE /* @@ -636,18 +633,6 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L633 ) { native_main_thread.id = pthread_self(); -#if MAINSTACKADDR_AVAILABLE - if (native_main_thread.stack_maxsize) return; - { - void* stackaddr; - size_t size; - if (get_main_stack(&stackaddr, &size) == 0) { - native_main_thread.stack_maxsize = size; - native_main_thread.stack_start = stackaddr; - return; - } - } -#endif #ifdef STACK_END_ADDRESS native_main_thread.stack_start = STACK_END_ADDRESS; #else @@ -665,7 +650,6 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L650 } #endif { -#if defined(HAVE_GETRLIMIT) #if defined(PTHREAD_STACK_DEFAULT) # if PTHREAD_STACK_DEFAULT < RUBY_STACK_SPACE*5 # error "PTHREAD_STACK_DEFAULT is too small" @@ -674,7 +658,15 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L658 #else size_t size = RUBY_VM_THREAD_VM_STACK_SIZE; #endif - size_t space; + size_t space = space_size(size); +#if MAINSTACKADDR_AVAILABLE + void* stackaddr; + STACK_GROW_DIR_DETECTION; + if (get_stack(&stackaddr, &size) == 0) { + space = STACK_DIR_UPPER((char *)addr - (char *)stackaddr, (char *)stackaddr - (char *)addr); + } + native_main_thread.stack_maxsize = size - space; +#elif defined(HAVE_GETRLIMIT) int pagesize = getpagesize(); struct rlimit rlim; STACK_GROW_DIR_DETECTION; @@ -724,8 +716,8 @@ native_thread_init_stack(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L716 rb_thread_id_t curr = pthread_self(); if (pthread_equal(curr, native_main_thread.id)) { - th->machine.stack_start = native_main_thread.stack_start; - th->machine.stack_maxsize = native_main_thread.stack_maxsize; + th->machine_stack_start = native_main_thread.stack_start; + th->machine_stack_maxsize = native_main_thread.stack_maxsize; } else { #ifdef STACKADDR_AVAILABLE @@ -733,22 +725,17 @@ native_thread_init_stack(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L725 size_t size; if (get_stack(&start, &size) == 0) { - th->machine.stack_start = start; - th->machine.stack_maxsize = size; - } -#elif defined get_stack_of - if (!th->machine.stack_maxsize) { - native_mutex_lock(&th->interrupt_lock); - native_mutex_unlock(&th->interrupt_lock); + th->machine_stack_start = start; + th->machine_stack_maxsize = size; } #else rb_raise(rb_eNotImpError, "ruby engine can initialize only in the main thread"); #endif } #ifdef __ia64 - th->machine.register_stack_start = native_main_thread.register_stack_start; - th->machine.stack_maxsize /= 2; - th->machine.register_stack_maxsize = th->machine.stack_maxsize; + th->machine_register_stack_start = native_main_thread.register_stack_start; + th->machine_stack_maxsize /= 2; + th->machine_register_stack_maxsize = th->machine_stack_maxsize; #endif return 0; } @@ -775,7 +762,7 @@ thread_start_func_1(void *th_ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L762 native_thread_init(th); /* run */ #if defined USE_NATIVE_THREAD_INIT - thread_start_func_2(th, th->machine.stack_start, rb_ia64_bsp()); + thread_start_func_2(th, th->machine_stack_start, rb_ia64_bsp()); #else thread_start_func_2(th, &stack_start, rb_ia64_bsp()); #endif @@ -895,19 +882,14 @@ native_thread_create(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L882 thread_debug("create (use cached thread): %p\n", (void *)th); } else { -#ifdef HAVE_PTHREAD_ATTR_INIT pthread_attr_t attr; - pthread_attr_t *const attrp = &attr; -#else - pthread_attr_t *const attrp = NULL; -#endif const size_t stack_size = th->vm->default_params.thread_machine_stack_size; const size_t space = space_size(stack_size); - th->machine.stack_maxsize = stack_size - space; + th->machine_stack_maxsize = stack_size - space; #ifdef __ia64 - th->machine.stack_maxsize /= 2; - th->machine.register_stack_maxsize = th->machine.stack_maxsize; + th->machine_stack_maxsize /= 2; + th->machine_register_stack_maxsize = th->machine_stack_maxsize; #endif #ifdef HAVE_PTHREAD_ATTR_INIT @@ -922,18 +904,10 @@ native_thread_create(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L904 CHECK_ERR(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED)); # endif CHECK_ERR(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)); -#endif -#ifdef get_stack_of - native_mutex_lock(&th->interrupt_lock); -#endif - err = pthread_create(&th->thread_id, attrp, thread_start_func_1, th); -#ifdef get_stack_of - if (!err) { - get_stack_of(th->thread_id, - &th->machine.stack_start, - &th->machine.stack_maxsize); - } - native_mutex_unlock(&th->interrupt_lock); + + err = pthread_create(&th->thread_id, &attr, thread_start_func_1, th); +#else + err = pthread_create(&th->thread_id, NULL, thread_start_func_1, th); #endif thread_debug("create: %p (%d)\n", (void *)th, err); #ifdef HAVE_PTHREAD_ATTR_INIT @@ -1527,24 +1501,15 @@ ruby_stack_overflowed_p(const rb_thread_ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L1501 const size_t water_mark = 1024 * 1024; STACK_GROW_DIR_DETECTION; + if (th) { + size = th->machine_stack_maxsize; + base = (char *)th->machine_stack_start - STACK_DIR_UPPER(0, size); + } #ifdef STACKADDR_AVAILABLE - if (get_stack(&base, &size) == 0) { -# ifdef __APPLE__ - if (pthread_equal(th->thread_id, native_main_thread.id)) { - struct rlimit rlim; - if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur > size) { - size = (size_t)rlim.rlim_cur; - } - } -# endif - base = (char *)base + STACK_DIR_UPPER(+size, -size); + else if (get_stack(&base, &size) == 0) { + STACK_DIR_UPPER((void)(base = (char *)base + size), (void)0); } - else #endif - if (th) { - size = th->machine.stack_maxsize; - base = (char *)th->machine.stack_start - STACK_DIR_UPPER(0, size); - } else { return 0; } Index: ruby_2_0_0/vm_core.h =================================================================== --- ruby_2_0_0/vm_core.h (revision 46671) +++ ruby_2_0_0/vm_core.h (revision 46672) @@ -585,17 +585,15 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_core.h#L585 VALUE (*first_func)(ANYARGS); /* for GC */ - struct { - VALUE *stack_start; - VALUE *stack_end; - size_t stack_maxsize; + VALUE *machine_stack_start; + VALUE *machine_stack_end; + size_t machine_stack_maxsize; #ifdef __ia64 - VALUE *register_stack_start; - VALUE *register_stack_end; - size_t register_stack_maxsize; + VALUE *machine_register_stack_start; + VALUE *machine_register_stack_end; + size_t machine_register_stack_maxsize; #endif - jmp_buf regs; - } machine; + jmp_buf machine_regs; int mark_stack_len; /* statistics data for profiler */ Index: ruby_2_0_0/thread.c =================================================================== --- ruby_2_0_0/thread.c (revision 46671) +++ ruby_2_0_0/thread.c (revision 46672) @@ -122,7 +122,7 @@ static inline void blocking_region_end(r https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread.c#L122 #ifdef __ia64 #define RB_GC_SAVE_MACHINE_REGISTER_STACK(th) \ - do{(th)->machine.register_stack_end = rb_ia64_bsp();}while(0) + do{(th)->machine_register_stack_end = rb_ia64_bsp();}while(0) #else #define RB_GC_SAVE_MACHINE_REGISTER_STACK(th) #endif @@ -130,8 +130,8 @@ static inline void blocking_region_end(r https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread.c#L130 do { \ FLUSH_REGISTER_WINDOWS; \ RB_GC_SAVE_MACHINE_REGISTER_STACK(th); \ - setjmp((th)->machine.regs); \ - SET_MACHINE_STACK_END(&(th)->machine.stack_end); \ + setjmp((th)->machine_regs); \ + SET_MACHINE_STACK_END(&(th)->machine_stack_end); \ } while (0) #define GVL_UNLOCK_BEGIN() do { \ @@ -444,9 +444,9 @@ thread_cleanup_func_before_exec(void *th https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread.c#L444 { rb_thread_t *th = th_ptr; th->status = THREAD_KILLED; - th->machine.stack_start = th->machine.stack_end = 0; + th->machine_stack_start = th->machine_stack_end = 0; #ifdef __ia64 - th->machine.register_stack_start = th->machine.register_stack_end = 0; + th->machine_register_stack_start = th->machine_register_stack_end = 0; #endif } @@ -498,9 +498,9 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread.c#L498 ruby_thread_set_native(th); - th->machine.stack_start = stack_start; + th->machine_stack_start = stack_start; #ifdef __ia64 - th->machine.register_stack_start = register_stack_start; + th->machine_register_stack_start = register_stack_start; #endif thread_debug("thread start: %p\n", (void *)th); Index: ruby_2_0_0/gc.c =================================================================== --- ruby_2_0_0/gc.c (revision 46671) +++ ruby_2_0_0/gc.c (revision 46672) @@ -2246,14 +2246,14 @@ init_mark_stack(mark_stack_t *stack) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L2246 #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_MACHINE_STACK_END(&th->machine_stack_end), 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_MACHINE_STACK_END(&th->machine_stack_end) #endif -#define STACK_START (th->machine.stack_start) -#define STACK_END (th->machine.stack_end) -#define STACK_LEVEL_MAX (th->machine.stack_maxsize/sizeof(VALUE)) +#define STACK_START (th->machine_stack_start) +#define STACK_END (th->machine_stack_end) +#define STACK_LEVEL_MAX (th->machine_stack_maxsize/sizeof(VALUE)) #if STACK_GROW_DIRECTION < 0 # define STACK_LENGTH (size_t)(STACK_START - STACK_END) @@ -2295,8 +2295,8 @@ stack_check(int water_mark) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L2295 ret = STACK_LENGTH > STACK_LEVEL_MAX - water_mark; #ifdef __ia64 if (!ret) { - ret = (VALUE*)rb_ia64_bsp() - th->machine.register_stack_start > - th->machine.register_stack_maxsize/sizeof(VALUE) - water_mark; + ret = (VALUE*)rb_ia64_bsp() - th->machine_register_stack_start > + th->machine_register_stack_maxsize/sizeof(VALUE) - water_mark; } #endif return ret; @@ -2518,7 +2518,7 @@ mark_current_machine_context(rb_objspace https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L2518 rb_gc_mark_locations(stack_start, stack_end); #ifdef __ia64 - rb_gc_mark_locations(th->machine.register_stack_start, th->machine.register_stack_end); + rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); #endif #if defined(__mc68000__) mark_locations_array(objspace, (VALUE*)((char*)STACK_END + 2), @@ -2535,7 +2535,7 @@ rb_gc_mark_machine_stack(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L2535 GET_STACK_BOUNDS(stack_start, stack_end, 0); rb_gc_mark_locations(stack_start, stack_end); #ifdef __ia64 - rb_gc_mark_locations(th->machine.register_stack_start, th->machine.register_stack_end); + rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); #endif } Index: ruby_2_0_0/cont.c =================================================================== --- ruby_2_0_0/cont.c (revision 46671) +++ ruby_2_0_0/cont.c (revision 46672) @@ -97,18 +97,16 @@ typedef struct rb_context_struct { https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/cont.c#L97 size_t vm_stack_slen; /* length of stack (head of th->stack) */ size_t vm_stack_clen; /* length of control frames (tail of th->stack) */ #endif - struct { - VALUE *stack; - VALUE *stack_src; - size_t stack_size; + VALUE *machine_stack; + VALUE *machine_stack_src; #ifdef __ia64 - VALUE *register_stack; - VALUE *register_stack_src; - int register_stack_size; + VALUE *machine_register_stack; + VALUE *machine_register_stack_src; + int machine_register_stack_size; #endif - } machine; rb_thread_t saved_thread; rb_jmpbuf_t jmpbuf; + size_t machine_stack_size; } rb_context_t; enum fiber_status { @@ -188,11 +186,11 @@ cont_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/cont.c#L186 #endif } - if (cont->machine.stack) { + if (cont->machine_stack) { if (cont->type == CONTINUATION_CONTEXT) { /* cont */ - rb_gc_mark_locations(cont->machine.stack, - cont->machine.stack + cont->machine.stack_size); + rb_gc_mark_locations(cont->machine_stack, + cont->machine_stack + cont->machine_stack_size); } else { /* fiber */ @@ -200,15 +198,15 @@ cont_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/cont.c#L198 rb_fiber_t *fib = (rb_fiber_t*)cont; GetThreadPtr(cont->saved_thread.self, th); if ((th->fiber != cont->self) && fib->status == RUNNING) { - rb_gc_mark_locations(cont->machine.stack, - cont->machine.stack + cont->machine.stack_size); + rb_gc_mark_locations(cont->machine_stack, + cont->machine_stack + cont->machine_stack_size); } } } #ifdef __ia64 - if (cont->machine.register_stack) { - rb_gc_mark_locations(cont->machine.register_stack, - cont->machine.register_stack + cont->machine.register_stack_size); + if (cont->machine_register_stack) { + rb_gc_mark_locations(cont->machine_register_stack, + cont->machine_register_stack + cont->machine_register_stack_size); } #endif } @@ -225,7 +223,7 @@ cont_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/cont.c#L223 #if FIBER_USE_NATIVE if (cont->type == CONTINUATION_CONTEXT) { /* cont */ - RUBY_FREE_UNLESS_NULL(cont->machine.stack); + RUBY_FREE_UNLESS_NULL(cont->machine_stack); } else { /* fiber */ @@ -255,10 +253,10 @@ cont_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/cont.c#L253 #endif } #else /* not FIBER_USE_NATIVE */ - RUBY_FREE_UNLESS_NULL(cont->machine.stack); + RUBY_FREE_UNLESS_NULL(cont->machine_stack); #endif #ifdef __ia64 - RUBY_FREE_UNLESS_NULL(cont->machine.register_stack); + RUBY_FREE_UNLESS_NULL(cont->machine_register_stack); #endif RUBY_FREE_UNLESS_NULL(cont->vm_stack); @@ -284,12 +282,12 @@ cont_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/cont.c#L282 size += n * sizeof(*cont->vm_stack); } - if (cont->machine.stack) { - size += cont->machine.stack_size * sizeof(*cont->machine.stack); + if (cont->machine_stack) { + size += cont->machine_stack_size * sizeof(*cont->machine_stack); } #ifdef __ia64 - if (cont->machine.register_stack) { - size += cont->machine.register_stack_size * sizeof(*cont->machine.register_stack); + if (cont->machine_register_stack) { + size += cont->machine_register_stack_size * sizeof(*cont->machine_register_stack); } #endif } @@ -377,42 +375,42 @@ cont_save_machine_stack(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/cont.c#L375 { size_t size; - SET_MACHINE_STACK_END(&th->machine.stack_end); + SET_MACHINE_STACK_END(&th->machine_stack_end); #ifdef __ia64 - th->machine.register_stack_end = rb_ia64_bsp(); + th->machine_register_stack_end = rb_ia64_bsp(); #endif - if (th->machine.stack_start > th->machine.stack_end) { - size = cont->machine.stack_size = th->machine.stack_start - th->machine.stack_end; - cont->machine.stack_src = th->machine.stack_end; + if (th->machine_stack_start > th->machine_stack_end) { + size = cont->machine_stack_size = th->machine_stack_start - th->machine_stack_end; + cont->machine_stack_src = th->machine_stack_end; } else { - size = cont->machine.stack_size = th->machine.stack_end - th->machine.stack_start; - cont->machine.stack_src = th->machine.stack_start; + size = cont->machine_stack_size = th->machine_stack_end - th->machine_stack_start; + cont->machine_stack_src = th->machine_stack_start; (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/