You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PCRE regular expressions with JIT enabled gives different result #11956
Hi,
The fallowing regex preg_match( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches ); in PHP >= 8.1 gives different results if PCRE JIT is enabled or not. ( Note, I tried to simplify the regex to isolate the problem, that's why it doesn't make much sense ).
I had this problem with PHP 7.3 where I found a bug report that sated the problem was the PCRE library and not PHP.
I've recently migrated the code the regex is used in to PHP 8.2 and found there's still an issue, so I tested it on 3v4l.org and it seems to be fixed in PHP <= 8.0 and broken in 8.1.
I noted the issue on the PCRE2 github but the author doesn't think the issue is with any changes in the PCRE library: PCRE2Project/pcre2#261 (comment)
It points to 5d42900 and 79755ca.
This is indeed a pcre2lib problem in 2.37. Given that the pcre2lib maintainer says it does not reproduce in their testings on 2.42, I'd say the solution here is updating PHP's bundled pcre2lib to the latest version.
As a temporary workaround you can configure & build with the flag to use your system's pcre2lib, and hope that version is high enough to not contain the bug.
Activity
ndossche commentedon Aug 13, 2023
I can reproduce this locally. I'll run a bisect. This will also reveal if the problem is in PHP or in PCRE.
ndossche commentedon Aug 13, 2023
Bisect finished.
It points to 5d42900 and 79755ca.
This is indeed a pcre2lib problem in 2.37. Given that the pcre2lib maintainer says it does not reproduce in their testings on 2.42, I'd say the solution here is updating PHP's bundled pcre2lib to the latest version.
As a temporary workaround you can configure & build with the flag to use your system's pcre2lib, and hope that version is high enough to not contain the bug.
hormus commentedon Aug 21, 2023
Or for compatibility
antman3351 commentedon Aug 21, 2023
Your regex doesn't cause the issue where there is a difference between JIT and non JIT.
Fix phpGH-11956: PCRE regular expressions with JIT enabled gives diff…
Fix GH-11956: PCRE regular expressions with JIT enabled gives differe…
Merge branch 'PHP-8.1' into PHP-8.2
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3'