From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows DLL crash in Release, but not Debug

My LabWindows 2012 CVI application crashes when executing DLL function in Release 64 mode, but not Debug 64 mode.  The 64-bit DLL was created in Matlab, and executes Matlab functionality.

 

The Just In Time debugger comes up right when the DLL function has finished executing.  If I link the process to LabWindows I get the following error:

A non-debuggable thread caused a 'General Protection' fault at address

 Any ideas?

0 Kudos
Message 1 of 7
(3,777 Views)

Hi softengr,

 

I would recommend determining whether this problem occurs because of the difference in speed between the debug and release modes of LabWindows/CVI.  To do this, reduce the number of debug options by navigating to Options » Build Options..., and select No run-time checking for the Debugging level.  You can also disable some features from the Environment options dialog by unchecking features in the Debug section (Options » Environment...).

You can also try to change the parameters of the Release build by changing parameters in the Build options.  

 

Are you doing any dynamic memory management inside your DLL?  Are you able to troubleshoot your DLL to find a specific line which causes this crash?

 

Any additional information about how you are calling your DLL, whether your DLL calls functions asynchronously, etc. would be very helpful and appreciated.

 

Warm Regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 2 of 7
(3,747 Views)

The DLL was created in Matlab, and performs an analysis on various input files.  The DLL writes output files and displays various plots of data.  The input parameters to the function that I am calling are of type "mxArray".   I had local mxArray variables declared at the beginning of the thread (the same thread that the DLL function is called in) that were used to pass into the input parameters of the DLL.  When I declared these same mxArray variables outside of the thread function, the DLL function no longer crashed.  Do you believe the Matlab DLL was doing some kind of dynamic memory management with these mxArray variables when using the mxCreateDoubleScalar function? Could this have been a reason for the crash?

 

I am going to continue testing to verify that the crash has been eliminated.

0 Kudos
Message 3 of 7
(3,729 Views)

Hi softengr,

 

The MathWorks, Inc. provides further documentation about the function in question here.  If you have further questions about the workings of your DLL, they may be able to provide more insight.

 

MATLAB® is a registered trademark of The MathWorks, Inc.  

 

Warm Regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 4 of 7
(3,725 Views)

A bit of a guess here, but have you checked that all your variables are being properly intialized? I seem to recall that in debug variables can be initalized to zero which might be creating nice inputs for your DLL that are not present in release.

0 Kudos
Message 5 of 7
(3,718 Views)

Yes, the variables that I input into the DLL function have all been initialized.  The crash occurs after the DLL performs all of its operations and is ready to return

0 Kudos
Message 6 of 7
(3,711 Views)

You might want to verify that the setting for EnableLoadExternalModule is the same in both Debug and Release in the Target Settings dialog box.  This can get inadvertently changed if the project is opened up and saved in older versions of CVI (especially when CVI 2010 is in the mix) 

Good Luck - Jim

0 Kudos
Message 7 of 7
(3,655 Views)