On Wed, 17 Sep 2025 03:03:56 GMT, Chris Plummer <[email protected]> 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.

This pull request has now been integrated.

Changeset: b8f2c738
Author:    Chris Plummer <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/b8f2c7387f4b5a60a6b671619d968d1d77aa9c27
Stats:     57 lines in 2 files changed: 12 ins; 34 del; 11 mod

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

Reviewed-by: dholmes, sspitsyn

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

PR: https://git.openjdk.org/jdk/pull/27327

Reply via email to