01-30-2006 04:13 PM
01-30-2006 08:50 PM - edited 01-30-2006 08:50 PM
Follow-up in case anyone has to deal with similar issue...
Problem seemed to be with string conversions in return-clusters. Looks like INPUTs to LV7.1 DLL are no problem. Removed all outputs, added a cluster with bool - OK. Added numeric to the cluster - OK. Added (Error.Source) string - crash.![]()
Found that passing OUTPUTS as variants, then (on 6.1 side) converting back to desired type works. ![]()
So, built/Compiled a "wrapper" VI. The wrapper converts target outputs to ActiveX Variant. Call Lib. Func. unpacks these as ActiveX Variant, and variants are transformed back to type on same diagram as CLF.

Message Edited by Dynamik on 01-30-2006 08:53 PM
01-31-2006 05:43 AM
You can't use LabVIEW datatypes in the DLL interface if the DLL is to run in a different LabVIEW process than the LabVIEW system calling it. In your case the DLL is running in the LabVIEW 7.1 runtime system while you call it from a LabVIEW 6.1 runtime or development system. The array handles allocated by your LabVIEW 6.1 system are totally and utterly meaningless to the LabVIEW 7.1 runtime system but since it is a LabVIEW handle in the API definition the DLL code simply assumes that it is valid to resize them at a certain point. ->>>> General Protection Fault.
@Dynamik wrote:Hi Folks,I need to distribute some code in a (LabVIEW) DLL, but a bug in LabVIEW 6.1 prevents me from distributing the 6.1 DLL so I'm compiling it under 7.1. It then works great when called by a 7.1 VI, but calling it from 6.1 produces the dreaded"Fatal Internal Error : "memory.cpp", line 638LabVIEW version 7.1".Most of the applications here are in 6.1, upgrading working programs to 7.1 or 8.0 is not realistic.Any insight - especially know incompatabilities between 6.1 and 7.1 - would be greatly appreciated - I could use a work-around.Thanks!(a bit more detail...)The bug in 6.1 is that neither the "GetRows" or "GetString" ADODB.RecordSet methods correctly return "null" values.I don't think it would be "Kosher" to post the code, but here's a bit more specific info related to DLL parameter-types:INPUTS (Qty, Descript, Type, DataFormat2, Clusters, AdaptToType, HandlesByValue1, Enum, Numeric(U16),Value1, ArrayOfClusters, AdaptToType,PointersToHandlesOUTPUTS2, Clusters, AdaptToType, HandlesByValue2, ArrayOfClusters, AdaptToType,PointersToHandles
01-31-2006 03:29 PM
@rolfk wrote:
You can't use LabVIEW datatypes in the DLL interface if the DLL is to run in a different LabVIEW process than the LabVIEW system calling it. In your case the DLL is running in the LabVIEW 7.1 runtime system while you call it from a LabVIEW 6.1 runtime or development system. The array handles allocated by your LabVIEW 6.1 system are totally and utterly meaningless to the LabVIEW 7.1 runtime system but since it is a LabVIEW handle in the API definition the DLL code simply assumes that it is valid to resize them at a certain point. ->>>> General Protection Fault.
01-31-2006 06:13 PM
Hi (again) Rolf,
Thanks again for your post - having re-read it a few times, perhaps I understand your warning, now. Essentially, the DLL shouldn't re-size data-structures that are allocated by the caller. I knew that!
But you forced me to think about memory allocation and now I'm worried about leaks. Will the (LV7.1) DLL allocate different memory for results every time it's called?
cheers.
01-31-2006 06:46 PM
I hope this helps!
Best Regards,
JLS
02-01-2006 01:44 AM
No, it is worse than that. Since the DLL really runs in a different process (your LabVIEW 7.1 runtime engine) it has absolutely no control over the memory it gets passed from the caller. But since you are using LabVIEW data types it assumes it can resize them anyhow to accommodate the data it wants to put in. So it does use it's own DSSetHandleSize fucntions and friends that allocate memory from its own heap, but at the first occurrence of such a call will recognize that the handle is not something it has ever allocated and therefore cause an assert.
@Dynamik wrote:Hi (again) Rolf,
Thanks again for your post - having re-read it a few times, perhaps I understand your warning, now. Essentially, the DLL shouldn't re-size data-structures that are allocated by the caller. I knew that!
But you forced me to think about memory allocation and now I'm worried about leaks. Will the (LV7.1) DLL allocate different memory for results every time it's called?
02-02-2006 12:41 AM
02-02-2006 05:17 AM
First not the DLL is recognizing anything but probably LabVIEW. Each LabVIEW DLL exports an extra function that LabVIEW can use to query or set certain information.
@Dynamik wrote:Hi Rolf, [and fellow App. Builders]I hate to confess my ignorance here, I'm new to the LabVIEW DLL.> ... the DLL really runs in a different process> ... has absolutely no control over the memory it gets passedThis would also be true when caller is non-LabVIEW, no?> since you are using LabVIEW data types it assumes it can resize them anyhow> to accommodate the data it wants to put inHow does the DLL figure-out [from the data passed,] that the caller is a LabVIEW program?Even if the DLL [erroneously] identifies an object as something it can resize,why would it want to "put in" any data, if the DLL only reads the [Input] datastructure?Can one pass data in such a way that the DLL will not assume it can resize things?Rolf's post(s) seem(s) to imply that LabVIEW DLL can be used safely by [practically] everything - except another version of LabVIEW!If there's a good app-note on this, please share the link.Thanks, Cheers.
02-04-2006 01:04 AM
Hi Rolf,
You warnings have me worried, but pre-allocating the [arbitrary amount of] memory required for a database query result is not feasible. Besides if, as you say, the 7.1 DLL runs in it's own process perhaps it's perfectly OK to let the DLL allocate the memory it needs for results. Anyway the strategy seems to be working as is (Lv6.1 calling 7.1) so I'll share what I have and search for a work-around to the 6.1 ADODB.Recordset problems so to keep it all in 6.1 per your advice. ![]()
Cheers.