a question about porting application from vc6 to vc2005 |
|
Author |
Message |
Leitch

|
Posted: Visual C++ General, a question about porting application from vc6 to vc2005 |
Top |
Hello,
I am porting a very large application from vc6 to vc2005. All compiling errors have been solved. Now when I run the application, it stops at the initilization. (A less components needed application can run)
Unhandled exception at 0x7c964ed1 (ntdll.dll) in Navigator.exe: 0xC0000005: Access violation.
Call stack:
() + 0x26 bytes
() + 0x26b95 bytes
() + 0x7 bytes
When I try to use dependency walker to start this application, the very end information is shown as below:
00:00:10.175: GetProcAddress(0x7C800000 [c:\windows\system32\KERNEL32.DLL], "GetLongPathNameW") called from "c:\windows\system32\ENTAPI.DLL" at address 0x370031AB and returned 0x7C8130C3 by thread 1.
00:00:10.175: DllMain(0x37000000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\system32\ENTAPI.DLL" returned 0 (0x0) by thread 1.
00:00:10.175: DllMain(0x37000000, DLL_PROCESS_DETACH, 0x00000000) in "c:\windows\system32\ENTAPI.DLL" called by thread 1.
00:00:10.175: DllMain(0x37000000, DLL_PROCESS_DETACH, 0x00000000) in "c:\windows\system32\ENTAPI.DLL" returned 0 (0x0) by thread 1.
00:00:10.175: DllMain(0x5B860000, DLL_PROCESS_DETACH, 0x00000000) in "c:\windows\system32\NETAPI32.DLL" called by thread 1.
00:00:10.175: DllMain(0x5B860000, DLL_PROCESS_DETACH, 0x00000000) in "c:\windows\system32\NETAPI32.DLL" returned 1 (0x1) by thread 1.
00:00:10.175: DllMain(0x76BF0000, DLL_PROCESS_DETACH, 0x00000000) in "c:\windows\system32\PSAPI.DLL" called by thread 1.
00:00:10.185: DllMain(0x76BF0000, DLL_PROCESS_DETACH, 0x00000000) in "c:\windows\system32\PSAPI.DLL" returned 131073 (0x20001) by thread 1.
00:00:10.185: Unloaded "c:\windows\system32\ENTAPI.DLL" at address 0x37000000 by thread 1.
00:00:10.185: Unloaded "c:\windows\system32\NETAPI32.DLL" at address 0x5B860000 by thread 1.
00:00:10.185: Unloaded "c:\windows\system32\PSAPI.DLL" at address 0x76BF0000 by thread 1.
00:00:10.185: First chance exception 0xC0000005 (Access Violation) occurred in "c:\windows\system32\NTDLL.DLL" at address 0x7C964ED1 by thread 1.
00:00:10.185: Second chance exception 0xC0000005 (Access Violation) occurred in "c:\windows\system32\NTDLL.DLL" at address 0x7C964ED1 by thread 1.
00:00:10.185: Exited "e:\files\ccsapps_full\target\debug\NAVIGATOR.EXE" (process 0x228) with code -1073741819 (0xC0000005) by thread 1.
00:00:08.683: Entrypoint reached. All implicit modules have been loaded.
If I let the application keep going, it finally stops at STL object operation as below.
list<CString>::iterator iterUser = ms_RegisteredUsersList.begin();
"ms_RegisteredUsersList" was declared as below:
static std::list<CString> ms_RegisteredUsersList;
run time error information:
Unhandled exception at 0x04280d73 (navfw.dll) in Navigator.exe: 0xC0000005: Access violation reading location 0x00000000.
Call stack information:
> navfw.dll!std::list<ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > >,std::allocator<ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > > > >::begin() Line 528 + 0x13 bytes C++ navfw.dll!exlNavigatorManager::SetOpMode(OpMode_t prevOpMode=buildMode, OpMode_t newOpMode=buildMode) Line 586 + 0xe bytes C++ Navigator.exe!Application_t::SetOpMode(OpMode_t opMode=buildMode, int notify=0, int checkSaveNeeded=0) Line 2558 + 0x10 bytes C++ Navigator.exe!Application_t::InitializeAll() Line 1039 + 0x18 bytes C++ Navigator.exe!Application_t::InitInstance() Line 733 + 0x12 bytes C++ mfc80d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f13, int nCmdShow=1) Line 37 + 0xd bytes C++ Navigator.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f13, int nCmdShow=1) Line 29 C++ Navigator.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C Navigator.exe!WinMainCRTStartup() Line 403 C
() + 0x23 bytes
All the dlls are compiled with Multi-threaded Debug DLL (/MDd). It seems the STL objects in this DLL are in illegal memroy address and couldn't be accessed. Did you have such problems before Could you give me some suggestions about it Appreciate your help!
Visual C++5
|
|
|
|
 |
Peter Ritchie

|
Posted: Visual C++ General, a question about porting application from vc6 to vc2005 |
Top |
Maybe you can provide some details with regard to what InitInstance is doing i.e it calls InitializeAll, which calls SetOpMode, which calls another SetOpMode, which appears to call std::list::begin; which is crashing.
|
|
|
|
 |
Leitch

|
Posted: Visual C++ General, a question about porting application from vc6 to vc2005 |
Top |
Hello Peter,
Thanks for your comments. Actually the application program is stopped at first before all the objects are initialized, If keep on going, the application is initialized with Application_t::InitializeAll() which calls SetOpMode() function. In SetOpMode() function, the function in Navfw.dll with the same name in the other DLL is called as "m_pNavigatorManager->SetOpMode (prevNavOpMode, newNavOpMode)"
In this Navfw.dll Static STL objects are used, like
list<CString>::iterator iterUser = ms_RegisteredUsersList.begin();
actually all the stl objects seem are in illegal address.
Please give me some suggestions. Many thanks!
|
|
|
|
 |
Peter Ritchie

|
Posted: Visual C++ General, a question about porting application from vc6 to vc2005 |
Top |
There's many reasons why an STL list object would generate an exception when begin() is called. The instance may be NULL, it may not have been initialized property, etc. I'd have to see some sample code that exhibits the problem to offer more details.
It just came to me; but, you'll probably want to peruse What's New in the Visual C++ Libraries. I details breaking changes that have been made with respect to the C++ libraries (CRT and STL). Also, I don't think this applies to your case; but, Breaking Changes in the Visual C++ 2005 Compiler should also be of interest.
|
|
|
|
 |
Leitch

|
Posted: Visual C++ General, a question about porting application from vc6 to vc2005 |
Top |
Thanks Peter,
Actually, In this dll, not only the list has problem, map object also has the same problem when doiong insert function. All these STL objects are declared as static in header files. But it looks fine when loading this dll dynamically.
typedef std::map< CString, exlGraphBuilder * > exlGraphBuilderInstanceMap_t;
static exlGraphBuilderInstanceMap_t ms_GraphBuilderInstanceMap;
bool
exlGraphBuilder::CreateInstance(
CString sUserName
)
{
// ** Error handling
if( sUserName == "" )
return false;
// ** if the instance is already created
if( GetInstance( sUserName ) )
return true;
exlGraphBuilder * pInstance = new exlGraphBuilder(sUserName, ms_InstanceCounter);
if( !pInstance )
return false;
// ** add to user instance map
std::pair<exlGraphBuilderInstanceMap_t::iterator, bool> result1 =
ms_GraphBuilderInstanceMap.insert( std::make_pair(sUserName, pInstance) );
if( !result1.second )
{
delete pInstance;
return false; // error occurred
}
// ** add new ID to lookup table
std::pair<exlGraphBuilderLookupMap_t::iterator, bool> result2 =
ms_IDLookupTable.insert( std::make_pair(pInstance->m_InstanceID, pInstance) );
if( !result2.second )
{
// ** must erase instance from instance map, and return error
exlGraphBuilderInstanceMap_t::iterator iter =
ms_GraphBuilderInstanceMap.find( sUserName );
ms_GraphBuilderInstanceMap.erase( iter );
delete pInstance;
return false; // error occurred
}
ms_InstanceCounter++;
return true;
}
|
|
|
|
 |
jotagrande

|
Posted: Visual C++ General, a question about porting application from vc6 to vc2005 |
Top |
I think I have a problem somewhat equal to the one you are describing.
I'm also porting an application from VC6 to VC2005, and it just keeps on giving me Access Violations exceptions.
Simple things like the following code gives me an Access Violation exception.
Code Snippet
CImageList img;
CBitmap *bitmapNormal = new CBitmap();
BITMAP bmInfo;
bitmapNormal->LoadBitmap(IDB_GROUPPROFILE);
bitmapNormal->GetObject(sizeof(bmInfo), &bmInfo) == sizeof(bmInfo);
bitmapNormal->DeleteObject();
img.Create(bmInfo.bmWidth, bmInfo.bmHeight, ILC_MASK, 1, 0);
CBitmap *bitmapMask = new CBitmap();
if (bitmapNormal->LoadBitmap(IDB_GROUPPROFILE) != NULL)
{
...
}
if (bitmapMask->LoadBitmap(IDB_GROUPPROFILE_MASK) != NULL)
{
...
}
if (img.Add(bitmapNormal, bitmapMask) >= 0)
{
...
}
The exception occurs in the Add method. And the weird thing, is that it only happens in release mode, and not in debug mode.
Can this be the same problem Or anyway related
|
|
|
|
 |
|
|