Jump to content
  • Advertisement
Sign in to follow this  
trzy

Bounds Checking in Multi-threaded Code (MSVC)

This topic is 2652 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 working on a moderately complex project that is multi-threaded (two very independent threads, synced up once per frame) and have experienced a few very difficult-to-reproduce but severe bugs. They occur semi-randomly although when one happens, it can persist for the entire day (with or without changes to the code) and then suddenly go away as mysteriously as it came.

I can confirm that the problem is due to memory being overwritten in a very peculiar, semi-random fashion. It typically occurs when threading is enabled and will not occur if threads are disabled and everything executes serially. But, I can also get similar problems in serial mode if I increase the size of a particular memory buffer that appears to be stomped on: by quadrupling the size of that buffer, problems develop in another part of the application in serial mode but things run fine with threads.

One variant of the bug can be triggered by passing command lines that are too long (somewhere around 140 characters or so). There's no obvious reason for it -- I don't ever copy the command line around, so there are no buffer overflow issues.

I suspect that there may be an overflow in a dynamically allocated memory buffer. It would be nice to have a tool that can log and track every bit of dynamically-allocated memory and perform bounds checking. I think BoundsChecker would do the job but I can't afford it. Has anyone faced similar problems? How did you tackle them?

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
If you're on a modern version of Windows, look into the Application Verifier tool by Microsoft. It should help find the problem.

Share this post


Link to post
Share on other sites
Thanks, I'll look into that! I found the problem and it turned out to be an uninitialized member in a struct.

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!