Discussion:
[libusb] Libusb memory free error under windows?
Dave Camarillo
2017-02-24 22:42:05 UTC
Permalink
Hello libusb folks! :) I'm trying to track down an occasional bug that we
keep running into. For some reason, our application keeps crashing when
doing certain libusb related function calls. This only occurs on windows,
and appears to be modal. When it occurs, we can run our application
multiple times in a row, and it will keep crashing in the same way. If we
unplug all our USB devices, then plug them back in, then the problem
"disappears". At some point later, maybe with the same runtime instance,
maybe after a restart it will happen again. We are really not sure how to
reproduce it. It has happened with many users, on many different machines
(all windows) but we are not sure about the hardware distribution
statistics. The offending function call seems to be part of the process of
freeing memory, but we don't understand the implementation details of the
windows implementation to say why/how it's happening, or why it might be
modal.

Has anyone else seen this? Have suggestions? Thoughts?

Thanks,
-Dave


Technical Details:
- Libusb Version 1.0.21
- Libusb has been compiled under mingw
- Windows 10, 64bit, fully updated
- Stack Trace:
warning: Critical error detected c0000374

Thread 118 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 8828.0x11fc]
0x00007ffc7b5b8243 in ntdll!RtlpNtMakeTemporaryKey () from
C:\WINDOWS\SYSTEM32\ntdll.dll
(gdb) backtrace
#0 0x00007ffc7b5b8243 in ntdll!RtlpNtMakeTemporaryKey () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#1 0x00007ffc7b5b8bda in ntdll!RtlpNtMakeTemporaryKey () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#2 0x00007ffc7b565b9a in ntdll!RtlRaiseStatus () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#3 0x00007ffc7b4fc895 in ntdll!RtlFreeHeap () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#4 0x00007ffc78c79dac in msvcrt!free () from C:\WINDOWS\System32\msvcrt.dll
#5 0x0000000066dd0033 in windows_get_device_list (ctx=0x177e1270,
_discdevs=0x2bacee08) at os/windows_winusb.c:1653
#6 0x0000000066dc539d in libusb_get_device_list (ctx=0x177e1270,
list=0x2bacef18) at core.c:842
#7 0x0000000066d61fb8 in apdm_usb_allocate_device_list
(dest_device_list=0x2bacf008) at apdm_usb.c:191

- Code Snipit from os/windows_winusb.c:1653
// Unref newly allocated devs
for (i = 0; i < unref_cur; i++)
safe_unref_device(unref_list[i]);
free(unref_list);
Matthias Bußjäger
2017-02-28 09:09:47 UTC
Permalink
Hi Dave,

it sounds like a similar issue I described on Feb., 23rd, but your code
snipit indicates another problem.
Just to double check issues with v1.0.21, could you check other versions
in case you run into this problem (without disconnecting your USB devices):
- v.1.0.20
- up to date sources from github

Thanks for your info,
Matthias
Post by Dave Camarillo
Hello libusb folks! :) I'm trying to track down an occasional bug that
we keep running into. For some reason, our application keeps crashing
when doing certain libusb related function calls. This only occurs on
windows, and appears to be modal. When it occurs, we can run our
application multiple times in a row, and it will keep crashing in the
same way. If we unplug all our USB devices, then plug them back in,
then the problem "disappears". At some point later, maybe with the
same runtime instance, maybe after a restart it will happen again. We
are really not sure how to reproduce it. It has happened with many
users, on many different machines (all windows) but we are not sure
about the hardware distribution statistics. The offending function
call seems to be part of the process of freeing memory, but we don't
understand the implementation details of the windows implementation to
say why/how it's happening, or why it might be modal.
Has anyone else seen this? Have suggestions? Thoughts?
Thanks,
-Dave
- Libusb Version 1.0.21
- Libusb has been compiled under mingw
- Windows 10, 64bit, fully updated
warning: Critical error detected c0000374
Thread 118 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 8828.0x11fc]
0x00007ffc7b5b8243 in ntdll!RtlpNtMakeTemporaryKey () from
C:\WINDOWS\SYSTEM32\ntdll.dll
(gdb) backtrace
#0 0x00007ffc7b5b8243 in ntdll!RtlpNtMakeTemporaryKey () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#1 0x00007ffc7b5b8bda in ntdll!RtlpNtMakeTemporaryKey () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#2 0x00007ffc7b565b9a in ntdll!RtlRaiseStatus () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#3 0x00007ffc7b4fc895 in ntdll!RtlFreeHeap () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#4 0x00007ffc78c79dac in msvcrt!free () from
C:\WINDOWS\System32\msvcrt.dll
#5 0x0000000066dd0033 in windows_get_device_list (ctx=0x177e1270,
_discdevs=0x2bacee08) at os/windows_winusb.c:1653
#6 0x0000000066dc539d in libusb_get_device_list (ctx=0x177e1270,
list=0x2bacef18) at core.c:842
#7 0x0000000066d61fb8 in apdm_usb_allocate_device_list
(dest_device_list=0x2bacf008) at apdm_usb.c:191
- Code Snipit from os/windows_winusb.c:1653
// Unref newly allocated devs
for (i = 0; i < unref_cur; i++)
safe_unref_device(unref_list[i]);
free(unref_list);
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
libusb-devel mailing list
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Loading...