Welcome! Log In Create A New Profile

Advanced

nginx regex module screws up pcre

Nick Kew
December 29, 2012 02:48PM
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
Subject Author Views Posted

nginx regex module screws up pcre

Nick Kew 1484 December 29, 2012 02:48PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 167
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready