Skip to content

Commit

Permalink
Merge pull request #19343 from fengxue-IS/18859
Browse files Browse the repository at this point in the history
Fix !vthreads command error with uninitialized Continuations
  • Loading branch information
keithc-ca authored May 10, 2024
2 parents d9a1f14 + 8a599a2 commit 851a4eb
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ private static long getVmRef(J9ObjectPointer continuation) throws CorruptDataExc
return J9ObjectHelper.getLongField(continuation, vmRefOffset);
}

private static J9ObjectPointer getName(J9ObjectPointer vthread) throws CorruptDataException {
if (nameOffset == null) {
nameOffset = J9ObjectHelper.getFieldOffset(vthread, "name", "Ljava/lang/String;");
private static String getName(J9ObjectPointer vthread) throws CorruptDataException {
String name = null;
if (vthread.notNull()) {
if (nameOffset == null) {
nameOffset = J9ObjectHelper.getFieldOffset(vthread, "name", "Ljava/lang/String;");
}
name = J9ObjectHelper.getStringField(vthread, nameOffset);
}
return J9ObjectHelper.getObjectField(vthread, nameOffset);

return (name != null) ? name : "<N/A>";
}

public VirtualThreadsCommand() {
Expand Down Expand Up @@ -112,15 +117,15 @@ private static void displayVirtualThreads(J9JavaVMPointer vm, PrintStream out) t
while (continuation.notNull()) {
long vmRef = getVmRef(continuation);
J9ObjectPointer vthread = getVirtualThread(continuation);
J9ObjectPointer name = getName(vthread);
String name = getName(vthread);

out.format(
outputFormat,
vmRef,
vmRef,
continuation.getHexAddress(),
vthread.getHexAddress(),
J9ObjectHelper.stringValue(name));
name);
continuation = ObjectReferencePointer.cast(continuation.addOffset(linkOffset)).at(0);
}
continuationObjectList = continuationObjectList._nextList();
Expand Down

0 comments on commit 851a4eb

Please sign in to comment.