Summary:ASTERISK-25262: Memory leak when a caller channel does multiple dials and CEL is enabled
Reporter:Etienne Lessard (hexanol)Labels:
Date Opened:2015-07-17 08:28:14Date Closed:2016-06-09 22:41:13
Versions:13.4.0 Frequency of
Description:Given I two users, SIP/alice and SIP/bob
Given I have the following queues.conf:

ringinuse = no
timeout = 1
retry = 1
member => SIP/alice
Given I have the following extension in extensions.conf:
exten = 201,1,Queue(foo)
Given I have the following cel.conf:
enable = yes
When Bob dials the 201 extension
And Alice never answers
Then Alice is called every 2 seconds
And the asterisk process memory usage grows a little each time Alice is called
And the only way for the memory to be freed is to stop/restart asterisk

In this scenario, a SIP/bob channel creates a new SIP/alice channel and dials it once every 2 second. The callback function "cel_dial_cb" in cel.c is thus called once (or twice in fact) every 2 seconds. An ast_multi_channel_blob is then stored in the "cel_dialstatus_store" ao2_container. But most of these ast_multi_chanel_blob object are never unlinked from the container, and thus memory usage of the asterisk process grows.

Took me a while to understand the leak; when I first saw it was occurring in asterisk, I tried running a REF_DEBUG version of asterisk, but since the container is cleaned at exit, it didn't show up; similar thing when running valgrind.

To give you an idea of the leak, on my test setup, after ~600 dial to SIP/alice, VSZ and RSS have grown about 10 MB each.

I used the Queue application in this example, but it's also possible to leak with the Dial application, or in fact any application that can create and "dial" channels.

It's also possible to use a tool like sipp to leak memory more rapidly.
Comments:By: Asterisk Team (asteriskteam) 2015-07-17 08:28:16.111-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Corey Farrell (coreyfarrell) 2015-10-19 08:48:34.135-0500

-Based on your description it looks like this is a CEL bug?  Does it still happen if you use the Dial app in a loop or does it require Queue to reproduce?-

Sorry I should have done better reading the description.  I'll try taking a look at this later this week when I have a chance.