summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 02:00:19 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 02:00:19 +0000
commitb1a18cf49bc475e6c563f55b23fa36594d70f4bc (patch)
tree0dc0c659cd7a5cfd335118f1c263978277fa6d35
parent8079f8a6f25bd1e6ef9fa0bff569a850c31c6fb3 (diff)
* thread.c (thread_join): raises ThreadError if target therad
is a main thread. * test/ruby/test_thread.rb (test_thread_join_main_thread): test for the above. * NEWS: news for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--NEWS2
-rw-r--r--test/ruby/test_thread.rb8
-rw-r--r--thread.c3
4 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index fea153073e..79815d9076 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Nov 27 09:29:11 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * thread.c (thread_join): raises ThreadError if target therad
+ is a main thread.
+ * test/ruby/test_thread.rb (test_thread_join_main_thread):
+ test for the above.
+ * NEWS: news for the above.
+
Tue Nov 27 09:24:47 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* thread.c (thread_join): raises ThreadError if target thread
diff --git a/NEWS b/NEWS
index 7417fb0824..269fcbe2b6 100644
--- a/NEWS
+++ b/NEWS
@@ -160,7 +160,7 @@ with all sufficient information, see the ChangeLog file.
* incompatible changes:
* Thread#join no longer allows to be used from trap handler. Now it raises
ThreadError.
- * Thread#join raises ThreadError if target therad is a current thread.
+ * Thread#join raises ThreadError if target therad is a current or main thread.
* Time
* change return value:
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 95f2c89db4..fb2efec552 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -881,4 +881,12 @@ class TestThreadGroup < Test::Unit::TestCase
Thread.current.join
end
end
+
+ def test_thread_join_main_thread
+ assert_raises(ThreadError) do
+ Thread.new(Thread.current) {|t|
+ t.join
+ }.join
+ end
+ end
end
diff --git a/thread.c b/thread.c
index cdba4a2106..5214c68955 100644
--- a/thread.c
+++ b/thread.c
@@ -739,6 +739,9 @@ thread_join(rb_thread_t *target_th, double delay)
if (th == target_th) {
rb_raise(rb_eThreadError, "Target thread must not be current thread");
}
+ if (GET_VM()->main_thread == target_th) {
+ rb_raise(rb_eThreadError, "Target thread must not be main thread");
+ }
arg.target = target_th;
arg.waiting = th;