Hi Chris,
On 19/10/2012 8:37 AM, Christian Thalinger wrote:
On Oct 18, 2012, at 3:31 PM, Mandy Chung<[email protected]> wrote:
Just curious - the test runs with a max of 10 GCs. You
reproduced this bug on a slower machine with fastdebug build.
If you increase the max number of GCs, I wonder how long
the test will take to complete/pass?
Around 14 GCs (runtime with -Xcomp approximately 40 seconds on that particular
machine).
With your fix, how many GC does it take to complete?
I suspect it's one.
Between 2 and 3 GCs.
I believe it takes two GC cycles to move a finalizable object into the
finalization queue.
I am guessing that the test might
want to test that the finalizers are being invoked during
GC and references are dequeued. I wonder if there is
another alternate fix instead of forcing the finalizers
to be run. Just a thought.
The fix was not my idea. I just picked the bug and tried the suggested fix and
it worked. The other suggested fix is to increase the sleep time (but I don't
like that).
The key here is what the test is trying to exercise. From this comment:
/* Cause a dummy object to be finalized, since the finalizer thread
might retain a reference to the Basic instance after it's been
finalized (this happens with java_g) */
we can see there is some intended interaction with the (primary)
finalizer thread. By calling runFinalization() we're introducing the
secondary finalizer thread and performing synchronous finalization -
which may (or may not) negate the intended interaction with the primary
finalizer thread.
There have been recent changes to other tests that require finalization
to basically add explicit loops testing a variable that is set by the
finalizer eg:
while (!obj.finalized) {
System.gc();
Thread.sleep(100);
}
It may be that this could be added to the ClearFinalizerThread object?
Unfortunately it can sometimes be very easy to "fix" these tests in a
way that negates the purpose of the test.
David
-- Chris
Mandy
On 10/18/2012 2:43 PM, Christian Thalinger wrote:
http://cr.openjdk.java.net/~twisti/6771058
6771058: TEST_BUG: java/lang/ref/Basic.java may fail with -server -Xcomp
Reviewed-by:
This test can fail if finalizer of Basic is not called for some
reason. It happens in compiled mode if compilation is more slow than
execution of the main loop.
The fix is to call System.runFinalization() after System.gc() to
ensure that finalizer is run.
test/java/lang/ref/Basic.java