[Home]

Summary:ASTERISK-20763: Memory Leak in chan_sip with TLS enabled clients
Reporter:deti (deti)Labels:
Date Opened:2012-12-05 02:59:48.000-0600Date Closed:2012-12-05 10:49:45.000-0600
Priority:CriticalRegression?Yes
Status:Closed/CompleteComponents:Channels/chan_sip/TCP-TLS
Versions:1.8.18.0 Frequency of
Occurrence
Constant
Related
Issues:
must be completed before resolvingASTERISK-20766 Open Blockers for 1.8.19.0
must be completed before resolvingASTERISK-20767 Open Blockers for 10.11.0
Environment:Ubuntu 12.04 LTS / Asterisk 1.8.18 via SVN branchAttachments:( 0) chan_sip.c.patch
( 1) chan_sip.c.patch
( 2) memory-allocations+1d.txt
( 3) memory-debug.txt
( 4) memory-debug+1d.txt
Description:Since we have enabled TLS for most of our 200+ clients (Snom 360) the Asterisk process faces a serious memory leak that consumes about 2GB RAM per day.
With memory debugging enabled you can see:

10399843 bytes in 11893 allocations in file 'chan_sip.c'

Most of the allocations seem to come from line 12089:
      342 bytes allocated in         copy_request at line 12089 of chan_sip.c
      702 bytes allocated in         copy_request at line 12089 of chan_sip.c
     1041 bytes allocated in         copy_request at line 12089 of chan_sip.c
      857 bytes allocated in         copy_request at line 12089 of chan_sip.c
      700 bytes allocated in         copy_request at line 12089 of chan_sip.c
      702 bytes allocated in         copy_request at line 12089 of chan_sip.c
      847 bytes allocated in         copy_request at line 12089 of chan_sip.c
      702 bytes allocated in         copy_request at line 12089 of chan_sip.c
     1044 bytes allocated in         copy_request at line 12089 of chan_sip.c
      850 bytes allocated in         copy_request at line 12089 of chan_sip.c
      342 bytes allocated in         copy_request at line 12089 of chan_sip.c

... and my educated guess is that comes from sip_tls_read. It seems that the reqcpy created in line 2580 does not get freed properly.
Comments:By: deti (deti) 2012-12-05 03:26:49.522-0600

Memory summary at start time and summary + allocations after one day.

By: deti (deti) 2012-12-05 03:39:20.294-0600

Isn't there a deinit_req(&reqcpy) missing whenever sip_tls_read is left?


By: Matt Jordan (mjordan) 2012-12-05 09:27:07.118-0600

Yes, yes it is.  Yikes.

By: Matt Jordan (mjordan) 2012-12-05 09:38:59.433-0600

So the "good news" is this is only in 1.8.19.0-rc1 currently.  We'll get this fixed ASAP.

By: Matt Jordan (mjordan) 2012-12-05 11:32:26.567-0600

So Josh just committed a fix for this.  Can you verify that it resolved the issue on your system as well?

By: deti (deti) 2012-12-05 11:57:26.844-0600

Works for me.