[Home]

Summary:ASTERISK-27305: res_ari: Memory leaks in ARI when using Content-Type: application/json
Reporter:David Hajek (hajekd)Labels:patch
Date Opened:2017-10-03 15:19:18Date Closed:2017-10-09 11:33:38
Priority:MajorRegression?
Status:Closed/CompleteComponents:
Versions:13.17.2 14.6.2 15.0.0-rc1 Frequency of
Occurrence
Constant
Related
Issues:
is duplicated byASTERISK-27261 Memory Leak when using ARI in json.c and stasis_channels.c
Environment:CentOS 6.9, jansson 2.9Attachments:( 0) json_memory_fix.patch
( 1) mmlog
( 2) mmlog.txt
Description:There is some memory leak when making ARI request with Content-Type: application/json. Every such call leaks few bytes of memory in json.c and its never freed. Making several thousands ARI requests results in asterisk being killed by kernel's OOM. Memory is not leaked when Content-Type application/json is not used.

We don't think this is duplicate of ASTERISK-27067.

We tried latest 13.17.2, 14.6.2 and 15.0.0 and all these versions are affected.



Steps to reproduce:

# Run asterisk with MALLOC_DEBUG
# Memory allocations in json.c after startup
{code}
asterisk  -rx 'memory show summary' | grep json.c
672 bytes in          5 allocations in file json.c
{code}
# Originate dummy call using ARI
{code}
curl -v -u ari:asterisk -X POST -H "Content-Type: application/json" "http://localhost:8088/ari/channels" -d '{"endpoint":"SIP/dummy", "extension":"123456", "context":"internal-routing", "priority":"1"}'
{code}
# Memory allocations in json.c after one ARI call. This memory is never freed and many requests results in OOM.
{code}
asterisk  -rx 'memory show summary' | grep json.c
     2288 bytes in         19 allocations in file json.c
{code}


Comments:By: Asterisk Team (asteriskteam) 2017-10-03 15:19:19.564-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: David Hajek (hajekd) 2017-10-03 15:23:29.988-0500

mmlog

By: Rusty Newton (rnewton) 2017-10-03 16:34:20.186-0500

reattaching with txt extension for ease of viewing.

By: David Hajek (hajekd) 2017-10-05 08:00:30.982-0500

I think this patch fixes the memory leak. I tried many thousands API ARI calls and there are no leaks. Please review.

By: David Hajek (hajekd) 2017-10-05 08:02:49.936-0500

Patch is for 13.17.2

By: Rusty Newton (rnewton) 2017-10-06 09:26:52.256-0500

[~hajekd] the patch should be pushed to Gerrit for review. See [Gerrit Usage|https://wiki.asterisk.org/wiki/display/AST/Gerrit+Usage].

By: Friendly Automation (friendly-automation) 2017-10-09 11:33:40.417-0500

Change 6684 merged by Jenkins2:
res/res_ari.c Fix: Memory leaks in ARI when using Content-Type: application/json

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

By: Friendly Automation (friendly-automation) 2017-10-09 11:40:58.523-0500

Change 6687 merged by Jenkins2:
res/res_ari.c Fix: Memory leaks in ARI when using Content-Type: application/json

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

By: Friendly Automation (friendly-automation) 2017-10-09 11:43:56.110-0500

Change 6686 merged by Jenkins2:
res/res_ari.c Fix: Memory leaks in ARI when using Content-Type: application/json

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

By: Friendly Automation (friendly-automation) 2017-10-09 11:57:12.624-0500

Change 6685 merged by Jenkins2:
res/res_ari.c Fix: Memory leaks in ARI when using Content-Type: application/json

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