vc++8.0 bug: access violtation upon any call of any CImageList methods

R

Robert Ludewig

I have sucessfully imported and compiled a complex MFC 6.0 project from
vc++6.0 (MFC6.0) into vc++ 8.0 (MFC 8.0). It contains several
subprojects (libs and dlls). In vc++ 6.0 those project linked MFC6.0
statically and after I imported it to vc++ 8.0 I set the linkage of
MFC8.0 to "shared". However when I try to compile and link the project
in vc++ 8.0 in release mode (debugmode works fine) I get an acess
violation in afxcomctl32.inl. This happnes whenever I call any of the
CImageList methods. When I comment out all lines that call mehtods of
CImageList everything work fine in release mode too.

When I look at the disassembly the crash pattern is always the same. The
access violation always happens after a call of AfxGetModuleState and
before a call to CComCtlWrapper::_ImageList_XXX

disassembly:

004DE7F5 call AfxGetModuleState (49CE2Ah)
004DE7FA mov eax,dword ptr [eax+90h] // it is always 90h added
004DE800 mov ecx,dword ptr [eax] <------------ access
violation !!!!
004DE802 call CComCtlWrapper::_ImageList_GetIcon (49E158h)
( the last line can be interchanged by
CComCtlWrapper::_ImageList_GetImageCount (49A805h) or any other call to
CImageList mehtods )

registers:

EAX = 00000004 EBX = 00180940 ECX = 781FF81B EDX = 782BA9DC
ESI = 7821A936 EDI = 00000000 EIP = 004DE800 ESP = 0012BB04
EBP = 0012BB5C EFL = 00000206

Can any explain what is going on here and give me hints how to solve
this problem? What does AfxGetModuleState do? What is afxcomctl32.inl ?
What could be obvious places to look for ? Is this a know bug in vc++ 8?
I have found a bug in vc++ 8.0 that is STILL UNRESOLVED that somehow
looks a little similar to mine:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=132410&SiteID=1*
*Nevertheless the problem described there and the workaround suggested
does not fit here, since all of my projects have the allignment set to
default and nowhere in my project I see any #pragma pack directives.

Also I wonder what the purpose of the addition of 90h in this line is:
004DE7FA mov eax,dword ptr [eax+90h]
 
S

Scherbina Vladimir

Robert Ludewig said:
I have sucessfully imported and compiled a complex MFC 6.0 project from
vc++6.0 (MFC6.0) into vc++ 8.0 (MFC 8.0). It contains several subprojects
(libs and dlls). In vc++ 6.0 those project linked MFC6.0 statically and
after I imported it to vc++ 8.0 I set the linkage of MFC8.0 to "shared".
However when I try to compile and link the project in vc++ 8.0 in release
mode (debugmode works fine) I get an acess violation in afxcomctl32.inl.
This happnes whenever I call any of the CImageList methods. When I comment
out all lines that call mehtods of CImageList everything work fine in
release mode too.

When I look at the disassembly the crash pattern is always the same. The
access violation always happens after a call of AfxGetModuleState and
before a call to CComCtlWrapper::_ImageList_XXX

disassembly:

004DE7F5 call AfxGetModuleState (49CE2Ah)
004DE7FA mov eax,dword ptr [eax+90h] // it is always 90h added
004DE800 mov ecx,dword ptr [eax] <------------ access violation
!!!!
004DE802 call CComCtlWrapper::_ImageList_GetIcon (49E158h)
( the last line can be interchanged by
CComCtlWrapper::_ImageList_GetImageCount (49A805h) or any other call to
CImageList mehtods )

registers:

EAX = 00000004 EBX = 00180940 ECX = 781FF81B EDX = 782BA9DC
ESI = 7821A936 EDI = 00000000 EIP = 004DE800 ESP = 0012BB04
EBP = 0012BB5C EFL = 00000206

Can any explain what is going on here and give me hints how to solve this
problem? What does AfxGetModuleState do? What is afxcomctl32.inl ? What
could be obvious places to look for ? Is this a know bug in vc++ 8? I have
found a bug in vc++ 8.0 that is STILL UNRESOLVED that somehow looks a
little similar to mine:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=132410&SiteID=1*
*Nevertheless the problem described there and the workaround suggested
does not fit here, since all of my projects have the allignment set to
default and nowhere in my project I see any #pragma pack directives.

Also I wonder what the purpose of the addition of 90h in this line is:
004DE7FA mov eax,dword ptr [eax+90h]

That probably may be the bug of a compiler.
When you invoke function it stores the resulting value in EAX register. The
ECX register is used to store the offset on a class object, so when you
invoke CComCtlWrapper::_ImageList_GetIcon it uses ECX inside to get an
access to the data of a class.
mov eax,dword ptr [eax+90h] ;
also seems strange to me. That probably not a bug of CImageList . Try to
rewrite that part of code using _asm keyword.

// pseudocode, I don't have VC8 over here..
__asm {
; make pushes if necessary
call AfxGetModuleState
mov ecx,eax
; make pushes if necessary
call CComCtlWrapper::_ImageList_GetIcon }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top