Thread: Finding leaks
View Single Post
Re: Finding leaks
Old
  (#3)
koraX
Member
 
koraX's Avatar
 
Status: Offline
Posts: 145
Join Date: Jan 2004
Location: Slovak Republic
Default Re: Finding leaks - 18-02-2005

I had very nasty bug in my bot recently. It ran fine on release mode, however it crashed in debug mode. It crashed bit randomly and after some specific sequence of commands.

Nevermind I said, I'll set breakpoints and I'll find out the problem. However when hl ran under debugger, there was no crash.

Nevermind I said, I have pretty cool logging system in my bot, I'll log code and debug it that way to find incriminated code.
However I was using buffer to speed up logging and after the crash, buffer was not written to disk.

Nevermind I said, I'll set buffer size to 0 and I'll see what was logged last before crash, I'd done it couple of times.
However after I set it to 0, crash was gone.

I was like wtf. After 4 hours I've finally found the problem. I had an array of size about 20 or so where I stored clients weapon when message came, but I didn't check bounds and one message came with index 255 9_9

After that I use std::vector whenever I can

electric fence may help you with dynamic memory : http://perens.com/FreeSoftware/


kXBot
koraX's utils
- see my homepage for other projects (OpenGL CSG Editor, FAT16 Sim, NNetwork Sim, ...)
  
Reply With Quote