From 22e39796f6ff99dce624545d4108e6e71ff94adf Mon Sep 17 00:00:00 2001 From: Dmitri Pivkine Date: Mon, 23 Oct 2023 11:37:43 -0400 Subject: [PATCH] Allow Last Responder thread pointer to be NULL 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 --- gc/verbose/VerboseHandlerOutput.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gc/verbose/VerboseHandlerOutput.cpp b/gc/verbose/VerboseHandlerOutput.cpp index b5abe129b55..43e667ef413 100644 --- a/gc/verbose/VerboseHandlerOutput.cpp +++ b/gc/verbose/VerboseHandlerOutput.cpp @@ -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()); @@ -608,8 +612,12 @@ MM_VerboseHandlerOutput::handleExclusiveStart(J9HookInterface** hook, uintptr_t writer->formatAndOutput(env, 0, ""); } writer->formatAndOutput(env, 0, "", tagTemplate, deltaTime / 1000, deltaTime % 1000); - writer->formatAndOutput(env, 1, "", - exclusiveAccessTime / 1000, exclusiveAccessTime % 1000, meanIdleTime / 1000, meanIdleTime % 1000, event->haltedThreads, (NULL == lastResponder ? NULL : lastResponder->_language_vmthread), escapedLastResponderName); + + writer->formatAndOutput( + env, 1, "", + exclusiveAccessTime / 1000, exclusiveAccessTime % 1000, meanIdleTime / 1000, meanIdleTime % 1000, event->haltedThreads, + (NULL == lastResponder ? NULL : lastResponder->_language_vmthread), escapedLastResponderName); + writer->formatAndOutput(env, 0, ""); writer->flush(env); exitAtomicReportingBlock();