php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77260 preg_match_all(): JIT compilation failed: no more memory
Submitted: 2018-12-07 13:42 UTC Modified: 2019-10-04 14:10 UTC
Votes:153
Avg. Score:4.3 ± 0.8
Reproduced:143 of 146 (97.9%)
Same Version:100 (69.9%)
Same OS:96 (67.1%)
From: ettore at themecraft dot studio Assigned: nikic (profile)
Status: Closed Package: PCRE related
PHP Version: 7.3.0 OS: macOS 10.13.6
Private report: No CVE-ID: None
 [2018-12-07 13:42 UTC] ettore at themecraft dot studio
Description:
------------
I'm experiencing an intermittent issue with WordPress 5.0 running on PHP 7.3.0:

[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/functions.php on line 4885
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/functions.php on line 4781
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/functions.php on line 4885
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/l10n.php on line 1202
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/functions.php on line 4885
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/l10n.php on line 1235
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/class-requests.php on line 563
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/Requests/IRI.php on line 329
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/Requests/IRI.php on line 764
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_replace_callback(): JIT compilation failed: no more memory in wp-includes/Requests/IRI.php on line 422
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/Requests/IRI.php on line 425
[07-Dec-2018 13:37:11 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/Requests/IDNAEncoder.php on line 115
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/class-requests.php on line 652
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/class-requests.php on line 654
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/class-requests.php on line 667
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/class-requests.php on line 752
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/functions.php on line 4885
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace_callback(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 4382
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace_callback(): JIT compilation failed: no more memory in wp-includes/kses.php on line 724
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/option.php on line 900
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/general-template.php on line 705
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match_all(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 229
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_split(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 235
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 289
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 295
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/admin-header.php on line 75
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/option.php on line 1021
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/admin-header.php on line 163
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/menu-header.php on line 14
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/menu-header.php on line 15
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/menu-header.php on line 16
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/menu-header.php on line 17
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/menu-header.php on line 108
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 4674
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 4549
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/functions.php on line 111
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/functions.php on line 112
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/functions.php on line 113
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/functions.php on line 114
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/functions.php on line 115
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-includes/functions.php on line 116
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/functions.php on line 122
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_split(): JIT compilation failed: no more memory in wp-admin/includes/class-core-upgrader.php on line 239
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_replace(): JIT compilation failed: no more memory in wp-admin/update-core.php on line 220
[07-Dec-2018 13:37:12 UTC] PHP Warning:  preg_match(): JIT compilation failed: no more memory in wp-includes/formatting.php on line 4768


I am not able to reproduce the issue by singling out any specific preg_* function and parameters. The ony way I can reproduce the issue is with a clean install of WordPress 5.0.




Below there's php -i:

PHP Version => 7.3.0

System => Darwin iMac.local 17.7.0 Darwin Kernel Version 17.7.0: Wed Oct 10 23:06:14 PDT 2018; root:xnu-4570.71.13~1/RELEASE_X86_64 x86_64
Build Date => Dec  7 2018 12:22:53
Configure Command =>  './configure'  '--prefix=/Users/ettore/.php/7.3.0' '--with-config-file-path=/Users/ettore/.php' '--enable-cli' '--with-apxs2' '--disable-cgi' '--without-pear' '--enable-pcntl' '--enable-bcmath' '--enable-mbstring' '--enable-intl' '--enable-soap' '--enable-zip' '--with-libzip' '--with-zlib-dir=/usr' '--with-pdo-mysql' '--with-mysqli' '--with-curl' '--with-openssl=/usr/local/opt/openssl' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-libedit' '--with-xsl' '--with-libxml-dir=/usr/local/opt/libxml2' '--with-xmlrpc' '--with-gmp'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /Users/ettore/.php
Loaded Configuration File => /Users/ettore/.php/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20180731
PHP Extension => 20180731
Zend Extension => 320180731
Zend Extension Build => API320180731,NTS
PHP Extension Build => API20180731,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies


php.ini:
[PHP]
short_open_tag = Off
max_execution_time = 600
memory_limit = 512M
post_max_size = 256M
upload_max_filesize = 128M
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = On
request_order = "GP"
zend.assertions = 1
assert.exception = On
pcre.jit = On

[CLI Server]
cli_server.color = On

[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = On

[Xdebug]
;zend_extension = xdebug.so
xdebug.remote_enable = 1
xdebug.profiler_output_dir=/Users/ettore/Workspace/xdebug_profiling
xdebug.profiler_output_name=%u.%R
xdebug.profiler_enable_trigger=1
;xdebug.remote_log = /Users/ettore/Workspace/xdebug/xdebug.log
xdebug.var_display_max_data = 2048


NOTICE that the issue appears with both XDebug 2.7.0beta1 disabled and enabled.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-07 14:03 UTC] cmb@php.net
> Warning: preg_match_all(): JIT compilation failed: no more
> memory

This warning is trigged, because pcre2_jit_compile() returns
PCRE2_ERROR_NOMEMORY, which hints at a too small JIT stack.
 [2018-12-07 14:05 UTC] nikic@php.net
@cmb: Wouldn't that generate a JIT_STACKLIMIT rather than NOMEMORY error?
 [2018-12-07 17:15 UTC] cmb@php.net
@nikic Indeed, you're right.  This is not about the JIT stack,
but rather about the machine stack.  From the docs[1]:

| There is a limit to the size of pattern that JIT supports,
| imposed by the size of machine stack that it uses.

I found an SO question which may be related[2], in which case this
wouldn't be Wordpress specific.

[1] <https://www.pcre.org/current/doc/html/pcre2jit.html#SEC3>
[2] <https://stackoverflow.com/questions/52718706/php-pcre2-no-more-memory>
 [2018-12-08 09:24 UTC] sbarex at gmail dot com
I have same problem with php 7.3 installed via homebrew on mojave (both with bottle package or compiled from source).
If i use xdebug extension no page can be viewed (php-fpm kill the child process).
If use php from command line without xdebug php works but kill when I use pcre functions.
Also if I use psysh (REPL cli) php crash on every command.
In all cases the code "crashed on child side of fork pre-exec" on php_pcre2_jit_compile or php_pcre2_jit_match.

This is a crash report:

Process:               php [24544]
Path:                  /usr/local/Cellar/php/7.3.0/bin/php
Identifier:            php
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        ??? [24543]
Responsible:           php [24544]
User ID:               501

Date/Time:             2018-12-07 21:58:04.395 +0100
OS Version:            Mac OS X 10.14.2 (18C54)
Report Version:        12
Bridge OS Version:     3.2 (16P2542)

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000106928478
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [24544]

VM Regions Near 0x106928478:
    MALLOC_LARGE           0000000106828000-0000000106918000 [  960K] rw-/rwx SM=COW  
--> 
    VM_ALLOCATE            0000000106a00000-0000000107000000 [ 6144K] rw-/rwx SM=COW  

Application Specific Information:
crashed on child side of fork pre-exec

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   php                           	0x0000000102d4a4fe jit_compile + 42782
1   php                           	0x0000000102d3fd82 php_pcre2_jit_compile + 78
2   php                           	0x0000000102d8371b pcre_get_compiled_regex_cache + 1808
3   php                           	0x0000000102d8725b php_do_pcre_match + 203
4   php                           	0x00000001030f4116 ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER + 81
5   php                           	0x00000001030abd32 execute_ex + 98
6   php                           	0x00000001030abeae zend_execute + 318
7   php                           	0x0000000103070cfa zend_execute_scripts + 277
8   php                           	0x000000010301c58f php_execute_script + 639
9   php                           	0x000000010311c78b do_cli + 3857
10  php                           	0x000000010311b70c main + 1108
11  libdyld.dylib                 	0x00007fff7a21ced9 start + 1
 [2018-12-08 13:16 UTC] cmb@php.net
This *might* be another manifestation of bug #77193.  Please try
again with the fix[1] applied, or with a recent Git snapshot.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=ef1269d5c158afaf052e3d79591462e0f5372b1a>
 [2018-12-10 15:17 UTC] ettore at themecraft dot studio
Just tried with the latest commit on master (ad06f1aa2e). The error persists. If you need more details on my system configuration, just ask.

I did not experience this issue on production servers running Debian and PHP 7.3 from sury.

Note and off-topic: I've run into some compilation troubles while building from git with XSL enabled. It fails to compile on my system after hundreds of warnings. I just disabled it since I did not even know why I left it enabled in the first place. I'm using libxml 2.9.7 from homebrew.
 [2019-01-14 14:26 UTC] sbarex at gmail dot com
Not solved in php 7.3.1.
With this bug php is unusable. Even phpinfo cause a crash.
 [2019-01-24 09:35 UTC] d dot kreuer at danielkreuer dot com
Disabling the JIT compilation of PCRE is a workaround for this error. Tweeted by Marcus Battle: https://twitter.com/themarcusbattle/status/1072929621790855174
 [2019-01-24 10:21 UTC] nikic@php.net
Is anyone who is *not* on macOS experiencing this issue?
 [2019-02-04 09:38 UTC] marek dot svent at gmail dot com
I do – on Linux, but in crosscompiled environment. Haven't investigated yet more deeply.
 [2019-02-18 06:42 UTC] gerwinkrist at gmail dot com
On RHEL 7 we also have the problem, so it's not Mac specific. To be more specific we have it with 7.3 and Laravel.
 [2019-03-01 20:22 UTC] veraxcloud at gmail dot com
Here same problem with centos 7 and PHP 7.3.2 FPM.  First noticed on "Wordpresss W3 Total Cache" with the minifying process but also on other Projects seen. Disabling JIT compilation solved the problem also here. :)
 [2019-03-13 07:25 UTC] ilya at ilya dot pp dot ua
openSUSE Tumbleweed PHP 7.3.1 (In 7.3.2 patch for pcre.jit=0)
https://bugzilla.opensuse.org/show_bug.cgi?id=1124446

https://bugs.php.net/bug.php?id=77260
In PHP 7.3 using pcre2 and using by default JIT compilation (pcre.jit=1)
This leads to errors like:
Warning in ./libraries/classes/Config.php#201 preg_match(): JIT compilation failed: no more memory
For everything that uses preg_*()
I get this error on the login screen in phpMyAdmin 4.8.5, while I have 128MB RAM allocated for PHP!
Until this is dealt with in the upstream. I suggest set in php.ini pcre.jit=0
 [2019-05-13 07:44 UTC] mathieu dot ferment at prestashop dot com
Same issue when trying to run composer install on prestashop project (ithub.com/PrestaShop/PrestaShop/). php7.3 installed using homebrew

$ /usr/local/Cellar/php/7.3.5/bin/php composer.phar install
PHP Fatal error:  Uncaught ErrorException: preg_match_all(): JIT compilation failed: no more memory in phar:///Users/mFerment/www/prestashop/PrestaShop/composer.phar/vendor/symfony/console/Formatter/OutputFormatter.php:137

Worked around it by switching pcre.jit from 1 to 0.

PHP 7.3.5 (cli) (built: May  2 2019 12:42:24) ( NTS )
 [2019-06-19 05:36 UTC] erik at coretech dot se
This is probably not a bug but selinux blocking php from fiddling with executable stacks. This is probably a bad idea to enable on a hardened system and should be disabled within php.ini (pcre.jit=0)

To check if this generated a selinux warning use: aureport --avc
1. 06/19/2019 07:17:05 httpd system_u:system_r:httpd_t:s0 9 process execmem system_u:system_r:httpd_t:s0 denied 240395

If you still want to enable this, use:
setsebool -P httpd_execmem on

/Erik Lundin
 [2019-06-20 18:45 UTC] self at danpock dot me
@erik, what do you think the issue on Mac OS is then? AFAIK, Mac doesn't have SE Linux - though I'm unsure if it has something similar?
 [2019-07-14 10:07 UTC] mc12345678 at mc12345678 dot com
Working with Zen Cart, most recently the development version 1.5.7 available from https://github.com/zencart/zencart.  With the following server characteristics:
Server OS: Linux 4.14.117-grsec-grsec+ 
Server Date: 07/14/2019 02:03:38  
Server Up Time: 02:03:38 up 6 days, 18:52, 0 users, load average: 3.28, 3.85, 3.73
HTTP Server: Apache
PHP Version: 7.3.6 (Zend: 3.3.6)
PHP File Uploads: On
Upload Max Size: 2M
PHP Memory Limit: 512M
POST Max Size: 8M
Database Engine: MySQL 5.7.25-log
Database Date: 07/14/2019 02:03:38
Database Data Size: 458 kB
Database Index Size: 559 kB
MySQL Slow Query Log Status: On
MySQL Slow Query Log File: /dh/mysql/logs/mysql.leberman.slow
MySQL Mode: NO_ENGINE_SUBSTITUTION 

Software is ableto use a few instances of a preg_xxxx function, but then appears to run out of memory.  Increasing the memory limit has had no positive impact on the generation of warning messages. So far other than potentially substituting another filter type method (strstr, strops, etc...), the only successful way of preventing the warnings has been some php.ini related disablement of jcre.jit 0 either directly in the php.ini (affecting all code that executes that php.ini file) or from within using '@ini_set("pcre.jit", "0");'. A suggestion has been made to disable using .htaccess; however, this particular software product does not use a base .htaccess file.  The recommended coding was: 'php_value pcre.jit 0'.

Someone using the same software on a Macintosh was able to operate without any such additional action.  Discussion is provided here: https://github.com/zencart/zencart/pull/2537
 [2019-07-31 19:05 UTC] funky99 at gmx dot de
I came accross this problem as we switched an internal apllication from PHP 7.0.32 to 7.3.6 (both FPM) on our Gentoo based Managed webserver.

I excpected no or at least a slight increase in performance, but the opposite happened.
I.e. on a rather small page, runtime changed from 20ms (7.0) to 40ms (7.3). On bigger pages it's worse.
I checked the PHP errors and saw a couple of "preg*: JIT compilation failed: no more memory" errors, directly after the restart of the FPM processes.

We are using an rather old framework which works a lot with preg* functions for the template engine. If I set pcre.jit = 0 performance in PHP 7.0 gets also down to 40ms.
As erik at coretech dot se mentioned it might have to do with SELinux. But it's the same machine and same Linux kernel, so if the problem is because of SELinux or other security feeatures, shouldn't it not work on PHP 7.0 as well? (I'm not a Linux expert)

So I it may be a bug which should have been fixed for PHP 7.3 (I has the same same problems for PHP 7.1. and 7.2).
 [2019-09-17 20:38 UTC] robertwildling at gmail dot com
I work with TYPO3. In the course of updating older versions, this same exact error happened to me, too. Turning of pcre_jit is no option, because TYPO3 won't work then. So I moved down to php 7.2.22. The interesting thing is that the error logger of TYPO3 catches the same preg* errors, too, but the system does not crash.

I am also on macos HighSierra with a brew installation.
 [2019-09-17 21:28 UTC] nikic@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: nikic
 [2019-09-17 21:28 UTC] nikic@php.net
I'm afraid that this bug report has ended up as a meta-issues for all kinds of mmap failures in pcre jit, which may not all have the same root cause.

I think the original problem and what is affecting macOS users is the fact that PCRE2 has introduced use of MAP_JIT to be compatible with macOS 10.14. However, MAP_JIT is badly broken on macOS 10.13.

We need to backport the following diff from PCRE2 10.33 to the 7.3 branch:

diff --git a/ext/pcre/pcre2lib/sljit/sljitExecAllocator.c b/ext/pcre/pcre2lib/sljit/sljitExecAllocator.c
index 7c18578618cf..3b37a9751f81 100644
--- a/ext/pcre/pcre2lib/sljit/sljitExecAllocator.c
+++ b/ext/pcre/pcre2lib/sljit/sljitExecAllocator.c
@@ -94,6 +94,46 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
 
 #else
 
+#ifdef __APPLE__
+/* Configures TARGET_OS_OSX when appropriate */
+#include <TargetConditionals.h>
+
+#if TARGET_OS_OSX && defined(MAP_JIT)
+#include <sys/utsname.h>
+#endif /* TARGET_OS_OSX && MAP_JIT */
+
+#ifdef MAP_JIT
+
+static SLJIT_INLINE int get_map_jit_flag()
+{
+#if TARGET_OS_OSX
+	/* On macOS systems, returns MAP_JIT if it is defined _and_ we're running on a version
+	   of macOS where it's OK to have more than one JIT block. On non-macOS systems, returns
+	   MAP_JIT if it is defined. */
+	static int map_jit_flag = -1;
+
+	/* The following code is thread safe because multiple initialization
+	   sets map_jit_flag to the same value and the code has no side-effects.
+	   Changing the kernel version witout system restart is (very) unlikely. */
+	if (map_jit_flag == -1) {
+		struct utsname name;
+
+		uname(&name);
+
+		/* Kernel version for 10.14.0 (Mojave) */
+		map_jit_flag = (atoi(name.release) >= 18) ? MAP_JIT : 0;
+	}
+
+	return map_jit_flag;
+#else /* !TARGET_OS_OSX */
+	return MAP_JIT;
+#endif /* TARGET_OS_OSX */
+}
+
+#endif /* MAP_JIT */
+
+#endif /* __APPLE__ */
+
 static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
 {
 	void *retval;
@@ -103,17 +143,17 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
 	int flags = MAP_PRIVATE | MAP_ANON;
 
 #ifdef MAP_JIT
-	flags |= MAP_JIT;
+	flags |= get_map_jit_flag();
 #endif
 
 	retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, flags, -1, 0);
-#else
+#else /* !MAP_ANON */
 	if (dev_zero < 0) {
 		if (open_dev_zero())
 			return NULL;
 	}
 	retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, dev_zero, 0);
-#endif
+#endif /* MAP_ANON */
 
 	return (retval != MAP_FAILED) ? retval : NULL;
 }
 [2019-09-17 21:41 UTC] nikic@php.net
Relevant discussion: https://bugs.exim.org/show_bug.cgi?id=2334

Unfortunately there's still the issue with MAP_JIT and fork() being incompatible, leading to the issue mentioned by sbarex at gmail dot com. It doesn't look like progress on avoiding that issue has been made.
 [2019-09-18 08:50 UTC] nikic@php.net
-Status: Assigned +Status: Feedback
 [2019-09-18 08:50 UTC] nikic@php.net
I've applied https://github.com/php/php-src/commit/03efeda53852842fe1a40240fce6793bba617959 and https://github.com/php/php-src/commit/e11ed028706dbedc51ba71736de21db15890a1c0, which should both fix the "no more memory" error on 10.13 and the segfaults on 10.14.

If someone could confirm that the issue is resolved, that would be great.
 [2019-09-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2019-10-03 18:57 UTC] ilya at ilya dot pp dot ua
openSUSE Tumbleweed php 7.3.10 pcre2 10.33 (patch from nickic aplayed)
If pcre.jit=1 phpMyadmin login page show errors
mod_fcgid: stderr: PHP Warning:  preg_replace_callback(): JIT compilation failed: no more memory
https://bugzilla.suse.com/show_bug.cgi?id=1124446

Please explain what feedback do you expect and what else do you need to provide?
 [2019-10-03 19:20 UTC] requinix@php.net
-Status: No Feedback +Status: Feedback
 [2019-10-03 19:20 UTC] requinix@php.net
@nikic's two referenced commits are only for PHP 7.4.0rc3. @ilya, can you test with that version?
 [2019-10-03 19:30 UTC] nikic@php.net
-Status: Feedback +Status: Closed
 [2019-10-03 19:30 UTC] nikic@php.net
@ilya: Can you please open a new bug for the opensuse issue, so that this one can stay macos specific? The macos issues are related to Apple's rather buggy MAP_JIT implementation, which does not exist on Linux.

It would be helpful to also provide an strace of the process, which should also show the mmap failure.
 [2019-10-04 14:10 UTC] nikic@php.net
For reference, further discussion is happening on #78630.
 [2019-10-16 09:45 UTC] ettore at themecraft dot studio
PHP 7.4.0-rc3 fixes the issue on macOS 10.13.6.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 18:02:35 2024 UTC