libftdi Archives

Subject: Memory leak in 'simple' example?

From: Hendrik <chasake@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 17 May 2016 18:58:35 +0200
Hi,

If I run the 'simple.c' example against libftdi 1.2 it works fine as long as 'nothing goes wrong'.

But if I put a 'sleep(5)' command just before the "if ((ret = ftdi_usb_close(ftdi)) < 0)" and I pull the USB plug while sleeping valgrind tells me that not all memory is freed so the ftdi_usb_close(ftdi) seems to leak in that specific case.

How come? Is the 'simple' example just oversimplified (although a lot of ftdi_frees are in place)?

FYI I am using libusb from Ubuntu 14.04 LTS itself:
    libusb-1.0-0-dev:amd64
    2:1.0.17-1ubuntu2
    amd64
    userspace USB programming library development files

Regards,
Hendrik

--- Valgrind trace ---
==19593== Memcheck, a memory error detector
==19593== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==19593== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==19593== Command: ./simple
==19593==
Initialized libftdi 1.2 (major: 1, minor: 2, micro: 0, snapshot ver: unknown)
ftdi_read_chipid: 0
FTDI chipid: 3B359ACD
unable to close ftdi device: -1 (all fine)
==19593==
==19593== HEAP SUMMARY:
==19593==     in use at exit: 3,543 bytes in 9 blocks
==19593== total heap usage: 1,198 allocs, 1,189 frees, 271,883 bytes allocated
==19593==
==19593== LEAK SUMMARY:
==19593==    definitely lost: 152 bytes in 1 blocks
==19593==    indirectly lost: 3,391 bytes in 8 blocks
==19593==      possibly lost: 0 bytes in 0 blocks
==19593==    still reachable: 0 bytes in 0 blocks
==19593==         suppressed: 0 bytes in 0 blocks
==19593== Rerun with --leak-check=full to see details of leaked memory
==19593==
==19593== For counts of detected and suppressed errors, rerun with: -v
==19593== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


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