LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLLs, Call Library Function Outputs, and TDM Header Writers

In using and troubleshooting dlls within my most recent labview application, I stumbled across a whitepaper stating that ALL inputs AND outputs of "call library function" nodes must be wired.

 

“If you do not wire the outputs, LabVIEW assumes that the DLL function does not need the allocated memory passed on the input side and will use it for something else. The DLL function will then overwrite reserved LabVIEW memory space, causing LabVIEW to crash.”

 

I had never seen this information before, so I started to look at some other, more official places, where I knew dll calls were being used to see if they followed the rules. I found that the NI TDM header writer VIs from here frequently have missing output terminal wires! 

 

How severe of a vulnerbility is this in the header writer VIs? Could they potentially, but not frequently, cause labview to unexpectedly crash?

 

And on a more general note, does anyone have more information or experience on this subject of missing output terminal wires? The only other anecdotal information I was able to glean from these forums is a fairly old post here, where one of the posters references the same white paper, and another claims to have witnessed data on an input wire change after execution of the downstream call library node, seemingly violating the dataflow paradigm.

 

Thanks!

0 Kudos
Message 1 of 3
(2,361 Views)

The most common problem when using DLLs is that the code cannot be unallocated from memory and it eventually causes LabVIEW to crash. As you mentioned referring to this other whitepaper, all the outputs have to be wired. When using DLLs and the Call Library Function Node, a good idea is to unload the DLL after is being used:

 

Can I Dynamically Load and Unload a DLL in LabVIEW?

http://digital.ni.com/public.nsf/allkb/77594203D78D12278625729100758BE5

0 Kudos
Message 2 of 3
(2,309 Views)

For whatever it's worth, this doesn't match my experience at all. I've never seen personally, nor seen reported elsewhere on this forum, problems due to not wiring the output from a DLL call. It should definitely be possible to pass data by pointer to a DLL without needing to wire the corresponding output. Perhaps there's some qualification missing from the white paper, for example that you must wire the outputs if the DLL modifies the corresponding input. If the DLL only reads the input (specifically the data pointed to by the input) then there is no need to wire the output.

 

Say you branch an array wire, with one branch going to a DLL call and the other to some other LabVIEW operation that uses but does not modify the array (such as an array sum). I can imagine that if the array output from the DLL call is left unwired, LabVIEW concludes that the DLL does not modify that memory and therefore it can pass the original array to the DLL rather than making a copy. If the DLL does, in fact, modify that memory, it could cause unexpected results in the other array operations. That's my best guess as to why that note exists.

0 Kudos
Message 3 of 3
(2,292 Views)