ruby-changes:34722
From: nagachika <ko1@a...>
Date: Sun, 13 Jul 2014 22:51:22 +0900 (JST)
Subject: [ruby-changes:34722] nagachika:r46805 (ruby_2_1): merge revision(s) r45423, r45424: [Backport #9674]
nagachika 2014-07-13 22:51:07 +0900 (Sun, 13 Jul 2014) New Revision: 46805 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46805 Log: merge revision(s) r45423,r45424: [Backport #9674] * ext/thread/thread.c (undumpable): ConditionVariable and Queue are not dumpable. [ruby-core:61677] [Bug #9674] * marshal.c (w_object): internal objects are not dumpable. [ruby-core:61677] [Bug #9674] Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/ext/thread/thread.c branches/ruby_2_1/marshal.c branches/ruby_2_1/test/thread/test_cv.rb branches/ruby_2_1/test/thread/test_queue.rb branches/ruby_2_1/version.h Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 46804) +++ ruby_2_1/ChangeLog (revision 46805) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Sun Jul 13 22:44:05 2014 Nobuyoshi Nakada <nobu@r...> + + * ext/thread/thread.c (undumpable): ConditionVariable and Queue + are not dumpable. [ruby-core:61677] [Bug #9674] + Fri Jul 11 23:07:09 2014 Marc-Andre Lafortune <ruby-core@m...> * lib/matrix.rb: Fix sign for cross_product [#9499] Index: ruby_2_1/ext/thread/thread.c =================================================================== --- ruby_2_1/ext/thread/thread.c (revision 46804) +++ ruby_2_1/ext/thread/thread.c (revision 46805) @@ -534,6 +534,13 @@ rb_szqueue_num_waiting(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/thread/thread.c#L534 #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) { @@ -572,11 +579,13 @@ Init_thread(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/thread/thread.c#L579 id_sleep = rb_intern("sleep"); rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0); + 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_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); Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 46804) +++ ruby_2_1/version.h (revision 46805) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-07-11" -#define RUBY_PATCHLEVEL 169 +#define RUBY_RELEASE_DATE "2014-07-13" +#define RUBY_PATCHLEVEL 170 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" Index: ruby_2_1/marshal.c =================================================================== --- ruby_2_1/marshal.c (revision 46804) +++ ruby_2_1/marshal.c (revision 46805) @@ -650,6 +650,11 @@ w_object(VALUE obj, struct dump_arg *arg https://github.com/ruby/ruby/blob/trunk/ruby_2_1/marshal.c#L650 else { VALUE v; + if (!RBASIC_CLASS(obj)) { + rb_raise(rb_eTypeError, "can't dump internal %s", + rb_builtin_type_name(BUILTIN_TYPE(obj))); + } + arg->infection |= (int)FL_TEST(obj, MARSHAL_INFECTION); if (rb_obj_respond_to(obj, s_mdump, TRUE)) { Index: ruby_2_1/test/thread/test_queue.rb =================================================================== --- ruby_2_1/test/thread/test_queue.rb (revision 46804) +++ ruby_2_1/test/thread/test_queue.rb (revision 46805) @@ -207,4 +207,24 @@ class TestQueue < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/thread/test_queue.rb#L207 timeout(1) { th2.join } end end + + (DumpableQueue = Queue.dup).class_eval {remove_method :marshal_dump} + + 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 + + q = DumpableQueue.new + assert_raise_with_message(TypeError, /internal Array/, bug9674) do + Marshal.dump(q) + end + end end Index: ruby_2_1/test/thread/test_cv.rb =================================================================== --- ruby_2_1/test/thread/test_cv.rb (revision 46804) +++ ruby_2_1/test/thread/test_cv.rb (revision 46805) @@ -188,4 +188,19 @@ INPUT https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/thread/test_cv.rb#L188 assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} } end + + (DumpableCV = ConditionVariable.dup).class_eval {remove_method :marshal_dump} + + def test_dump + bug9674 = '[ruby-core:61677] [Bug #9674]' + condvar = ConditionVariable.new + assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do + Marshal.dump(condvar) + end + + condvar = DumpableCV.new + assert_raise_with_message(TypeError, /internal Array/, bug9674) do + Marshal.dump(condvar) + end + end end Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r45423-45424 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/