Tackling memory leaks #139
Replies: 4 comments 25 replies
-
Beta Was this translation helpful? Give feedback.
-
My valgrind output definitely appears to only have issues with v3 sessions. Commenting out SNMPv3 session arguments shows zero It's honestly strange as I comb through the code. Referencing the above blocks: /* lines 1692 to 1697, for blocks 600 to 601 */
session.securityEngineIDLen =
hex_to_binary2((unsigned char *)sec_eng_id, STRLEN(sec_eng_id),
(char **) &session.securityEngineID);
session.contextEngineIDLen =
hex_to_binary2((unsigned char *)context_eng_id, STRLEN(sec_eng_id),
(char **) &session.contextEngineID);
/* lines 1719 to 1723, for block 744 */
else if (!strcmp(auth_proto, "DEFAULT"))
{
const oid* a = get_default_authtype(&session.securityAuthProtoLen);
session.securityAuthProto
= snmp_duplicate_objid(a, session.securityAuthProtoLen);
}
/* lines 1765 to 1770, for block 745 */
else if (!strcmp(priv_proto, "DEFAULT"))
{
const oid *p = get_default_privtype(&session.securityPrivProtoLen);
session.securityPrivProto =
snmp_duplicate_objid(p, session.securityPrivProtoLen);
}
static void
snmp_free_session(netsnmp_session * s)
{
if (s) {
SNMP_FREE(s->localname);
SNMP_FREE(s->peername);
SNMP_FREE(s->community);
SNMP_FREE(s->contextEngineID);
SNMP_FREE(s->contextName);
SNMP_FREE(s->securityEngineID);
SNMP_FREE(s->securityName);
SNMP_FREE(s->securityAuthProto);
SNMP_FREE(s->securityPrivProto);
SNMP_FREE(s->paramName);
#ifndef NETSNMP_NO_TRAP_STATS
SNMP_FREE(s->trap_stats);
#endif /* NETSNMP_NO_TRAP_STATS */
/*
* clear session from any callbacks
*/
netsnmp_callback_clear_client_arg(s, 0, 0);
free((char *) s);
}
} I'll have to read up on |
Beta Was this translation helpful? Give feedback.
-
I believe I've detected the source of the leaks for v3 sessions. It appears that calling |
Beta Was this translation helpful? Give feedback.
-
Outstanding issues revolving around memory leaks have been addressed. This conversation will be locked for archival purposes and may be unlocked in the future if the issue(s) resurface. |
Beta Was this translation helpful? Give feedback.
-
I've created branch memork-leaks to address outstanding issues regarding memory leaks. The first commit appears to reduce leaks from
13,684 bytes in 261 blocks
to10,044 bytes in 248 blocks
. It's not much but it's a start. The next chunk of leaks I need to tackle seem to originate from v3 sessions:There are a lot of "possibly lost" blocks that do not seem to tie directly back to any invoking code from interface.c, so for now I'm going to assume that these are caused from strings created in Python that get passed to our v3 sessions and are lost because they are not able to be safely deallocated. So hopefully tackling the "definitely lost" results in clearing the "possibly lost".
Beta Was this translation helpful? Give feedback.
All reactions