Skip to content

Commit

Permalink
Allow Last Responder thread pointer to be NULL
Browse files Browse the repository at this point in the history
Last Responder thread can be NULL in the case of Safe Point Exclusive.
Check pointer for NULL and leave thread name empty.

Signed-off-by: Dmitri Pivkine <[email protected]>
  • Loading branch information
dmitripivkine committed Oct 24, 2023
1 parent 501add5 commit 22e3979
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions gc/verbose/VerboseHandlerOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,12 @@ MM_VerboseHandlerOutput::handleExclusiveStart(J9HookInterface** hook, uintptr_t
manager->setLastExclusiveAccessStartTime(currentTime);

OMR_VMThread* lastResponder = event->lastResponder;
char escapedLastResponderName[64];
getThreadName(escapedLastResponderName,sizeof(escapedLastResponderName),lastResponder);
char escapedLastResponderName[64] = "";

/* Last Responder thread can be passed NULL in the case of Safe Point Exclusive */
if (NULL != lastResponder) {
getThreadName(escapedLastResponderName, sizeof(escapedLastResponderName), lastResponder);
}

char tagTemplate[200];
getTagTemplate(tagTemplate, sizeof(tagTemplate), manager->getIdAndIncrement(), omrtime_current_time_millis());
Expand All @@ -608,8 +612,12 @@ MM_VerboseHandlerOutput::handleExclusiveStart(J9HookInterface** hook, uintptr_t
writer->formatAndOutput(env, 0, "<warning details=\"clock error detected, following timing may be inaccurate\" />");
}
writer->formatAndOutput(env, 0, "<exclusive-start %s intervalms=\"%llu.%03.3llu\">", tagTemplate, deltaTime / 1000, deltaTime % 1000);
writer->formatAndOutput(env, 1, "<response-info timems=\"%llu.%03.3llu\" idlems=\"%llu.%03.3llu\" threads=\"%zu\" lastid=\"%p\" lastname=\"%s\" />",
exclusiveAccessTime / 1000, exclusiveAccessTime % 1000, meanIdleTime / 1000, meanIdleTime % 1000, event->haltedThreads, (NULL == lastResponder ? NULL : lastResponder->_language_vmthread), escapedLastResponderName);

writer->formatAndOutput(
env, 1, "<response-info timems=\"%llu.%03.3llu\" idlems=\"%llu.%03.3llu\" threads=\"%zu\" lastid=\"%p\" lastname=\"%s\" />",
exclusiveAccessTime / 1000, exclusiveAccessTime % 1000, meanIdleTime / 1000, meanIdleTime % 1000, event->haltedThreads,
(NULL == lastResponder ? NULL : lastResponder->_language_vmthread), escapedLastResponderName);

writer->formatAndOutput(env, 0, "</exclusive-start>");
writer->flush(env);
exitAtomicReportingBlock();
Expand Down

0 comments on commit 22e3979

Please sign in to comment.