Bug #66881 [Opn->Fbk]: Out of memory when spl_autoload_register() called after ini_set()
Edit report at https://bugs.php.net/bug.php?id=66881&edit=1
ID: 66881
Updated by: nikic@php.net
Reported by: keith at bronstrup dot com
Summary: Out of memory when spl_autoload_register() called
after ini_set()
-Status: Open
+Status: Feedback
Type: Bug
Package: Reproducible crash
Operating System: Linux
PHP Version: 5.4.26
Block user comment: N
Private report: N
New Comment:
I can't reproduce this issue, and it sounds rather unlikely in the first place. If you still
experience this problem in a recent PHP version (PHP >= 5.6), please reopen the bug report.
Previous Comments:
------------------------------------------------------------------------
[2014-03-11 05:05:02] keith at bronstrup dot com
The supplied test code would actually fail on line 6. The 15 extra lines in my example (error on
line 21) are comments, which I removed before posting. Sorry about that.
------------------------------------------------------------------------
[2014-03-11 04:05:19] keith at bronstrup dot com
This behavior seems to also occur when error_reporting() is called before spl_autoload_register().
------------------------------------------------------------------------
[2014-03-11 03:59:08] keith at bronstrup dot com
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-di!
r=/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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66881&edit=1
Thread (5 messages)