com php-src: Improve diagnostic on PCRE JIT mmap failure: ext/pcre/php_pcre.c

From: Date: Fri, 04 Oct 2019 14:03:38 +0000
Subject: com php-src: Improve diagnostic on PCRE JIT mmap failure: ext/pcre/php_pcre.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108727@lists.php.net to get a copy of this message
Commit: 1d6e9da7433bddca5c591ef5b2eeef9c410543bb Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 4 Oct 2019 16:01:10 +0200 Parents: 1ce8c805e27c96093365aad36aa4fadc8c73824c Branches: PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1d6e9da7433bddca5c591ef5b2eeef9c410543bb Log: 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. Bugs: https://bugs.php.net/78630 Changed paths: M ext/pcre/php_pcre.c Diff: diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index a131ecd884e..59217349b50 100644 --- a/ext/pcre/php_pcre.c +++ b/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);

« previous php.cvs (#108727) next »