
Hi libsmi team, This is to report two issues with regards to : libsmi-0.4.8-16.fc23.x86_64
Issue #1Although smiExit() does good job of freeing memory blocks allocated by smiInit, it misses one. To be precise, 44 out of 45 allocated memory block are freed. (Details of the experiment at the end of this mail)
Issue #2The libsmi examples here^ do not call smiExit():^ https://www.ibr.cs.tu-bs.de/projects/libsmi/example.html%5E https://www.ibr.cs.tu-bs.de/projects/libsmi/libsmi.html
Details of the memory leak:To investigate this issue, first noted by 'tcpdump' project, I wrote two simple programs; one calls smiExit(), and the other does not.(Platform: Fedora Core 23 (64 bit))
The following sample program does not call smiExit();$ cat libsmi_noexit.c #include <smi.h> void main(){ smiInit(NULL);} Relevant parts of Valgrind Output:==10291== HEAP SUMMARY:==10291== in use at exit: 3,834 bytes in 45 blocks==10291== total heap usage: 45 allocs, 0 frees, 3,834 bytes allocated ==10291== LEAK SUMMARY:==10291== definitely lost: 80 bytes in 1 blocks==10291== indirectly lost: 0 bytes in 0 blocks==10291== possibly lost: 0 bytes in 0 blocks==10291== still reachable: 3,754 bytes in 44 blocks==10291== suppressed: 0 bytes in 0 blocks
The following sample program calls smiExit();$ cat libsmi_exit.c#include <smi.h> void main(){ smiInit(NULL); smiExit();} Relevant parts of Valgrind Output:==10299== HEAP SUMMARY:==10299== in use at exit: 80 bytes in 1 blocks==10299== total heap usage: 45 allocs, 44 frees, 3,834 bytes allocated==10299== ==10299== 80 bytes in 1 blocks are definitely lost in loss record 1 of 1==10299== at 0x4C2A988: calloc (vg_replace_malloc.c:711)==10299== by 0x4E48A9D: smiMalloc (in /usr/lib64/libsmi.so.2.0.27)==10299== by 0x4E448E5: smiInitData (in /usr/lib64/libsmi.so.2.0.27)==10299== by 0x4E4B8B2: smiInit (in /usr/lib64/libsmi.so.2.0.27)==10299== by 0x4006F3: main (in /home/bijal/projects/libsmi_leaktest/libsmi_exit) ==10299== LEAK SUMMARY:==10299== definitely lost: 80 bytes in 1 blocks ==10299== indirectly lost: 0 bytes in 0 blocks==10299== possibly lost: 0 bytes in 0 blocks==10299== still reachable: 0 bytes in 0 blocks==10299== suppressed: 0 bytes in 0 blocks`
I have just begun to contribute to tcpdump project, and have no experience of using libsmi,but glad to participate in discussion with regards to this.
ThanksBijal