Summary: | ASTERISK-16486: [patch] SIP peers memory leak | ||
Reporter: | Kirill Katsnelson (kkm) | Labels: | |
Date Opened: | 2010-07-31 22:55:40 | Date Closed: | 2011-04-22 09:59:16 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Channels/chan_sip/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) 017774-sip-peer-leak-1.6.2.10.diff ( 1) 017774-sip-peer-leak-1.8.diff | |
Description: | There is a memory leak associated with sip peer creation and destruction, because of a bug in reference counting. Patch attached. ****** STEPS TO REPRODUCE ****** * Compile chan_sip with #define REF_DEBUG 1 and set core debug level 3. * Register and unregister an automatic or realtime peer a few times. * Wait until 'sip show scheduler' is all zeroes, and shut down core. Observe: 1. The message "chan_sip.c: sip_destroy_peer: Destroying SIP peer {peer-name}" is NOT ever displayed (it is unconditionally printed at debug level 3 in the destructor). 2. utils/refcount shows sip_peer structures, one per each registration, with outstanding ref count of 2. | ||
Comments: | By: Kirill Katsnelson (kkm) 2010-08-05 14:54:28 As it is not very clear from looking at the patch what is going on, I should describe the problem. As you see, a single line of code is moved down. I moved it right below where the peer->addr is last used as a key to remove the peer from peer_by_ip list: Zero it out too early, and the peer is never removed. By: David Vossel (dvossel) 2010-08-09 13:51:11 good catch! By: Digium Subversion (svnbot) 2010-08-09 15:46:48 Repository: asterisk Revision: 281430 U branches/1.6.2/channels/chan_sip.c ------------------------------------------------------------------------ r281430 | dvossel | 2010-08-09 15:46:48 -0500 (Mon, 09 Aug 2010) | 13 lines fixes SIP peers memory leak We zeroed out the peer's addr before it was removed from the peers_by_ip container. This made it impossible to be removed from the container as the addr is the key used by the container to find the peer. (closes issue ASTERISK-16486) Reported by: kkm Patches: 017774-sip-peer-leak-1.6.2.10.diff uploaded by kkm (license 888) 017774-sip-peer-leak-1.8.diff uploaded by kkm (license 888) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=281430 By: Digium Subversion (svnbot) 2010-08-09 15:47:52 Repository: asterisk Revision: 281432 _U branches/1.8/ U branches/1.8/channels/chan_sip.c ------------------------------------------------------------------------ r281432 | dvossel | 2010-08-09 15:47:52 -0500 (Mon, 09 Aug 2010) | 20 lines Merged revisions 281430 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ........ r281430 | dvossel | 2010-08-09 15:46:50 -0500 (Mon, 09 Aug 2010) | 13 lines fixes SIP peers memory leak We zeroed out the peer's addr before it was removed from the peers_by_ip container. This made it impossible to be removed from the container as the addr is the key used by the container to find the peer. (closes issue ASTERISK-16486) Reported by: kkm Patches: 017774-sip-peer-leak-1.6.2.10.diff uploaded by kkm (license 888) 017774-sip-peer-leak-1.8.diff uploaded by kkm (license 888) ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=281432 By: Digium Subversion (svnbot) 2010-08-09 15:49:12 Repository: asterisk Revision: 281433 _U trunk/ U trunk/channels/chan_sip.c ------------------------------------------------------------------------ r281433 | dvossel | 2010-08-09 15:49:12 -0500 (Mon, 09 Aug 2010) | 27 lines Merged revisions 281432 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r281432 | dvossel | 2010-08-09 15:47:53 -0500 (Mon, 09 Aug 2010) | 20 lines Merged revisions 281430 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ........ r281430 | dvossel | 2010-08-09 15:46:50 -0500 (Mon, 09 Aug 2010) | 13 lines fixes SIP peers memory leak We zeroed out the peer's addr before it was removed from the peers_by_ip container. This made it impossible to be removed from the container as the addr is the key used by the container to find the peer. (closes issue ASTERISK-16486) Reported by: kkm Patches: 017774-sip-peer-leak-1.6.2.10.diff uploaded by kkm (license 888) 017774-sip-peer-leak-1.8.diff uploaded by kkm (license 888) ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=281433 |