Req #75133 [NEW]: When preg_replace fails, please write to error_log

From: Date: Mon, 28 Aug 2017 18:33:50 +0000
Subject: Req #75133 [NEW]: When preg_replace fails, please write to error_log
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210858@lists.php.net to get a copy of this message
From: php at richardneill dot org Operating system: Linux PHP version: 7.0.22 Package: PCRE related Bug Type: Feature/Change Request Bug description:When preg_replace fails, please write to error_log Description: ------------ It's very rare that preg_replace() fails (i.e. returns null). But when it happens, it's really unexpected, and therefore particularly hard to debug. All the normal tools show nothing helpful. Can I request that whenever preg_replace (and preg_replace_callback) return a null, that preg_last_error() is printed to the error_log, at least at E_NOTICE? Test script: --------------- It may be helpful to give an example. This code generates a PREG_JIT_STACKLIMIT_ERROR, with only ~ 5kB of data in $contents $contents = preg_replace_callback ('/^\s*\%LOOP_(\d+|(ITR)(\d))\s*\n((((?!%LOOP_ITR).)*\n)*)\s*\%END_LOOP\s*\n/mU', 'repeat_n_times', $contents); Expected result: ---------------- It shouldn't be possible to write a 1-line regexp which hits resource-limits on one screenful of text. But if we do, it would be really helpful if there were some error message in the log files. Actual result: -------------- PHP Notice: preg_replace experienced a PREG_JIT_STACKLIMIT_ERROR in (filename) on (line_number) -- Edit bug report at https://bugs.php.net/bug.php?id=75133&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75133&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75133&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75133&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75133&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75133&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75133&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75133&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75133&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75133&r=support Expected behavior: https://bugs.php.net/fix.php?id=75133&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75133&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75133&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75133&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75133&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75133&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75133&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75133&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75133&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75133&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75133&r=mysqlcfg

« previous php.bugs (#210858) next »