RFR: 8255987: JDI tests fail with com.sun.jdi.ObjectCollectedException

Per Liden pliden at openjdk.java.net
Mon Dec 7 11:00:15 UTC 2020


On Mon, 7 Dec 2020 05:14:36 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Another options is to save away the weakref in the node when strengthening. This would benefit `ObjectReference.disableCollection()` also, since it would no longer need to deal with a potential OOM. However, I'm not so sure it's actually worth doing. Trying to keep the debug session alive will having allocation errors is probably a fools errand.
>
> I agree a fatal error here seems excessive. Simply maintaining the strong ref seems reasonable.

I was trying to mimic what we already do in `strengthenNode()`, i.e. it's a fatal error if we can't create a JNI ref. Here:

        strongRef = JNI_FUNC_PTR(env,NewGlobalRef)(env, node->ref);
        /*
         * NewGlobalRef on a weak ref will return NULL if the weak
         * reference has been collected or if out of memory.
         * It never throws OOM.
         * We need to distinguish those two occurrences.
         */
        if ((strongRef == NULL) && !isSameObject(env, node->ref, NULL)) {
            EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"NewGlobalRef");
        }

So it seems appropriate to do the same thing if we fail to create a JNI weak ref. Also, as @plummercj mentioned, if we can't create a JNI ref, continuing the debug session seems rather pointless as we're about to go down anyway (the next allocation in the JVM will be fatal).

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

PR: https://git.openjdk.java.net/jdk/pull/1595



More information about the hotspot-gc-dev mailing list