We have a C application that loads COBOL DLLs at runtime and makes calls into them. This is working, but the application is leaking memory. The reason for the leaks is because we are currently NOT calling the cobthreadtidy() method whenever a C created thread terminates. However, I am unable to successfully call into conthreadtidy() without receiving an Access Violation. I then added a call to cobinit() to our application, but that also results in an Access Violation.
I have also written a very small console application that simply calls cobinit(), but that too throws an Access Violation! There must be something missing from what I’m doing. Here is the source code for the sample console application:
#include "stdafx.h"
#include "../Microfocus/INCLUDE/cobmain.h"
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE hModule = ::LoadLibrary(_T("CBLRTSM.dll"));
cobinit();
return 0;
}
I have tried with and without the LoadLibrary() call, but this seems to make no difference to the outcome. I am linking my code to CBLRTSM.lib so shouldn’t need the LoadLibrary() call.
My main question is : What compiler options and libraries do I need in order to call successfully into cobinit() and conthreadtidy()?
The Access Violation is coming from the very start of the cobinit() method. The first few lines of disassembly are shown below:
_cobinit:
0042A760 push ecx
0042A761 mov eax,dword ptr [_mFt_rt_trace_flags (489DA4h)]
0042A766 mov dword ptr [esp],0
0042A76E mov ecx,dword ptr [eax]
The second instruction loads an address into the EAX register, but this address is 0x00000000. So when the fourth instruction attempts to read the contents of that address, the Access Violation is triggered.
The address of ‘_mFt_rt_trace_flags’ appears to be unknown to the CBLRTSM.lib library. Is there anything else that I need to do to have this value defined?
I’m using Visual Studio 2008 & Netexpress 6.1
Any help/advice would be much appreciated, Thanks a lot