<div dir="ltr">Hello list,<div><br></div><div style>We are porting ModSecurity to NGINX. However we are seeing sometimes an issue. Nginx eats 100% of cpu and when i use gdb i see:</div><div style><br></div><div style><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;padding:0px;border:0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:22px;background-color:rgb(251,251,251);margin-top:0px!important">
gdb -p 8645</p><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;padding:0px;border:0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:22px;background-color:rgb(251,251,251);margin-top:0px!important">
ngx_event_pipe_write_to_downstream (p=0x9bbc720, do_write=0) at src/event/ngx_event_pipe.c:551</p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:22px;background-color:rgb(251,251,251);margin-bottom:0px!important">
551 if (cl->buf->recycled) {<br>(gdb)</p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:22px;background-color:rgb(251,251,251);margin-bottom:0px!important">
Looks like it is happening when we call ngx_http_modsecurity_body_filter() then go to this conditions;</p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;background-color:rgb(251,251,251);margin-bottom:0px!important">
</p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">    rc = move_chain_to_brigade(in, ctx->brigade, r->pool, 0);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><span style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px">    if (rc != NGX_OK)  {</span></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        r->buffered |= NGX_HTTP_SSI_BUFFERED;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><span style="line-height:22px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif">        return rc;</span></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><span style="line-height:22px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif">     }</span></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><span style="line-height:22px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif">move_chainto_brigade is defined as:</span></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><span style="line-height:22px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif"><br></span></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important">
<font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">ngx_int_t</span></font></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important">
<font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">move_chain_to_brigade(ngx_chain_t *chain, apr_bucket_brigade *bb, ngx_pool_t *pool, ngx_int_t last_buf) {</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">    apr_bucket         *e;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">    ngx_chain_t        *cl;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px"><br>
</span></font></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">    while (chain) {</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        e = ngx_buf_to_apr_bucket(chain->buf, bb->p, bb->bucket_alloc);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        if (e == NULL) {</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">            return NGX_ERROR;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        }</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px"><br>
</span></font></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        APR_BRIGADE_INSERT_TAIL(bb, e);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        if (chain->buf->last_buf) {</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">            e = apr_bucket_eos_create(bb->bucket_alloc);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">            APR_BRIGADE_INSERT_TAIL(bb, e);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">            chain->buf->last_buf = 0;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">            return NGX_OK;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        }</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        cl = chain;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        chain = chain->next;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        ngx_free_chain(pool, cl);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">    }</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px"><br>
</span></font></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">    if (last_buf) {</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        e = apr_bucket_eos_create(bb->bucket_alloc);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        APR_BRIGADE_INSERT_TAIL(bb, e);</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">        return NGX_OK;</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">    }</span></font></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><span style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px">    return NGX_AGAIN;</span></p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><span style="line-height:22px">}</span></font></p>
<div style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px">Let me know if you guys can help us understanding why sometimes we trigger this issue</div><div style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px">
Thanks</div><div style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px"><br></div><div style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px">
Breno</div><p></p><div style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:22px"><br></div><p></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;padding:0px;border:0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:22px;background-color:rgb(251,251,251);margin-bottom:0px!important">
<br></p></div></div>