Project

General

Profile

Actions

Bug #14998

closed

Race conditions in MonitorMixin when interrupted

Added by Eregon (Benoit Daloze) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-08-16 trunk 64394) [x86_64-linux]
[ruby-core:88502]

Description

From https://bugs.ruby-lang.org/issues/14859#note-9

The code of MonitorMixin#wait is:

    def wait(timeout = nil)
      @monitor.__send__(:mon_check_owner)
      count = @monitor.__send__(:mon_exit_for_cond)
      begin
        @cond.wait(@monitor.instance_variable_get(:@mon_mutex), timeout)
        return true
      ensure
        # What if Thread#raise happens here?
        @monitor.__send__(:mon_enter_for_cond, count)
      end
    end

Probably this code needs to carefully use Thread.handle_interrupt.

Actions

Also available in: Atom PDF

Like0
Like0Like0