Jump to content

CLF Dll vc++ exception


Recommended Posts

  • 4 weeks later...

Hello:

In labview. I call many dll files using CLF node. During debug, everything is right. But build a .exe application, and run it , an error message show as follow:

An exception occurred within the external code called by a Call Library Function Node. This might have corrupted LabVIEW's memory. Save any work to a new location and restart LabVIEW.

Why is everybody posting into LabVIEW general nowadays. This and most other topics here are clearly posts that should have been placed in the relevant thread under LabVIEW (By Category)!

Just because it doesn't crash during debug run does not mean everything is right. The symptoms you describe clearly point into one of these directions.

1) You have setup an output parameter (a buffer parameter where the DLL function is supposed to write data into, such as an array or string) but forgotten to allocate memory for it before passing it to the function. While LabVIEW's automatic memory management takes care of everything as long as you stay in LabVIEW, there is no way for LabVIEW to know how big a buffer it should preallocate when calling a C function. Therefore it doesn't and relies on you to do so. You have two options here, in LabVIEW 8.5 and higher you can define the minimum size of elements LabVIEW should allocate for such a parameter in the CLN or you can do it explicitedly by using the Initialize Array function.

The reason it doesn't always crash is that by not allocating (enough) memory for the buffer, the DLL function will write into some memory area anyhow. This can overwrite information that is vital to LabVIEW but sometimes also information that does not immediately lead to a crash. In an executable most diagram and other information removed and only the runtime data remaining, chances are higher that it will touch vital data so a crash is more likely but that is not a rule. It can also be opposite, or depend on the moon phase or anything else rather esoteric :rolleyes:.

2) You configured the parameters not quite right.

3) You pass data to the DLL that trigger a bug.

Link to comment

I have resolved this problem.

You could help potentially others who might use the search function before posting, by posting an explanation of what caused your problem and how you resolved it, rather than just posting that you solved the problem. This last information is more or less meaningless to everyone here as it is not our problem so if you solved it or not has little importance to us, but how you solved it may be very interesting and helpful to others.

Link to comment
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.