Sign in to follow this  

Bounds Checking in Multi-threaded Code (MSVC)

Recommended Posts


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?


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this