Bug #81647 [Ver->Nab]: regex times out when pcre.jit is enabled
| From: | cmb@php.net | Date: | Mon, 22 Nov 2021 13:38:55 +0000 |
| Subject: | Bug #81647 [Ver->Nab]: regex times out when pcre.jit is enabled | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237909@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81647&edit=1
ID: 81647
Updated by: cmb@php.net
Reported by: jack dot johansson at yahoo dot com
Summary: regex times out when pcre.jit is enabled
-Status: Verified
+Status: Not a bug
Type: Bug
Package: PCRE related
Operating System: Windows 11 22000.194
PHP Version: 8.1.0RC6
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is a stack overflow due to too deep nesting[1], because of
the nature of that regex. It is not related to a recent patch to
our bundled libpcre2[2]. Consider to report it upstream[3], but
I'm not sure whether that can be fixed (by falling back to non JIT
mode).
[1] <https://gist.github.com/cmb69/7ce76968c3917c8234811cb52ec845e8>
[2] <https://github.com/php/php-src/pull/7573>
[3] <https://github.com/PhilipHazel/pcre2/issues>
Previous Comments:
------------------------------------------------------------------------
[2021-11-22 10:13:49] cmb@php.net
Thanks for the swift reply! I can confirm the crash when running
mod_php, but not on CLI. I'll have a look.
------------------------------------------------------------------------
[2021-11-22 09:58:12] jack dot johansson at yahoo dot com
I'm using the same version, 10.37 2021-05-26. It's bundled into this release on
windows.php.net:
https://windows.php.net/downloads/qa/php-8.1.0RC6-Win32-vs16-x64.zip
Would you please take a look at the issue on the github link that I posted? There was someone with a
similar issue too.
------------------------------------------------------------------------
[2021-11-22 09:34:55] cmb@php.net
I can't reproduce this with the bundled libpcre2[1]. Which
libpcre2 version do you use?
[1] <https://3v4l.org/WBdZJ>
------------------------------------------------------------------------
[2021-11-21 21:15:24] jack dot johansson at yahoo dot com
Description:
------------
I've recently installed PHP 8.1.0RC6 and Laravel 9 to test some new features. After requests
resulted in a connection reset, I've submitted this bug on the Laravel repository:
https://github.com/laravel/framework/issues/39716
Tracing the issue ended up to a regex, which crashed Apache when the pcre.jit was set to 1 in the
ini file ( or commented out ).
I'm using the latest version of Apache ( 2.4.51 ).
Turning off the pcre.jit solves the issue. I'm not sure if this is a PHP issue, but I'm
submitting a bug just in case.
Test script:
---------------
<?php
var_dump(
preg_match(
'(([\\r\\n]{1,1000})|([^\\S\\r\\n]{1,1000})|(\\\\)|(\')|(")|(\\#)|(\\$)|(([^(\\s\\\\\'"\\#\\$)]|\\(|\\)){1,1000}))A',
'Laravel',
$matches
)
);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81647&edit=1