-
Enhancement
-
Resolution: Fixed
-
P3
-
22
-
b26
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 inJDK-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.
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
Closing panama memory segments should use async handshakes so that we can guarantee progress, while also alleviating from users handling failures to close.
- duplicates
-
JDK-8319782 Use asynchronous handshake to support shared arena close
-
- Closed
-
- relates to
-
JDK-8321064 Test java/foreign/TestHandshake.java fails with IndexOutOfBoundsException
-
- Closed
-
-
JDK-8321066 Multiple JFR tests have started failing
-
- Closed
-
-
JDK-8319756 Missing volatile check for Scope::isAlive
-
- Closed
-
(1 links to)