LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL crash after a long time

Hi there,

I am having a problem with calling a VC++ DLL from LabVIEW 7.0 (running Win2k). Everything seems to work fine, passing buffers for reading/writing etc. However, after some extended period of time (sometimes several hours, sometimes only tens of minutes) the DLL crashes with an exception. I do not have the exact error code, but its similar to the one I have seen when the parameters of a DLL are not properly specified.

This is extremely difficult to debug as often it takes hours before the DLL crashes! I have monitored the memory usage of the VI/DLL and it seems to be stable so I dont think its a memory leak inside the DLL. I have also confirmed that the parameters types defined in the VI DLL call match the DLL iteself.

The DLL is using some form of multi-threading, and I saw a post which indicated that it may be something in the LabVIEW garbage-collection which is interfering with this. I have tested this by switching OFF the multi-threading in the LabVIEW options (I assume this setting then gets correctly used when building the .exe?) but the problem seems to persist.

Has anyone had similar problem to this random behaviour?

Any help or advice would be greatly appreciated.

Thanks
Neil
0 Kudos
Message 1 of 3
(2,907 Views)
nrp wrote:

> This is extremely difficult to debug as often it takes hours

> before the DLL crashes! I have monitored the memory usage of the

> VI/DLL and it seems to be stable so I dont think its a memory

> leak inside the DLL. I have also confirmed that the parameters

> types defined in the VI DLL call match the DLL iteself.

While the types may match your DLL still could write over the end of a
buffer you are passing in. This is one of the most common errors and
will usually go undedected for a long time. In the worst case the DLL is
only overwriting data non-vital for the LabVIEW system during runtime so
that LabVIEW only crashes when you try to close the application, because
LabVIEW trips over some pointers it tries to deallocate but aren't valid
anymore.

> The DLL is using some form of multi-threading, and I saw a post which
> indicated that it may be something in the LabVIEW garbage-collection
> which is interfering with this. I have tested this by switching OFF
> the multi-threading in the LabVIEW options (I assume this setting then
> gets correctly used when building the .exe?)

Only if you make sure that the according labview.ini file setting is
reproduced in your application ini file.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 3
(2,901 Views)
Thanks Rolf,

Hopefully the DLL function is not writing past the end of the buffer, I am passing in much more free space than necessary, so I don't think that is happening. But that said I haven't peered over the c++ source code too much. If the problem persists I may have to do that.

As luck/fate would have it, I cannot seem to reproduce my problem!

I will try adding the .ini setting though, I think its ESys.StdNParallel=0 to force LabVIEW to use only a single thread?

Neil
0 Kudos
Message 3 of 3
(2,893 Views)