01-09-2009, 01:32 AM | #1 |
New Member
Join Date: Nov 2008
Posts: 23
|
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. |
01-09-2009, 05:21 AM | #2 |
Member
|
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.
|
01-09-2009, 08:22 AM | #3 |
New Member
Join Date: Nov 2008
Posts: 23
|
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); } |
01-09-2009, 08:46 AM | #4 |
Member
|
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?
|
01-09-2009, 10:01 AM | #5 |
New Member
Join Date: Nov 2008
Posts: 23
|
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? |
01-09-2009, 10:08 AM | #6 |
Member
|
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.
|
01-09-2009, 10:49 AM | #7 |
New Member
Join Date: Nov 2008
Posts: 23
|
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; |