diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2021-06-14 17:56:53 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 17:56:53 +1200 |
commit | 050a89543952a2c9e7c9bc938f4fdb538f6c9278 (patch) | |
tree | 892fdfcf5188842ca6ae4e176a57284aa2a1e0b0 /test/fiber/test_thread.rb | |
parent | 626427c2e0f886ff8353c5faa8254699afd88ca8 (diff) | |
download | ruby-050a89543952a2c9e7c9bc938f4fdb538f6c9278.tar.gz |
Wake up join list within thread EC context. (#4471)
* Wake up join list within thread EC context.
* Consume items from join list so that they are not re-executed.
If `rb_fiber_scheduler_unblock` raises an exception, it can result in a
segfault if `rb_threadptr_join_list_wakeup` is not within a valid EC. This
change moves `rb_threadptr_join_list_wakeup` into the thread's top level EC
which initially caused an infinite loop because on exception will retry. We
explicitly remove items from the thread's join list to avoid this situation.
* Verify the required scheduler interface.
* Test several scheduler hooks methods with broken `unblock` implementation.
Diffstat (limited to 'test/fiber/test_thread.rb')
-rw-r--r-- | test/fiber/test_thread.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/fiber/test_thread.rb b/test/fiber/test_thread.rb index 5fc80f0e6c..b7323d7237 100644 --- a/test/fiber/test_thread.rb +++ b/test/fiber/test_thread.rb @@ -42,4 +42,24 @@ class TestFiberThread < Test::Unit::TestCase assert_equal :done, thread.value end + + def test_broken_unblock + thread = Thread.new do + Thread.current.report_on_exception = false + + scheduler = BrokenUnblockScheduler.new + + Fiber.set_scheduler scheduler + + Fiber.schedule do + Thread.new{}.join + end + + scheduler.run + end + + assert_raise(RuntimeError) do + thread.join + end + end end |