Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8369944

Notification can be lost due to interrupt in Object.wait

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • 26
    • 26
    • hotspot

      If a thread waiting in Object.wait is interrupted at the same time it is being notified, it could wake up, read node.TState as TS_ENTER but then read node._notified as false. There is no ordering in notify_internal() between setting iterator->_notified and setting iterator->TState to TS_ENTER.
      This means that WasNotified will be false and the thread will throw IE. But we missed a notification as per the JLS 17.2.4 specs:

      “Note that if a thread is both interrupted and woken via notify, and that thread returns from wait by throwing an InterruptedException, then some other thread in the wait set must be notified.”

      There is no need for _notified, since the value of node.TState can be already used to tell if the thread was notified or not.

            pchilanomate Patricio Chilano Mateo
            pchilanomate Patricio Chilano Mateo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: