diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-26 02:20:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-26 02:20:26 +0000 |
commit | 1dd527012b5da0f7d84986a201c3b7f834adef78 (patch) | |
tree | 0f0fa30635fe967a05a490e407c600f173e51e3d | |
parent | f3867e2203738c0ef5907e6b4251e780daa075c2 (diff) | |
download | ruby-1dd527012b5da0f7d84986a201c3b7f834adef78.tar.gz |
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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/thread/thread.c | 9 | ||||
-rw-r--r-- | test/thread/test_cv.rb | 8 | ||||
-rw-r--r-- | test/thread/test_queue.rb | 13 |
4 files changed, 35 insertions, 0 deletions
@@ -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 diff --git a/ext/thread/thread.c b/ext/thread/thread.c index cec8a5b4fa..38b8a8c4e7 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -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); diff --git a/test/thread/test_cv.rb b/test/thread/test_cv.rb index 92179e8e45..bb0bcb8685 100644 --- a/test/thread/test_cv.rb +++ b/test/thread/test_cv.rb @@ -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 diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 6d527ad68c..b3662742c1 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -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 |