Skip to content

Commit e82f871

Browse files
committed
8362350: recompute_enable hit assertion "should never come here before live phase" if happens in post_vm_start
Reviewed-by: cjplummer, sspitsyn
1 parent 152fa85 commit e82f871

4 files changed

Lines changed: 26 additions & 47 deletions

File tree

src/hotspot/share/prims/jvmtiEventController.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,11 @@ JvmtiEventControllerPrivate::recompute_env_thread_enabled(JvmtiEnvThreadState* e
544544
}
545545

546546
switch (JvmtiEnv::get_phase()) {
547+
case JVMTI_PHASE_ONLOAD:
548+
case JVMTI_PHASE_PRIMORDIAL:
549+
case JVMTI_PHASE_START:
550+
now_enabled &= EARLY_EVENT_BITS;
551+
break;
547552
case JVMTI_PHASE_DEAD:
548553
// no events allowed when dead
549554
now_enabled = 0;

test/hotspot/jtreg/ProblemList-jvmti-stress-agent.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ gc/stringdedup/TestStringDeduplicationInterned.java 8362562 generic-all
3232
gc/stringdedup/TestStringDeduplicationPrintOptions.java 8362562 generic-all
3333

3434

35-
serviceability/jvmti/events/SingleStep/singlestep02/singlestep02.java 8362350 generic-all
36-
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t007/TestDescription.java 8362350 generic-all
3735

3836
# Incompatbile tests
3937

test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep02/libsinglestep02.cpp

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,6 @@
2929

3030
extern "C" {
3131

32-
#define STATUS_FAILED 2
33-
#define PASSED 0
34-
35-
static volatile jint result = PASSED;
36-
static volatile long wrongStepEv = 0;
3732

3833
static jvmtiEnv *jvmti = nullptr;
3934

@@ -44,31 +39,25 @@ SingleStep(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, jloca
4439
jvmtiError err;
4540

4641
err = jvmti->GetPhase(&phase);
47-
if (err != JVMTI_ERROR_NONE) {
48-
result = STATUS_FAILED;
49-
COMPLAIN("TEST FAILED: unable to obtain phase of the VM execution during SingleStep callback\n\n");
50-
} else {
51-
if (phase != JVMTI_PHASE_LIVE) {
52-
wrongStepEv++;
53-
result = STATUS_FAILED;
54-
COMPLAIN("TEST FAILED: SingleStep event received during non-live phase %s\n", TranslatePhase(phase));
55-
}
42+
check_jvmti_status(jni, err, "Error in GetPhase");
43+
if (phase != JVMTI_PHASE_LIVE) {
44+
COMPLAIN("TEST FAILED: SingleStep event received during non-live phase %s\n", TranslatePhase(phase));
45+
jni->FatalError("Event SingleStep event received during non-live phase.");
5646
}
5747
}
5848

49+
/*
50+
* The ClassLoad event is not used. This is thread filtered event that should
51+
* be sent during start phase. It is enabled to trigger creation of jvmti thread state
52+
* in the START phase. So test ensures that even jvmti state for thread is created
53+
* before live phase the SingleStep event is sent only during live phase.
54+
*/
5955
void JNICALL
60-
VMDeath(jvmtiEnv *jvmti, JNIEnv *jni) {
61-
LOG("VMDeath event received\n");
62-
63-
if (wrongStepEv != 0) {
64-
LOG("TEST FAILED: there are %ld SingleStep events\n"
65-
"sent during non-live phase of the VM execution\n", wrongStepEv);
66-
jni->FatalError("Test Failed.");
67-
}
56+
ClassLoad(jvmtiEnv *jvmti_env,
57+
JNIEnv* jni_env,
58+
jthread thread,
59+
jclass klass) {
6860

69-
if (result == STATUS_FAILED) {
70-
jni->FatalError("Test Failed.");
71-
}
7261
}
7362

7463
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
@@ -105,19 +94,20 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
10594
/* set event callback */
10695
LOG("setting event callbacks ...\n");
10796
(void) memset(&callbacks, 0, sizeof(callbacks));
97+
callbacks.ClassLoad = &ClassLoad;
10898
callbacks.SingleStep = &SingleStep;
109-
callbacks.VMDeath = &VMDeath;
11099
err = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
111100
if (err != JVMTI_ERROR_NONE) {
112101
return JNI_ERR;
113102
}
114103

115104
LOG("setting event callbacks done\nenabling JVMTI events ...\n");
116-
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr);
105+
106+
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr);
117107
if (err != JVMTI_ERROR_NONE) {
118108
return JNI_ERR;
119109
}
120-
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr);
110+
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr);
121111
if (err != JVMTI_ERROR_NONE) {
122112
return JNI_ERR;
123113
}
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,39 +21,25 @@
2121
* questions.
2222
*/
2323

24-
import jdk.test.lib.jvmti.DebugeeClass;
2524
import java.io.*;
2625

2726
/*
2827
* @test
2928
*
3029
* @summary converted from VM Testbase nsk/jvmti/SingleStep/singlestep002.
31-
* VM Testbase keywords: [jpda, jvmti, onload_only_caps, noras]
32-
* VM Testbase readme:
33-
* DESCRIPTION
3430
* This test exercises the JVMTI event SingleStep.
35-
* It verifies that this event s sent only during the live phase
31+
* It verifies that this event is sent only during the live phase
3632
* of VM execution.
3733
* The test works as follows. The tested event is enabled in the
3834
* 'OnLoad' phase. Then all received SingleStep events is checked
3935
* to be sent only during the live phase via the GetPhase() call.
40-
* COMMENTS
4136
*
42-
* @library /test/lib
4337
* @run main/othervm/native -agentlib:singlestep02 singlestep02
4438
*/
4539

4640
public class singlestep02 {
4741

48-
static {
49-
System.loadLibrary("singlestep02");
50-
}
51-
5242
public static void main(String[] args) {
53-
new singlestep02().runThis(args);
5443
}
5544

56-
private int runThis(String argv[]) {
57-
return DebugeeClass.TEST_PASSED;
58-
}
5945
}

0 commit comments

Comments
 (0)