php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43952 Apache crash while using preg_replace_callback
Submitted: 2008-01-28 13:43 UTC Modified: 2008-01-28 22:57 UTC
From: Maks dot V dot Sidorenko at gmail dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.2.5 OS: Win XP x64 SP2
Private report: No CVE-ID: None
 [2008-01-28 13:43 UTC] Maks dot V dot Sidorenko at gmail dot com
Description:
------------
This change of PHP Manual example results in Apache crash. 
Apache/1.3.27, PHP 5.2.5. PHP4 - the same.

Reproduce code:
---------------
<?php
$arResults = array();

$text = "April fools day is 04/01/2002\n";
$text .= "Last christmas was 12/24/2001\n";
function next_year($matches) 
{
	global $arResults;
	$arResults[] = $matches;
	return $matches[2];
}

echo preg_replace_callback(
	"/(April|Last) ([\S]*)/",
	"next_year",
	$text);

echo '<pre>'; print_r($arResults); echo '</pre>';
?> 

Expected result:
----------------
fools day is 04/01/2002 christmas was 12/24/2001

Array
(
    [0] => Array
        (
            [0] => April fools
            [1] => April
            [2] => fools
        )

    [1] => Array
        (
            [0] => Last christmas
            [1] => Last
            [2] => christmas
        )

)


Actual result:
--------------
Apache crash

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-28 22:57 UTC] tony2001@php.net
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 http://www.php.net/support.php 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.

http://php.net/pcre

pcre.recursion_limit integer 

PCRE's recursion limit. Please note that if you set this value to a high number you may consume all the available process stack and eventually crash PHP (due to reaching the stack size limit imposed by the Operating System).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 15:01:30 2024 UTC