Skip to content

Commit

Permalink
Add an unknown thread entry to JFR constant pool
Browse files Browse the repository at this point in the history
This fixes the error of "Size of check point event doesn't match
content" while reading a JFR chunk.

Signed-off-by: Gengchen Tuo <[email protected]>
  • Loading branch information
thallium committed Dec 5, 2024
1 parent d06ae14 commit add84dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runtime/vm/JFRConstantPoolTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,10 @@ VM_JFRConstantPoolTypes::freeThreadNameEntries(void *entry, void *userData)
J9VMThread *currentThread = (J9VMThread *)userData;
PORT_ACCESS_FROM_VMC(currentThread);

j9mem_free_memory(tableEntry->javaThreadName);
/* Name of the unknown thread entry cannot be freed */
if (0 != tableEntry->index) {
j9mem_free_memory(tableEntry->javaThreadName);
}
tableEntry->javaThreadName = NULL;

return FALSE;
Expand Down
17 changes: 17 additions & 0 deletions runtime/vm/JFRConstantPoolTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ J9_DECLARE_CONSTANT_UTF8(nativeMethod, "(nativeMethod)");
J9_DECLARE_CONSTANT_UTF8(nativeMethodSignature, "()");
J9_DECLARE_CONSTANT_UTF8(defaultPackage, "(defaultPackage)");
J9_DECLARE_CONSTANT_UTF8(bootLoaderName, "boostrapClassLoader");
J9_DECLARE_CONSTANT_UTF8(unknownThread, "unknown thread");

enum JFRStringConstants {
DefaultString = 0,
Expand Down Expand Up @@ -542,6 +543,21 @@ class VM_JFRConstantPoolTypes {
return value;
}

void addUnknownThreadEntry() {
ThreadEntry unknownThreadEntry = {0};
unknownThreadEntry.vmThread = NULL;
unknownThreadEntry.index = 0;
unknownThreadEntry.osTID = 0;
unknownThreadEntry.javaTID = 0;
unknownThreadEntry.javaThreadName = (J9UTF8 *)&unknownThread;
unknownThreadEntry.osThreadName = (J9UTF8 *)&unknownThread;
unknownThreadEntry.threadGroupIndex = 0;

ThreadEntry *entry = (ThreadEntry *)hashTableAdd(_threadTable, &unknownThreadEntry);
_firstThreadEntry = entry;
_previousThreadEntry = entry;
}

protected:

public:
Expand Down Expand Up @@ -1276,6 +1292,7 @@ class VM_JFRConstantPoolTypes {

/* Leave index 0 as a NULL entry for unknown notifier thread. */
_threadCount += 1;
addUnknownThreadEntry();

done:
return;
Expand Down

0 comments on commit add84dd

Please sign in to comment.