Hello all,
    I am currently grappling with a strange problem that has been plaguing the ROM24b6 MUD I code on for some time.  What happens is that if a container of some type (eg. guild donation chest) gets enough items in it, looking in it will cause the MUD to crash.  I have dynamic buffer code that expands the buffer as needed and it seems to be doing it's job just fine.  It actually crashes in the "color" fucntion call from the page_to_char function.  However, from the GDB output I can see that the problems start with address out of bounds issues before then.
 
do_look calls show_list_to_char which puts together the buffer and then calls page_to_char to display it.
 
    Here is the output from GDB:
 
Program received signal SIGSEGV, Segmentation fault.
0x807e204 in color (type=120 'x', ch=0x333b305b, string=0xbfffa5d7 "") at comm.c:2515
2515        if( ch != NULL && IS_NPC( ch ) )
(gdb) bt
#0  0x807e204 in color (type=120 'x', ch=0x333b305b, string=0xbfffa5d7 "") at comm.c:2515
#1  0x807d628 in page_to_char (txt=0x1b20646d <Address 0x1b20646d out of bounds>, ch=0x333b305b) at comm.c:2071
#2  0x30333b31 in ?? ()
Cannot access memory at address 0x5b1b656c.
(gdb) frame 1
#1  0x807d628 in page_to_char (txt=0x1b20646d <Address 0x1b20646d out of bounds>, ch=0x333b305b) at comm.c:2071
2071                        skip = color( *point, ch, point2 );
(gdb) print txt
$1 = 0xffffffff <Address 0xffffffff out of bounds>
(gdb) print ch->name
Cannot access memory at address 0x333b30af.
 

    As you can see the 'txt' variable is messed up as early as the page_to_char.  This whole problem seems like a buffer overflow issue, but I'm not sure how to resolve it.  When I output the Length, Size and State I get the following:
 
Length: 10240 Size: 16384 State: 0 (not overflowed)
 
    Also, I have tried to narrow down a specific buffer length at which the problem occurs.  For some reason, this number seems to change from time to time so I'm really boggled.
 
    If anyone has any ideas of what I might do or further investigation I might do to track down this problem it would be greatly appreciated.
 
Thanks,
Cameron

Reply via email to