|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-03-11 04:05 UTC] keith at bronstrup dot com
[2014-03-11 05:05 UTC] keith at bronstrup dot com
[2016-05-06 14:10 UTC] nikic@php.net
-Status: Open
+Status: Feedback
[2016-05-06 14:10 UTC] nikic@php.net
[2016-05-15 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 21:00:01 2025 UTC |
Description: ------------ When using ini_set() to override configuration settings and using spl_autoload_register() with an anonymous function, PHP attempts to allocate nearly 3GB or RAM, causing a fatal error with ini_set() is called before spl_autoload_register(). Works as expected if spl_autoload_register() is called first. I initially discovered this condition in PHP 5.4.21 and it appears to have persisted after upgrading to 5.4.26 (built with WHM 11.42.0 EasyApache). I have provided two test scripts, the first of which works as expected (outputs 'Success!'), while the second results in a fatal error resulting from the script attempting to allocate nearly 3GB of RAM. The only difference between these scripts (save for comments) is the order of the ini_set() and spl_autoload_register() functions. My php.ini is using recommended defaults (from php.ini comments) and my configure line is as follows: './configure' '--enable-bcmath' '--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-intl' '--enable-libxml' '--enable-mbstring' '--enable-pdo=shared' '--enable-sockets' '--enable-wddx' '--enable-zip' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-bz2' '--with-curl=/opt/curlssl/' '--with-curlwrappers' '--with-enchant=/usr' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-icu-dir=/usr' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libexpat-dir=/usr' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mm=/opt/mm/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-png-dir=/usr' '--with-pspell' '--with-tidy=/opt/tidy/' '--with-xpm-dir=/usr' '--with-xsl=/opt/xslt/' '--with-zlib' '--with-zlib-dir=/usr' Test script: --------------- <?php // This fails attempting to allocate nearly 3GM of RAM ini_set('display_errors', 1); spl_autoload_register(function ($class) { // Doesn't matter what's here, so I've left it empty. }); die('Success!'); ?> ----- <?php // This outputs 'Success!' spl_autoload_register(function ($class) { // Doesn't matter what's here, so I've left it empty. }); ini_set('display_errors', 1); die('Success!'); ?> Expected result: ---------------- As in the first test script: Success! Actual result: -------------- Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 3050313117 bytes) in /home/bronscon/public_html/keywordcms-oo/failure.php on line 21