Bug #76270 [NEW]: regex-related functions crash instead of triggering memory-limit error
| From: | teo8976 at gmail dot com | Date: | Wed, 25 Apr 2018 17:02:24 +0000 |
| Subject: | Bug #76270 [NEW]: regex-related functions crash instead of triggering memory-limit error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-214895@lists.php.net to get a copy of this message | ||
From: teo8976 at gmail dot com
Operating system:
PHP version: 5.6.35
Package: Reproducible crash
Bug Type: Bug
Bug description:regex-related functions crash instead of triggering memory-limit error
Description:
------------
When memory usage exceeds the memory limit during the execution of
regular-expression related functions (such as preg_replace,
preg_replace_callback, etc), instead of triggering the error that you
would normally get when exceeding the memory limit, php execution is
simply abruptly aborted (it crashes?) and produces empty output,
regardless of whether you have display_errors set to true and/or have
set an error handler.
Test script:
---------------
// PSEUDOCODE
ini_set('memory_limit', $some_low_limit);
$s="a huge string (not big enough to exceed the memory limit itself";
preg_replace_callback(
"/some_complex_regex_with_a_lot_of_matches/",
function($match) { return whatever; },
$s
);
Expected result:
----------------
Should trigger the memory-limit error in the same way as when you exceed
the memory limit without regular expressions.
With display_errors set to true, you should see an error message
Actual result:
--------------
crashes and produces a f*****g blank page, even if display_errors is set
to true, and you have no way of debugging what the f**k is going on.
Took me ages to narrow it down to regular expressions.
--
Edit bug report at https://bugs.php.net/bug.php?id=76270&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76270&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76270&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76270&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76270&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76270&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76270&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76270&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76270&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76270&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76270&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76270&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76270&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76270&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76270&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76270&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76270&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76270&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76270&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76270&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76270&r=mysqlcfg