<div dir="ltr">Hello,<div> <div>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 (<a href="http://www.opensips.org/html/docs/modules/1.11.x/regex.html#id249240" target="_blank">http://www.opensips.org/html/docs/modules/1.11.x/regex.html#id249240</a>) :</div><div><br></div><div><div>for (i=0; i<max_groups; i++) {</div><div> if ((patterns[i] = pkg_malloc(sizeof(char) * group_max_size)) == 0) {</div><div> LM_ERR("no more memory for patterns[%d]\n", i);</div><div> fclose(f);</div><div> goto err;</div><div> }</div><div> memset(patterns[i], '\0', group_max_size);</div><div> }</div></div><div><br></div><div>but when you free memory, it seems that it's only done for the patterns that actually are being used.</div><div><br></div><div>In fact, if I set the max_groups parameter to the same amount of patterns in the regex file:</div><div><br></div><div>modparam("regex", "max_groups", 4)<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">when I run the "fifo regex_reload" loop, I never run out of pkmemory.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards<br clear="all"><div><div><div dir="ltr"><br></div></div></div>
<br><div class="gmail_quote">On Fri, Sep 4, 2015 at 12:18 PM, Federico Edorna <span dir="ltr"><<a href="mailto:fedorna@anura.com.ar" target="_blank">fedorna@anura.com.ar</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi Team, I've found an issue when I reload regular expresion file for opensips 1.11.5.<div><br></div><div>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:</div><div><br></div><div><div>root@toro:~# sudo -u gc /home/gc/local/opensips/sbin/opensipsctl fifo ps | grep "ID=4 "</div><div>Process:: ID=4 PID=11040 Type=MI FIFO</div><div>root@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</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 3353184</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 1466776</div><div>pkmem:4-free_size:: 140696</div><div>500 Server Internal Error</div><div>pkmem:4-free_size:: 140696</div><div>500 Server Internal Error</div><div>pkmem:4-free_size:: 140696</div><div>500 Server Internal Error</div><div>pkmem:4-free_size:: 140696</div><div>500 Server Internal Error</div><div>^C</div><div>root@toro:~#</div><div><br></div><div>For the following regex_reload commands the error in the syslog file is this :</div><div><br></div><div><div>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]</div><div>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</div></div><div><br></div><div>The only way to recover from this is to restart opensips.</div><div><br></div><div>I've pasted the syslog (compiled with DBG_QM_MALLOC option) when the command is succesfull: <a href="http://pastebin.com/VnMZrYrh" target="_blank">http://pastebin.com/VnMZrYrh</a></div></div><div><br></div><div><br></div><div>I tyied to increase the pkmem for the process, but sooner or later the error came up</div><div><br></div><div>Thanks in advance!</div><span><font color="#888888"><div>Federico</div><div><br></div><div><br></div></font></span></div>
</blockquote></div><br></div></div></div>