Summary:ASTERISK-24491: Memory leak in res_hep
Reporter:Zane Conkle (zconkle)Labels:
Date Opened:2014-11-04 16:37:32.000-0600Date Closed:2014-11-06 03:42:41.000-0600
Versions:13.0.0 Frequency of
Environment:Attachments:( 0) ASTERISK-24491-13.diff
( 1) xaa
( 2) xab
( 3) xac
Description:Received an alert that one of our Asterisk boxes was using 7.3Gb of ram. Recompiled with malloc. Discovered that res_hep.c was constantly chewing through memory. Attached is the memory allocation dump after 30 minutes of uptime.

We are not using res_hep and do not have a config file for it; I can try to noload that module. In attempt to narrow down the problem I attempted to add a hep.conf file and reload the module and received the following:

pbx*CLI> reload res_hep
The module 'res_hep' was not properly initialized. Before reloading the module, you must run "module load res_hep" and fix whatever is preventing the module from being initialized.

Comments:By: Zane Conkle (zconkle) 2014-11-04 16:40:13.597-0600

Had to split the memory_allocation dump into three files since it exceeded the 10mb limit.

By: Zane Conkle (zconkle) 2014-11-04 16:43:30.320-0600

From IRC:

[4:28pm] coreyfarrell: without much understanding of the code, the leak might be in hepv3_send_packet.  looks like that function is supposed to take over 1 reference to the param capture_info, but if (!config || !config->general->enabled) { return 0; }
[4:29pm] coreyfarrell: If I'm right "ao2_ref(capture_info, -1);" before the "return 0;" should fix it

By: Zane Conkle (zconkle) 2014-11-04 18:33:44.762-0600

coreyfarrell's above fix resolved the issue. He indicated he would put a patch up on reviewboard.

By: Matt Jordan (mjordan) 2014-11-04 21:34:12.951-0600

Attached is a patch that should fix the memory leak in {{res_hep}}. It is currently leaking a constructed HEPv3 packet if the configuration is not enabled.

By: Matt Jordan (mjordan) 2014-11-04 21:34:43.415-0600

Ha! That's what I get for not re-loading the issue.