8334085: Test crash: assert(thread->held_monitor_count() == 0) failed: Must be

Reviewed-by: dholmes, pchilanomate
This commit is contained in:
Serguei Spitsyn 2024-07-25 01:35:03 +00:00
parent 0898ab7f74
commit d3e51daf73
2 changed files with 7 additions and 4 deletions

View File

@ -2450,8 +2450,8 @@ static inline intptr_t* thaw_internal(JavaThread* thread, const Continuation::th
intptr_t* const sp = thw.thaw(kind);
assert(is_aligned(sp, frame::frame_alignment), "");
// All the frames have been thawed so we know they don't hold any monitors
assert(thread->held_monitor_count() == 0, "Must be");
// All or part of the frames have been thawed so we know they don't hold any monitors except JNI monitors.
assert(thread->held_monitor_count() == thread->jni_monitor_count(), "Must be");
#ifdef ASSERT
intptr_t* sp0 = sp;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,7 @@
/**
* @test
* @bug 8185164 8320515
* @bug 8185164 8320515 8334085
* @summary Checks that a contended monitor does not show up in the list of owned monitors.
* 8320515 piggy-backs on this test and injects an owned monitor with a dead object,
and checks that that monitor isn't exposed to GetOwnedMonitorInfo.
@ -86,6 +86,9 @@ public class GetOwnedMonitorInfoTest {
System.out.println("Thread doing JNI call: "
+ Thread.currentThread().getName());
// Extra unmount helps to reproduce 8334085.
// Two sub-sequential thaws are needed in that scenario.
Thread.yield();
jniMonitorEnterAndLetObjectDie();
}