Skip to content

Commit

Permalink
Fix bad assertion code and assert earlier in release safe point
Browse files Browse the repository at this point in the history
The code for Trc_Assert_BCU_mustHaveExclusiveVMAccess is simply
incorrect. Fix it to check the exclusiveCount field.

Also move the new assertion in releaseSafePointVMAccess to earlier in
the function to detect more error cases.

Signed-off-by: Graham Chapman <[email protected]>
  • Loading branch information
gacholio committed Oct 5, 2023
1 parent a193ab3 commit 86150ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion runtime/bcutil/j9bcu.tdf
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ TraceException=Trc_BCU_ClassFileOracle_walkMethodCodeAttributeAttributes_Duplica
TraceAssert=Trc_BCU_Assert_SupportedByteCode NoEnv Overhead=1 Level=1 Assert="(0 != sunJavaInstructionSizeTable[P1])"
TraceEntry=Trc_BCU_avl_intern_verify_EntryV2 Noenv Overhead=1 Level=3 Template="BCU avl_intern_verify Entry: tree=%p sharedPool=%p localPool=%p"

TraceAssert=Trc_Assert_BCU_mustHaveExclusiveVMAccess NoEnv overhead=1 Level=1 Assert="(P1)->publicFlags & (J9_PUBLIC_FLAGS_VM_ACCESS | J9_PUBLIC_FLAGS_HALT_THREAD_EXCLUSIVE)"
TraceAssert=Trc_Assert_BCU_mustHaveExclusiveVMAccess NoEnv overhead=1 Level=1 Assert="(0 != (P1)->omrVMThread->exclusiveCount)"

TraceAssert=Trc_BCU_Assert_InternVerificationFailure NoEnv Overhead=1 Level=1 Assert="(0)"

Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/VMAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ releaseSafePointVMAccess(J9VMThread * vmThread)
}
Assert_VM_mustHaveVMAccess(vmThread);
Assert_VM_false(vmThread->safePointCount == 0);
Assert_VM_true(1 == vmThread->omrVMThread->exclusiveCount);
Assert_VM_true(J9_XACCESS_EXCLUSIVE == vm->safePointState);

if (--(vmThread->safePointCount) == 0) {
Expand All @@ -1251,7 +1252,6 @@ releaseSafePointVMAccess(J9VMThread * vmThread)
VM_VMAccess::clearPublicFlags(currentThread, J9_PUBLIC_FLAGS_HALTED_AT_SAFE_POINT | J9_PUBLIC_FLAGS_NOT_COUNTED_BY_SAFE_POINT, true);
} while ((currentThread = currentThread->linkNext) != vmThread);

Assert_VM_true(1 == vmThread->omrVMThread->exclusiveCount);
vmThread->omrVMThread->exclusiveCount = 0;

omrthread_monitor_enter(vm->exclusiveAccessMutex);
Expand Down

0 comments on commit 86150ca

Please sign in to comment.