JDK-8242484 : Rework thread deletion during VM termination
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-10
  • Updated: 2020-04-30
  • Resolved: 2020-04-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b20Fixed
Related Reports
Relates :  
Description
The fix for JDK-8240918 had to deal with a problem when the thread terminating the VM had to be careful not to delete itself if it may be accessible from a local ThreadsList:

"To avoid this possible issue of deleting a JavaThread that called Thread::destroy_vm() while there are handshakers blocked in the handshake_turn_sem semaphore, I added a check to verify the JavaThread in question is not protected by some ThreadsList reference before attempting the delete it. In case it is protected, we need to at least clear the value for _thread_key to avoid possible infinite loops at thread exit (this can happen in Solaris). "

This worked but seemed somewhat awkward to me:

" At some point during the shutdown sequence the thread needs to be able to execute "process any pending handshake and mark this thread as no longer handshake-capable". But it is unclear how to achieve that at this time so I'm okay with deferring this to a future RFE."

I think a possible simple fix here is to have a variant of ThreadSMRSupport::smr_delete that blocks until it is safe to delete but doesn't do the delete. The destroying thread can call that early on before the termination safepoint and then safely delete itself later.  That will not only address this situation but also more generally allow greater flexibility in the thread termination protocol by allowing other actions to occur between the point where the thread becomes safe-to-delete and the actual deletion.
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/28cb7248e0f6 User: pchilanomate Date: 2020-04-21 17:51:57 +0000
21-04-2020