Skip to content

Commit

Permalink
Merge pull request #21232 from theresa-m/jvmti_getobjectmonitor
Browse files Browse the repository at this point in the history
GetObjectMonitorUsage waiter lists should be null for 0 waiters
  • Loading branch information
babsingh authored Feb 28, 2025
2 parents 5ea72a5 + a08ad4d commit abf8fa7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions runtime/jvmti/jvmtiObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,22 @@ jvmtiGetObjectMonitorUsage(jvmtiEnv *env,
walkThread = J9_LINKED_LIST_NEXT_DO(vm->mainThread, walkThread);
}

stats.waiting = j9mem_allocate_memory(sizeof(jthread) * stats.numWaiting, J9MEM_CATEGORY_JVMTI_ALLOCATE);
if (NULL == stats.waiting) {
rc = JVMTI_ERROR_OUT_OF_MEMORY;
} else {
stats.blocked = j9mem_allocate_memory(sizeof(jthread) * stats.numBlocked, J9MEM_CATEGORY_JVMTI_ALLOCATE);
if (NULL == stats.blocked) {
j9mem_free_memory(stats.waiting);
if (stats.numWaiting > 0) {
stats.waiting = j9mem_allocate_memory(sizeof(jthread) * stats.numWaiting, J9MEM_CATEGORY_JVMTI_ALLOCATE);
if (NULL == stats.waiting) {
rc = JVMTI_ERROR_OUT_OF_MEMORY;
} else {
}
}

if (JVMTI_ERROR_NONE == rc) {
if (stats.numBlocked > 0) {
stats.blocked = j9mem_allocate_memory(sizeof(jthread) * stats.numBlocked, J9MEM_CATEGORY_JVMTI_ALLOCATE);
if (NULL == stats.blocked) {
j9mem_free_memory(stats.waiting);
rc = JVMTI_ERROR_OUT_OF_MEMORY;
}
}
if ((JVMTI_ERROR_NONE == rc) && ((stats.numWaiting > 0) || (stats.numBlocked > 0))) {
rv_notify_waiters = stats.waiting;
rv_waiters = stats.blocked;

Expand Down

0 comments on commit abf8fa7

Please sign in to comment.