VMware Cloud Community
dlutz_hyperic
Contributor
Contributor

memory leak in sigar_util.c::sigar_rpc_ping()

I am posting this to the forum at the request of Doug MacEachern,
after an offline conversation about this issue...

I recently spent some time helping a colleague debug a
memory leak, and tracked it down to sigar_rpc_ping()
in sigar_util.c. I searched on http://jira.hyperic.com/browse/SIGAR
and didn't see an open bug for this. I also checked the
source code for version 1.6, and the issue appears to
exist there (we were running version 1.5).

To be specific, sigar_rpc_ping() in hyperic-sigar-1.6.0-src/src/sigar_util.c
calls clntudp_create() or clnttcp_create() and eventually executes:

===========
rpc_stat = clnt_call(client, NULLPROC, (xdrproc_t)xdr_void, NULL,
(xdrproc_t)xdr_void, NULL, timeout);

if (rpc_stat != RPC_SUCCESS) {
return rpc_stat;
}

clnt_destroy(client);

return RPC_SUCCESS;
}
===========

Note that if clnt_call() does not return RPC_SUCCESS, we return
from sigar_rpc_ping() without calling clnt_destroy().

I think this could be fixed by changing the code to:

===========
rpc_stat = clnt_call(client, NULLPROC, (xdrproc_t)xdr_void, NULL,
(xdrproc_t)xdr_void, NULL, timeout);

clnt_destroy(client);

return rpc_stat;
}
===========

HTH,
David
Reply
0 Kudos
1 Reply
dougm_hyperic
VMware Employee
VMware Employee

Many thanks David! The bug is tracked in http://jira.hyperic.com/browse/SIGAR-132 and I've applied your fix to be included in the 1.6.2 release.
Reply
0 Kudos