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

Fix for JDK-8255987 can be subverted with ObjectReference.EnableCollection



    • Bug
    • Resolution: Fixed
    • P5
    • 19
    • 16
    • core-svc
    • b07


      The fix for JDK-8255987 prevents objects from being GC'd while under a "suspend all". This was done to honor the spirit of the following wording in the spec, which is now somewhat obsolete now that collections can happen even when all threads are suspended.

      "Note that while the target VM is suspended, no garbage collection will occur because all threads are suspended."

      It does this by increasing the strongCount of each tracked object when under a "suspend all". This increasing of the strongCount is indistinguishable from doing the same when using ObjectReference.DisableCollection. As a result, performing an ObjectReference.EnableCollection will undo this strongCount increment, allowing the object to be GC'd while still under a "suspend all". I don't think this was the intent of the fix, and should be prevented with an added restriction that strongCount cannot be decremented from 1 to 0 if the global pinAllCount is > 0.

      Note this is only an issue at the JDWP layer. It cannot be reproduced by using JDI ObjectReference.enableCollection() during a "suspend all". This is because JDI keeps a gcDisableCount on the debugger side for each ObjectReference, and only issues a JDWP ObjectReference.EnableCollection when the count transitions from 1 to 0 (oddly it does not protect the count from going negative).

      Note that the fix for JDK-8269542 will also end up addressing this issue.


        Issue Links



              cjplummer Chris Plummer
              cjplummer Chris Plummer
              0 Vote for this issue
              5 Start watching this issue