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

[macos] java/awt/Toolkit/RealSync/Test.java occasionally crashes on macOS

XMLWordPrintable

      The test java/awt/Toolkit/RealSync/Test.java occasionally crashes on macOS. The crash occurs in [NSApplicationAWT sendEvent:] using seenDummyEventLock with value nil.

      I believe the source of the problem is that LWCToolkit.nativeSyncQueue is not thread safe. Here is an example of a possible sequence of events that could cause this problem:

      * thread1 postDummyEvent: creates condition lock #1 (condition NO), records timestamp #1, and posts event #1
      * thread1 waitForDummyEvent: waits for lock #1 condition to be YES or timeout
      * AppKit thread receives event #1 with timestamp #1, sets lock #1 condition to YES
      * thread2 postDummyEvent: creates condition lock #2 (condition NO), records timestamp #2 and posts event #2 [note that the condition lock #1 is now inaccessible and cannot be released]
      * thread2 waitForDummyEvent: waits for lock #2 condition to be YES or timeout
      * thread1 waitForDummyEvent: acquires lock #1 because the condition is YES
      * thread1 waitForDummyEvent: unlocks, releases lock #2 [using the global variable seenDummyEventLock] and sets seenDummyEventLock to nil
      * AppKit thread receives event with timestamp #2 — sendEvent: crashes because the global variable seenDummyEventLock is nil

            achung Alisen Chung
            alans Alan Snyder
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: