Skip to content

JITServerSharedROMClassCache double-initialization after purging all client session data triggers assert #18631

Closed
@cjjdespres

Description

@cjjdespres

During a purge operation, the JITServer will delete client session data:

// Time for a purge operation.
// Scan the entire table and delete old elements that are not in use
for (auto iter = _clientSessionMap.begin(); iter != _clientSessionMap.end(); ++iter)
{
TR_ASSERT(iter->second->getInUse() >= 0, "_inUse=%d must be positive\n", iter->second->getInUse());
if (iter->second->getInUse() == 0 &&
crtTime - iter->second->getTimeOflastAccess() > oldAge)
{
if (TR::Options::getVerboseOption(TR_VerboseJITServer))
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "t=%u Server will purge session data for clientUID %llu of age %lld. Number of clients before purge: %u",
(uint32_t)_compInfo->getPersistentInfo()->getElapsedTime(), (unsigned long long)iter->first, (long long)oldAge, size());
ClientSessionData::destroy(iter->second); // delete the client data
_clientSessionMap.erase(iter); // delete the mapping from the hashtable
}
}

It is possible for this operation to delete every entry in the _clientSessionMap. If it does, the next time a client connects, this code will run:

// If this is the first client, initialize the shared ROMClass cache
if (_clientSessionMap.empty())
{
if (auto cache = TR::CompilationInfo::get()->getJITServerSharedROMClassCache())
cache->initialize(jitConfig);
}

However, the shared ROM class cache will have already been created, leading to an assert triggering in initialize():

TR_ASSERT(!isInitialized(), "Already initialized");

I think the purge operation may need to check if _clientSessionMap is empty post-purge, and shut down the shared ROM class cache if it is. You can see that the deleteClientSession() function does this properly:

// If this was the last client, shutdown the shared ROMClass cache
if (_clientSessionMap.empty())
{
if (auto cache = TR::CompilationInfo::get()->getJITServerSharedROMClassCache())
cache->shutdown();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions