[PATCH] fixing possible PANIC condition

Stipe Tolj <[email protected]> Mon, 10 Sep 2018 12:21:07 +0200
Newsgroups gmane.comp.mobile.kannel.devel
Organization Kannel Software Foundation (KSF)
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------080901000208060601020409
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi list,

attached is a patch that fixes a PANIC condition we have been reported:

2018-09-07 11:38:07.241 [25148] [9] PANIC: gwlib/conn.c:889: 
conn_unregister: Assertion `conn != NULL' failed.
2018-09-07 11:38:07.255 [25148] [9] PANIC: 
/opt/kannel/sbin/smsbox(gw_backtrace+0xbe) [0x44e82e]
2018-09-07 11:38:07.255 [25148] [9] PANIC: 
/opt/kannel/sbin/smsbox(gw_panic+0x1ce) [0x44ea0e]
2018-09-07 11:38:07.255 [25148] [9] PANIC: /opt/kannel/sbin/smsbox() 
[0x44a21c]
2018-09-07 11:38:07.255 [25148] [9] PANIC: /opt/kannel/sbin/smsbox() 
[0x43fba1]
2018-09-07 11:38:07.255 [25148] [9] PANIC: /opt/kannel/sbin/smsbox() 
[0x443783]

where:

# addr2line -e /opt/kannel/sbin/smsbox 0x44a21c 0x43fba1 0x443783
/tmp/kannel/smppbox-1.9.4/gateway-ha/gwlib/http.c:1213
/tmp/kannel/smppbox-1.9.4/gateway-ha/gwlib/fdset.c:354
/tmp/kannel/smppbox-1.9.4/gateway-ha/gwlib/gwthread-pthread.c:165

so this was coming from gwlib/http.c:handle_transaction().

In fact we DO conn_destroy in gwlib/http.c:/send_request() if a 
conn_write() fails, and then again in handle_transaction() bail out and 
try to conn_unregister() and conn_destroy().

The conn_destroy() is safe as it tests for conn == NULL, but the 
conn_unregister() would raise an assertion panic here.

Suggested patch simply removes the gw_assert() check and leaves it to 
the function to test (what it does) to bail out if the conn is NULL.

If no objections arise, will commit to svn trunk.

Stipe



-- 
Best Regards,
Stipe Tolj

-------------------------------------------------------------------
Düsseldorf, NRW, Germany

Kannel Foundation                 tolj.org system architecture
http://www.kannel.org/            http://www.tolj.org/

stolj at kannel.org               st at tolj.org
-------------------------------------------------------------------

--------------080901000208060601020409
Content-Type: text/plain;
 name="workspace-gateway-conn-unreg.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="workspace-gateway-conn-unreg.diff"

Index: gwlib/conn.c
===================================================================
--- gwlib/conn.c	(revision 5261)
+++ gwlib/conn.c	(working copy)
@@ -855,8 +855,6 @@
     int fd = -1;
     void *data = NULL;
     conn_callback_data_destroyer_t *destroyer = NULL;
-    
-    gw_assert(conn != NULL);
 
     if (conn == NULL || conn->fd < 0)
         return;

--------------080901000208060601020409--