Page 1 of 2

PHP Fatal error: Allowed memory size after 5.4 to 5.6 upgr

Posted: Mon Aug 21, 2017 8:56 pm
by genna
Hi,
I am testing PHP upgrade from 5.4 to 5.6 for Nagios XI.
I have Centos 7 and installed XI from xi-5.4.8.tar.gz and got a working XI instance. I have not done any additional config steps - so this is fresh, "out of the box" installation.

Then I have unistalled php 5.4 and installed 5.6

Code: Select all

yum install centos-release-scl
yum remove php-common-5.4.16-42.el7.x86_64 php-mcrypt-5.4.16-4.el7.x86_64 php-cli-5.4.16-42.el7.x86_64 php-pgsql-5.4.16-42.el7.x86_64  php-process-5.4.16-42.el7.x86_64 php-gd-5.4.16-42.el7.x86_64 php-xml-5.4.16-42.el7.x86_64 php-ldap-5.4.16-42.el7.x86_64 php-mysql-5.4.16-42.el7.x86_64 php-mssql-5.4.16-4.el7.x86_64 php-snmp-5.4.16-42.el7.x86_64 php-pdo-5.4.16-42.el7.x86_64 php-pecl-ssh2-0.12-1.el7.x86_64 php-5.4.16-42.el7.x86_64 php-mbstring-5.4.16-42.el7.x86_64

yum install rh-php56-php-common rh-php56-php-mcrypt rh-php56-php-cli rh-php56-php-pgsql rh-php56-php-process rh-php56-php-gd rh-php56-php-xml rh-php56-php-ldap rh-php56-php-mysql  rh-php56-php-snmp rh-php56-php-pdo  rh-php56-php rh-php56-php-mbstring

mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php54.off
mv /etc/httpd/conf.modules.d/10-php.conf /etc/httpd/conf.modules.d/10-php54.off
cp /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php56-php.conf /etc/httpd/conf.d/
cp /opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-rh-php56-php.conf /etc/httpd/conf.modules.d/
cp /opt/rh/httpd24/root/etc/httpd/modules/librh-php56-php5.so /etc/httpd/modules/
Finally fixed SouthGuardian and set PHP memory limit to 512M

After restarting httpd service I tried to open Nagios XI page and got HTTP 500 and this error httpd errpr_log:

[:error] [pid 10010] [client 192.168.56.1:63467] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4294902125 bytes) in /usr/local/nagiosxi/html/includes/dbl.inc.php on line 2, referer: http://192.168.56.110/nagiosxi/install.php

So why suddenly it is trying to allocate 4GB of memory and how do I fix it ?

Thanks
Genna

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Tue Aug 22, 2017 9:45 am
by mcapra
This is probably not supported, but I'll defer to the techs on that.

A good place to start might be to share the output of this command executed from the CLI of your Nagios XI machine:

Code: Select all

php -r 'phpinfo();'
And if you wanted to troubleshoot this on your own, you could diff the output against the output of the same command run on a stock Nagios XI OVA.

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Tue Aug 22, 2017 11:22 am
by scottwilkerson
One thing I know for sure you would need to do is edit /etc/php.d/sourceguardian.ini to read

Code: Select all

extension=ixed.5.6.lin
and then restart httpd

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Wed Aug 23, 2017 12:00 am
by genna
Hi
I have rerun the same steps on RHEL7 ( simply because this is a targeted platform for the final installation). The results is the same. As suggested I have captured phpinfo before and after PHP upgrade. The major difference that stands out is the use of mysqlnd driver in PHP 5.6 and MariaDB client API in PHP 5.4 .

Code: Select all

# PHP 5.4
mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => 5.5.56-MariaDB
MYSQL_MODULE_TYPE => external
MYSQL_SOCKET => /var/lib/mysql/mysql.sock
MYSQL_INCLUDE => -I/usr/include/mysql
MYSQL_LIBS => -L/usr/lib64/mysql -lmysqlclient 

# PHP 5.4
mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
Unfortunately since I'm not an expert in either MySQL or PHP I have no idea if there are any implications because of that change. /etc/php.d/sourceguardian.ini file is not loaded as additional configuration so I simply added it extension to php.ini file.
Any additional help will be highly appreciated
Thanks
Genna

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Wed Aug 23, 2017 9:10 am
by scottwilkerson
genna wrote: /etc/php.d/sourceguardian.ini file is not loaded as additional configuration so I simply added it extension to php.ini file.
For clarity you added it as follows correct, not 5.4 as it was?

Code: Select all

extension=ixed.5.6.lin

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Wed Aug 23, 2017 7:37 pm
by genna
For clarity you added it as follows correct, not 5.4 as it was?
Yes. I have pointed to 5.6 version.
I also did a bit of a search for PHP error requesting 4GB memory allocation and come across number of posts similar to this one: https://stackoverflow.com/questions/308 ... emory-size
They all seem to relate to a MySQL field type. But unfortunately their recommendations all push well beyond my knowledge of PHP and MySQL.

I'm running a POC for using Nagios XI in our company, and this issue is a showstopper for us. When I installed XI with PHP 5.4 vulnerability scanner came up with hundreds of vulnerabilities. Running it on 5.4 is out of question for us ( regardless of what we might think of the correctness of that scan) .

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Thu Aug 24, 2017 8:37 am
by mcapra
My first thought it it's some issue with how the rh-php56-php-mysql rpm was built. I never encountered this particular longtext leak when using Remi's repos or the Webtatic repos for similar 5.6 setups. I'm not sure how your org feels about 3rd party repos, though.

I recall handing some notes off to a co-worker regarding upgrading XI to 5.6 using the Webtatic repos, but I don't have them anymore. I imagine if you compared the libmysql used in Webtatic's repos to the official CentOS repos, the cause might become obvious.

I assume PHP is still configured to run under mod_php and not something like FastCGI or PHP-FPM?

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Thu Aug 24, 2017 11:15 am
by scottwilkerson
Our development team has determined the cause of this problem and it is do to an encryption bug.

They are working on a new release that will resolve the issue shortly

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Thu Sep 07, 2017 11:06 pm
by genna
Hi Scott
Do you have an approximate time frame for the fix. I was told to put my implementation on hold until this is resolved.
Alternatively, if this is a recently introduced issue, is there an older release which would work with PHP 5.6
Thanks
Genna

Re: PHP Fatal error: Allowed memory size after 5.4 to 5.6 u

Posted: Fri Sep 08, 2017 8:25 am
by scottwilkerson
genna wrote:Hi Scott
Do you have an approximate time frame for the fix. I was told to put my implementation on hold until this is resolved.
Alternatively, if this is a recently introduced issue, is there an older release which would work with PHP 5.6
Thanks
Genna
This was released yesterday. The fix is included in 5.4.9