Phidgets DLL Crashes Consistently w/Multiple InterfaceKits

Supporting Visual Studio on Windows
dans
Phidgetsian
Posts: 5
Joined: Wed Oct 28, 2015 3:13 pm
Contact:

Phidgets DLL Crashes Consistently w/Multiple InterfaceKits

Postby dans » Thu Feb 11, 2016 9:45 am

I am able to consistently replicate a crash that occurs when Phidget21.dll calls ntdll. The crash occurs in a background thread while my application is idle.

Here's the order of events: plug in a PhidgetInterfaceKit 8/8/8, plug in a PhidgetInterfaceKit 2/2/2 (both through the same hub), I run my application, application opens both interfacekits and waits for attachment, application creates another interfacekit instance, application waits for attachment (which never occurs because there are only two devices), application closes the third interfacekit instance. When application opens a second form and user moves the mouse, the application quickly crashes.

By attaching to the application with a debugger before it crashes, I am able to determine that Phidgets21.dll is calling EnterCriticalSection in ntdll
(ntdll.dll!_RtlEnterCriticalSection@4() + 0x1b577 bytes_) when the crash occurs. The crash is either an access violation (0xC0000005) or an invalid handle (0xC0000008) exception. In the call stack, I can see the addresses of the Phidget21.dll code making function calls. Going up the stack, the address offsets (relative to base) are: 0x7d8c, 0x7df9, and 0x4fdec. (using the latest drivers, dll date is 2/2/2016.) Is a symbol file (pdb) available for this dll?

Note, my second form uses a large background image. For reasons I don't understand, when I remove this image, the application stops crashing. The code for displaying a background image is created by the Visual Studio designer and is managed (C#) code, so I don't think that this code can be wrong. My best guess is that displaying the background image allocates a large buffer to hold the image and this causes garbage collection that affects Phidget21.NET.dll, or possibly it is reusing memory previously freed by Phidget21.dll and code in the dll is still using the memory even though it was freed.

Do you have any suggestions on how I can work around this problem?

dans
Phidgetsian
Posts: 5
Joined: Wed Oct 28, 2015 3:13 pm
Contact:

Re: Phidgets DLL Crashes Consistently w/Multiple InterfaceKi

Postby dans » Thu Feb 11, 2016 10:40 am

Additional information: my application is written in C# and targets the .NET Framework 4 Client Profile. The application is running on Windows 7 on a 64 bit machine, using 64 bit Phidgets drivers. I have replicated the crash on two other Windows 7 machines.

dans
Phidgetsian
Posts: 5
Joined: Wed Oct 28, 2015 3:13 pm
Contact:

Re: Phidgets DLL Crashes Consistently w/Multiple InterfaceKi

Postby dans » Thu Feb 11, 2016 10:46 am

Additional information: if I do NOT attempt to open a third device and connect (unsuccessfully) when starting my application, then the application does not crash.

dans
Phidgetsian
Posts: 5
Joined: Wed Oct 28, 2015 3:13 pm
Contact:

Re: Phidgets DLL Crashes Consistently w/Multiple InterfaceKi

Postby dans » Fri Feb 12, 2016 10:37 am

Solution: if I keep a reference to the InterfaceKit that fails to attach after I close it, then my application does not crash. So probably the crashing is occurring when the InterfaceKit instance gets garbage collected. However, I do not think it should be an error to allow garbage collection of the instance after I am done with it.


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 0 guests