[OpenSIPS-Users] Memory leak fifo process

Federico Edorna fedorna at anura.com.ar
Fri Sep 11 16:07:17 CEST 2015


Hello,

in function load_pcres in regex_mod.c, I see that when you allocate memory
to read regex groups, the loop goes up to the max_groups parameter (
http://www.opensips.org/html/docs/modules/1.11.x/regex.html#id249240) :

for (i=0; i<max_groups; i++) {
                if ((patterns[i] = pkg_malloc(sizeof(char) *
group_max_size)) == 0) {
                        LM_ERR("no more memory for patterns[%d]\n", i);
                        fclose(f);
                        goto err;
                }
                memset(patterns[i], '\0', group_max_size);
        }

but when you free memory, it seems that it's only done for the patterns
that actually are being used.

In fact, if I set the max_groups parameter to the same amount of patterns
in the regex file:

modparam("regex", "max_groups", 4)


when I run the "fifo regex_reload" loop, I never run out of pkmemory.


Regards


On Fri, Sep 4, 2015 at 12:18 PM, Federico Edorna <fedorna at anura.com.ar>
wrote:

> Hi Team, I've found an issue when I reload regular expresion file for
> opensips 1.11.5.
>
> After executing a few "opensipsctl fifo regex_reload", the fifo process
> runs out of pkmem. This is a small loop where I do a regex_reload and then
> I print the pkmem for MI FIFO processs:
>
> root at toro:~# sudo -u gc /home/gc/local/opensips/sbin/opensipsctl fifo ps
> | grep "ID=4 "
> Process::  ID=4 PID=11040 Type=MI FIFO
> root at toro:~# while [ 1 -eq 1 ] ; do sudo -u gc
> /home/gc/local/opensips/sbin/opensipsctl fifo regex_reload; sudo -u gc
> /home/gc/local/opensips/sbin/opensipsctl fifo get_statistics pkmem: |grep
> "pkmem:4-free_size::"  ; done
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 3353184
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 1466776
> pkmem:4-free_size:: 140696
> 500 Server Internal Error
> pkmem:4-free_size:: 140696
> 500 Server Internal Error
> pkmem:4-free_size:: 140696
> 500 Server Internal Error
> pkmem:4-free_size:: 140696
> 500 Server Internal Error
> ^C
> root at toro:~#
>
> For the following regex_reload commands the error in the syslog file is
> this :
>
> 2015-09-04T11:56:05.645485-03:00 toro
> /home/gc/local/opensips/sbin/opensips[11040]: ERROR:regex:load_pcres: no
> more memory for patterns[11]
> 2015-09-04T11:56:05.645567-03:00 toro
> /home/gc/local/opensips/sbin/opensips[11040]: ERROR:regex:mi_pcres_reload:
> failed to reload pcres
>
> The only way to recover from this is to restart opensips.
>
> I've pasted the syslog (compiled with DBG_QM_MALLOC option) when the
> command is succesfull: http://pastebin.com/VnMZrYrh
>
>
> I tyied to increase the pkmem for the process, but sooner or later the
> error came up
>
> Thanks in advance!
> Federico
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20150911/fc44b31d/attachment.htm>


More information about the Users mailing list