1 Reply Latest reply: Jan 6, 2009 9:27 AM by dougm_hyperic RSS

    memory leak in sigar_util.c::sigar_rpc_ping()

    dlutz_hyperic Hot Shot
      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