Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

nginx regex module screws up pcre

$
0
0
I've just spent a long debug session figuring this out!

nginx's regex module sets pcre_malloc and pcre_free globally:

void
ngx_regex_init(void)
{
pcre_malloc = ngx_regex_malloc;
pcre_free = ngx_regex_free;
}

So any other module or library using pcre inherits nginx's
functions. But those functions rely on an nginx pool, which
gets set and unset in ngx_regex_module_init and in
ngx_regex_compile. So anything else calling pcre_compile
gets a NULL pool, and allocation fails.

Another module may be able to work around that by using
ngx_regex_compile in place of pcre_compile. For a third-
party library that's not an option: we're basically screwed!

If nginx is setting pcre_malloc and pcre_free, it should set
them to functions that will work at any time a third-party
might call them.

The outline of a scheme might be for ngx_regex_init to set
ngx_pcre_pool to the cycle pool, and thereafter each pool
creation/cleanup event gets a callback that may push/pop
the new/old pool. I guess that still needs care to limit it to
connection and request pools, and not automatically trigger
on inappropriate special-purpose pools.

Does that make sense?

--
Nick Kew

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Viewing all articles
Browse latest Browse all 53287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>