We use LabVIEW for our software, where we call C++ DLLs containing QtCore classes to do most of the operations. Since a long time, we were confronted with a mysterious bug. Upon closing LabVIEW, we always got an exception with the following details:

Faulting application name: LabVIEW.exe, version: 12.0.1.4005, time stamp: 0x50d25315
Faulting module name: QtCore4.dll_unloaded, version: 0.0.0.0, time stamp: 0x520367f0
Exception code: 0xc0000005
Fault offset: 0x000000001864846e
Faulting process id: 0xec4
Faulting application start time: 0x01cf53fb199ed2db
Faulting application path: C:\Program Files\National Instruments\LabVIEW 2012\LabVIEW.exe
Faulting module path: QtCore4.dll
Report Id: 79aaef7e-bfee-11e3-9456-06e9c199960a
Faulting package full name:
Faulting package-relative application ID:

I couldn't grasp what was happening, especially since the exception kept on occurring after stripping both the C++ and the LabVIEW code almost to the bone. In the end, I found the cause but I can not find a complete explanation.

The exception occurs because we call a function from our DLL inside a loop in LabVIEW, which includes a Wait function of 1 ms. This LabVIEW Wait as introduced to make the UI more responsive, certainly not the ideal solution. Removing this Wait function removes the exception. Some more research on line shows me that the wait is handled by the OS, and the current thread is put to sleep for a period equal to the Wait input:

http://www.grahamwideman.com/gw/tech...timingmech.htm

Can anyone help me to understand what happens with the code in the DLL then? I stripped everything down to such an extent that there were only some QString objects still used in the DLL. Can the memory management of these objects be affected by putting the thread to sleep?

Any feedback is welcome!