Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ set_pager_color crash???
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Mon 11 Oct 2004 06:51 PM (UTC) |
Message
| Hi, i'm still really new to coding and whatnot. I've come across this crash that has drastically lost the playerbase. Everytime a player is destroyed/quits/idles out etc. and the next command executed uses "set_pager_color" it crashes with this backtrace. "do_who" "do_score" "do_pract" etc.
#0 0x400c64a1 in malloc_consolidate () from /lib/libc.so.6
#1 0x400c5d83 in _int_malloc () from /lib/libc.so.6
#2 0x400c578c in calloc () from /lib/libc.so.6
#3 0x08126e6f in write_to_pager (d=0x853aef0, txt=0x8194d3b "\e[0;36m", length=7) at color.c:1021
#4 0x08126dde in set_pager_color (AType=6, ch=0x853cdb8) at color.c:999
#5 0x080e7a51 in do_score (ch=0x853cdb8, argument=0xbfffed02 "") at player.c:123
#6 0x080c6a2f in interpret (ch=0x853cdb8, argument=0xbfffed02 "") at interp.c:737
#7 0x08096de2 in game_loop () at comm.c:682
#8 0x080966b4 in main (argc=2, argv=0xbffff120) at comm.c:329
#9 0x40063d06 in __libc_start_main () from /lib/libc.so.6
I've installed Samsons ansii color code. I even recently remade the codebase on another server, built it all back up, and still have this same problem. If anyone could possibly help me with this that would be awesome. Thanks.
| Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Mon 11 Oct 2004 07:49 PM (UTC) |
Message
| Could you show this function and show which line is the one given by GDB:
#3 0x08126e6f in write_to_pager (d=0x853aef0, txt=0x8194d3b "\e[0;36m", length=7) at color.c:1021
That looks like a good place to start since it's where the code leaves SMAUG and enters library functions. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Reply #2 on Mon 11 Oct 2004 07:58 PM (UTC) Amended on Mon 11 Oct 2004 08:01 PM (UTC) by Nicklfire
|
Message
| void write_to_pager( DESCRIPTOR_DATA *d, const char *txt, int length )
{
int pageroffset; /* Pager fix by thoric */
if( length <= 0 )
length = strlen( txt );
if( length == 0 )
return;
if( !d->pagebuf )
{
d->pagesize = MAX_STRING_LENGTH;
CREATE( d->pagebuf, char, d->pagesize );
}
if( !d->pagepoint )
{
d->pagepoint = d->pagebuf;
d->pagetop = 0;
d->pagecmd = '\0';
}
if( d->pagetop == 0 && !d->fcommand )
{
d->pagebuf[0] = '\n';
d->pagebuf[1] = '\r';
d->pagetop = 2;
}
pageroffset = d->pagepoint - d->pagebuf; /* pager
fix (goofup fixed 08/21/97) */
while( d->pagetop + length >= d->pagesize )
{
if( d->pagesize > 32000 )
{
bug( "%s", "Pager overflow. Ignoring.\n\r" );
d->pagetop = 0;
d->pagepoint = NULL;
DISPOSE( d->pagebuf );
d->pagesize = MAX_STRING_LENGTH;
return;
}
d->pagesize *= 2;
RECREATE( d->pagebuf, char, d->pagesize );
}
d->pagepoint = d->pagebuf + pageroffset; /* pager fix (goofup fixed 08/21/97) */
strncpy( d->pagebuf + d->pagetop, txt, length );
d->pagetop += length;
d->pagebuf[d->pagetop] = '\0';
return;
}
------------------
Thats the function and heres the line the backtrace points to.
CREATE( d->pagebuf, char, d->pagesize );
Thanks.
| Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #3 on Mon 11 Oct 2004 08:10 PM (UTC) |
Message
| In the gdb backtrace, could you go to that frame and type:
print d
print d->pagebuf
print d->pagesize
and say what it prints out? |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Reply #4 on Mon 11 Oct 2004 08:13 PM (UTC) |
Message
| (gdb) print d
$1 = (DESCRIPTOR_DATA *) 0x853aef0
(gdb) print d->pagebuf
$2 = 0x0
(gdb) print d->pagesize
$3 = 4096
(gdb)
I'm still super new to GDB but i think thats it o_0. Thanks. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #5 on Mon 11 Oct 2004 08:28 PM (UTC) |
Message
| OK. Since that looks normal, and since the bug is in malloc_consolidate, my bet is that somewhere you are either:
a) freeing something twice
b) using free on a STRALLOCed string (instead of STRFREE), or using STRFREE on a malloced string (instead of free)
I would go through the stuff you added in the snippet and make sure you did it all correctly and exactly as specified. If that doesn't work, I would suggest uninstalling the snippet to see if the problem is somewhere else. And finally, I would suggest using a program such as Valgrind to hunt down the memory error. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Reply #6 on Mon 11 Oct 2004 08:38 PM (UTC) Amended on Mon 11 Oct 2004 09:29 PM (UTC) by Nicklfire
|
Message
| Ok well i was playing around with connect/destroy. I have 2 servers running, 1 with the leak i mentioned, the other is stock smaug with the ansii color snippet installed. When i destroy a player on the leaked one i get "Player Name destroyed. Pfile saved in backup directory. Then i "who" or "score" and it crashes. But on the new one with the same snippet installed exactly I get "Player does not exist." but it still destroys them. I type "who" after and it works fine. So now i'm starting to look into that freeing stuff. Just posted this incase it could help pinpoint the problem. Thanks.
Edit: I also came to the conclusion that it's not anything in destroy that's crashing it, because i had a player log on, save, quit. Typed "who" it crashed. Logged back on and destroyed the player while they were offline and it didn't crash. -sulks- | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #7 on Mon 11 Oct 2004 09:38 PM (UTC) |
Message
| I would look at the code that gets rid of descriptors. Seems that something in there isn't working right at all - seems that every time somebody leaves one way or another (cleanly or abruptly) the game is put into an unstable state. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Reply #8 on Mon 11 Oct 2004 09:45 PM (UTC) |
Message
| Hrm.. I thought about that at first but I have 2 of the exact same codebases, all the one that crashes has different is things added to nanny for making a char. Such as ch->overdrive, ch->ap, ch->suppress. Added them to mud.h, save.c and that's about it. I haven't touched descriptors or anything :/ . Thanks again. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #9 on Mon 11 Oct 2004 10:09 PM (UTC) |
Message
| Well, I would go look at those variables then and make sure that they are allocated and destroyed correctly (e.g. hashed string creation matches with hashed string deletion...)
Since the error is in malloc_consolidate, that implies that some pointer somewhere wasn't manipulated properly. If you have access to Valgrind I suggest you run it - it'll most likely be able to tell you exactly where the bad manipulation takes place. And maybe even some other bugs you didn't know about. :-) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Reply #10 on Tue 12 Oct 2004 02:33 AM (UTC) |
Message
| Thanks again for the help. Valgrind looks a bit complicating :/ . It's weird though. There will be the odd time where it doesn't crash for like.. 5-6 quits. And then one will. Even if there all after each other. (All these quits are just made chars btw, so there all the same) | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #11 on Tue 12 Oct 2004 03:32 AM (UTC) |
Message
| Valgrind is certainly daunting but then again you have a rather daunting problem. :-) Memory bugs like this are among the hardest to track down.
There's a way to turn on malloc debugging without valgrind, and it helps a bit but it's fairly complicated. Something about setting an environment variable (MALLOC_CHECK) to 2 and compiling your code with #define MALLOC_CHECK 2 as well. I think it's that. You could check the manpage for malloc, it might tell you more precisely what you need to do.
That turns on internal malloc-library debugging which will help spot double-frees or things like that. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #12 on Tue 12 Oct 2004 03:40 AM (UTC) |
Message
| With these snippets that you added, did any of them add/remove strings that are in char_data/pc_data? I would double check all those strings to make sure that:
1. If is allocated using STRALLOC, it is being freed with STRFREE, and that anything allocated with str_dup is being freed with DISPOSE
2. Check that your STRFREE/DISPOSE have checks in the macros in mud.h for null input.
3. Check that, like Ksilyan said, that your not double freeing your strings.
If you have valgrind installed, I would recommend that you use this:
valgrind -v --leak-check=yes --show-reachable=yes --gdb-attach=yes --num-callers=10 --logfile=valgrind ../src/smaug 4000 &
This should create log files from the output. You could then paste the output so otheres could look at them and help you out from them. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Reply #13 on Tue 12 Oct 2004 05:00 AM (UTC) Amended on Tue 12 Oct 2004 06:50 PM (UTC) by Nicklfire
|
Message
| The only snippets i've added are... hotboot and ansii color fix. And i added ch->overdrive, ch->ap, ch->suppress
ch->mod to the char_data structure. int, int, long int, float. I'll try that valgrind thing like you said when i first opened it i was like O_O what is this. :/ but yeah i'll post back when I can get it to work. Thanks guys :D
Edit: I checked my macros and it has the stuff for null, weirdly i have 2 macros for STRFREE that's probably not the problem considering both the leaking codebase and working one have 2.
Edit2: Ok I tried to install valgrind but it tries to install stuff into the servers folders and i don't have the permissions... so I guess thats outta the question x_x;. | Top |
|
Posted by
| Nicklfire
(17 posts) Bio
|
Date
| Reply #14 on Tue 12 Oct 2004 09:37 PM (UTC) |
Message
| Any idea as to why I created a character, did the EXACT same process everytime. Log on. 2 enters from the ansii screens. save, quit. First 4 times it didn't crash. Then the fifth did. -confused- | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
49,063 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top