From: Eric Wong <normalperson@...> Date: 2014-02-14T10:07:12+00:00 Subject: [ruby-core:60730] Re: [ruby-trunk - Bug #7805][Open] ruby 2.0rc2 core on solaris The following should work without RB_GC_GUARD nor volatile. I plan to commit unless there are objections, I see no possible way for a compiler to mess things up: --- a/marshal.c +++ b/marshal.c @@ -950,7 +950,7 @@ marshal_dump(int argc, VALUE *argv) VALUE obj, port, a1, a2; int limit = -1; struct dump_arg *arg; - volatile VALUE wrapper; + VALUE wrapper; /* used to avoid memory leak in case of exception */ port = Qnil; rb_scan_args(argc, argv, "12", &obj, &a1, &a2); @@ -964,7 +964,7 @@ marshal_dump(int argc, VALUE *argv) else if (NIL_P(a1)) io_needed(); else port = a1; } - RB_GC_GUARD(wrapper) = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg); + wrapper = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg); arg->dest = 0; arg->symbols = st_init_numtable(); arg->data = st_init_numtable(); @@ -993,8 +993,8 @@ marshal_dump(int argc, VALUE *argv) rb_io_write(arg->dest, arg->str); rb_str_resize(arg->str, 0); } - clear_dump_arg(arg); - RB_GC_GUARD(wrapper); + free_dump_arg(arg); + rb_gc_force_recycle(wrapper); /* also guards from premature GC */ return port; } @@ -1957,7 +1957,7 @@ marshal_load(int argc, VALUE *argv) VALUE port, proc; int major, minor, infection = 0; VALUE v; - volatile VALUE wrapper; + VALUE wrapper; /* used to avoid memory leak in case of exception */ struct load_arg *arg; rb_scan_args(argc, argv, "11", &port, &proc); @@ -1973,7 +1973,7 @@ marshal_load(int argc, VALUE *argv) else { io_needed(); } - RB_GC_GUARD(wrapper) = TypedData_Make_Struct(rb_cData, struct load_arg, &load_arg_data, arg); + wrapper = TypedData_Make_Struct(rb_cData, struct load_arg, &load_arg_data, arg); arg->infection = infection; arg->src = port; arg->offset = 0; @@ -2004,8 +2004,8 @@ marshal_load(int argc, VALUE *argv) if (!NIL_P(proc)) arg->proc = proc; v = r_object(arg); - clear_load_arg(arg); - RB_GC_GUARD(wrapper); + free_load_arg(arg); + rb_gc_force_recycle(wrapper); /* also guards from premature GC */ return v; } --- http://bogomips.org/ruby.git/patch/?id=e9f200e99 The following changes since commit 4d33c0e965a1ccce82f7e26a0ef21fef6bef3d2b: * vm_insnhelper.c (vm_call_method): should check ci->me->flag of a refining method in case the method is private. [ruby-core:60111] [Bug #9452] (2014-02-13 14:44:41 +0000) are available in the git repository at: git://80x24.org/ruby.git marshal-force_recycle for you to fetch changes up to e9f200e99bc58894971f51b41825b8fac8e28572: marshal.c: use rb_gc_force_recycle for GC-safety (2014-02-14 09:46:54 +0000) ---------------------------------------------------------------- Eric Wong (1): marshal.c: use rb_gc_force_recycle for GC-safety marshal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)