<div dir="ltr"><div class="gmail_extra">Hi Răzvan,</div><div class="gmail_extra">I tested the fix, it&#39;s working fine now</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks!</div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"></div></div></div>
<br><div class="gmail_quote">On Mon, Sep 14, 2015 at 4:52 AM, Răzvan Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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 bgcolor="#FFFFFF" text="#000000">
    <tt>Hi, Federico!<br>
      <br>
      Nice catch! Indeed, there seems to be a pkg memory leak during
      reload.<br>
      I committed a fix on the master branch that shoul fix this
      issue[1]. Can you pelase test and let me know everything is ok
      this time, so I can backport the fix to the other branches (2.1,
      1.11).<br>
      <br>
      [1]
<a href="https://github.com/OpenSIPS/opensips/commit/aa7429e0124478f999ba3737b10ae39900e16b2c" target="_blank">https://github.com/OpenSIPS/opensips/commit/aa7429e0124478f999ba3737b10ae39900e16b2c</a><br>
      <br>
      Thanks,<br>
    </tt>
    <pre cols="72">Răzvan Crainea
OpenSIPS Solutions
<a href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre><div><div class="h5">
    <div>On 09/11/2015 05:07 PM, Federico Edorna
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <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&lt;max_groups; i++) {</div>
            <div>                if ((patterns[i] =
              pkg_malloc(sizeof(char) * group_max_size)) == 0) {</div>
            <div>                        LM_ERR(&quot;no more memory for
              patterns[%d]\n&quot;, i);</div>
            <div>                        fclose(f);</div>
            <div>                        goto err;</div>
            <div>                }</div>
            <div>                memset(patterns[i], &#39;\0&#39;,
              group_max_size);</div>
            <div>        }</div>
          </div>
          <div><br>
          </div>
          <div>but when you free memory, it seems that it&#39;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(&quot;regex&quot;, &quot;max_groups&quot;, 4)<br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">when I run the &quot;fifo regex_reload&quot;
            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">&lt;<a href="mailto:fedorna@anura.com.ar" target="_blank"></a><a href="mailto:fedorna@anura.com.ar" target="_blank">fedorna@anura.com.ar</a>&gt;</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&#39;ve found an issue when I
                  reload regular expresion file for opensips 1.11.5.
                  <div><br>
                  </div>
                  <div>After executing a few &quot;opensipsctl fifo
                    regex_reload&quot;, 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 &quot;ID=4 &quot;</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 &quot;pkmem:4-free_size::&quot;
                       ; 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&#39;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>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div></div>