It appears in our testing that there exist serious memory leaks in VDDK on Linux 32 bit. Any pointers would be appreciated.
A sample program is at the end of this message. With calls to VixDiskLib_Open() and Close(), no reading of data, each call to Open leaks a good chunk of memory. The below valgrind output is from a single Open/Close pair.
Over 1000 errors are reported, mostly out of libxml2 and libcurl.
==715==
==715== ERROR SUMMARY: 39170 errors from 1000 contexts (suppressed: 42 from 1)
==715== malloc/free: in use at exit: 383,967 bytes in 8,033 blocks.
==715== malloc/free: 19,217 allocs, 11,184 frees, 2,394,652 bytes allocated.
==715== For counts of detected errors, rerun with: -v
==715== searching for pointers to 8,033 not-freed blocks.
==715== checked 2,474,068 bytes.
==715==
==715== LEAK SUMMARY:
==715== definitely lost: 366,477 bytes in 7,944 blocks.
==715== possibly lost: 0 bytes in 0 blocks.
==715== still reachable: 17,490 bytes in 89 blocks.
==715== suppressed: 0 bytes in 0 blocks.
==715== Rerun with --leak-check=full to see details of leaked memory.
Without the call to VixDiskLib_Open() and Close():
==687==
==687== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 25 from 1)
==687== malloc/free: in use at exit: 39,651 bytes in 1,757 blocks.
==687== malloc/free: 1,970 allocs, 213 frees, 137,174 bytes allocated.
==687== For counts of detected errors, rerun with: -v
==687== searching for pointers to 1,757 not-freed blocks.
==687== checked 2,493,324 bytes.
==687==
==687== LEAK SUMMARY:
==687== definitely lost: 0 bytes in 0 blocks.
==687== possibly lost: 0 bytes in 0 blocks.
==687== still reachable: 39,651 bytes in 1,757 blocks.
==687== suppressed: 0 bytes in 0 blocks.
==687== Rerun with --leak-check=full to see details of leaked memory.
Here is a simple test case:
#include <string.h>
#include <stdio.h>
#include <vixDiskLib.h>
#define VIXDISKLIB_VERSION_MAJOR 1
#define VIXDISKLIB_VERSION_MINOR 0
#define VDDK_DISK_OPEN 1
static void
panic_if_vixerror(VixError vixError, const char *func_name)
{
if (VIX_FAILED(vixError)) {
fprintf(stderr, "%s failed: %s\n", func_name, VixDiskLib_GetErrorText(vixError, NULL));
exit(1);
}
fprintf(stderr, "%s: OK\n", func_name);
}
static void
init_connect_params(VixDiskLibConnectParams *cp)
{
(void) memset(cp, 0, sizeof(*cp));
cp->vmxSpec = NULL;
cp->serverName = "192.168.201.106";
cp->credType = VIXDISKLIB_CRED_UID;
cp->creds.uid.userName = "root";
cp->creds.uid.password = "abc123";
cp->port = 902;
}
int
main(int argc, char **argv)
{
(void) argv;
VixError vixError;
VixDiskLibConnection conn = NULL;
VixDiskLibConnectParams cp;
if (argc <= 1) {
fprintf(stderr, "Usage: $0 <vmdk path>\n");
return 1;
}
init_connect_params(&cp);
vixError = VixDiskLib_Init(VIXDISKLIB_VERSION_MAJOR,
VIXDISKLIB_VERSION_MINOR,
NULL, NULL, NULL, // Log, warn, panic
NULL); // libDir
panic_if_vixerror(vixError, "VixDiskLib_Init");
vixError = VixDiskLib_Connect(&cp, &conn);
panic_if_vixerror(vixError, "VixDiskLib_Connect");
#if VDDK_DISK_OPEN
{
const char *disk_name = argv[1];
VixDiskLibHandle disk_handle = NULL;
VixError vixError = VixDiskLib_Open(conn, disk_name, VIXDISKLIB_FLAG_OPEN_READ_ONLY, &disk_handle);
panic_if_vixerror(vixError, "VixDiskLib_Open");
vixError = VixDiskLib_Close(disk_handle);
panic_if_vixerror(vixError, "VixDiskLib_Close");
}
#endif
if (conn != NULL) {
vixError = VixDiskLib_Disconnect(conn);
panic_if_vixerror(vixError, "VixDiskLib_Disconnect");
conn = NULL;
}
VixDiskLib_Exit();
printf("--done--\n");
return 0;
}
It doesn't seem to matter if VIXDISKLIB_VERSION_MINOR is 0 or 1.
The code is built with:
$ gcc -I/usr/lib/vmware-vix-disklib/include -L/usr/lib/vmware-vix-disklib/lib32 -g -lvixDiskLib -o testvddk test_vddk.c
Attachments:
- test_vddk.c (2.0 K)