It's normally caused by double-freeing a string... either freeing it twice
in a row, or freeing something that is still in use, then freeing it again
later.
Unfortunately most attempts to debug this type of problem with gdb or the
likes will take all day and leave you pulling your hair out, since the
'polluted' strings can show up all over the place.

Since you say it's always prog code giving you trouble, take a look through
the process of editing progs and make note of anywhere strings are freed.
Many of the editing functions (string_append, string_replace, string_add...)
free strings on their own and you may have freed a string after using them.

Here is something that is sure to fix it if nothing else does... rename
free_string function to true_free_string.
Then in merc.h, define a macro..

#define free_string(str)        {true_free_string((str));(str) =
&str_empty[0];}

Clean compile, and now there's no chance for a double-free!!
Sloppy, but nobody ever needs to see your code anyway ;)

--Palrich.

----- Original Message -----
From: "Josh" <[EMAIL PROTECTED]>
To: "Rom" <[email protected]>
Sent: Wednesday, November 20, 2002 4:02 PM
Subject: Memory problem... still...


> Alright heres the problem:
>
> Occasionally (never when I'm trying to get it to happen, and NEVER when
I'm
> in gdb) A piece of PROG_CODE gets randomly replaced with soemthing like
the
> who list, or a tell, or something.  This has been going on for a very long
> time and I have been unable to track it down.  From what people tell me,
its
> a 'memory problem.'  How would I go about tracking it down, if its not
> repeatable, and I can't get it to do on command?  I've read and re-read my
> code, I've asked for help, all to no avail.  I'm not really interested in
> someone just handing me the answer (Although I sure as hell wouldn't
> complaim) moreso as coming up with some battle strategies for HOW to find
> the problem.  I can post code if it would help.
>
> Josh
>
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom


Reply via email to