diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-09-20 13:29:24 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-09-20 13:35:39 +0200 |
commit | 6987c8997e6cd8f45bbd7ece6582c0024be0cc0f (patch) | |
tree | e4c29386daeb1e4179c8b5f180782cd511898b65 /test/fiber/test_mutex.rb | |
parent | 73a626c0789161911aa5753859c4a81ed2dfd999 (diff) |
Remove from waiter in Mutex#lock with ensure when calling rb_scheduler_block()
* Previously this could lead to an invalid waiter entry and then trying
to wake up that waiter would result in various issues in rb_mutex_unlock_th().
Diffstat (limited to 'test/fiber/test_mutex.rb')
-rw-r--r-- | test/fiber/test_mutex.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/fiber/test_mutex.rb b/test/fiber/test_mutex.rb index a70c6992ab..258f5358a6 100644 --- a/test/fiber/test_mutex.rb +++ b/test/fiber/test_mutex.rb @@ -70,6 +70,38 @@ class TestFiberMutex < Test::Unit::TestCase thread.join end + def test_mutex_fiber_raise + mutex = Mutex.new + ran = false + + main = Thread.new do + mutex.lock + + thread = Thread.new do + scheduler = Scheduler.new + Thread.current.scheduler = scheduler + + f = Fiber.schedule do + assert_raise_with_message(RuntimeError, "bye") do + assert_same scheduler, Thread.scheduler + mutex.lock + end + ran = true + end + + Fiber.schedule do + f.raise "bye" + end + end + + thread.join + end + + main.join # causes mutex to be released + assert_equal false, mutex.locked? + assert_equal true, ran + end + def test_condition_variable mutex = Mutex.new condition = ConditionVariable.new |