Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 01-09-2009, 01:32 AM   #1
Hyena
New Member
 
Join Date: Nov 2008
Posts: 23
Hyena is on a distinguished road
Weird crash bug at low level writing to descriptor

Codebase is ROM

Program received signal SIGPIPE, Broken pipe.
0x400fc228 in write () from /lib/libc.so.6
(gdb) bt
#0 0x400fc228 in write () from /lib/libc.so.6
#1 0x00000000 in ?? ()
#2 0x0808cf97 in write_to_descriptor (desc=12,
txt=0x42a2f8b0 "You do not see that here.\n\r\n\r^ >oblin patrolman has arrived from the north.\n\r\n\r^ >ded by a force shield.\n\r\n\r^ >fect >s are low and brutal.\n\rRed eyes are psychopathicly seeking for any kind of enemies."..., length=32) at comm.c:1324
#3 0x0808c380 in process_output (d=0x41dfc13c, fPrompt=224 'ā') at comm.c:1016
#4 0x0808b8a6 in game_loop_unix (control=8) at comm.c:501
#5 0x0808af59 in main (argc=2, argv=0x8) at comm.c:136


It happened when a player using jaba mud client typed #99 look goblin and spammed it about 5 times. He then was summoned by another player (which I don't think the problem was) and then it crashed.

Neither me nor he were able to repeat that crash later. Any suggestions?

Edit:
One more thing. That player should have been disconnected by server for overflooding the input but strangely he wasn't and then the crash came. When we repeated the same action we got disconnected by the server every time.

Last edited by Hyena : 01-09-2009 at 01:41 AM.
Hyena is offline   Reply With Quote
Old 01-09-2009, 05:21 AM   #2
Kylotan
Member
 
Join Date: Jun 2003
Location: Nottingham, UK
Home MUD: Abattoir (Smaug)
Home MUD: ex-Jellybean (Smaug)
Home MUD: ex-Dark Chambers (Merc)
Posts: 174
Kylotan is on a distinguished road
Send a message via ICQ to Kylotan Send a message via AIM to Kylotan Send a message via MSN to Kylotan Send a message via Yahoo to Kylotan
Re: Weird crash bug at low level writing to descriptor

Sometimes write() can send SIGPIPE. Best to ignore it as it's mostly useless. You may find examples elsewhere in the ROM code for ignoring signals, otherwise look on Google. Do that for SIGPIPE. It seems a bit strange that I've never seen this occur in any networking code I've written though.
Kylotan is offline   Reply With Quote
Old 01-09-2009, 08:22 AM   #3
Hyena
New Member
 
Join Date: Nov 2008
Posts: 23
Hyena is on a distinguished road
Re: Weird crash bug at low level writing to descriptor

in signals.c doesn't the following already ignore all cases of SIGPIPE? If it does then why I still got the crash? How can I fix it?

void init_signals()
{
signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, sig_handler);
signal(SIGSEGV, sig_handler);
signal(SIGFPE, sig_handler);
signal(SIGUSR2, sig_handler);
signal(SIGTSTP, sig_message);
}

void un_init_signals()
{
signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, SIG_DFL);
signal(SIGSEGV, SIG_DFL);
signal(SIGFPE, SIG_DFL);
signal(SIGUSR2, SIG_DFL);
signal(SIGTSTP, SIG_DFL);
}
Hyena is offline   Reply With Quote
Old 01-09-2009, 08:46 AM   #4
Kylotan
Member
 
Join Date: Jun 2003
Location: Nottingham, UK
Home MUD: Abattoir (Smaug)
Home MUD: ex-Jellybean (Smaug)
Home MUD: ex-Dark Chambers (Merc)
Posts: 174
Kylotan is on a distinguished road
Send a message via ICQ to Kylotan Send a message via AIM to Kylotan Send a message via MSN to Kylotan Send a message via Yahoo to Kylotan
Re: Weird crash bug at low level writing to descriptor

I would think init_signals() would do the trick, yes. I guess the next question is: why is there an un_init_signals() function, and has that perhaps been called?
Kylotan is offline   Reply With Quote
Old 01-09-2009, 10:01 AM   #5
Hyena
New Member
 
Join Date: Nov 2008
Posts: 23
Hyena is on a distinguished road
Re: Weird crash bug at low level writing to descriptor

void sig_handler(int sig)
{
un_init_signals(); /* signal caught, don't wanna catch it again, 'cause me might loop */
switch (sig) {
case SIGTERM:
bug("Sig_handler: SIGTERM (crashed or killed)", 0);
do_auto_shutdown(TRUE);
raise(SIGTRAP);
break;
case SIGSEGV:
bug("Sig_handler: SIGSEGV (crashed)", 0);
do_auto_shutdown(TRUE);
raise(SIGTRAP);
break;
case SIGFPE:
bug("Sig_handler: SIGFPE (crashed)", 0);
do_auto_shutdown(TRUE);
raise(SIGTRAP);
break;
case SIGUSR2:
bug("Sig_handler: SIGUSR2 (external signal for auto-rebooting)", 0);
do_auto_shutdown(FALSE);
raise(SIGTRAP);
break;
default:
bug("Sig_handler: Unknown signal caught, shutting down", 0);
do_auto_shutdown(TRUE);
raise(SIGTRAP);
break;
}
}


Seems that if any signal is caught then it un_inits them am I right? As init_signal is executed only once in the very beginning of the whole program. So basically I would have to cancel un_init when there is SIGPIPE?
Hyena is offline   Reply With Quote
Old 01-09-2009, 10:08 AM   #6
Kylotan
Member
 
Join Date: Jun 2003
Location: Nottingham, UK
Home MUD: Abattoir (Smaug)
Home MUD: ex-Jellybean (Smaug)
Home MUD: ex-Dark Chambers (Merc)
Posts: 174
Kylotan is on a distinguished road
Send a message via ICQ to Kylotan Send a message via AIM to Kylotan Send a message via MSN to Kylotan Send a message via Yahoo to Kylotan
Re: Weird crash bug at low level writing to descriptor

Looks like all those signals would result in the mud shutting down though. If a situation arose where the mud wasn't going to shut down immediately, then restoring the signals at the end of the function would seem wise. But it looks like a bit of an awkward design to be honest.
Kylotan is offline   Reply With Quote
Old 01-09-2009, 10:49 AM   #7
Hyena
New Member
 
Join Date: Nov 2008
Posts: 23
Hyena is on a distinguished road
Re: Weird crash bug at low level writing to descriptor

So I added a quick case for SIGPIPE, do you think it should do it?
case SIGPIPE:
logm("SIGPIPE received, ignoring it.",101);
init_signals();
break;
Hyena is offline   Reply With Quote
Reply


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

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

All times are GMT -4. The time now is 04:48 PM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2022