In C++, using Visual Studio 2010 Professional, get "Access violation" after the return on main

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi, I am using Visual Studio 2010 to write some C++ code, which I have been working on for over a year now
My problem is that recently I am getting a runtime exception when running in debug mode:
Unhandled exception at 0x77bf15de in Server.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
From 0xfeeefeee I assume the problem is code that is trying to deeference deallocated memory. But when I go to the call stack, I find myself after main exited, meaning I cant get hold on any of my lines of code:
><span style="white-space:pre ntdll.dll!77bf15de() <span style="white-space:pre
<br/>
<span style="white-space:pre [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]<span style="white-space:pre
<br/>
<span style="white-space:pre ntdll.dll!77bf15de() <span style="white-space:pre
<br/>
<span style="white-space:pre ntdll.dll!77be014e() <span style="white-space:pre
<br/>
<span style="white-space:pre kernel32.dll!764f14dd() <span style="white-space:pre
<br/>
<span style="white-space:pre apphelp.dll!717e2c62() <span style="white-space:pre
<br/>
<span style="white-space:pre apphelp.dll!717e2c75() <span style="white-space:pre
<br/>
<span style="white-space:pre ntdll.dll!77c09950() <span style="white-space:pre
<br/>
<span style="white-space:pre ntdll.dll!77c1d6b2() <span style="white-space:pre
<br/>
<span style="white-space:pre ntdll.dll!77c1d554() <span style="white-space:pre
<br/>
<span style="white-space:pre kernel32.dll!764f79f5() <span style="white-space:pre
<br/>
<span style="white-space:pre msvcr100d.dll!__crtExitProcess(int status) Line 709<span style="white-space:pre
C<br/>
<span style="white-space:pre msvcr100d.dll!doexit(int code, int quick, int retcaller) Line 621 + 0x9 bytes<span style="white-space:pre
C<br/>
<span style="white-space:pre msvcr100d.dll!exit(int code) Line 393 + 0xd bytes<span style="white-space:pre
C<br/>
<span style="white-space:pre Server.exe!__tmainCRTStartup() Line 568<span style="white-space:pre
C<br/>
<span style="white-space:pre Server.exe!mainCRTStartup() Line 371<span style="white-space:pre
C<br/>
<span style="white-space:pre kernel32.dll!764f339a() <span style="white-space:pre
<br/>
<span style="white-space:pre ntdll.dll!77c09ef2() <span style="white-space:pre
<br/>
<span style="white-space:pre ntdll.dll!77c09ec5() <span style="white-space:pre
<br/>
<br/>
The accesible code that is furthest up on the call stack is from msvcr100d.dll:
void __cdecl __crtExitProcess (<br/>
int status<br/>
)<br/>
{<br/>
__crtCorExitProcess(status);<br/>
<br/>
<br/>
/*<br/>
* Either mscoree.dll isnt loaded,<br/>
* or CorExitProcess isnt exported from mscoree.dll,<br/>
* or CorExitProcess returned (should never happen).<br/>
* Just call ExitProcess.<br/>
*/<br/>
<br/>
<br/>
ExitProcess(status);<br/>
}

and its pointing at the closing bracket }.
The even more worrying thing is that it dosent always happen, and it has a VERY LOW rate of happening so its not easy at all to reproduce. Normally, by putting breakpoints here, the code enters __crtCorExitProcess, fails to load mscoree.dll,
then returns, and then pressing Step Into (F11) on the ExitProcess(status) just stops the program. Still my computer is very stable, it hasnt given me BSODs pretty much since I bought it years ago and Im a heavy user, so I dont think its the hardware flipping
bits.<br/>

I will gladly give more details but I do not quite know what more info would be useful.
From looking around this is the most relevant post I found:
http://www.sfml-dev.org/forum/viewtopic.php?p=27106&sid=46a9709b397f5c3eb09a5e01402f8cf1 http://www.sfml-dev.org/forum/viewtopic.php?p=27106&sid=46a9709b397f5c3eb09a5e01402f8cf1
which refers to
http://www.sfml-dev.org/forum/viewtopic.php?p=26069&sid=e7bf4a86d949efc9597409db8220c7f0 http://www.sfml-dev.org/forum/viewtopic.php?p=26069&sid=e7bf4a86d949efc9597409db8220c7f0
They are both talking about Radeon HD Video card, but I have NVIDIA GeForce GT 430. I dont know if it helps but my processor is 64-bit (Intel(R) Core(TM) i5-2300).
And I dont like their solution, its a pray-for-it-to-work patch, I want to know the reason.. so it doesnt happen again in the future when things are just harder to debug.
Does anybody have any clue what it could be? Where to continue looking for answers? What causes things to be different in the code that runs after main retuns?<br/>

<br/>

Thank you

View the full article
 
Back
Top