Jump to content
  • Advertisement
Sign in to follow this  
SymLinked

Memory Corruption - using third party tools to troubleshoot.

This topic is 2444 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

Hi,

I'm a C++ developer and I keep running into memory corruption issues. To this day I've always been able to fix those errors, but it takes a lot of time which I'd rather spend coding.

I thought MSVC had some sort of memory corruption detection (memory guards?) but they never trigger or show me any useful information. If I'm lucky I sometimes get shown *what* was corrupted, but not when. I even implemented my own memory guards and increased their size to see if I could spot any corruption, but I couldn't. They were perfect.

Mostly the stack trace is corrupted itself - not very useful.

I thought I'd try Purify, Valgrind or Insure++. Are these worth it, in your opinion? Are there any alternatives that won't empty my wallet?

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I just tried the Purify trial and it does seem magic. It tells me I got a dozen issues but I can't check any without buying the full version which is a month's salary for me.

Thanks SiCrane! I've tried the Application Verifier before but I can't remember if it helped. I'll try again.

Share this post


Link to post
Share on other sites
That's one of the options in Application Verifier. It adds a guard page after the end of memory allocations so that you get a access violation upon buffer overrun.

Share this post


Link to post
Share on other sites

That's one of the options in Application Verifier. It adds a guard page after the end of memory allocations so that you get a access violation upon buffer overrun.


When does it tell me I've overstepped my bounds, upon new/free or upon the actual operation? That's my major gripe with MSVC's debugger.

Share this post


Link to post
Share on other sites
Application Verifier shows 0 errors and 0 warnings for me, and the log is empty. Even when I deliberatly make buffer overruns. It detects program startup and the correct checkboxes are checked.

Oh well.

Share this post


Link to post
Share on other sites
If you're scribbling over stack memory, there's probably not a lot a tool like application verifier can do as the stack area has to stay highly mutable (though I've never used it -- interested to hear if I'm wrong).

A low-tech solution would be to use something akin to boost::array<> rather than raw arrays that will catch overruns via assertions in operator[], etc.

EDIT: Oh, and /RTCs is worth a punt if you haven't tried it already.

Share this post


Link to post
Share on other sites

If you're scribbling over stack memory, there's probably not a lot a tool like application verifier can do as the stack area has to stay highly mutable (though I've never used it -- interested to hear if I'm wrong).

A low-tech solution would be to use something akin to boost::array<> rather than raw arrays that will catch overruns via assertions in operator[], etc.

EDIT: Oh, and /RTCs is worth a punt if you haven't tried it already.


Yeah, I'm using safe arrays (and the RTCs switch) but they can't catch when you use a raw pointer and go out of bounds on that. I guess I'll have to take a look at Purify again..

Thanks everyone!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!