Skip to content
Permalink
Browse files

Improve diagnostic on PCRE JIT mmap failure

Print a more informative message that indicates that this is
likely a permission issue, and also indicate that pcre.jit=0
can be used to work around it.

Also automatically disable the JIT, so that this message is
only shown once.

See bug #78630.
  • Loading branch information
nikic committed Oct 4, 2019
1 parent 1ce8c80 commit 1d6e9da7433bddca5c591ef5b2eeef9c410543bb
Showing with 6 additions and 0 deletions.
  1. +6 −0 ext/pcre/php_pcre.c
@@ -783,6 +783,12 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
if (!pcre2_pattern_info(re, PCRE2_INFO_JITSIZE, &jit_size) && jit_size > 0) {
poptions |= PREG_JIT;
}
} else if (rc == PCRE2_ERROR_NOMEMORY) {
php_error_docref(NULL, E_WARNING,
"Allocation of JIT memory failed, PCRE JIT will be disabled. "
"This is likely caused by security restrictions. "
"Either grant PHP permission to allocate executable memory, or set pcre.jit=0");
PCRE_G(jit) = 0;
} else {
pcre2_get_error_message(rc, error, sizeof(error));
php_error_docref(NULL, E_WARNING, "JIT compilation failed: %s", error);

0 comments on commit 1d6e9da

Please sign in to comment.
You can’t perform that action at this time.