Bug #70868 [Opn]: PCRE JIT and pattern reuse segfault
| From: | marcio@php.net | Date: | Fri, 06 Nov 2015 01:32:41 +0000 |
| Subject: | Bug #70868 [Opn]: PCRE JIT and pattern reuse segfault | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197069@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70868&edit=1
ID: 70868
Updated by: marcio@php.net
Reported by: marcio@php.net
Summary: PCRE JIT and pattern reuse segfault
Status: Open
Type: Bug
Package: PCRE related
PHP Version: 7.0.0RC6
Block user comment: N
Private report: N
New Comment:
phpt test pull requested at https://github.com/php/php-src/pull/1621
Previous Comments:
------------------------------------------------------------------------
[2015-11-06 01:19:10] marcio@php.net
Description:
------------
It seems there is a conflict when reusing patters while PCRE JIT is enabled, causing a segfault.
It's an obscure bug that I couldn't find a solution and had to disable PCRE JIT to get
things working.
These are the (strange) requirements to reproduce the segfault:
1) code MUST be namespaced;
2) code must be run on a non debug build;
3) a preg_replace call must happen while iterating over a regex iterator or derivated;
4) both the preg_replace and the regex iterator instance involved must have the exact same regexp
patter;
The test script may be easier to understand. Requirement 1 is really a mystery to me :/
Test script:
---------------
<?php
namespace X;
$iterator =
new \RegexIterator(
new \ArrayIterator(['A.phpt', 'B.phpt', 'C.phpt']),
'/\.phpt$/'
)
;
foreach ($iterator as $foo) {
var_dump($foo);
preg_replace('/\.phpt$/', '', '');
}
echo "Done", PHP_EOL;
?>
Expected result:
----------------
No segfault.
Actual result:
--------------
Segfault.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70868&edit=1