If Agent_OnAttach() in JVMTI agent which is attempted to load via JVMTI.agent_load dcmd is failed, it would not be unloaded.
How to reproduce:
1. Build JVMTI agent for test
$ git clone https://github.com/YaSuenag/jvmti-examples.git
$ cd jvmti-examples/helloworld/out/build
$ cmake ../..
2. Run JShell
3. Load JVMTI agent via `jcmd <PID> JVMTI.agent_load` with "error" ("error" means Agent_OnAttach() returns JNI_ERR)
$ jcmd
89456 jdk.jshell.execution.RemoteExecutionControl 45651
89547 sun.tools.jcmd.JCmd
89436 jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider
$ jcmd 89436 JVMTI.agent_load `pwd`/libhelloworld.so error
89436:
return code: -1
4. Check loaded libraries via `jcmd <PID> VM.dynlibs`
$ jcmd 89436 VM.dynlibs | grep libhelloworld
7f2f8b06b000-7f2f8b06c000 r--p 00000000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06c000-7f2f8b06d000 r-xp 00001000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06d000-7f2f8b06e000 r--p 00002000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06e000-7f2f8b06f000 r--p 00002000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06f000-7f2f8b070000 rw-p 00003000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
How to reproduce:
1. Build JVMTI agent for test
$ git clone https://github.com/YaSuenag/jvmti-examples.git
$ cd jvmti-examples/helloworld/out/build
$ cmake ../..
2. Run JShell
3. Load JVMTI agent via `jcmd <PID> JVMTI.agent_load` with "error" ("error" means Agent_OnAttach() returns JNI_ERR)
$ jcmd
89456 jdk.jshell.execution.RemoteExecutionControl 45651
89547 sun.tools.jcmd.JCmd
89436 jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider
$ jcmd 89436 JVMTI.agent_load `pwd`/libhelloworld.so error
89436:
return code: -1
4. Check loaded libraries via `jcmd <PID> VM.dynlibs`
$ jcmd 89436 VM.dynlibs | grep libhelloworld
7f2f8b06b000-7f2f8b06c000 r--p 00000000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06c000-7f2f8b06d000 r-xp 00001000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06d000-7f2f8b06e000 r--p 00002000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06e000-7f2f8b06f000 r--p 00002000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
7f2f8b06f000-7f2f8b070000 rw-p 00003000 fd:00 11818202 /home/ysuenaga/github/jvmti-examples/helloworld/out/build/libhelloworld.so
- csr for
-
JDK-8256918 JVMTI agent is not unloaded when Agent_OnAttach is failed
-
- Closed
-
- relates to
-
JDK-8269558 fix of JDK-8252657 missed to update history at the end of JVM TI spec
-
- Resolved
-