|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70562 preg_replace segmentation fault - string length
Submitted: 2015-09-23 14:02 UTC Modified: 2016-07-31 04:22 UTC
Avg. Score:4.4 ± 0.5
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:2 (40.0%)
From: malcolm at memiah dot co dot uk Assigned: cmb (profile)
Status: No Feedback Package: PCRE related
PHP Version: 5.6.13 OS: CentOS Linux release 7.0.1406 (C
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: malcolm at memiah dot co dot uk
New email:
PHP Version: OS:


 [2015-09-23 14:02 UTC] malcolm at memiah dot co dot uk
Running preg_replace on a string length over 8435 causes a segmentation fault. Running default php.ini config. 

Please see attached script to reproduce. This happens on the CLI as well as through an apache handler. 

Test script:

$pattern   = '/(.)*/';
$limit     = 9000;
$string    = 'a';

for ( $i = 0; $i <= $limit; $i++ ) {

    $string .= 'a';
    echo strlen($string) . "\n";
    echo mb_strlen($string);

    preg_replace($pattern, '', $string);

echo 'done';



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-21 12:34 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2016-07-21 12:34 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read for *NIX and for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
 [2016-07-31 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 03:01:29 2024 UTC