I'm writing a library in C++ for OpenGL and in the same time a program to test this library. Recently I made some changes which produced an error.
Unhandled exception at 0x7c91ac4a in testOpenGL.exe : 0xC0000005:
Access violation writing location 0x00000010.
Pressing Break appears this message:
There is no source code available for the current location.
I can press Ok and Show Disassembly. I press Show Disassembly and the assembly code of my program (I guess) shows up. Here it is:
7C91ABEA nop
7C91ABEB nop
7C91ABEC nop
7C91ABED nop
7C91ABEE nop
7C91ABEF mov edi,edi
7C91ABF1 push ebp
7C91ABF2 mov ebp,esp
7C91ABF4 sub esp,68h
7C91ABF7 push ebx
7C91ABF8 push esi
7C91ABF9 mov esi,dword ptr [ebp+8]
7C91ABFC xor ebx,ebx
7C91ABFE cmp esi,7C97E178h
7C91AC04 mov dword ptr [ebp-8],ebx
7C91AC07 sete byte ptr [ebp+0Bh]
7C91AC0B mov eax,dword ptr fs:[00000018h]
7C91AC11 movzx ecx,byte ptr [ebp+0Bh]
7C91AC15 mov dword ptr [eax+0F84h],ecx
7C91AC1B cmp byte ptr ds:[7C97E0C4h],bl
7C91AC21 jne 7C91A4DB
7C91AC27 mov al,byte ptr ds:[7C97E1E8h]
7C91AC2C neg al
7C91AC2E push edi
7C91AC2F sbb eax,eax
7C91AC31 not eax
7C91AC33 and eax,7C97E1E0h
7C91AC38 mov edi,eax
7C91AC3A mov eax,dword ptr [esi+10h]
7C91AC3D cmp eax,ebx
7C91AC3F mov dword ptr [ebp-4],eax
7C91AC42 je 7C91ACE6
7C91AC48 mov eax,dword ptr [esi]
7C91AC4A inc dword ptr [eax+10h] <<----------------------------------------------------------------<<
7C91AC4D mov eax,dword ptr [ebp-4]
7C91AC50 and eax,1
7C91AC53 mov dword ptr [ebp-18h],eax
7C91AC56 mov eax,dword ptr [esi]
7C91AC58 inc dword ptr [eax+14h]
7C91AC5B test byte ptr ds:[7FFE02F0h],1
7C91AC62 jne 7C9439C6
7C91AC68 cmp dword ptr [ebp-18h],ebx
7C91AC6B push edi
7C91AC6C push ebx
7C91AC6D jne 7C92BE6D
7C91AC73 push dword ptr [ebp-4]
7C91AC76 call 7C90DF4E
7C91AC7B cmp eax,102h
7C91AC80 je 7C943A51
7C91AC86 cmp eax,ebx
7C91AC88 jl 7C943B0E
7C91AC8E cmp byte ptr [ebp+0Bh],bl
7C91AC91 pop edi
7C91AC92 je 7C91ACAC
7C91AC94 mov eax,dword ptr fs:[00000018h]
7C91AC9A mov eax,dword ptr [eax+24h]
7C91AC9D mov dword ptr [esi+0Ch],eax
7C91ACA0 mov eax,dword ptr fs:[00000018h]
7C91ACA6 mov dword ptr [eax+0F84h],ebx
7C91ACAC pop esi
7C91ACAD pop ebx
7C91ACAE leave
7C91ACAF ret 4
7C91ACB2 nop
7C91ACB3 nop
7C91ACB4 nop
7C91ACB5 nop
7C91ACB6 nop
And here is the part of the source code of my library that has the problem:
bool myAnotherClass::myMethod(string name) {
if(pointerTo_myStruct == NULL){
pointerTo_myStruct = new myStruct(); // <<--------------------<< Source code of the myStruct (1)
pointerTo_myStruct->Name = name;
pointerTo_myStruct->pointerTo_myClass = new myClass(this);
}else{
//Does not enter here for the moment
}
};
return true; // <<-----------------------------<< Here is were the error pops up.
}
/*(1)*/ struct myStruct{
myStruct(){ Name = "No Name"; pointerTo_myClass = NULL; Next = NULL; }
//~myStruct(){ delete Next; };
string Name;
myClass* pointerTo_myClass;
myStruct* Next;
};
I'm not pasting the source code of myClass because it's not new and it has no changes. All tested and working and irrelevant.
Now the changes I've made was: adding this struct and start using the string template class (#include string.h) which, I think, there is the problem. Something
that I'm not using right.
if anyone can think anything I'll appreciate it.
Ask anything you want.
Thanks