1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

thread.c: undumpable

* ext/thread/thread.c (undumpable): ConditionVariable and Queue
  are not dumpable.  [ruby-core:61677] [Bug #9674]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-03-26 02:20:26 +00:00
parent f3867e2203
commit 1dd527012b
4 changed files with 35 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Wed Mar 26 11:20:24 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/thread/thread.c (undumpable): ConditionVariable and Queue
are not dumpable. [ruby-core:61677] [Bug #9674]
Wed Mar 26 10:36:39 2014 NARUSE, Yui <naruse@ruby-lang.org>
* addr2line.c (follow_debuglink): show message if it closes opened

View file

@ -534,6 +534,13 @@ rb_szqueue_num_waiting(VALUE self)
#define UNDER_THREAD 1
#endif
static VALUE
undumpable(VALUE obj)
{
rb_raise(rb_eTypeError, "can't dump %"PRIsVALUE, rb_obj_class(obj));
UNREACHABLE;
}
void
Init_thread(void)
{
@ -573,12 +580,14 @@ Init_thread(void)
rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0);
rb_undef_method(rb_cConditionVariable, "initialize_copy");
rb_define_method(rb_cConditionVariable, "marshal_dump", undumpable, 0);
rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, -1);
rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0);
rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0);
rb_define_method(rb_cQueue, "initialize", rb_queue_initialize, 0);
rb_undef_method(rb_cQueue, "initialize_copy");
rb_define_method(rb_cQueue, "marshal_dump", undumpable, 0);
rb_define_method(rb_cQueue, "push", rb_queue_push, 1);
rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1);
rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0);

View file

@ -196,4 +196,12 @@ INPUT
condvar.dup
end
end
def test_dump
bug9674 = '[ruby-core:61677] [Bug #9674]'
condvar = ConditionVariable.new
assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do
Marshal.dump(condvar)
end
end
end

View file

@ -215,4 +215,17 @@ class TestQueue < Test::Unit::TestCase
q.dup
end
end
def test_dump
bug9674 = '[ruby-core:61677] [Bug #9674]'
q = Queue.new
assert_raise_with_message(TypeError, /#{Queue}/, bug9674) do
Marshal.dump(q)
end
sq = SizedQueue.new(1)
assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do
Marshal.dump(sq)
end
end
end