Skip to content

Commit 70c8ff1

Browse files
author
Serguei Spitsyn
committedApr 1, 2024
8328665: serviceability/jvmti/vthread/PopFrameTest failed with a timeout
Reviewed-by: lmesnik, cjplummer
1 parent ecd2b71 commit 70c8ff1

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed
 

‎test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread,
4949
{
5050
RawMonitorLocker rml(jvmti, jni, monitor);
5151
bp_sync_reached = true;
52-
rml.wait(0);
52+
while (bp_sync_reached) { // guard against spurious wakeups
53+
rml.wait(0);
54+
}
5355
}
5456
LOG("Breakpoint: In method TestTask.B(): after sync section\n");
5557

56-
if (do_pop_frame != 0) {
58+
if (do_pop_frame) {
5759
err = jvmti->PopFrame(thread);
5860
LOG("Breakpoint: PopFrame returned code: %s (%d)\n", TranslateError(err), err);
5961
check_jvmti_status(jni, err, "Breakpoint: Failed in PopFrame");
@@ -152,20 +154,25 @@ Java_PopFrameTest_popFrame(JNIEnv *jni, jclass cls, jthread thread) {
152154

153155
JNIEXPORT void JNICALL
154156
Java_PopFrameTest_ensureAtBreakpoint(JNIEnv *jni, jclass cls) {
155-
bool need_stop = false;
156-
157157
LOG("Main: ensureAtBreakpoint\n");
158-
while (!need_stop) {
159-
RawMonitorLocker rml(jvmti, jni, monitor);
160-
need_stop = bp_sync_reached;
161-
sleep_ms(1); // 1 millisecond
158+
RawMonitorLocker rml(jvmti, jni, monitor);
159+
int attempts = 0;
160+
while (!bp_sync_reached) {
161+
if (++attempts > 100) {
162+
fatal(jni, "Main: ensureAtBreakpoint: waited 20 sec");
163+
}
164+
LOG("Main: ensureAtBreakpoint: waiting 200 millis\n");
165+
rml.wait(200); // 200 milliseconds
162166
}
163167
}
164168

165169
JNIEXPORT void JNICALL
166170
Java_PopFrameTest_notifyAtBreakpoint(JNIEnv *jni, jclass cls) {
167171
LOG("Main: notifyAtBreakpoint\n");
168172
RawMonitorLocker rml(jvmti, jni, monitor);
173+
if (!bp_sync_reached) { // better diagnosability
174+
fatal(jni, "Main: notifyAtBreakpoint: expected: bp_sync_reached==true");
175+
}
169176
bp_sync_reached = false;
170177
rml.notify_all();
171178
}

0 commit comments

Comments
 (0)
Please sign in to comment.