From 70c8ff1c9a9adf21a16d8a6b4da1eeec65afe61d Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Mon, 1 Apr 2024 23:37:07 +0000 Subject: [PATCH] 8328665: serviceability/jvmti/vthread/PopFrameTest failed with a timeout Reviewed-by: lmesnik, cjplummer --- .../vthread/PopFrameTest/libPopFrameTest.cpp | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp index 4001296e967..4118251cf4f 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp @@ -49,11 +49,13 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, { RawMonitorLocker rml(jvmti, jni, monitor); bp_sync_reached = true; - rml.wait(0); + while (bp_sync_reached) { // guard against spurious wakeups + rml.wait(0); + } } LOG("Breakpoint: In method TestTask.B(): after sync section\n"); - if (do_pop_frame != 0) { + if (do_pop_frame) { err = jvmti->PopFrame(thread); LOG("Breakpoint: PopFrame returned code: %s (%d)\n", TranslateError(err), err); check_jvmti_status(jni, err, "Breakpoint: Failed in PopFrame"); @@ -152,13 +154,15 @@ Java_PopFrameTest_popFrame(JNIEnv *jni, jclass cls, jthread thread) { JNIEXPORT void JNICALL Java_PopFrameTest_ensureAtBreakpoint(JNIEnv *jni, jclass cls) { - bool need_stop = false; - LOG("Main: ensureAtBreakpoint\n"); - while (!need_stop) { - RawMonitorLocker rml(jvmti, jni, monitor); - need_stop = bp_sync_reached; - sleep_ms(1); // 1 millisecond + RawMonitorLocker rml(jvmti, jni, monitor); + int attempts = 0; + while (!bp_sync_reached) { + if (++attempts > 100) { + fatal(jni, "Main: ensureAtBreakpoint: waited 20 sec"); + } + LOG("Main: ensureAtBreakpoint: waiting 200 millis\n"); + rml.wait(200); // 200 milliseconds } } @@ -166,6 +170,9 @@ JNIEXPORT void JNICALL Java_PopFrameTest_notifyAtBreakpoint(JNIEnv *jni, jclass cls) { LOG("Main: notifyAtBreakpoint\n"); RawMonitorLocker rml(jvmti, jni, monitor); + if (!bp_sync_reached) { // better diagnosability + fatal(jni, "Main: notifyAtBreakpoint: expected: bp_sync_reached==true"); + } bp_sync_reached = false; rml.notify_all(); }