Skip to content

Commit 1d6e9da

Browse files
committed
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.
1 parent 1ce8c80 commit 1d6e9da

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ext/pcre/php_pcre.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,12 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
783783
if (!pcre2_pattern_info(re, PCRE2_INFO_JITSIZE, &jit_size) && jit_size > 0) {
784784
poptions |= PREG_JIT;
785785
}
786+
} else if (rc == PCRE2_ERROR_NOMEMORY) {
787+
php_error_docref(NULL, E_WARNING,
788+
"Allocation of JIT memory failed, PCRE JIT will be disabled. "
789+
"This is likely caused by security restrictions. "
790+
"Either grant PHP permission to allocate executable memory, or set pcre.jit=0");
791+
PCRE_G(jit) = 0;
786792
} else {
787793
pcre2_get_error_message(rc, error, sizeof(error));
788794
php_error_docref(NULL, E_WARNING, "JIT compilation failed: %s", error);

0 commit comments

Comments
 (0)