libftdi Archives

Subject: Re: memory leak in examples/find_all.c (1.0)

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 20 Jun 2011 17:25:04 +0200
>>>>> "Matthias" == Matthias Janke <matthias.janke@xxxxxxxxxxxxxxxxxxxxxxx> 
>>>>> writes:

    Matthias> Hi, I used ftdi_usb_find_all() in my own program, which eposed
    Matthias> a memory leak, so I tested examples/find_all.c and it leaks,
    Matthias> too (valgrind output below). Is this the leak Uwe mentioned
    Matthias> here
    Matthias> 
http://developer.intra2net.com/mailarchive/html/libftdi/2010/msg00213.html
    Matthias> ?  If so is there a patch I've overlooked? I'm using a fresh
    Matthias> libftdi-1.0/master checkout from today.

I guess the memory leak happens inside our versions of libusb.
On my system (Opensuse 11.4) with libusb-1_0-0-1.0.8-4.1.x86_64 and e.g.
 baudtest I still get:

hertz:/spare/bon/ftdi/libftdi-1.0/build> valgrind --leak-check=full 
--show-reachable=yes examples/baud_test 
==30085== Memcheck, a memory error detector
==30085== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==30085== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==30085== Command: examples/baud_test
==30085== 
Can't open ftdi device: device not found
==30085== 
==30085== HEAP SUMMARY:
==30085==     in use at exit: 504 bytes in 3 blocks
==30085==   total heap usage: 76 allocs, 73 frees, 123,667 bytes allocated
==30085== 
==30085== 24 bytes in 1 blocks are possibly lost in loss record 1 of 3
==30085==    at 0x4C2683D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==30085==    by 0x5041049: ??? (in /usr/lib64/libusb-1.0.so.0.0.0)
==30085==    by 0x5041188: ??? (in /usr/lib64/libusb-1.0.so.0.0.0)
==30085==    by 0x503E2E2: libusb_init (in /usr/lib64/libusb-1.0.so.0.0.0)
==30085==    by 0x4E2F814: ftdi_init (ftdi.c:84)
==30085==    by 0x401118: main (baud_test.c:114)
==30085== 
==30085== 24 bytes in 1 blocks are possibly lost in loss record 2 of 3
==30085==    at 0x4C2683D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==30085==    by 0x5041049: ??? (in /usr/lib64/libusb-1.0.so.0.0.0)
==30085==    by 0x50411C3: ??? (in /usr/lib64/libusb-1.0.so.0.0.0)
==30085==    by 0x503E2E2: libusb_init (in /usr/lib64/libusb-1.0.so.0.0.0)
==30085==    by 0x4E2F814: ftdi_init (ftdi.c:84)
==30085==    by 0x401118: main (baud_test.c:114)
==30085== 
==30085== 456 bytes in 1 blocks are still reachable in loss record 3 of 3
==30085==    at 0x4C2683D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==30085==    by 0x503E253: libusb_init (in /usr/lib64/libusb-1.0.so.0.0.0)
==30085==    by 0x4E2F814: ftdi_init (ftdi.c:84)
==30085==    by 0x401118: main (baud_test.c:114)
==30085== 
==30085== LEAK SUMMARY:
==30085==    definitely lost: 0 bytes in 0 blocks
==30085==    indirectly lost: 0 bytes in 0 blocks
==30085==      possibly lost: 48 bytes in 2 blocks
==30085==    still reachable: 456 bytes in 1 blocks
==30085==         suppressed: 0 bytes in 0 blocks
==30085== 
==30085== For counts of detected and suppressed errors, rerun with: -v
==30085== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4)

find_all has also similar errors.
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread