You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking into the source code of jdk21 it seems that the function GetCurrentThreadCpuTime doesn't support virtual threads:
// nanos_ptr - pre-checked for null
jvmtiError
JvmtiEnv::GetCurrentThreadCpuTime(jlong* nanos_ptr) {
Thread* thread = Thread::current();
// Surprisingly the GetCurrentThreadCpuTime is used by non-JavaThread's.
if (thread->is_Java_thread()) {
if (JavaThread::cast(thread)->is_vthread_mounted()) {
// No support for a VirtualThread (yet).
return JVMTI_ERROR_UNSUPPORTED_OPERATION;
}
}
*nanos_ptr = os::current_thread_cpu_time();
return JVMTI_ERROR_NONE;
} /* end GetCurrentThreadCpuTime */
To Reproduce
Create the following program TriggerVisualVMProfileCrash.java:
andrebreves
changed the title
Profiler fails when profiling a virtual thread in jdk21
Profiled program crashes when profiling virtual thread using jdk21
Jan 24, 2024
I just hit this same issue. Here's my full output:
Profiler Agent: JNI OnLoad Initializing...
Profiler Agent: JNI OnLoad Initialized successfully
Profiler Agent: Waiting for connection on port 5140 (Protocol version: 20)
Profiler Agent: Established connection with the tool
*** Profiler engine warning: Cannot use ClassLoader.findLoadedClass() and/or ClassLoader.findBootstrapClass() in ClassLoaderManager
Profiler Agent: Local accelerated session
Profiler Agent Error: GetCurrentThreadCpuTime failed with 73
Assertion failed: (res == JVMTI_ERROR_NONE), function Java_org_graalvm_visualvm_lib_jfluid_server_system_Timers_getThreadCPUTimeInNanos, file ../src-jdk15/Timers.c, line 108.
./start.sh: line 36: 40735 Abort trap: 6 ~/dev/java/current21/bin/java ${suspend} -Djdk.instrument.traceUsage -XX:+EnableDynamicAgentLoading -Xverify:none -Xshare:off -cp "${CLASSPATH}" io.fusionauth.http.load.Main
This is simple to reproduce in the https://github.com/FusionAuth/java-http project using the branch bpontarelli/virtual-threads. Happy to provide build and run instructions if needed.
Describe the bug
Whenever I try to Profile the CPU for a program with virtual threads it fails with the following error:
The error code
73
corresponds to JVMTI_ERROR_UNSUPPORTED_OPERATION.The error seems to be triggered in
Timers.c
:Looking into the source code of jdk21 it seems that the function
GetCurrentThreadCpuTime
doesn't support virtual threads:To Reproduce
TriggerVisualVMProfileCrash.java
:Activate de CPU Profiler for the class
TriggerVisualVMProfileCrash
:Press
enter
in the console so the program continues execution.The program will crash
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: