On Thu, 9 May 2024 01:00:52 GMT, Chris Plummer <[email protected]> wrote:
>> Okay, thanks. Please, let me list the variants with some analysis.
>> We have 3 variants:
>> 1. Both monitors are leaf: Entering any monitor while a leaf monitor has
>> been entered is a violation (`LEAF RULE` violation). The order does not
>> matter. Any order is unacceptable.
>>
>> 2. A non-leaf monitor is being entered while a leaf monitor has been
>> entered: This is also a `LEAF RULE` violation. This violation is at the same
>> time always a "RANK ORDER VIOLATION" for the non-leaf monitor. My view is
>> there is no need to report this "RANK ORDER VIOLATION" as it always coexists
>> with the `LEAF RULE` violation for non-leaf monitors. But if you insist on
>> reporting it additionally then it is not a problem to check and report it in
>> the `assertOrderFailure()` function. It has all needed info available for it.
>>
>> 3. A non-leaf monitor is being entered while a non-leaf monitor has been
>> entered: It is a case+report for "RANK ORDER VIOLATION".
>>
>> There is one more variant:
>> 4. A leaf monitor is being entered while a non-leaf monitor has been
>> entered: It is never a violation, so this variant is excluded from the list
>> above.
>
> But 2 and 1 are very different. You can call them both leaf violations, but
> they are leaf violations for very different reasons, and 2 is more akin to a
> rank violation than a leaf violation.
>
> I'm reversing the ranks and reworking the loop a bit (both the comments and
> how the errors are reported). I'll try to post later tonight after testing is
> done.
This is updated function `assertOrderFailure()` to print "RANK ORDER" failure
for the case #2 above:
static void
assertOrderFailure(jthread thread, DebugRawMonitorRank rank, DebugRawMonitor*
dbg_monitor, char* msg)
{
char* threadName = getThreadName(thread);
tty_message("DebugRawMonitor %s failure: (%s: %d > %d) for thread (%s)",
msg, dbg_monitor->name, dbg_monitor->rank, rank, threadName);
if (rank < FIRST_LEAF_DEBUG_RAW_MONITOR &&
dbg_monitor ->rank >= FIRST_LEAF_DEBUG_RAW_MONITOR) {
tty_message("DebugRawMonitor RANK ORDER failure: (%s: %d > %d) for
thread (%s)",
msg, dbg_monitor->name, dbg_monitor->rank, rank,
threadName);
}
jvmtiDeallocate(threadName);
JDI_ASSERT(JNI_FALSE);
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19044#discussion_r1595383612