|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75539 Recursive call errors are not reported by preg_last_error()
Submitted: 2017-11-20 00:47 UTC Modified: -
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: grzegorz129 at gmail dot com Assigned:
Status: Closed Package: PCRE related
PHP Version: 7.2.0RC6 OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: grzegorz129 at gmail dot com
New email:
PHP Version: OS:


 [2017-11-20 00:47 UTC] grzegorz129 at gmail dot com
I found a strange (yet consistent across since 5.6) regarding infinite loop patterns error reporting. preg_match() correctly identifies broken patterns and triggers E_WARN, however preg_last_error() returns PREG_NO_ERROR instead of expected PREG_RECURSION_LIMIT_ERROR.

It may be related to

Test script:
// Test at

var_dump(preg_match('/((?1)?z)/', ''));
var_dump(preg_last_error() === \PREG_NO_ERROR);

Expected result:
- preg_match() returning false
- preg_last_error() returning value of PREG_RECURSION_LIMIT_ERROR

Actual result:
- preg_match() returns false
- preg_last_error() returns value of PREG_NO_ERROR


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-21 11:45 UTC] andrew dot nester dot dev at gmail dot com
Thanks for reporting this issue! I've just added PR fixing this
 [2017-11-21 19:28 UTC]
Automatic comment on behalf of
Log: Fixed #75539 and #74183 - preg_last_error not returning error code after error
 [2017-11-21 19:28 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 24 01:03:38 2021 UTC