Project

General

Profile

Actions

Bug #20907

closed

Fiber scheduler does not correctly re-lock mutex if `Mutex#sleep` is interrupted.

Added by ioquatix (Samuel Williams) 28 days ago. Updated 22 days ago.

Status:
Closed
Target version:
-
[ruby-core:119998]

Description

The following test fails with a ThreadError instead of a RuntimeError:

  def test_condition_variable
    condition_variable = ::Thread::ConditionVariable.new
    mutex = ::Thread::Mutex.new

    error = nil

    thread = Thread.new do
      Thread.current.report_on_exception = false

      scheduler = Scheduler.new
      Fiber.set_scheduler scheduler

      fiber = Fiber.schedule do
        begin
          mutex.synchronize do
            condition_variable.wait(mutex)
          end
        rescue => error
        end
      end

      fiber.raise(RuntimeError)
    end

    thread.join
    assert_kind_of RuntimeError, error
  end

Fix: https://github.com/ruby/ruby/pull/12158

Actions

Also available in: Atom PDF

Like0
Like0Like0