RFR: 8252657: JVMTI agent is not unloaded when Agent_OnAttach is failed

David Holmes david.holmes at oracle.com
Wed Sep 2 05:00:11 UTC 2020


Hi Yasumasa,

On 1/09/2020 11:42 pm, Yasumasa Suenaga wrote:
> Hi all,
> 
> Please review this change:
> 
>    JBS: https://bugs.openjdk.java.net/browse/JDK-8252657
>    webrev: http://cr.openjdk.java.net/~ysuenaga/JDK-8252657/webrev.00/
> 
> I tried to attach JVMTI agent which returns JNI_ERR in Agent_OnUnload 
> via JVMTI.agent_load dcmd. I expected the library would be unloaded, but 
> I saw it in VM.dynlibs dcmd even though it was failed to load.

I'm not so sure there is a bug here. The specification is quite lax:

"Instead the VM ignores the error, or takes some implementation specific 
action -- for example it might print an error to standard error, or 
record the error in a system log. "

So not unloading the library is not a bug in respect of the 
specification. Further by unloading the library do you not now permit it 
to be re-loaded and the OnAttach function to be executed repeatedly? 
That seems wrong to me. It could also be argued that if you will 
re-execute onAttach then you should first have called OnUnload, which 
you don't do.

So while this current behaviour may not meet with your expectations it 
is not a bug per-se, and the change in behaviour could have other 
implications that are not insignificant.

If the new behaviour is considered desirable then a CSR request should 
also be filed for this.

Cheers,
David
-----

> Please see JBS how to reproduce.
> 
> 
> Thanks,
> 
> Yasumasa


More information about the serviceability-dev mailing list