Project

General

Profile

Bug #15992

An exception breaks monitor state and cause deadlock

Added by naruse (Yui NARUSE) about 1 month ago. Updated 1 day ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
[ruby-core:93652]

Description

lib/monitor.rb provides Monitor.
But its state handling is weak for interrupts caused by Thread.kill for example timeout libraries.

Timeout exception may happen everywhere. If it raised when the thread is executing

  def mon_exit
    mon_check_owner
    @mon_count -=1
    if @mon_count == 0
      @mon_owner = nil
      # HERE!!!
      @mon_mutex.unlock
    end
  end

It breaks the state of the monitor and it causes deadlock.

Associated revisions

Revision f91879a7
Added by naruse (Yui NARUSE) about 1 month ago

handle_interrupt to defend monitor state [Bug #15992]

If an exception is raised from another thread for example Timeout
and this thread is just after mon_exit's @mon_owner = nil,
the exception breaks the state of MonitorMixin. To prevent that situation,
it need to block interruption in mon_enter and mon_exit.

Revision 9ab43c7a
Added by nagachika (Tomoyuki Chikanaga) 1 day ago

merge revision(s) f91879a7b548284c93743168acfd11e3d2aeefac: [Backport #15992]

    handle_interrupt to defend monitor state [Bug #15992]

    If an exception is raised from another thread for example Timeout
    and this thread is just after `mon_exit`'s `@mon_owner = nil`,
    the exception breaks the state of MonitorMixin. To prevent that situation,
    it need to block interruption in mon_enter and mon_exit.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 67742
Added by nagachika (Tomoyuki Chikanaga) 1 day ago

merge revision(s) f91879a7b548284c93743168acfd11e3d2aeefac: [Backport #15992]

handle_interrupt to defend monitor state [Bug #15992]

If an exception is raised from another thread for example Timeout
and this thread is just after `mon_exit`'s `@mon_owner = nil`,
the exception breaks the state of MonitorMixin. To prevent that situation,
it need to block interruption in mon_enter and mon_exit.

History

#1

Updated by naruse (Yui NARUSE) about 1 month ago

  • Status changed from Open to Closed

Applied in changeset git|f91879a7b548284c93743168acfd11e3d2aeefac.


handle_interrupt to defend monitor state [Bug #15992]

If an exception is raised from another thread for example Timeout
and this thread is just after mon_exit's @mon_owner = nil,
the exception breaks the state of MonitorMixin. To prevent that situation,
it need to block interruption in mon_enter and mon_exit.

Updated by nagachika (Tomoyuki Chikanaga) 1 day ago

  • Backport changed from 2.5: REQUIRED, 2.6: REQUIRED to 2.5: REQUIRED, 2.6: DONE

ruby_2_6 r67742 merged revision(s) f91879a7b548284c93743168acfd11e3d2aeefac.

Also available in: Atom PDF