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

Ensure Cleaner.Cleanable instance is not reclaimed until cleaning is complete

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
      None

      Description

      The java.lang.ref.Cleaner maintains Cleaner.Cleanable, a subclass of PhantomReference referring to an object and the corresponding cleaning function.
      The Cleanable instances are visible to and retained by clients of the Cleaner.
      It should be possible to observe the existence of the Cleanable to know whether the cleaning function has yet to be performed.

      A race condition may exist in the processing of the Cleanable when it is removed from the ReferenceQueue that might indicate the cleaning function has been completed, while it is still in progress.

      The race is between the garbage collector and the CleanerImpl.
      After the reference to the Cleanable is removed from the ReferenceQueue, the cleaning function is invoked. The garbage collector may determine that the Cleanable itself is no longer referenced (except perhaps by another Weak/Soft/ or PhantomReference) and reclaim it.

      jdk.internal.ref.CleanerImpl:144 should be a call to ReachabilityFence(ref) to keep it alive until the call to the cleaning function returns.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rriggs Roger Riggs
              Reporter:
              rriggs Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: