views:

26

answers:

0

I've got a little tool to help debug client problems with our Java application. Basically it runs jps.exe to get all the Java processes running on the machine, and then calls jstack and jmap on each of them in turn. Finally, it zips everything up and FTP's it to us for forensic analysis. To run any of the commands it uses the ProcessBuilder and Process objects.

This all has been working great for a year or two now. We recently started supporting running our app in 64-bit Java as well, and this tool doesn't work to help debug a running 64-bit instance. It successfully runs jps, but as soon as it tries to run jstack on the application, the application itself dies completely. The information that Windows gives is below. The Process object itself has no content in either the stdout or stderr streams. However, I can run jstack just fine from the command line.

The tool can definitely run jstack. If it calls with no arguments, then jstack returns the help blurb, etc. It just can't actually use it to do anything useful, like attach to the target process. I also tried to write a batch file that runs jstack, and execute the batch file from Java, but that crashed the same way. Next step on a workaround would be to code the entire thing in a batch file, but I'd really rather not.

So my question is, how can you use ProcessBuilder and Process to run 64-bit jstack.exe to get the stack snapshot of a 64-bit java process? This is on Window7 64-bit with JVM 1.6.0_22 64-bit.

------- Windows crash information ----------
Problem signature:
  Problem Event Name:   BEX64
  Application Name: javaw.exe
  Application Version:  6.0.220.4
  Application Timestamp:    4c9088dd
  Fault Module Name:    StackHash_b4ee
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Offset: 000007fefd19a7d0
  Exception Code:   c0000005
  Exception Data:   0000000000000008
  OS Version:   6.1.7600.2.0.0.256.48
  Locale ID:    1033
  Additional Information 1: b4ee
  Additional Information 2: b4ee5de6a2322745523997a782b35692
  Additional Information 3: 277e
  Additional Information 4: 277e19c30fbd5f6bb531ec9e027c37c3