basvandijk / usb

Communicate with USB devices
Other
27 stars 12 forks source link

Potential memory issues with 1.3 #4

Closed bgamari closed 10 years ago

bgamari commented 10 years ago

While testing 1.3 with a package of mine I noticed some strange behavior and occassional crashes. Running in valgrind made it very clear that there were some object lifetime issues introduced between 1.2.0.1 (which works well) and eba5bcc552caa282441185995a76f1d059374448,

$ sudo valgrind dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host
==5254== Memcheck, a memory error detector
==5254== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==5254== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==5254== Command: dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host
==5254== 
Just "Hello World!"
==5254== Thread 3:
==5254== Invalid read of size 4
==5254==    at 0x6958414: pthread_mutex_lock (pthread_mutex_lock.c:66)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953A03: __pthread_mutex_lock_full (pthread_mutex_lock.c:177)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x4E3B673: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010948 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid write of size 4
==5254==    at 0x4E3B67C: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010948 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x69597C0: pthread_mutex_unlock (pthread_mutex_unlock.c:41)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953F8F: __pthread_mutex_unlock_full (pthread_mutex_unlock.c:102)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6958414: pthread_mutex_lock (pthread_mutex_lock.c:66)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953A03: __pthread_mutex_lock_full (pthread_mutex_lock.c:177)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x4E3B673: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013988 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid write of size 4
==5254==    at 0x4E3B67C: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013988 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x69597C0: pthread_mutex_unlock (pthread_mutex_unlock.c:41)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953F8F: __pthread_mutex_unlock_full (pthread_mutex_unlock.c:102)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6958414: pthread_mutex_lock (pthread_mutex_lock.c:66)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953A03: __pthread_mutex_lock_full (pthread_mutex_lock.c:177)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x4E3B673: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013988 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid write of size 4
==5254==    at 0x4E3B67C: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013988 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x69597C0: pthread_mutex_unlock (pthread_mutex_unlock.c:41)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953F8F: __pthread_mutex_unlock_full (pthread_mutex_unlock.c:102)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x4E3B6BE: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6958414: pthread_mutex_lock (pthread_mutex_lock.c:66)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x57A13A: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953A03: __pthread_mutex_lock_full (pthread_mutex_lock.c:177)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x57A13A: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x4E3B673: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x57A13A: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010948 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid write of size 4
==5254==    at 0x4E3B67C: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x57A13A: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010948 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x69597C0: pthread_mutex_unlock (pthread_mutex_unlock.c:41)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x57A13A: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953F8F: __pthread_mutex_unlock_full (pthread_mutex_unlock.c:102)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x57A13A: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe010930 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579E02: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6958414: pthread_mutex_lock (pthread_mutex_lock.c:66)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953A03: __pthread_mutex_lock_full (pthread_mutex_lock.c:177)
==5254==    by 0x4E3B672: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x4E3B673: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013988 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid write of size 4
==5254==    at 0x4E3B67C: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013988 is 40 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x69597C0: pthread_mutex_unlock (pthread_mutex_unlock.c:41)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
==5254== Invalid read of size 4
==5254==    at 0x6953F8F: __pthread_mutex_unlock_full (pthread_mutex_unlock.c:102)
==5254==    by 0x4E3B683: libusb_unref_device (in /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254==  Address 0xe013970 is 16 bytes inside a block of size 152 free'd
==5254==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5254==    by 0x579CF5: ??? (in /home/bgamari/trees/tracker-host/dist/dist-sandbox-1cbac515/build/tracker-host/tracker-host)
==5254== 
basvandijk commented 10 years ago

Hi @bgamari, thanks for reporting this.

Could you check if the same error occurs if you change the condition in the mkDev function from:

if parentDevPtr == nullPtr

to:

if True

I suspect it might have some to do with the parent device feature I added.

It would also be useful if you can share your faulty program with me.

bgamari commented 10 years ago

I also suspected the parent device patch. I'll let you know when I get a chance to test this.

The failing program can be found here. In particular, the USB-facing code is Tracker.LowLevel. Unfortunately I doubt this will be of much use to use as the only instances of the associated hardware in existence exist in my lab and in a box in my apartment ;).

basvandijk commented 10 years ago

Hi @bgamari, did you already had a chance to test this?

bgamari commented 10 years ago

Indeed this fixes the Valgrind warnings.

Despite Valgrind being clean the library appears to deadlock after a few USB transactions. This also occurs when the memory issues are left unfixed. This is with GHC 7.8; usb-1.2.0.1 is known to work in this configuration.

bgamari commented 10 years ago

Actually, I take it back, it seems that usb-1.2.0.1 is also affected by the deadlock issue with GHC 7.8. I've opened #7 to track this unrelated issue.

basvandijk commented 10 years ago

I pushed https://github.com/basvandijk/usb/commit/89ae21d787f8840e99dedba13e15be4bb47b7388 which removes the parent device feature. This should clear up the Valgrind warnings.

Thanks for testing this.

I will close this and continue working on a fix for #7.