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

From: Date: Fri, 04 Oct 2019 13:42:41 +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-223080@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:         ilya at ilya dot pp dot ua
 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:

Does something have to change if I rebuild pcre2 without option "--enable-jit-sealloc" and
rebuild php with this?
I am now waiting for the building to complete.


Previous Comments:
------------------------------------------------------------------------
[2019-10-04 13:28:28] bugreports at gmail dot com

this bugreport here was the reason that i opened https://bugs.php.net/bug.php?id=78631 last night

things like https://bugs.exim.org/show_bug.cgi?id=2453 as
well as the summarized changelog from fedora pcre2-10.33 for me are questioning if cherrypicking
alone scales

------------------------------------------------------------------------
[2019-10-04 13:23:57] bugreports at gmail dot com

than that fallback simply happen in pcre itself and for some reason not in pcre2

mod_security uses pcre_jit too, had an issue some years ago and was forced to rebuild it without to
prevent some specific crashes and it shares the MemoryDenyWriteExecute=yes

> then people may not get good performance, but at least code will work

not sure if that's the best thing to do, i would have preferred a one time startup warning
because in that case while trying out "MemoryDenyWriteExecute=yes" i would have reverted
it which will happen now :-)

------------------------------------------------------------------------
[2019-10-04 13:22:47] nikic@php.net

Additional issue I ran into while looking into JIT fallback: https://bugs.exim.org/show_bug.cgi?id=2453

------------------------------------------------------------------------
[2019-10-04 12:55:47] nikic@php.net

Strace log has:

mmap(NULL, 65536, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 EPERM
(Operation not permitted)

So clearly the mmap does fail and JIT won't work. As the preg call still succeeds, it does
looks like an automatic fallback to non-JIT happens.

So we should implement this fallback for PHP 7.3 as well ... then people may not get good
performance, but at least code will work.

------------------------------------------------------------------------
[2019-10-04 12:51:48] nikic@php.net

strace log by bugreports at gmail dot com deleted moved to https://gist.github.com/nikic/9cedba68cf25343ae9a4a53d4b52eb03
and deleted from here. With these additional notes:

> php 7.2.24-dev snashot from last night with bundeled pcre (--with-pcre-jit --with-pcre-regex)
> 
> systemd-run -p MemoryDenyWriteExecute=yes strace -o /downloads/strace-preg_match.log php -r
> "preg_match('/^[\w.-]+@[\w.-]+\.\w{2,}$/','ilya@ilya.pp.ua');"

Please avoid pasting huge output as comments.

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


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 (#223080) next »