Jump to content

random crash of DLL


Recommended Posts

hi!

I'm building a dll file to fit some measurement data. To test the routine I use some sets of measured data, the strange thing is when I fit the same data a couple of times, so press the fit button a couple of times to start over and over. Labview is saying the call library function node threw an exeption.

I've read on the fora that this can occure when deviding by 0 of take the sqrt of an negative number, but since the input is the same all the time this can't be the case.

Anyone a suggestion what it could be?

I'm using the calloc and free function.

thanks!

Link to comment

Typically this is a problem with your DLL and/or how you call it. You do not say how you created the DLL (LabVIEW or C) nor how you try to call it. But a common problem is that people calling a DLL from LabVIEW using the Call Library Node do forget that in this case normal C rules apply and the automatic memory allocation management they have gotten so used to in LabVIEW does and can not work here.

So they call a function to sum array a and b and hope that the DLL magically allocates array c to write the result in. Well the DLL can't do so and LabVIEW can't do so for you either as the development of the LabVIEW mind reader interface to read the programmers intentions is still in the early stages of prototyping :D .

So what happens is that the DLL writes its results in the invalid (or to small) memory pointer that is passed to the DLL and sometimes that overwrites only non-vital data, sometimes it overwrites very vital data that will make LabVIEW crash after the fucntion returns (or destroy the VIs that you have in memory) and sometimes it happens to write to memory locations the OS knows are not valid for the current process, which will throw the exception during the fucntion call already.

Review your DLL for possible out of bounds array references, make sure you call it with preallocated arrays that are long enough for all array and string output parameters and then come back with more info such as the DLL source code and test harness itself if it still fails.

Rolf Kalbermatter

Link to comment

Join the conversation

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

Guest
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.