Details
-
Bug
-
Resolution: Fixed
-
P5
-
16
-
b07
Description
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 forJDK-8269542 will also end up addressing this issue.
"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
Attachments
Issue Links
- relates to
-
JDK-8269542 JDWP: EnableCollection support is no longer spec compliant after JDK-8255987
- Resolved
-
JDK-8257921 Clarify JDI/JDWP specs with regards to object reachability and GC
- Open
-
JDK-8255987 JDI tests fail with com.sun.jdi.ObjectCollectedException
- Resolved