8000 Race condition during JVMTI shutdown results in rare GPF or other Program Error · Issue #21704 · eclipse-openj9/openj9 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Race condition during JVMTI shutdown results in rare GPF or other Program Error #21704
Open
@jjohnst-us

Description

@jjohnst-us

No diagnostics are available for this issue, furthermore the issue will be very hard to reproduce unless running on the z/TPF platform. The primary reason is how the z/TPF scheduler works compared to other platforms in that it drives different timing scenarios.

However, the good news is the general problem area has been identified. Below are the two areas that require some kind of synchronization.

while (nativeLibrary != NULL) {
callback(currentThread, nativeMethod, nativeLibrary, longJNI, shortJNI, functionArgCount, TRUE);
if (J9_NATIVE_METHOD_IS_BOUND(nativeMethod)) {
goto done;
}
nativeLibrary = nativeLibrary->next;
}

if (jvmtiData->agentLibraries != NULL) {
PORT_ACCESS_FROM_JAVAVM(vm);
J9JVMTIAgentLibrary * agentLibrary;
pool_state state;
agentLibrary = pool_startDo(jvmtiData->agentLibraries, &state);
while(agentLibrary) {
if (agentLibrary->nativeLib.handle != 0) {
void (JNICALL * onUnload)(J9JavaVM *);
/* If the agent was loaded/attached through static linking, check for the
* presence of Agent_OnUnload_L. If this cannot be found, go on to look for
* Agent_OnUnload, or else invoke Agent_OnUnload_L.
*/
if (J9NATIVELIB_LINK_MODE_STATIC == agentLibrary->nativeLib.linkMode) {
j9str_printf(
nameBuffer,
sizeof(nameBuffer),
"%s_%s",
J9JVMTI_AGENT_ONUNLOAD,
agentLibrary->nativeLib.name);
} else /* J9NATIVELIB_LINK_MODE_DYNAMIC == linkMode */ {
strcpy(nameBuffer, J9JVMTI_AGENT_ONUNLOAD);
}
if (j9sl_lookup_name(agentLibrary->nativeLib.handle, nameBuffer, (void *) &onUnload, "VL") == 0) {
UDATA loadCount;
Trc_JVMTI_shutDownAgentLibraries_invokingAgentShutDown(nameBuffer);
for (loadCount = 0; loadCount < agentLibrary->loadCount; loadCount++) {
onUnload(vm);
}
}
if (closeLibrary && (agentLibrary->xRunLibrary == NULL)) {
j9sl_close_shared_library(agentLibrary->nativeLib.handle);
}
}
if (agentLibrary->xRunLibrary == NULL) {
j9mem_free_memory(agentLibrary->nativeLib.name);
}
/* Jazz 99339: release memory allocated for J9InvocationJavaVM in issueAgentOnLoadAttach() */
if (NULL != agentLibrary->invocationJavaVM) {
j9mem_free_memory(agentLibrary->invocationJavaVM);
agentLibrary->invocationJavaVM = NULL;
}
agentLibrary = pool_nextDo(&state);
}
pool_kill(jvmtiData->agentLibraries);
jvmtiData->agentLibraries = NULL;
}

The problem encountered is that the nativeLibrary linked list is in the middle of being cleaned up by JVMTI shutdown processing while simultaneously being accessed in jvmtiHook. The simultaneous access leads to undefined behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0