|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51784 Segmentation fault! causes apache to crash.
Submitted: 2010-05-10 13:52 UTC Modified: 2010-05-10 14:19 UTC
From: notdefix at hotmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: Irrelevant OS:
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: notdefix at hotmail dot com
New email:
PHP Version: OS:


 [2010-05-10 13:52 UTC] notdefix at hotmail dot com
Copied from:
PHP version: Unknown

preg_replace (and str_replace too) will crash php if you use ' ' (space) as replace value for a large number of matches.

following Apache Error-Log message:

[Mon May 10 09:23:58 2010] [notice] child pid 39251 exit signal Illegal instruction (4)

where pid 39251 was the PHP-thread processing that request.

Test script:
Copied from:
PHP version: Unknown

For example:

$string = preg_replace('/( )+/', ' ', $string);
$string = str_replace(' ', ' ', $string);

will crash if $string contains many seperate matches of ' ' producing 

$string = preg_replace('/( )+/', '', $string);
$string = str_replace(' ', '', $string);


$string = preg_replace('/( )+/', '_', $string);
$string = str_replace(' ', '_', $string);

do all work fine.

This seems to be a bug in the underlying PCRE implementation, and not in PHP itself.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-10 14:19 UTC]
-Status: Open +Status: Bogus
 [2010-05-10 14:19 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Jan 28 19:03:44 2022 UTC