Bug #78630 [Com]: PHP 7.3 preg_match(): JIT compilation failed: no more memory (need pcre.jit=0)

From: Date: Fri, 04 Oct 2019 11:58:18 +0000
Subject: Bug #78630 [Com]: PHP 7.3 preg_match(): JIT compilation failed: no more memory (need pcre.jit=0)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223068@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78630&edit=1

 ID:                 78630
 Comment by:         bugreports at gmail dot com
 Reported by:        ilya at ilya dot pp dot ua
 Summary:            PHP 7.3 preg_match(): JIT compilation failed: no
                     more memory (need pcre.jit=0)
 Status:             Open
 Type:               Bug
 Package:            PCRE related
 Operating System:   openSUSE Tumbleweed
 PHP Version:        7.3.10
 Block user comment: N
 Private report:     N

 New Comment:

> You can't use the JIT compiler if your /tmp directory 
> (wherever it may be mounted) is noexec

can't be entirely true

/dev/sdd2 on /tmp type ext4 (rw,noexec,relatime,lazytime,commit=30)

pcre.jit = 1

no problem from PHP 7.0.x up to 7.2.24-dev over years combined with
"MemoryDenyWriteExecute=yes" in the systemd unit for at least a year


Previous Comments:
------------------------------------------------------------------------
[2019-10-04 11:54:05] build+suse at de-korte dot org

You can't use the JIT compiler if your /tmp directory (wherever it may be mounted) is noexec.
You basically want your PHP process to dynamically generate executable code, but disallow executing
it. That doesn't fly. This is probably documented somewhere, but I don't have the time to
find where.

In your case, if you choose to mount your /tmp noexec, your need to set 'pcre.jit = 0',
but this is by no means a default openSUSE Tumbleweed setup.

------------------------------------------------------------------------
[2019-10-04 11:12:55] ilya at ilya dot pp dot ua

Thank you!
sudo strace -o strace-preg_match.log php -r
"preg_match('/^[\w.-]+@[\w.-]+\.\w{2,}$/','ilya@ilya.pp.ua');"
https://bugzilla.suse.com/attachment.cgi?id=820544

------------------------------------------------------------------------
[2019-10-04 11:05:39] ilya at ilya dot pp dot ua

Of course with noexec!

sudo cat /etc/fstab
/swap none swap defaults 0 0
UUID=b996e925-3e85-4970-ac69-9c8250989666 / ext4 noatime,acl,user_xattr 1 1
UUID=a8050355-3331-4c81-8cc9-104a8b1632b6 /ILYA ext4 noatime 1 2
tmpfs /tmp tmpfs nodev,nosuid,noexec,size=2G 0 0
tmpfs /var/tmp tmpfs nodev,nosuid,noexec,size=2G 0 0
tmpfs /var/cache/zypp tmpfs nodev,nosuid,noexec,mode=0755,size=2G 0 0
tmpfs /run tmpfs nodev,nosuid,noexec,mode=0755,size=32m 0 0
tmpfs /run/lock tmpfs nodev,nosuid,noexec,mode=0755,size=8m 0 0
tmpfs /root/.cache tmpfs nodev,nosuid,noexec,mode=0700,size=2G 0 0
tmpfs /home/ilya/.cache tmpfs nodev,nosuid,noexec,mode=0700,uid=1000,size=2G 0 0
tmpfs /var/lib/wwwrun/.cache tmpfs nodev,nosuid,noexec,mode=0700,uid=30,size=2G 0 0

------------------------------------------------------------------------
[2019-10-04 11:02:45] bugreports at gmail dot com

> But I don’t know how to execute it in such a way as to connect 
> strace to it, because there is no process before the code execution

that's the much easier case than attach a running process

strace php -r
"preg_match('/^[\w.-]+@[\w.-]+\.\w{2,}$/','ilya@ilya.pp.ua');"

--------------------

usage: strace [-ACdffhikqqrtttTvVwxxyyzZ] [-I n] [-b execve] [-e expr]...
              [-a column] [-o file] [-s strsize] [-X format] [-P path]...
              [-p pid]... [--seccomp-bpf]
              { -p pid | [-D] [-E var=val]... [-u username] PROG [ARGS] }
   or: strace -c[dfwzZ] [-I n] [-b execve] [-e expr]... [-O overhead]
              [-S sortby] [-P path]... [-p pid]... [--seccomp-bpf]
              { -p pid | [-D] [-E var=val]... [-u username] PROG [ARGS] }

------------------------------------------------------------------------
[2019-10-04 10:59:16] ilya at ilya dot pp dot ua

I found a shorter and more reliable way to show the problem right from the console.
php -r "preg_match('/^[\w.-]+@[\w.-]+\.\w{2,}$/','ilya@ilya.pp.ua');"
PHP Warning:  preg_match(): JIT compilation failed: no more memory in Command line code on line 1
This code always gives an error no matter how much I run it.

But I don’t know how to execute it in such a way as to connect strace to it, because there is
no process before the code execution ..., you can probably try sleep(30) &&.

And now I'm even more confused ...
php -r "preg_match('/^[\w.-]+@[\w.-]+\.\w{2,}$/','ilya@ilya.pp.ua');"
Always performed with an error!
php -r
"sleep(30)&&preg_match('/^[\w.-]+@[\w.-]+\.\w{2,}$/','ilya@ilya.pp.ua');"
It always runs without error, so I put it strace You will not be interested.
Is there a way to connect strace without knowing the process number in advance?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=78630


--
Edit this bug report at https://bugs.php.net/bug.php?id=78630&edit=1


Thread (34 messages)

« previous php.bugs (#223068) next »