#3413 ipa-kdb plugin leaks memory
Closed: Fixed None Opened 5 years ago by mkosek.

When developing a new feature for ipa-kdb plugin I noticed that we leak memory in many occasions. Just few examples:

# LD_PRELOAD="/usr/lib64/krb5/plugins/kdb/ipadb.so" valgrind --trace-children=yes --leak-check=full  /usr/sbin/krb5kdc -n -w 1
...
==23856== 47 bytes in 1 blocks are definitely lost in loss record 554 of 659
==23856==    at 0x4C2A83C: malloc (vg_replace_malloc.c:270)
==23856==    by 0x6EEADD1: strndup (strndup.c:45)
==23856==    by 0x4E37026: ipadb_ldap_attr_to_str (ipa_kdb_common.c:383)
==23856==    by 0x4E3BF21: ipadb_reinit_mspac (ipa_kdb_mspac.c:1936)
==23856==    by 0x4E36445: ipadb_get_connection (ipa_kdb.c:328)
==23856==    by 0x4E3675E: ipadb_init_module (ipa_kdb.c:430)
==23856==    by 0x548D796: krb5_db_open (kdb5.c:619)
==23856==    by 0x11CB4B: init_realm (main.c:400)
==23856==    by 0x11D6CE: initialize_realms (main.c:874)
==23856==    by 0x10E33F: main (main.c:1003)
...
==23856== 72 bytes in 1 blocks are definitely lost in loss record 570 of 659
==23856==    at 0x4C28B2F: calloc (vg_replace_malloc.c:593)
==23856==    by 0x4E3EA6F: parse_bval_key_salt_tuples (ipa_krb5.c:591)
==23856==    by 0x4E36404: ipadb_get_connection (ipa_kdb.c:308)
==23856==    by 0x4E3675E: ipadb_init_module (ipa_kdb.c:430)
==23856==    by 0x548D796: krb5_db_open (kdb5.c:619)
==23856==    by 0x11CB4B: init_realm (main.c:400)
==23856==    by 0x11D6CE: initialize_realms (main.c:874)
==23856==    by 0x10E33F: main (main.c:1003)
...
==23856== 495 (56 direct, 439 indirect) bytes in 1 blocks are definitely lost in loss record 611 of 659
==23856==    at 0x4C28B2F: calloc (vg_replace_malloc.c:593)
==23856==    by 0x7225314: ber_memcalloc_x (memory.c:283)
==23856==    by 0x7442344: ldap_result (result.c:971)
==23856==    by 0x7444C7E: ldap_pvt_search_s (search.c:181)
==23856==    by 0x7444D0F: ldap_search_ext_s (search.c:150)
==23856==    by 0x4E3698B: ipadb_simple_search (ipa_kdb_common.c:167)
==23856==    by 0x4E3BA90: ipadb_mspac_get_trusted_domains (ipa_kdb_mspac.c:1765)
==23856==    by 0x4E3BED4: ipadb_reinit_mspac (ipa_kdb_mspac.c:1958)
==23856==    by 0x4E36445: ipadb_get_connection (ipa_kdb.c:328)
==23856==    by 0x4E3675E: ipadb_init_module (ipa_kdb.c:430)
==23856==    by 0x548D796: krb5_db_open (kdb5.c:619)
==23856==    by 0x11CB4B: init_realm (main.c:400)
...

This should not happen as krb5kdc is a long running daemon and leaks like these could consume a lot of memory in a long run.


Patch freeipa-mkosek-370-ipa-kdb-remove-memory-leaks.patch sent for review

master:[[BR]]
dfad439 ipa-kdb: fix retry logic in ipadb_deref_search[[BR]]
93ea8a6 ipa-kdb: remove memory leaks

ipa-3-1:[[BR]]
4e9081f ipa-kdb: fix retry logic in ipadb_deref_search[[BR]]
f14e7da ipa-kdb: remove memory leaks

Metadata Update from @mkosek:
- Issue assigned to mkosek
- Issue set to the milestone: FreeIPA 3.2 - 2013/02

2 years ago

Login to comment on this ticket.

Metadata