RFR: 8308764: Reporting errors from create_vm may crash
David Holmes
dholmes at openjdk.org
Fri Jun 2 01:23:05 UTC 2023
On Thu, 1 Jun 2023 15:18:02 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> src/hotspot/share/runtime/threads.cpp line 552:
>>
>>> 550: if (status != JNI_OK) {
>>> 551: // Don't delete main_thread here as we may need to report exceptions.
>>> 552: *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
>>
>> So could the jni code try to create a vm, fail and then go on to do other stuff? Would this then be a memory leak?
>
> maybe this should be a if (!HAS_PENDING_EXCEPTION) main_thread->smr_delete(); and then in the caller will exit with vm_exit_during_initialization() which does exit() so not necessary to delete the main thread.
> Would this then be a memory leak?
Yes but at this point we are "leaking everything that VM initialization created but does not clean up. So adding a JavaThread instance to that seems insignificant.
> maybe this should be a if (!HAS_PENDING_EXCEPTION) main_thread->smr_delete();
That would work too. I can make that switch.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14238#discussion_r1213820157
More information about the hotspot-runtime-dev
mailing list