ruby-changes:35296
From: nagachika <ko1@a...>
Date: Thu, 4 Sep 2014 00:47:59 +0900 (JST)
Subject: [ruby-changes:35296] nagachika:r47378 (ruby_2_1): merge revision(s) r47217: [Backport #10062]
nagachika 2014-09-04 00:47:46 +0900 (Thu, 04 Sep 2014) New Revision: 47378 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47378 Log: merge revision(s) r47217: [Backport #10062] * ext/thread/thread.c (get_array): check instance variables are initialized properly. [ruby-core:63826][Bug #10062] 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/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 47377) +++ ruby_2_1/ChangeLog (revision 47378) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Thu Sep 4 00:31:23 2014 Nobuyoshi Nakada <nobu@r...> + + * ext/thread/thread.c (get_array): check instance variables are + initialized properly. [ruby-core:63826][Bug #10062] + Thu Sep 4 00:29:10 2014 Nobuyoshi Nakada <nobu@r...> * io.c (rb_io_initialize): [DOC] fix rdoc of append mode. it does Index: ruby_2_1/ext/thread/thread.c =================================================================== --- ruby_2_1/ext/thread/thread.c (revision 47377) +++ ruby_2_1/ext/thread/thread.c (revision 47378) @@ -11,15 +11,25 @@ enum { https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/thread/thread.c#L11 SZQUEUE_MAX = 3 }; -#define GET_CONDVAR_WAITERS(cv) RSTRUCT_GET((cv), CONDVAR_WAITERS) +#define GET_CONDVAR_WAITERS(cv) get_array((cv), CONDVAR_WAITERS) -#define GET_QUEUE_QUE(q) RSTRUCT_GET((q), QUEUE_QUE) -#define GET_QUEUE_WAITERS(q) RSTRUCT_GET((q), QUEUE_WAITERS) -#define GET_SZQUEUE_WAITERS(q) RSTRUCT_GET((q), SZQUEUE_WAITERS) +#define GET_QUEUE_QUE(q) get_array((q), QUEUE_QUE) +#define GET_QUEUE_WAITERS(q) get_array((q), QUEUE_WAITERS) +#define GET_SZQUEUE_WAITERS(q) get_array((q), SZQUEUE_WAITERS) #define GET_SZQUEUE_MAX(q) RSTRUCT_GET((q), SZQUEUE_MAX) #define GET_SZQUEUE_ULONGMAX(q) NUM2ULONG(GET_SZQUEUE_MAX(q)) static VALUE +get_array(VALUE obj, int idx) +{ + VALUE ary = RSTRUCT_GET(obj, idx); + if (!RB_TYPE_P(ary, T_ARRAY)) { + rb_raise(rb_eTypeError, "%+"PRIsVALUE" not initialized", obj); + } + return ary; +} + +static VALUE ary_buf_new(void) { return rb_ary_tmp_new(1); Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 47377) +++ ruby_2_1/version.h (revision 47378) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-09-04" -#define RUBY_PATCHLEVEL 221 +#define RUBY_PATCHLEVEL 222 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 Index: ruby_2_1/test/thread/test_queue.rb =================================================================== --- ruby_2_1/test/thread/test_queue.rb (revision 47377) +++ ruby_2_1/test/thread/test_queue.rb (revision 47378) @@ -5,6 +5,18 @@ require 'timeout' https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/thread/test_queue.rb#L5 require_relative '../ruby/envutil' class TestQueue < Test::Unit::TestCase + def test_queue_initialized + assert_raise(TypeError) { + Queue.allocate.push(nil) + } + end + + def test_sized_queue_initialized + assert_raise(TypeError) { + SizedQueue.allocate.push(nil) + } + end + def test_queue grind(5, 1000, 15, Queue) end Index: ruby_2_1/test/thread/test_cv.rb =================================================================== --- ruby_2_1/test/thread/test_cv.rb (revision 47377) +++ ruby_2_1/test/thread/test_cv.rb (revision 47378) @@ -4,6 +4,12 @@ require 'tmpdir' https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/thread/test_cv.rb#L4 require_relative '../ruby/envutil' class TestConditionVariable < Test::Unit::TestCase + def test_initialized + assert_raise(TypeError) { + ConditionVariable.allocate.wait(nil) + } + end + def test_condvar_signal_and_wait mutex = Mutex.new condvar = ConditionVariable.new Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r47217 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/