.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
Finding leaks
Old
  (#1)
Maleficus
Member
 
Maleficus's Avatar
 
Status: Offline
Posts: 1,054
Join Date: May 2004
Location: Planet Earth
Default Finding leaks - 18-02-2005

I recently discovered a leak of some kind in Fritz. It doesn't do it always, and usually only after a while. It always crashes in the .exe, with an error msg about "referencing memory that could not be read".

I've run Fritz with various monitors running, and the Private Bytes count and the Handle counts for the game never increase, so I'm wondering if anyone with some C experience has some ideas where would be the "usual suspects" to look for. I've checked my pointers and strucs, they all look good.

I don't alloc any memory, don't play around with the game's internal pointers/strucs (much.....).

Its the randomness of the crash, and the fact that no memory or handles are used, that really confuses me ATM. ???


Dum Spiro Spero


  
Reply With Quote
Re: Finding leaks
Old
  (#2)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Finding leaks - 18-02-2005

mostly its with indexes. Ie:

Code:
 
int test[10];
 
for (int i=0; i < 10; i++)
 test[i]=-1;
 
// and this is bad
test[i] = 0; // means i = 10 , ouch
Or simply having a bigger content in a char then possible:

Code:
 
char msg[10];
// this 11 characters + carriage return! (so needs 12)
sprintf(msg, "Hello world\n");
its within all these little obvious things. Easy to overlook. Perhaps you can use assert to track down suspecious variables.


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
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
Re: Finding leaks
Old
  (#4)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Finding leaks - 21-02-2005

Quote:
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.
at the first when I was messing around POD-Bot source code I had the first time (I was using MSVC6 at that time), but the problem disappeared if I changed one item in the project options from "Multithread Debug" to "Multithread".

Quote:
electric fence may help you with dynamic memory : http://perens.com/FreeSoftware/
there is also a small utility from Netscape (now Mozilla.org):
http://filebase.bots-united.com/inde...on=file&id=254
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com