gib
29th March 2010, 07:50
I am able to invoke a procedure in my DLL successfully, and all seems OK until the execution is complete. On return from the DLL procedure my Qt application crashes silently.
I am executing the DLL from within a thread.
void ExecThread::run()
{
...
QLibrary myLib(dll_path);
typedef int (*MyPrototype)(int *, char *, int, char *, int, char *, int, char *, int);
MyPrototype execute = (MyPrototype) myLib.resolve("EXECUTE");
if (execute) {
execute(...)
}
myLib.unload();
}
If I comment out the call to execute() the program doesn't crash. I suspect the problem is stack related. My DLL is in Fortran90, and there is a trick to passing strings from C to Fortran. My Fortran subroutine expects an integer (by reference) and four strings, each of which is passed as a pair of arguments, a C string and an int holding the string length. This works fine in Python (using windll.LoadLibrary()), and almost works here, since the subroutine executes correctly.
I am executing the DLL from within a thread.
void ExecThread::run()
{
...
QLibrary myLib(dll_path);
typedef int (*MyPrototype)(int *, char *, int, char *, int, char *, int, char *, int);
MyPrototype execute = (MyPrototype) myLib.resolve("EXECUTE");
if (execute) {
execute(...)
}
myLib.unload();
}
If I comment out the call to execute() the program doesn't crash. I suspect the problem is stack related. My DLL is in Fortran90, and there is a trick to passing strings from C to Fortran. My Fortran subroutine expects an integer (by reference) and four strings, each of which is passed as a pair of arguments, a C string and an int holding the string length. This works fine in Python (using windll.LoadLibrary()), and almost works here, since the subroutine executes correctly.