[ircd-ratbox] [PATCH] ratbox-services: finally found that nasty crash

Jilles Tjoelker jilles at stack.nl
Wed May 4 13:38:01 UTC 2005


I finally found and fixed the stack overflow that I had been getting on
ratbox-services for months.

When a read or write on a DCC connection fails for certain reasons (e.g.
connection timed out, broken pipe), a notification of the termination of
the connection is sent to all DCC connections, including the problematic
one. This causes another broken pipe on the problematic DCC connection,
which causes another notification to be sent. The result is a stack
overflow.

The attached patch fixes this by marking the connection dead right away
in signoff_client(), before sending out the notifications. To avoid
potential further trouble, I have also moved the SetConnDead() in
signoff_server up (even though nothing in signoff_server() can cause
anything to be sent to the server currently).

-- 
Jilles Tjoelker
-------------- next part --------------
--- src/io.c.orig	Mon Apr 25 10:22:24 2005
+++ src/io.c	Wed May  4 14:39:34 2005
@@ -702,6 +702,9 @@
 	if(ConnDead(conn_p))
 		return;
 
+	/* Mark it as dead right away to avoid infinite calls! -- jilles */
+	SetConnDead(conn_p);
+
 	if(UserAuth(conn_p))
                 sendto_all(UMODE_AUTH, "%s has logged out", conn_p->name);
 
@@ -709,7 +712,6 @@
 		deallocate_conf_oper(conn_p->oper);
 
 	sock_close(conn_p);
-	SetConnDead(conn_p);
 }
 
 static void
@@ -721,6 +723,9 @@
 	if(ConnDead(conn_p))
 		return;
 
+	/* Mark it as dead right away to avoid infinite calls! -- jilles */
+	SetConnDead(conn_p);
+
 	/* clear any introduced status */
 	DLINK_FOREACH(ptr, service_list.head)
 	{
@@ -740,7 +745,6 @@
 	}
 
 	sock_close(conn_p);
-	SetConnDead(conn_p);
 }
 
 


More information about the ircd-ratbox mailing list