crashing as chars log off..

Posted by Typhon on Tue 25 Jun 2002 03:22 PM — 6 posts, 19,845 views.

USA #0
its seems that when i put in the hometowns code by noplex when players go to logg off it kills the mud.. i think its trying to free somethign that doesnt exsist as the exit but i dont know where to look for that typ of thing.. i know ive changed it before for other snippets and such but i just cant seem to remember where.. if anyone know it'd be helpful
thanks -typ
Australia Forum Administrator #1
Try using gdb (the debugger) to see why it is crashing. Search for gdb on this forum for some examples of using it.
USA #2
ok ive used the gdb debugger and it seems thats im getting a BUG: Freeing null pointer db.c:2913
STRFREEing NULL in db.c, line 2913
/* Free Hometown Stuff -Nopey */
STRFREE( ch->pcdata->htown_name );
if( ch->pcdata->hometown )
{
STRFREE( ch->pcdata->hometown->name );
STRFREE( ch->pcdata->hometown->filename ); //this line
DISPOSE( ch->pcdata->hometown );
}

in pc_data there are the lines..
char * htown_name;
HOMETOWN_DATA *hometown;

and the hometown_data structure is
struct hometown_data
{
HOMETOWN_DATA *next;
HOMETOWN_DATA *prev;
char *name;
char *filename;
int recall;
};

im assuming something is all screwy in there but how would i go about checking what exactly is goin on there thats making it die.
USA #3
ok a little update...
this char that i made (jon) is a newcreated char.. with the hometown selected when he created.. for any other char its fine they can log on and off but with jon when i go to log off i get that strfree null stuff.
where i was getting that error in db.c i put in bugs to display the name of the filename and what not that was causing the crash. well heres the code i put in and what i got in return
if( ch->pcdata->hometown )
{
bug("%s",ch->pcdata->hometown->name);
STRFREE( ch->pcdata->hometown->name );
bug("%s",ch->pcdata->hometown->filename);
STRFREE( ch->pcdata->hometown->filename );
DISPOSE( ch->pcdata->hometown );
}
Sat Jun 29 09:44:15 2002 :: Jon has quit (Room 10385).
Sat Jun 29 09:44:15 2002 :: [*****] BUG:
Sat Jun 29 09:44:15 2002 :: [*****] BUG: (null)
Sat Jun 29 09:44:15 2002 :: [*****] BUG: Freeing null pointer db.c:2915
STRFREEing NULL in db.c, line 2915
Australia Forum Administrator #4
It seems pretty clear from both the original crash and your debugging that the field ch->pcdata->hometown->filename is NULL (ie. zero).

When you create a hometown you should put something into that field, alternatively check it is not null before you free it, like this:


if (ch->pcdata->hometown->filename)
  STRFREE( ch->pcdata->hometown->filename );
USA #5
well all in all it seemed easier to rewrite the whole hometown thing so thats what im nthe process of doing :-p i did like the hometown code by noplex but there were a bunch of glitchs i had to go find.. it seems as if it would work on a stock smaug mud fhowever im not running a stock one at this point :-p thanks for you help