Backport #2240

returning from Monitor#synchronize causes 'ThreadError: killed thread' when no waiting thread is alive

Added by Hiroshi Nakamura over 2 years ago. Updated 10 months ago.

[ruby-core:26185]
Status:Closed Start date:10/21/2009
Priority:Normal Due date:
Assignee:Kirk Haines % Done:

100%

Category:-
Target version:-

Description

def test_killed_thread_in_synchronize
    ary = []
    queue = Queue.new
    t1 = Thread.start {
      queue.pop
      @monitor.synchronize {
        ary << :t1
      }
    }
    t2 = Thread.start {
      queue.pop
      @monitor.synchronize {
        ary << :t2
      }
    }
    @monitor.synchronize do
      queue.enq(nil)
      queue.enq(nil)
      assert_equal([], ary)
      t1.kill
      t2.kill
      ary << :main
    end
    assert_equal([:main], ary)
  end

Associated revisions

Revision 25420
Added by nahi over 2 years ago

* lib/monitor.rb (MonitorMixin.mon_release): ensure the scheduled thread to be alive when a thread is releasing a monitor. #2240

Revision 28232
Added by wyhaines over 1 year ago

lib/monitor.rb: Backport #2240 [ruby-core:26185]; backport r25420 to ensure that the scheduled thread is alive when a monitor is released. test/monitor/test_monitor.rb: Backport #2240 [ruby-core:26185]; added a test for the above functionality.

History

Updated by Hiroshi Nakamura over 2 years ago

NOTE: 1.9 (ruby 1.9.2dev (2009-10-20 trunk 25411) [i686-linux]) is safe.

Updated by Hiroshi Nakamura over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r25420.
Hiroshi, thank you for your reporting of the issue.
You have greatfully contributed toward Ruby.
May Ruby be with you.

Updated by Hiroshi Nakamura over 2 years ago

Title must be '... when the scheduled thread is not alive' as you see the fix.

Updated by Shyouhei Urabe about 2 years ago

  • Status changed from Closed to Assigned
  • Assignee set to Kirk Haines
1.8.6 also fails on this test case.

Updated by Kirk Haines over 1 year ago

  • Status changed from Assigned to Closed
This issue was solved with changeset r28232.
Hiroshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Also available in: Atom PDF