marshal.c: do not recycle wrapper objects
* marshal.c (marshal_dump, marshal_load): do not recycle wrapper objects, to prevent from segfault with continuation. [ruby-dev:47970] [Bug #9523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8ae07cf34b
commit
dd998dd561
@ -1,3 +1,9 @@
|
|||||||
|
Mon Feb 17 17:41:55 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* marshal.c (marshal_dump, marshal_load): do not recycle wrapper
|
||||||
|
objects, to prevent from segfault with continuation.
|
||||||
|
[ruby-dev:47970] [Bug #9523]
|
||||||
|
|
||||||
Mon Feb 17 15:43:59 2014 Zachary Scott <e@zzak.io>
|
Mon Feb 17 15:43:59 2014 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
* doc/keywords.rdoc: [DOC] Add keywords doc by documenting-ruby/ruby#29
|
* doc/keywords.rdoc: [DOC] Add keywords doc by documenting-ruby/ruby#29
|
||||||
|
@ -993,8 +993,8 @@ marshal_dump(int argc, VALUE *argv)
|
|||||||
rb_io_write(arg->dest, arg->str);
|
rb_io_write(arg->dest, arg->str);
|
||||||
rb_str_resize(arg->str, 0);
|
rb_str_resize(arg->str, 0);
|
||||||
}
|
}
|
||||||
free_dump_arg(arg);
|
clear_dump_arg(arg);
|
||||||
rb_gc_force_recycle(wrapper); /* also guards from premature GC */
|
RB_GC_GUARD(wrapper);
|
||||||
|
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
@ -2004,8 +2004,8 @@ marshal_load(int argc, VALUE *argv)
|
|||||||
|
|
||||||
if (!NIL_P(proc)) arg->proc = proc;
|
if (!NIL_P(proc)) arg->proc = proc;
|
||||||
v = r_object(arg);
|
v = r_object(arg);
|
||||||
free_load_arg(arg);
|
clear_load_arg(arg);
|
||||||
rb_gc_force_recycle(wrapper); /* also guards from premature GC */
|
RB_GC_GUARD(wrapper);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -611,4 +611,23 @@ class TestMarshal < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
assert_empty(tainted.map {|x| [x, x.class]}, bug8945)
|
assert_empty(tainted.map {|x| [x, x.class]}, bug8945)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Bug9523
|
||||||
|
attr_reader :cc
|
||||||
|
def marshal_dump
|
||||||
|
callcc {|c| @cc = c }
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
def marshal_load(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_continuation
|
||||||
|
require "continuation"
|
||||||
|
c = Bug9523.new
|
||||||
|
assert_raise_with_message(RuntimeError, /Marshal\.dump reentered at marshal_dump/) do
|
||||||
|
Marshal.dump(c)
|
||||||
|
c.cc.call
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user