From a6929d1d7e276184427d861797fff8cc7e9badb6 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 12 Sep 2013 17:11:50 +0000 Subject: [PATCH] merge revision(s) 42906: [Backport #8891] * thread.c (rb_mutex_unlock): Mutex#unlock no longer raise an exception even if uses on trap. [Bug #8891] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@42926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_thread.rb | 17 +++++++++++++++++ thread.c | 5 ----- version.h | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d15478fd4..7bdf546079 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Sep 13 01:44:54 2013 KOSAKI Motohiro + + * thread.c (rb_mutex_unlock): Mutex#unlock no longer raise + an exception even if uses on trap. [Bug #8891] + Fri Sep 13 01:09:59 2013 Shota Fukumori * vm_backtrace.c (vm_backtrace_to_ary): Ignore the second argument if diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 7913845da7..9cd55bcbed 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -877,6 +877,23 @@ Thread.new(Thread.current) {|mth| end end + def test_mutex_unlock_on_trap + assert_in_out_err([], <<-INPUT, %w(locked unlocked false), []) + m = Mutex.new + + Signal.trap("INT") { |signo| + m.unlock + puts "unlocked" + } + + m.lock + puts "locked" + Process.kill("INT", $$) + sleep 0.01 + puts m.locked? + INPUT + end + def invoke_rec script, vm_stack_size, machine_stack_size, use_length = true env = {} env['RUBY_THREAD_VM_STACK_SIZE'] = vm_stack_size.to_s if vm_stack_size diff --git a/thread.c b/thread.c index 4c5a5e97a5..b2ec68a623 100644 --- a/thread.c +++ b/thread.c @@ -4425,11 +4425,6 @@ rb_mutex_unlock(VALUE self) rb_mutex_t *mutex; GetMutexPtr(self, mutex); - /* When running trap handler */ - if (!mutex->allow_trap && GET_THREAD()->interrupt_mask & TRAP_INTERRUPT_MASK) { - rb_raise(rb_eThreadError, "can't be called from trap context"); - } - err = rb_mutex_unlock_th(mutex, GET_THREAD()); if (err) rb_raise(rb_eThreadError, "%s", err); diff --git a/version.h b/version.h index c1cfaa40ed..9a91645c7b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-09-13" -#define RUBY_PATCHLEVEL 308 +#define RUBY_PATCHLEVEL 309 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 9