Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Access Violation

tschicker
Beginner
514 Views
I have C++ DLL that is called by a Fortran application using LoadLibrary and
releasing using FreeLibrary. The DLL performs large amounts of SQL inserts
using
OLEDB. I override the the default initInstance of the DLL with the
following:

BOOL CProsym_sqlApp::InitInstance()
{
file://Create the database conection
if (CreateDBConn()<0) return FALSE;
return true;
// return CWinApp::InitInstance();
}

and also I override the default ExitInstance of the DLL with the following:

BOOL CProsym_sqlApp::ExitInstance()
{
file://Cleanup OLEDB Session
if (CloseOLEDBSession()<0) return FALSE;
return true;
// return CWinApp::ExitInstance();
}

where

file://Close OLEDB Session
int CloseOLEDBSession()
{
try
{
session.Close(); // close session
ds.Close();
}
catch (...)
{
return ERR_DB_CLOSE_OLEDB_SESSION;
}
return TRUE;
}

I am finding that the FORTRAN application is exiting with an ACCESS
VIOLATION
when the DLL tries to execute the CloseOLEDBSession. Specifically, when I
step
through the code and I session.Close() I am taken to the following:

file://Close the session in ATLDBCLI.H
void Close()
{
m_spOpenRowSet.Release();
}

which takes me to the following in ATLBASE.H
void Release()
{
IUnknown* pTemp = p;
if (pTemp)
{
p = NULL;
pTemp->Release(); <---this line causes the access Violation
}

I am pretty sure that the problem is related to Fortran because when I build a simple C++ console application to call the DLL, things work fine. It is only when the Fortran application calls the DLL that I get this access violation error.

Any suggestions on how to eliminate the Access Violation and successfully close the connection to SQL?

Tom
0 Kudos
1 Reply
Intel_C_Intel
Employee
514 Views
After the f90 call to LoadLibrary, how are you making calls to the C++ code? What routines are being called by f90 caller? What C++ routines are exported from the dll? Are they class instance methods (or perhaps did you export the class)? How is an object of your class instantiated? (who does it?)

Your comments that things work with a C++ caller but not a f90 caller make me wonder if you're trying to call class methods, which would work in C++ but the f90 code probably doesn't have the this pointer.

hth,
John
0 Kudos
Reply