Protocol version of Attach API
David Holmes
david.holmes at oracle.com
Tue Feb 26 06:41:05 UTC 2019
On 26/02/2019 4:32 pm, Yasumasa Suenaga wrote:
> Hi David,
>
> 2019年2月26日(火) 15:14 David Holmes <david.holmes at oracle.com>:
>>
>> On 26/02/2019 4:01 pm, Yasumasa Suenaga wrote:
>>> Hi all,
>>>
>>> When I attached to VM which is after 8215622 change via jcmd in JDK 8
>>> on Linux, jcmd hanged.
>>
>> What command are you trying to execute through jcmd?
>
> I tried VM.info, Thread.print, and GC.run .
Right a simple "jcmd <pid> help" hangs.
>
>> Do we support connection to later VMs from earlier JDK tools?
>
> I could not find the spec about this.
> So I asked to serviceability folks before filing this to JBS :-)
I'm not certain either but this is a huge compatibility change even if
not officially supported.
>
>>> I checked the status of target VM and jcmd,
>>> LinuxAttachListener::read_request() on target VM was waiting for
>>> subsequent argument.
>>>
>>> 8215622 increased number of arguments of Attach API [1].
>>
>> Isn't that supposed to be a maximum number of arguments? So if less are
>> sent it should still work okay?
>
> This change affects to request reading on AttachListener.
>
> AttachListener set expected string (includes arguments) count from
> maximum number of arguments.
> http://hg.openjdk.java.net/jdk/jdk/file/616a32d6b463/src/hotspot/os/linux/attachListener_linux.cpp#l247
>
> This value uses as loop condition.
> http://hg.openjdk.java.net/jdk/jdk/file/616a32d6b463/src/hotspot/os/linux/attachListener_linux.cpp#l297
That code looks wrong to me. It's a maximum number of args not the
expected number. As per the comment:
// Read until all (expected) strings have been read, the buffer is
// full, or EOF.
if we have fewer than max args we should get EOF and handle it fine!
>
>>> Of course it is my mistake, but I think we can increase version number
>>> (PROTOCOL_VERSION) because Attach API has been updated in 8215622.
>>>
>>> What do you think?
>>
>> That will just cause it be rejected rather than hang - right?
>
> No, jcmd is hanged.
> You can reproduce it on Linux box.
>
> My environment:
> Target VM: jdk/jdk fastdebug build (changeset: 53918:616a32d6b463)
> jcmd: OpenJDK 8u201 (java-1.8.0-openjdk-1.8.0.201.b09-2.fc29.x86_64)
>
> I checked the value of `str_count` and `left` on
> LinuxAttachListener::read_request() in target VM via GDB.
> Target VM waited subsequent arguments.
Yes but if we change the protocol version that will cause the incoming
request from the earlier jcmd to be rejected - right? Or are we going to
adjust the expected number of args based on the protocol version?
I'm trying to understand how changing the protocol version will fix the
problem.
Thanks,
David
-----
>
> Thanks,
>
> Yasumasa
>
>
>> Thanks,
>> David
>> -----
>>
>>> If it is accepted, I will file it to JBS.
>>>
>>>
>>> Thanks,
>>>
>>> Yasumasa
>>>
>>>
>>> [1] http://hg.openjdk.java.net/jdk/jdk/rev/e7cf035682e3#l2.1
>>>
More information about the serviceability-dev
mailing list