[Home]

Summary:ASTERISK-17510: [patch] uncached realtime peers are put in peers_by_ip => memory leak
Reporter:Walter Doekes (wdoekes)Labels:
Date Opened:2011-03-04 01:53:32.000-0600Date Closed:2011-04-25 14:06:10
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) issue18924_uncached_realtime_peers_leak-1.6.2.17.patch
Description:Hi,

I was having problems with UDP leaks at first. This was kindly fixed by rgagnon with his patch in ASTERISK-16023. After applying that fix, I noticed that memory usage was *still* increasing.

I've managed to trace the problem to the following:

Peers are put in the peers_by_ip list in parse_register_contact. However, only if the peer is static or cached(-realtime), does it get a scheduled expire_register() call. The expire_register makes sure the peer gets removed from the global 'peers' and 'peers_by_ip' list.

These uncached realtime peers should not be in any of those lists, but they are in the peers_by_ip list. (Which was hard to see, because the sip show objects only shows the 'peers' container.)

Furthermore, when asterisk is stopped with 'core stop gracefully', these peers from these two containers are properly unreferenced: the refcount utility shows no problem.

But, in the mean time, asterisk has been eating away memory because it keeps on adding peers to the peers_by_ip list which are never removed.

****** STEPS TO REPRODUCE ******

(1) Configure a system for uncached realtime peers.
(2) Register a peer.
(3) memory show allocations => shows one more allocation for build_peer for every time you register


****** ADDITIONAL INFORMATION ******

Related items:
(1) The fix for ASTERISK-16023 is needed, otherwise you get those leaks too. (You'll notice reference leaks immediately if you test without this.)
(2) This might be the second part of the fix for ASTERISK-16710, 17255 being the first.

Regards,
Walter Doekes
OSSO B.V.
Comments:By: Digium Subversion (svnbot) 2011-04-25 14:00:26

Repository: asterisk
Revision: 315212

U   branches/1.6.2/channels/chan_sip.c

------------------------------------------------------------------------
r315212 | russell | 2011-04-25 14:00:25 -0500 (Mon, 25 Apr 2011) | 7 lines

Don't link non-cached realtime peers into the peers_by_ip container.

(closes issue ASTERISK-17510)
Reported by: wdoekes
Patches:
     issue18924_uncached_realtime_peers_leak-1.6.2.17.patch uploaded by wdoekes (license 717)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=315212

By: Digium Subversion (svnbot) 2011-04-25 14:04:30

Repository: asterisk
Revision: 315213

_U  branches/1.8/
U   branches/1.8/channels/chan_sip.c

------------------------------------------------------------------------
r315213 | russell | 2011-04-25 14:04:29 -0500 (Mon, 25 Apr 2011) | 14 lines

Merged revisions 315212 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

........
 r315212 | russell | 2011-04-25 14:00:24 -0500 (Mon, 25 Apr 2011) | 7 lines
 
 Don't link non-cached realtime peers into the peers_by_ip container.
 
 (closes issue ASTERISK-17510)
 Reported by: wdoekes
 Patches:
       issue18924_uncached_realtime_peers_leak-1.6.2.17.patch uploaded by wdoekes (license 717)
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=315213

By: Digium Subversion (svnbot) 2011-04-25 14:06:09

Repository: asterisk
Revision: 315214

_U  trunk/
U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r315214 | russell | 2011-04-25 14:06:09 -0500 (Mon, 25 Apr 2011) | 21 lines

Merged revisions 315213 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
 r315213 | russell | 2011-04-25 14:04:28 -0500 (Mon, 25 Apr 2011) | 14 lines
 
 Merged revisions 315212 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.6.2
 
 ........
   r315212 | russell | 2011-04-25 14:00:24 -0500 (Mon, 25 Apr 2011) | 7 lines
   
   Don't link non-cached realtime peers into the peers_by_ip container.
   
   (closes issue ASTERISK-17510)
   Reported by: wdoekes
   Patches:
         issue18924_uncached_realtime_peers_leak-1.6.2.17.patch uploaded by wdoekes (license 717)
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=315214