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

Make panama memory segment close use async handshakes

    XMLWordPrintable

Details

    • b26

    Description

      When a thread T closes a shared arena, the following operations are performed:

      1. check that the session is still alive
      2. put the session in the CLOSING state - from this point on, any subsequent attempt to access the segment will throw ISE (because MemorySession::checkValidState will fail - assuming they see the new value)
      3. start the thread-local handshake. Two outcomes are possible:
        a) If the handshake succeeds (no threads are found accessing the segments) the session moves to CLOSED;
        b) Otherwise, the session is put back into the ALIVE state (which means that subsequent accesses will succeed again!)

      This logic is problematic, as it is possible for accessing threads to observe IllegalStateException, and then to see that the scope of the accessed segment is still alive!

      We have attempted to fix this in JDK-8282061. Unfortunately that fix had issues and was backed out: on Windows especially, it seems like the thread scheduler was uncooperative, and threads that should make progress (by detecting that the scope is no longer alive, and then bailout) were never executed, which resulted in the `close` operation stalling.

      Closing panama memory segments should use async handshakes so that we can guarantee progress, while also alleviating from users handling failures to close.

      Attachments

        Issue Links

          Activity

            People

              eosterlund Erik Ă–sterlund
              eosterlund Erik Ă–sterlund
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: