From: Eric Wong Date: 2014-02-18T08:01:11+00:00 Subject: [ruby-core:60816] Re: [ruby-trunk - Bug #7805] ruby 2.0rc2 core on solaris Can you please try the following patch? This is hopefully robust enough for all future compilers: http://bogomips.org/ruby.git/patch?id=1b5d3c0b9d --- a/gc.c +++ b/gc.c @@ -88,10 +88,14 @@ #define rb_setjmp(env) RUBY_SETJMP(env) #define rb_jmp_buf rb_jmpbuf_t -#if defined(HAVE_RB_GC_GUARDED_PTR) && HAVE_RB_GC_GUARDED_PTR +#if defined(HAVE_RB_GC_GUARDED_PTR_VAL) && HAVE_RB_GC_GUARDED_PTR_VAL +/* trick the compiler into thinking a external signal handler uses this */ +volatile VALUE rb_gc_guarded_val; volatile VALUE * -rb_gc_guarded_ptr(volatile VALUE *ptr) +rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val) { + rb_gc_guarded_val = val; + return ptr; } #endif diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 55ea252..abd4b4b 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -515,12 +515,16 @@ static inline int rb_type(VALUE obj); static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;} #pragma optimize("", on) #else -volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr); -#define HAVE_RB_GC_GUARDED_PTR 1 +volatile VALUE *rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val); +#define HAVE_RB_GC_GUARDED_PTR_VAL 1 +#define RB_GC_GUARD(v) (*rb_gc_guarded_ptr_val(&(v),(v))) #endif #define RB_GC_GUARD_PTR(ptr) rb_gc_guarded_ptr(ptr) #endif + +#ifndef RB_GC_GUARD #define RB_GC_GUARD(v) (*RB_GC_GUARD_PTR(&(v))) +#endif #ifdef __GNUC__ #define RB_UNUSED_VAR(x) x __attribute__ ((unused)) ------------------------------8<--------------------------- If you prefer git pull: git pull git://80x24.org/ruby.git gc-guard-harder-v2 Maybe my original idea works, too, but it is weaker, I think: git pull git://80x24.org/ruby.git gc-guard-harder http://bogomips.org/ruby.git/patch?id=ecc6f50ca