On Thu, 18 Jul 2024 18:50:48 GMT, Chris Plummer <[email protected]> wrote:
> The test is failing with an ObjectCollectedException. The test hits a
> SUSPEND_ALL breakpoint. It then uses JDI to allocate an Object on the
> debuggee side:
>
> testedObject = testedClass.newInstance(thread, ctor, params, 0);
>
> Since we are under a SUSPEND_ALL, the object is not initially at risk of
> getting GC'd. However, the test then calls invokeMethod() in a loop:
>
> if (method.isStatic()) {
> voidValue = (VoidValue) testedClass.invokeMethod(thread,
> method, params, 0);
> } else {
> voidValue = (VoidValue) testedObject.invokeMethod(thread,
> method, params, 0);
> }
>
> On the first iteration of the loop, invokeMethod() will do a resumeAll() so
> it can execute the method on the specified thread. During this time a GC can
> happen, and that GC is likely to collect the object that testedObject is
> mirroring since it is only weakly kept alive. Then on a subsequent iteration
> of the loop, testedObject.invokeMethod() is called again, but this time you
> get the ObjectCollectedException because the object that testedObject is
> mirroring has been collected. The test needs to add a call to
> testedObject.disableCollection() to prevent it from being collected.
>
> I'm not able to reproduce this failure, but the bug is pretty clear. Testing
> is in progress. I'll run tier1 CI and also tier2 and tier5 test tasks that
> run this test.
Thank you for the reviews Alex and Leonid!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20242#issuecomment-2240267099