RFR: 8367614: Test vmTestbase/nsk/jdi/stress/serial/heapwalking001/TestDescription.java failed, passed and timed-out

David Holmes dholmes at openjdk.org
Wed Sep 17 04:14:31 UTC 2025


On Wed, 17 Sep 2025 03:03:56 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

> This test has been silently throwing ObjectCollectedException probably but still passing. I believe it has always done this. The exception went unnoticed because it is caught and then setSuccess(false) is never called. It was finally noticed when this test failed due to a timeout (which seems to be a separate issue), and the ObjectCollectedException was noted in the log.
> 
> This PR fixes the setSuccess(false) call in a few places, including in one other test that didn't seem to be otherwise be failing.
> 
> The cause of the ObjectCollectedException is a test bug. The test is testing the following:
> 
>     // can't force collection of thread group because of 1 reference is always
>     // left in parent tread group
> 
> So it forces a GC and expects the ObjectReference it has for a ThreadGroup to still be alive. However, the above comment is incorrect. The ThreadGroup spec says:
> 
> "A thread group is weakly reachable from its parent group so that it is eligible for garbage collection when there are no live threads in the group and the thread group is otherwise unreachable. "
> 
> So this ThreadGroup is being collected, resulting in the ObjectCollectedException in the following code:
> 
>             for (ObjectReference objectReference : objectReferences)
>                 objectReference.referringObjects(0);
> 
> This part of the test is invalid and has been removed. I also slightly updated the rest of the test by forcing a gc earlier so we can verify that the ThreadGroup is collected.

Seems quite reasonable.

Thanks

-------------

Marked as reviewed by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27327#pullrequestreview-3232592556


More information about the serviceability-dev mailing list