United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7154822 forward port fix for Bug 13645891 to JDK8 jcmd (1024 byte file size limit issue)
JDK-7154822 : forward port fix for Bug 13645891 to JDK8 jcmd (1024 byte file size limit issue)

Details
Type:
Bug
Submit Date:
2012-03-19
Status:
Resolved
Updated Date:
2013-04-30
Project Name:
JDK
Resolved Date:
2012-04-24
Component:
core-svc
OS:
generic
Sub-Component:
tools
CPU:
generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
8
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
This is a "forward port" of the fix for Bug 13645891 in JRockit's JRCMD command to Oracle JDK's new jcmd command.

From 13645891
===
I created a jrcmd script and was using something like the below to run it:

jrcmd 12345 -f commands.txt

It turns out that the contents of the commands.txt file must not be more than roughly 256 bytes, otherwise jrcmd will return a cryptic error message (OS dependent, the below is what it looks like on Linux):

jrcmd 11052 -f commands.txt
11052:
java.io.IOException: Premature EOF
        at
sun.tools.attach.HotSpotVirtualMachine.readInt(HotSpotVirtualMachine.java:226)
        at sun.tools.attach.LinuxVirtualMachine.execute(LinuxVirtualMachine.java:175)
        at
sun.tools.attach.HotSpotVirtualMachineAccess.execute(HotSpotVirtualMachineAccess.java:17)
        at jrockit.tools.jrcmd.JrCmd.executeCommandForPid(JrCmd.java:115)
        at jrockit.tools.jrcmd.JrCmd.main(JrCmd.java:90)

The reason for this is that the attach implementation in JRockit limits the attach operation commands to 256 characters (see attach_internal.h/MAX_ARG_LEN) and jrcmd sends the whole file contents as a single command to the VM. The actual check which bails out the execution can be found in attach.c:attachOperationSetArg called from attach_linux.c:read_request on Linux.
===

                                    

Comments
EVALUATION

Fix is to break the input into individual lines and sent each one to the JVM one at a time. We still have a 1024-byte limit on the size of each line, but in practice I do not believe this will be an issue.
                                     
2012-03-30



Hardware and Software, Engineered to Work Together