[Linux-ha-dev] [patch] Fix potential memory leaks in the HB client library

Keisuke MORI kskmori at intellilink.co.jp
Tue Oct 30 05:53:54 MDT 2007


Hi,

I've been testing the heartbeat with valgrind enabled,
and found that it reported a couple of leaks which are
in the heartbeat API client library.

I'm submitting my proposed patch to fix them, so
could somebody please review it and the correctness?

In my understanding, these leaks are not so serious 
because the leaks only happens when the heartbeat exits,
but it may be a problem if a HB client does signon()/signoff()/delete()
repeatedly in a single process.


The valgrind report is below:
(It's excerpt. I used the hbagent to generate this, but it has
some other problems and I'm still looking into it.)

----8<--------8<--------8<--------8<--------8<--------8<--------8<----
(1) ==13900== 72 (28 direct, 44 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 47
(1) ==13900==    at 0x4004405: malloc (vg_replace_malloc.c:149)
(1) ==13900==    by 0xAB1B72: g_malloc (in /usr/lib/libglib-2.0.so.0.400.7)
(1) ==13900==    by 0xAA142E: g_hash_table_new_full (in /usr/lib/libglib-2.0.so.0.400.7)
(1) ==13900==    by 0xAA14C4: g_hash_table_new (in /usr/lib/libglib-2.0.so.0.400.7)
(1) ==13900==    by 0x404D5A0: hb_api_signon (client_lib.c:359)
(1) ==13900==    by 0x804A12B: init_heartbeat (hbagent.c:572)
(1) ==13900==    by 0x804AF1B: main (hbagent.c:1382)
(1) ==13900== 
(1) ==13900== 
(1) ==13900== 881 (12 direct, 869 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 47
(1) ==13900==    at 0x4004405: malloc (vg_replace_malloc.c:149)
(1) ==13900==    by 0x4049760: enqueue_msg (client_lib.c:1535)
(1) ==13900==    by 0x404B51E: read_api_msg (client_lib.c:1684)
(1) ==13900==    by 0x404D680: hb_api_signon (client_lib.c:396)
(1) ==13900==    by 0x804A12B: init_heartbeat (hbagent.c:572)
(1) ==13900==    by 0x804AF1B: main (hbagent.c:1382)
----8<--------8<--------8<--------8<--------8<--------8<--------8<----


-- 
Keisuke MORI
NTT DATA Intellilink Corporation

-------------- next part --------------
A non-text attachment was scrubbed...
Name: valgrind-hbclient.patch
Type: text/x-patch
Size: 1705 bytes
Desc: not available
Url : http://lists.community.tummy.com/pipermail/linux-ha-dev/attachments/20071030/5307a3df/valgrind-hbclient.bin


More information about the Linux-HA-Dev mailing list