[Home]

Summary:ASTERISK-27067: res_ari_channels: channel_state_invalid always leaks snapshot reference.
Reporter:Marin Odrljin (modrljin)Labels:patch pjsip
Date Opened:2017-06-19 10:59:15Date Closed:2017-11-01 07:37:46
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:Resources/res_ari_channels
Versions:14.2.1 14.5.0 GIT 15.1.0 Frequency of
Occurrence
Constant
Related
Issues:
is duplicated byASTERISK-27261 Memory Leak when using ARI in json.c and stasis_channels.c
Environment:Debian 8Attachments:( 0) ASTERISK-27067.patch
( 1) asterisk-full.txt
( 2) debug_log.txt
( 3) mem1.txt
( 4) mem2.txt
( 5) mem3.txt
( 6) mem4.txt
( 7) mmlog.txt
( 8) refs2.zip
Description:Starting with Asterisk 14 and usage of ARI, memory is leaking on stasis_channels.c file. In Asterisk v13.11.2 this is not happening. After I have noticed it on version 14.2.1, I've found an open issue ASTERISK-26767 and thought this is the problem (althought I don't use channelvars in ari.conf, but I do use vars in dialplan when starting ari app) and installed 14.5 but unfortunately problem didn't dissapear so it must be something else.

In extensions.conf I have following:
{noformat}
[from-iax2-server-1]
exten => _.,1,Stasis(AriStart,TRUNK=${CHANNEL(peername)})
{noformat}
My ARI app originates calls to other server through IAX2 and receives calls back from the same server and channel driver. I've also tried other channel drivers SIP and PJSIP and issue was still there.

What is obvious is when I run CLI command 'memory show summary', there is large memory allocation growth in file 'stasis_channels.c'. You can see it in attached files 'memX.txt'.

I have enabled 'MALLOC_DEBUG' but unfortunatelly there is only one line in 'mmlog' file, and I don't understand why.

Memory is growing until Asterisk eats all available memory and then crashes!
Comments:By: Asterisk Team (asteriskteam) 2017-06-19 10:59:15.847-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) 2017-10-23 16:51:01.816-0500

Can you retest this with Asterisk 15?  If this is still an issue please provide a reference debugging log [1].  I ask since most of the allocations in stasis_channel are actually AO2 objects.

[1] https://wiki.asterisk.org/wiki/display/AST/Reference+Count+Debugging

By: Marin Odrljin (modrljin) 2017-10-24 08:22:52.754-0500

We'll try to test it ASAP, hopefully this week.

By: Marin Odrljin (modrljin) 2017-10-31 07:32:39.124-0500

Problem still exists in Asterisk 15.0.0, but I can't get "refs.txt" less than 10 MB. Already after approx few minutes and 20-30 calls, file size is more than 30 MB. Actually, file is huge already after few minutes without any call made! What I can see, there is a lot of lines containing "media_index.c" and "format_cap.c".

I am using command "/var/lib/asterisk/scripts/refcounter.py -f /var/log/asterisk/refs -n > /tmp/refs.txt" to generate it.

By: Marin Odrljin (modrljin) 2017-10-31 09:21:06.075-0500

I have compressed and attached refs2.zip

By: Corey Farrell (coreyfarrell) 2017-10-31 13:12:55.434-0500

The refs file you've attached has shown a problem.  You're leaking objects created by {{ast_channel_snapshot_create}}.  I've attached [^ASTERISK-27067.patch] which fixes a leak of this object type.

It's possible this wasn't the only leak shown in your refs file, but it was so large I did not review the whole thing.  If you experience additional leaks it's probably best to open a new ticket, I'll be updating the topic of this one to be more specific to the issue that I've found you were experiencing.

By: Friendly Automation (friendly-automation) 2017-11-01 07:37:47.500-0500

Change 6944 merged by Jenkins2:
res_ari_channels: Fix reference leak in channel_state_invalid.

[https://gerrit.asterisk.org/6944|https://gerrit.asterisk.org/6944]

By: Friendly Automation (friendly-automation) 2017-11-01 07:42:55.432-0500

Change 6945 merged by Joshua Colp:
res_ari_channels: Fix reference leak in channel_state_invalid.

[https://gerrit.asterisk.org/6945|https://gerrit.asterisk.org/6945]

By: Marin Odrljin (modrljin) 2017-11-02 05:20:16.472-0500

Thanks Corey, bug seems to be fixed, at least this one you have mentioned. If I found any other leaks, I'll create new issue as you suggested.

By: Asterisk Team (asteriskteam) 2017-11-02 05:20:17.035-0500

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.