Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JITServer client does not acquire correct monitors for local compilation following remote compilation #19975

Closed
cjjdespres opened this issue Aug 7, 2024 · 0 comments · Fixed by #20002

Comments

@cjjdespres
Copy link
Contributor

While looking at #14755, I managed to build JDK21 in debug mode (after commenting out various asserts that would cause the JDK to fail to build). I got one assert to fire that should be fixed, though it's not the cause of that test failure.

The failing assert is:

Assertion failed at /home/despresc/dev/testing/openj9-openjdk-jdk21/openj9/runtime/compiler/infra/J9MonitorTable.cpp:255: false
VMState: 0x00050080
	comp thread 1 does not have classUnloadMonitor

What happens is here:

if ((rtn = compiler->compile()) != COMPILATION_SUCCEEDED)

we compile locally following a remote compilation (since I enabled enableJITServerFollowRemoteCompileWithLocalCompile for a particular method), and this eventually calls some frontend method (TR_J9VMBase::isInvokeCacheEntryAnArray in this case) during IL generation that tries to enter a TR::VMAccessCriticalSection::VMAccessCriticalSection, which eventually asserts if it finds that the thread hasn't acquired a class unload monitor.

Judging from this bit of the code just before a local compilation starts:

// If we want to compile without VM access, now it's the time to release it
// For the JITClient we must not enter this path. The class unload monitor
// will not be acquired/released and we'll only release VMaccess when
// waiting for a reply from the server
if (!compiler->getOption(TR_DisableNoVMAccess) &&
!_methodBeingCompiled->_aotCodeToBeRelocated &&
!_methodBeingCompiled->isRemoteCompReq())
{
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
bool doAcquireClassUnloadMonitor = true;
#else
bool doAcquireClassUnloadMonitor = compiler->getOption(TR_EnableHCR) || compiler->getOption(TR_FullSpeedDebug);
#endif
if (doAcquireClassUnloadMonitor)
{
_compInfo.debugPrint(NULL, "\tcompilation thread acquiring class unload monitor\n");
TR::MonitorTable::get()->readAcquireClassUnloadMonitor(getCompThreadId());
haveLockedClassUnloadMonitor = true;
}
releaseVMAccess(vmThread);
// GC can go ahead now.
}

I think we should be acquiring the class unload monitor just before we release vm access before our local-following-remote compilation in the JIT client compilation thread code.

@mpirvu Does that seem right to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant