Anonymous - 2010-07-14

Greetings,

I continue to have stability problems with this library, as I mentioned in an earlier post. These seem to be related to JNA or VIX memory management calls leading to invalid pointer / double free errors or seg faults.

I narrowed down my issue to being triggered by listRunningVms and getProcessesInGuest. When I call one or both of these, my code either crashes immediately or crashes on some later call (probably when the corrupt memory is referenced). If I call neither of these, other functions seem to work. I started to look for commonality between them and the first thing that jumped out was that these both involve list result processing.

I focused on getProcessesInGuest and compared VixUtils.java to the VMware VIX api C sample…
http://vixjava.svn.sourceforge.net/viewvc/vixjava/trunk/src/main/com/vmware/vix/VixUtils.java?revision=12&view=markup
http://www.vmware.com/support/developer/vix-api/vix18_reference/lang/c/functions/VixVM_ListProcessesInGuest.html

I noticed that in VixUtils.java you are calling Vix_FreeBuffer() on pid. I'm wondering if that's needed since pid is a long, not a string.

151          mVix.Vix_FreeBuffer(pid.getPointer());
152          mVix.Vix_FreeBuffer(procName.getPointer());
153          mVix.Vix_FreeBuffer(owner.getPointer());
154          mVix.Vix_FreeBuffer(command.getPointer());

In the VIX api sample, they don't call FreeBuffer() on pid:

   Vix_FreeBuffer(processName);
   Vix_FreeBuffer(owner);
   Vix_FreeBuffer(cmdline)

I'm not sure if that would make a difference, but I thought I'd run to by you in case.  Please let me know what you think.

If I have time, I'll test it myself and report the results.

Thanks,

- Chris