Jump to content
  • Advertisement
Sign in to follow this  
utilae

Memory Corruption Error - I need to understand this error

This topic is 4846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using c++ in Visual Studio .NET 2003. Ok, here's the situation. I have a variable whoose data is corrupted causing my app to quit out during runtime. The variable is a string and has been set previously in a different function. Within the function (when it is set) the variable is accesable (I can read it and output that data to my log). Outside of the function, when this variable is accessed, my app crashes (this is during runtime). If I set the variable to something new (eg sVariable="NewString";) and then access it, it still crashes. So it seems it's not the data that is corrupted, but the memory location where the data is stored. Here is the error I get when I debug it in Visual Studio:
Quote:
HEAP[Project.exe]: Invalid allocation size - FEEEFF14 (exceeded 7ffdefff) First-chance exception at 0x7c81eb33 in Project.exe: Microsoft C++ exception: std::bad_alloc @ 0x0012f4e0. HEAP[Project.exe]: Invalid allocation size - FEEEFF13 (exceeded 7ffdefff) First-chance exception at 0x7c81eb33 in Project.exe: Microsoft C++ exception: std::bad_alloc @ 0x0012ee70. First-chance exception at 0x7c81eb33 in Project.exe: Microsoft C++ exception: [rethrow] @ 0x00000000. Unhandled exception at 0x7c81eb33 in Project.exe: Microsoft C++ exception: std::bad_alloc @ 0x0012ee70. The program '[776] Project.exe: Native' has exited with code 0 (0x0).
Has anyone ever come across this error before? I cannot find anything about this error on the net. Is it possible that a another variable has corrupted my problem section of memory, having never even been involved with my problem variable? Can someone give me a list of things that could possibly cause this error? Could storing an iterator cause problems? I am storing an iterator to a font, in each object. That object also contains the problem variable that causes the app to crash when it is accessed. Any ideas would help.

Share this post


Link to post
Share on other sites
Advertisement
If your program is not windows specific, i would suggest, that you run it under linux with valgrind. This program tracks all memory accesses and helps you to find easily any bugs of this kind:
http://valgrind.org/

Share this post


Link to post
Share on other sites
Find the variables that lie before and after the corrupted one in memory, scan your code to locate all points where these are assigned a value or modified in any way and check for writing-beyond-bounds errors. You just might find your culprit there (the strongest candidates are always the strings)... :)

If you don't find anything, check further than the immediate neighbours.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!