From: Nobuyoshi Nakada Date: 2009-02-26T14:14:46+09:00 Subject: [ruby-core:22535] Re: [Bug #1205] SET_STACK_END crashes due to uninitialized ruby_current_thread Hi, At Wed, 25 Feb 2009 09:37:32 +0900, hiro sugawara wrote in [ruby-core:22439]: > The executable crashed at an early stage. I succeeded in > tracing the crash to a null pointer reference to > ruby_current_thread in SET_STACK_END (through GET_THREAD()) > called in ruby_get_stack_grow_direction() called in > STACK_UPPER() called in ruby_init_stack() called in > Init_stack(). Isn't the stack direction on Android defined statically? > Reversing the calling order of Init_BareVM() and Init_stack > in eval.c:ruby_init() seems to fix the problem. Does this patch fix it? Index: gc.c =================================================================== --- gc.c (revision 22639) +++ gc.c (working copy) @@ -1103,8 +1103,8 @@ int ruby_get_stack_grow_direction(VALUE *addr) { - rb_thread_t *th = GET_THREAD(); - SET_STACK_END; + VALUE *end; + SET_MACHINE_STACK_END(&end); - if (STACK_END > addr) return ruby_stack_grow_direction = 1; + if (end > addr) return ruby_stack_grow_direction = 1; return ruby_stack_grow_direction = -1; } -- Nobu Nakada