Bug #70868 [Opn->Csd]: PCRE JIT and pattern reuse segfault

From: Date: Fri, 06 Nov 2015 03:39:31 +0000
Subject: Bug #70868 [Opn->Csd]: PCRE JIT and pattern reuse segfault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197071@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: laruence@php.net Reported by: marcio@php.net Summary: PCRE JIT and pattern reuse segfault -Status: Open +Status: Closed Type: Bug Package: PCRE related PHP Version: 7.0.0RC6 Block user comment: N Private report: N New Comment: Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=27aef97f658dd956db0cf4145963d9d57d31dacc Log: Fixed bug #70868 (PCRE JIT and pattern reuse segfault) Previous Comments: ------------------------------------------------------------------------ [2015-11-06 01:32:40] marcio@php.net phpt test pull requested at https://github.com/php/php-src/pull/1621 ------------------------------------------------------------------------ [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

« previous php.bugs (#197071) next »