diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 4787247d722..48dcb9a88ff 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -625,6 +625,7 @@ JNI_ENTRY(void, jni_FatalError(JNIEnv *env, const char *msg)) tty->print_cr("FATAL ERROR in native method: %s", msg); thread->print_jni_stack(); + assert(false, "crash in JNI"); os::abort(); // Dump core and abort JNI_END diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index 554b4baf7b2..6a870fa7ce6 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -602,6 +602,10 @@ JvmtiEnv::SetEventNotificationMode(jvmtiEventMode mode, jvmtiEvent event_type, j } JvmtiEventController::set_user_enabled(this, java_thread, thread_obj, event_type, enabled); + + if (enabled && java_thread != nullptr && java_thread->log_jvmti()) { + os::naked_short_sleep(20); + } } return JVMTI_ERROR_NONE; diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index c68692a2fa1..84bf0881f55 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -1332,7 +1332,12 @@ void JvmtiExport::at_single_stepping_point(JavaThread *thread, Method* method, a methodHandle mh(thread, method); // update information about current location and post a step event + thread->set_log_jvmti(true); + if (!thread->is_in_VTMS_transition()) { + os::naked_short_sleep(20); + } JvmtiThreadState *state = get_jvmti_thread_state(thread); + thread->set_log_jvmti(false); if (state == nullptr) { return; } @@ -1345,6 +1350,9 @@ void JvmtiExport::at_single_stepping_point(JavaThread *thread, Method* method, a if (state->is_pending_step_for_earlyret()) { state->process_pending_step_for_earlyret(); } + if (thread->is_suspended()) { + os::naked_short_sleep(10); + } JvmtiExport::post_single_step(thread, mh(), location); } } diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index 86aa62fd3fb..096607a044e 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -462,6 +462,8 @@ JavaThread::JavaThread(MemTag mem_tag) : _is_VTMS_transition_disabler(false), #endif #endif + _log_jvmti(false), + _jni_attach_state(_not_attaching_via_jni), _is_in_internal_oome_mark(false), #if INCLUDE_JVMCI diff --git a/src/hotspot/share/runtime/javaThread.hpp b/src/hotspot/share/runtime/javaThread.hpp index 9a74a6248d0..55d8ea0222e 100644 --- a/src/hotspot/share/runtime/javaThread.hpp +++ b/src/hotspot/share/runtime/javaThread.hpp @@ -335,6 +335,12 @@ class JavaThread: public Thread { #endif #endif + public: + bool _log_jvmti; + bool log_jvmti() { return _log_jvmti; } + void set_log_jvmti(bool val) { _log_jvmti = val; } + + private: // JNI attach states: enum JNIAttachStates { _not_attaching_via_jni = 1, // thread is not attaching via JNI diff --git a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/GetStackTraceSuspendedStressTest.java b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/GetStackTraceSuspendedStressTest.java index fb0945678db..bc4dc99e6a1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/GetStackTraceSuspendedStressTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/GetStackTraceSuspendedStressTest.java @@ -39,7 +39,7 @@ private static final String agentLib = "GetStackTraceSuspendedStress"; static final int MSG_COUNT = 1000; - static final int VTHREAD_COUNT = 60; + static final int VTHREAD_COUNT = 1000; static final SynchronousQueue QUEUE = new SynchronousQueue<>(); static void producer(String msg) throws InterruptedException { diff --git a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp index 037448a6428..258ff48a244 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp @@ -192,7 +192,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { return; } check_jvmti_status(jni, err, "Error in GetVirtualThread"); - if (iter > 50 && vthread != nullptr) { + if (vthread != nullptr) { // char* cname = get_thread_name(jvmti, jni, cthread); // char* vname = get_thread_name(jvmti, jni, vthread); @@ -214,7 +214,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { //check_jvmti_status(jni, jvmti->Deallocate((unsigned char *) vname), "Error in Deallocate"); iter++; - sleep_ms(20); + //sleep_ms(20); } LOG("Agent: finished\n"); }