RFR: 8248609: [Graal] vmTestbase/nsk/jdi/VoidValue/toString/tostring001/TestDescription.java failed with Unexpected com.sun.jdi.ObjectCollectedException

Chris Plummer cjplummer at openjdk.org
Thu Jul 18 18:55:42 UTC 2024


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.

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

Commit messages:
 - call disableCollection() on allocated object so it is not collected during the invokeMethod() call

Changes: https://git.openjdk.org/jdk/pull/20242/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20242&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8248609
  Stats: 5 lines in 1 file changed: 5 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/20242.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20242/head:pull/20242

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


More information about the serviceability-dev mailing list