Skip to content

Commit d94b94d

Browse files
JITServer: handle non-null compilation
When a JITServer stream failure is thrown, sometimes setting the compilation object to NULL can be skiped to head straight into exception handling. This causes an assert to be tripped. In this particular case, there is a front-end call in outOfProcessCompilationEnd (within computeDataForCHTableCommit) which can cause a stream error. Since it isn't guarded by a global try-catch, it results in the given assert being tripped. Addresses this issue: #23845
1 parent a5901da commit d94b94d

1 file changed

Lines changed: 37 additions & 26 deletions

File tree

runtime/compiler/control/JITServerCompilationThread.cpp

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,20 @@ void outOfProcessCompilationEnd(TR_MethodToBeCompiled *entry, TR::Compilation *c
133133
std::string codeCacheStr((const char *)codeCacheHeader, codeSize);
134134
std::string dataCacheStr((const char *)dataCacheHeader, dataSize);
135135

136+
bool chTableDataValid = false;
137+
136138
// The CH table commit data may be needed even if TR_DisableCHOpts is set,
137139
// because if there were bonds, it may be necessary for the client's CH
138140
// table commit to create unload assumptions.
139141
CHTableCommitData chTableData;
140142
if (!entry->_useAotCompilation) {
141143
TR_CHTable *chTable = comp->getCHTable();
142-
chTableData = chTable->computeDataForCHTableCommit(comp);
144+
try {
145+
chTableData = chTable->computeDataForCHTableCommit(comp);
146+
chTableDataValid = true;
147+
} catch (JITServer::StreamFailure &e) {
148+
fprintf(stderr, "JITServer stream error: %s", e.what());
149+
}
143150
}
144151

145152
auto classesThatShouldNotBeNewlyExtended = compInfoPT->getClassesThatShouldNotBeNewlyExtended();
@@ -214,18 +221,20 @@ void outOfProcessCompilationEnd(TR_MethodToBeCompiled *entry, TR::Compilation *c
214221
for (auto r : records)
215222
serializedRecords.push_back(std::string((const char *)r, r->size()));
216223

217-
entry->_stream->finishAotStoreCompilation(
218-
std::string((const char *)&methodRecord->data(), methodRecord->data().size()), serializedRecords,
219-
chTableData,
220-
std::vector<TR_OpaqueClassBlock *>(classesThatShouldNotBeNewlyExtended->begin(),
221-
classesThatShouldNotBeNewlyExtended->end()),
222-
logFileStr,
223-
resolvedMirrorMethodsPersistIPInfo
224-
? std::vector<TR_ResolvedJ9Method *>(resolvedMirrorMethodsPersistIPInfo->begin(),
225-
resolvedMirrorMethodsPersistIPInfo->end())
226-
: std::vector<TR_ResolvedJ9Method *>(),
227-
*entry->_optimizationPlan, serializedRuntimeAssumptions, memoryState, activeThreadState,
228-
methodsRequiringTrampolines);
224+
if (chTableDataValid) {
225+
entry->_stream->finishAotStoreCompilation(
226+
std::string((const char *)&methodRecord->data(), methodRecord->data().size()), serializedRecords,
227+
chTableData,
228+
std::vector<TR_OpaqueClassBlock *>(classesThatShouldNotBeNewlyExtended->begin(),
229+
classesThatShouldNotBeNewlyExtended->end()),
230+
logFileStr,
231+
resolvedMirrorMethodsPersistIPInfo
232+
? std::vector<TR_ResolvedJ9Method *>(resolvedMirrorMethodsPersistIPInfo->begin(),
233+
resolvedMirrorMethodsPersistIPInfo->end())
234+
: std::vector<TR_ResolvedJ9Method *>(),
235+
*entry->_optimizationPlan, serializedRuntimeAssumptions, memoryState, activeThreadState,
236+
methodsRequiringTrampolines);
237+
}
229238
if (TR::Options::getVerboseOption(TR_VerboseJITServer)) {
230239
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer,
231240
"compThreadID=%d has successfully compiled AOT cache store %s memoryState=%d",
@@ -241,21 +250,23 @@ void outOfProcessCompilationEnd(TR_MethodToBeCompiled *entry, TR::Compilation *c
241250
comp->cg()->getConstRefInfoOnServer(constRefInfo);
242251
#endif
243252

244-
entry->_stream->finishCompilation(codeCacheStr, dataCacheStr, chTableData,
245-
std::vector<TR_OpaqueClassBlock *>(classesThatShouldNotBeNewlyExtended->begin(),
246-
classesThatShouldNotBeNewlyExtended->end()),
247-
logFileStr,
248-
resolvedMirrorMethodsPersistIPInfo
249-
? std::vector<TR_ResolvedJ9Method *>(resolvedMirrorMethodsPersistIPInfo->begin(),
250-
resolvedMirrorMethodsPersistIPInfo->end())
251-
: std::vector<TR_ResolvedJ9Method *>(),
252-
*entry->_optimizationPlan, serializedRuntimeAssumptions, memoryState, activeThreadState,
253-
methodsRequiringTrampolines
253+
if (chTableDataValid) {
254+
entry->_stream->finishCompilation(codeCacheStr, dataCacheStr, chTableData,
255+
std::vector<TR_OpaqueClassBlock *>(classesThatShouldNotBeNewlyExtended->begin(),
256+
classesThatShouldNotBeNewlyExtended->end()),
257+
logFileStr,
258+
resolvedMirrorMethodsPersistIPInfo
259+
? std::vector<TR_ResolvedJ9Method *>(resolvedMirrorMethodsPersistIPInfo->begin(),
260+
resolvedMirrorMethodsPersistIPInfo->end())
261+
: std::vector<TR_ResolvedJ9Method *>(),
262+
*entry->_optimizationPlan, serializedRuntimeAssumptions, memoryState, activeThreadState,
263+
methodsRequiringTrampolines
254264
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
255-
,
256-
constRefInfo
265+
,
266+
constRefInfo
257267
#endif
258-
);
268+
);
269+
}
259270
if (TR::Options::getVerboseOption(TR_VerboseJITServer)) {
260271
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer,
261272
"compThreadID=%d has successfully compiled %s memoryState=%d", compInfoPT->getCompThreadId(),

0 commit comments

Comments
 (0)