开发者

Buffer overflow error randomly appearing and then disappearing

I have a problem with one of my programs in which a buffer overflow error suddenly appeared after i added some mo开发者_开发问答re functions to the program. The error showed up at the very beginning of the program, a section that was completely unrelated to the new code I added. After placing down a couple of breakpoints to narrow down the source of the bug, the error disappeared on the next run.

Can anyone simply conceptually explain to me what kind of situations might caused the problem I encountered? I'm not asking you to debug my code but rather give me some insight as to what may have happens so I can avoid running into the problem again.


This bug has the odor of dynamic data becoming too long for its preassigned (assigned at compile time, I mean) storage array, but I think the error message "buffer overflow" is just a coincidental red herring. As a first step, I would try doubling the sizes of all of my static arrays or, even better, increasing their sizes by a big number -- like 100,000 -- and I'd rerun the program. If the program runs OK, then you can go through the code to find the offending section.

If the program still blows up, well, you're facing a bug that's harder to find.

HTH

-- pete


Fill your code full of ASSERTs! Having learned from hellish experience, it's something I now do naturally while dealing with buffer handling code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜