09-21-2013 12:57 AM
Hello we have a labview Vi which tries to call a C function from a C/C++ dll. the function sets the python script paths and then calls Py_initialize.
Labview exits with no warning or error notification.
Windows error log shows the following.
3843485786 |
1 |
APPCRASH |
Not available |
0 |
LabVIEW.exe |
12.0.1.4008 |
51421a0a |
python27.dll |
2.7.3150.1013 |
4f84a6c7 |
40000015 |
0006016a |
C:\Users\fernav2\AppData\Local\Temp\WER5E2C.tmp.WERInternalMetadata.xml C:\Users\fernav2\AppData\Local\Temp\WER78DE.tmp.appcompat.txt C:\Users\fernav2\AppData\Local\Temp\WER8E62.tmp.hdmp C:\Users\fernav2\AppData\Local\Temp\WER90F2.tmp.mdmp |
C:\Users\fernav2\AppData\Local\Microsoft\Windows\WER\ReportQueue\AppCrash_LabVIEW.exe_7b2562e45cd521149b2c133520fac1153acca60_cab_1b7c918b |
0 |
60c5909a-2199-11e3-859b-005056c00008 |
8 |
The code to launch labview is as follows
/*Initializes the python script*/
DllExport
intStartPythonScript()
{
intindex =0;
Py_SetProgramName(
"PYTHON");
Py_SetPythonHome(s_py_path);
Py_Initialize();
if(s_py_path)
{
char* new_path= (char* )malloc(strlen(Py_GetPath())+1+strlen(s_py_path)+4);
memset(new_path,
'\0',strlen(Py_GetPath())+1+strlen(s_py_path)+4);
strcpy(new_path,Py_GetPath());
strcat(new_path,
";.;");
strcat(new_path,s_py_path);
PySys_SetPath(new_path);
printf(
"\r\n %s ",new_path);
free( new_path);
}
for(index =0;index<100;index++)
{
s_PyObjectInst[index] = NULL;
}
returnTRUE;
}
Would appriciate any help possible.
Regards
09-21-2013 05:33 PM
I don't understand what you mean by the code to launch LabVIEW.
You said that LV is calling a function in a DLL. Did you write the code to make the call yourself or did you use the import utility?
If you have access to the header file associated with the DLL, the first thing to do would be to use the import utility to generate VIs for the function calls you want to use. It is very easy to cause memory allocation problems when calling DLLs.
Mike...
09-21-2013 09:11 PM
I apologize for the typo. The code snippet is the code to launch Python interpereter. It is in the C dll that i have compiled . I am the author of the DLL and have simple wrapper calls to initialize python, load a module and execute the modules from it .
The same DLL is used with Labwindows and works fine.
However the when py_initialize is called from a Labview Call function node or a Importe LVLib, the result is the same , labview exits with no warning.
I would have to say that it does work on rare occasions , but they are rare.
Regards