[jdk17] RFR: 8260684: vmTestbase/gc/gctests/PhantomReference/phantom002/TestDescription.java timed out
kbarrett at openjdk.java.net
Sun Jun 20 18:50:38 UTC 2021
Please review this fix of
to eliminate a race that can lead to the test very occasionally hanging and
eventually timing out.
When the referent being tested by a particular iteration is a finalizable
class, the test invoked eatMemory() repeatedly until the referent's
finalize() function set a flag, then called eatMemory() once more to cause
the reference to be cleared and notified. The problem with this is that
eatMemory() might trigger its GCs before the finalization thread has dropped
the referent, so the referent is still live and the reference has not been
cleared and notified afterward.
The testing thread then proceeds to wait for the reference to be notified.
This usually doesn't cause a problem because other threads will trigger
further GCs, and the finalization thread will eventually drop the object.
However, if the test is nearing completion and this situation arises in the
last thread running, it will wait forever for the notification that isn't
While investigating this issue I did a bunch of code cleanup (for example,
there was some really badly formatted code), refactoring, and commenting.
As a result, a large fraction of the test has changed, though mostly in ways
that don't affect it's function. The first of the two commits in the PR is
a whitespace-only cleanup. Excluding it may make reviewing easier.
Ran the phantom002 test a couple thousand times.
Using a modified version of the test, verified that the described problem
case actually occurs; that is, one eatMemory call is sometimes insufficient
to cause clearing of the reference because the referent is still live on the
- refactor and fix
- fix indentation
Stats: 95 lines in 1 file changed: 68 ins; 2 del; 25 mod
Fetch: git fetch https://git.openjdk.java.net/jdk17 pull/106/head:pull/106
More information about the hotspot-gc-dev