Bug #53099 [NEW]: ereg_replace uses 100% cpu and takes >10 minutes to execute.
From:
Operating system: Ubuntu 9.10
PHP version: 5.3.3
Package: Regexps related
Bug Type: Bug
Bug description:ereg_replace uses 100% cpu and takes >10 minutes to execute.
Description:
------------
I have written a mb_trim function in php which uses ereg_replace to trim
strings in the same manner as trim() does.
The function is available at http://php.net/manual/en/ref.mbstring.php
Under the heading 'phpnet at rcpt dot at - 19-Aug-2010 02:46'
Using the string excerpt from our production environment
(http://pastebin.com/wmyjPmBV), ereg_replace appears to enter some sort of
recursive loop, in my environment it takes 100% cpu for 20 minutes before
finally returning the correct result.
When the section which reads: array( "\s","\t","\n","\r",
"\0", "\x0B" )
...is changed to array( "\s", "\0", "\x0B" ) then ereg_replace returns
promptly with the correct result.
Test script:
---------------
The function is available at http://php.net/manual/en/ref.mbstring.php
Under the heading 'phpnet at rcpt dot at - 19-Aug-2010 02:46'
It is also available here:
http://pastebin.com/CCpaVXay
The (serialized) string that causes the problem is:
s:488:"<I>Swans </I> Wisely moving from the middle of
July to the middle of autumn, this indoor, forward-thinking avant-rock
weekend brings together all sorts of fiercely experimental noisemakers,
from psychedelic-folk to death metal, with a hotly anticipated headline set
from Michael Gira's New York noise inspiration Swans. Don't expect many
stony-faced rock nerds, though. The organisers serve tea and cake
throughout and they're promising other fun and games this year.";
It is also available for download here:
http://pastebin.com/wmyjPmBV
You can execute the script with the following syntax:
<?php mb_trim( $string );
Expected result:
----------------
PHP will return the correct result quickly.
Actual result:
--------------
PHP will run at 100% CPU for 20 minutes.
--
Edit bug report at http://bugs.php.net/bug.php?id=53099&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53099&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53099&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53099&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53099&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53099&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53099&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53099&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53099&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53099&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53099&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53099&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53099&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53099&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53099&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53099&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53099&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53099&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53099&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53099&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53099&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53099&r=mysqlcfg
Thread (6 messages)
- phpnet at rcpt dot at