php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81647 regex times out when pcre.jit is enabled
Submitted: 2021-11-21 21:15 UTC Modified: 2021-11-22 13:38 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jack dot johansson at yahoo dot com Assigned: cmb (profile)
Status: Not a bug Package: PCRE related
PHP Version: 8.1.0RC6 OS: Windows 11 22000.194
Private report: No CVE-ID: None
 [2021-11-21 21:15 UTC] 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
	)
);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-22 09:34 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-11-22 09:34 UTC] 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-22 09:58 UTC] 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 10:13 UTC] cmb@php.net
-Status: Feedback +Status: Verified
 [2021-11-22 10:13 UTC] 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 13:38 UTC] cmb@php.net
-Status: Verified +Status: Not a bug
 [2021-11-22 13:38 UTC] cmb@php.net
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>
 [2021-11-23 08:11 UTC] jack dot johansson at yahoo dot com
Thank you @cmb. I've posted an issue on their repository, alongside the links to this post and Laravel's. Here's a link for future reference:

https://github.com/PhilipHazel/pcre2/issues/57
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jan 26 09:03:33 2022 UTC