LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview crushed after call library function node

Hi,

 

The labview crushed after call library function node. The library vi runs fine by it owen, but the labview crushed after I try to call the dll I created base on that library vi.  I can not figure why. Here I attach my library vi file.

0 Kudos
Message 1 of 5
(2,481 Views)

Do you mean crashed?

 

I don't see a call library function node in the VI you attached. I'm guess it is in the subVI that you failed to attach.

 

In all likelihood, you set up something wrong in the calling of that dll code.

 

You should probably attach the .h file and the dll code itself as the problem may be in the dll.  Just because you are able to call it sometimes without crashing doesn't mean it doesn't have a problem.  It may be that you just got lucky that the problem didn't reveal itself.

0 Kudos
Message 2 of 5
(2,453 Views)

Hi RavensFan,

 

oh, that vi is the library(dll file).  Here attaches the vi include the call  library functional node.

and here is the .h file (the web does not allowed me upload the .h file):

#include "extcode.h"
#pragma pack(push)
#pragma pack(1)

#ifdef __cplusplus
extern "C" {
#endif

/*!
* Cal_try
*/
void __stdcall Cal_try(Path *PathConfigurationFilePath,
LVBoolean *Cal_check_result);

MgErr __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);

#ifdef __cplusplus
} // extern "C"
#endif

#pragma pack(pop)

 

Thanks

0 Kudos
Message 3 of 5
(2,439 Views)

That missing VI is not the dll, it is the subVI that calls the dll.

 

You can attach other files if you zip them up and attach the zip file.  Include the C code as well.

 

I don't know C, so can't help with that.  But I've read plenty of messages where people have problems calling C code and it usually comes down to them setting up the calls wrong or not allocating space for what is being returned.

 

What exactly are you trying to to in your C code?  It seems odd that you are passing in a LabVIEW path and have a LVBoolean declared as the output.

Who created the dll?  If you know what is the underlying code, it is probably far easier to just recreate the code in pure LabVIEW rather than calling a dll.

0 Kudos
Message 4 of 5
(2,431 Views)

Definitely need to see the whole picture:

 

It would seem that your DLL is actually a LabVIEW VI turned into a DLL. Aside that that is of course a terrible roundabout way of doing business (create a DLL from a LabVIEW VI to call it through the Call Library Node) there are virtually 100 things that could not match up. We would need the LabVIEW project and the VI from which this DLL was build.

 

The most obvious problem you absolutely have and which makes it totally impossible this ever could have worked is the fact that you totally borked the parameter list. As can be seen in the header file, the first parameter is the path and the second one is the boolean. You try to do it in the opposite order. So the DLL function sees the Boolean and tries to interprete it as a Path:

- Since you don't initialize the left side LabVIEW passes in a reference to a False. LAbVIEW booleans are 8-bit but the compiler will likely extend that to a full 32-bit register value and pass in a NULL. The DLL sees a NULL handle (it assumes this is a Path) and does pass an empty handle to the actual VI inside the DLL. This VI does what it is supposed to do with this path, most likely causing some internal errors as the path is invalid. Then the output boolean is generated and put in the memory location where you passed in the path. => Instant Memory Corruption!!!!!! The Path handle that you passed in has been (partially) overwritten and is now invalid. At some point LabVIEW decides that it does not need that path anymore and tries to dispose it, but as the handle is now invalid the memory manager barks out as it got told to deallocate some memory that it can't match to allocated memory blocks! 💥 💥

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