|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81101 PCRE2 10.37 shows unexpected result
Submitted: 2021-06-03 14:19 UTC Modified: 2021-06-19 19:31 UTC
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (100.0%)
From: rlanting at move4mobile dot com Assigned: ab (profile)
Status: Closed Package: PCRE related
PHP Version: 8.0.6 OS: MacOS 11.3.1
Private report: No CVE-ID: None
 [2021-06-03 14:19 UTC] rlanting at move4mobile dot com
This week I updated php and pcre through homebrew. As a result I got pcre2 10.37. For that specific version preg_match doesn't work as expected. Reverting only pcre2 to 10.36 makes it work again.

The regex originates from

Homebrew issue:

Test script:

$matches = [];
$test = ' App\Domain\Repository\MetaData\SomethingRepositoryInterface';

preg_match('/\\\\([^\\\\]+)\s*$/', $test, $matches);

$test2 = ' App\Domain\Exception\NotFoundException';

preg_match('/\\\\([^\\\\]+)\s*$/', $test2, $matches);

Expected result:
array(2) {
  string(29) "\SomethingRepositoryInterface"
  string(28) "SomethingRepositoryInterface"
array(2) {
  string(18) "\NotFoundException"
  string(17) "NotFoundException"

Actual result:
array(0) {
array(2) {
  string(18) "\NotFoundException"
  string(17) "NotFoundException"


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-03 14:25 UTC] rlanting at move4mobile dot com
As an additional note, I tried reproducing with the pcre2test binary but couldn't get it to break with that.
 [2021-06-03 14:40 UTC] Danack at basereality dot com
As a simple thing to check, please could you set ini_set("pcre.jit", "0"); to see if that makes any difference on the broken version.
 [2021-06-03 14:41 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: ab
 [2021-06-03 14:41 UTC]
Can reproduce on master, where bundled PCRE is 10.37. It does not reproduce with -d pcre.jit=0, so this is clearly a PCRE JIT bug.

Assigning to @ab as he did the upgrade of the bundled version, but in the end this will need an upstream report and fix.
 [2021-06-04 06:59 UTC] rlanting at move4mobile dot com
PCRE bug report:
 [2021-06-04 12:06 UTC]
-Status: Verified +Status: Analyzed
 [2021-06-04 12:06 UTC]
Thanks for filing the upstream report. The offending commit is

It'd be still better if it were fixable on our side, as 10.37 is already out. I'll see for that.

 [2021-06-04 13:51 UTC] rlanting at move4mobile dot com
Upstream has fixed it in r1315:
 [2021-06-06 23:56 UTC]
I pushed a potential fix to master. I'd suggest to observe for a week or two and backport into 7.4+ if it goes ok.

 [2021-06-19 19:31 UTC]
-Status: Analyzed +Status: Closed
 [2021-06-19 19:31 UTC]
The mitigation patch backported to 7.4 and 8.0.

 [2022-07-18 21:34 UTC] shuklahimanshu512 at gmail dot com
The following pull request has been associated:

Patch Name: Git ready
On GitHub:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 03:01:31 2024 UTC