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-01-24 10:21 UTC
Votes:131
Avg. Score:4.3 ± 0.8
Reproduced:121 of 124 (97.6%)
Same Version:81 (66.9%)
Same OS:82 (67.8%)
From: ettore at themecraft dot studio Assigned:
Status: Open Package: PCRE related
PHP Version: 7.3.0 OS: macOS 10.13.6
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 05:01:26 2019 UTC