What does "zend_mm_heap corrupted" mean

Viewed 179078

All of the sudden I've been having problems with my application that I've never had before. I decided to check the Apache's error log, and I found an error message saying "zend_mm_heap corrupted". What does this mean.

OS: Fedora Core 8 Apache: 2.2.9 PHP: 5.2.6

41 Answers

After much trial and error, I found that if I increase the output_buffering value in the php.ini file, this error goes away

If you are on Linux box, try this on the command line

export USE_ZEND_ALLOC=0

As per the bug tracker, set opcache.fast_shutdown=0. Fast shutdown uses the Zend memory manager to clean up its mess, this disables that.

Look for any module that uses buffering, and selectively disable it.

I'm running PHP 5.3.5 on CentOS 4.8, and after doing this I found eaccelerator needed an upgrade.

"zend_mm_heap corrupted" means problems with memory management. Can be caused by any PHP module. In my case installing APC worked out. In theory other packages like eAccelerator, XDebug etc. may help too. Or, if you have that kind of modules installed, try switching them off.

A lot of people are mentioning disabling XDebug to solve the issue. This obviously isn't viable in a lot of instances, as it's enabled for a reason - to debug your code.

I had the same issue, and noticed that if I stopped listening for XDebug connections in my IDE (PhpStorm 2019.1 EAP), the error stopped occurring.

The actual fix, for me, was removing any existing breakpoints.

A possibility for this being a valid fix is that PhpStorm is sometimes not that good at removing breakpoints that no longer reference valid lines of code after files have been changed externally (e.g. by git)

Edit: Found the corresponding bug report in the xdebug issue tracker: https://bugs.xdebug.org/view.php?id=1647

The issue with zend_mm_heap corrupted boggeld me for about a couple of hours. Firstly I disabled and removed memcached, tried some of the settings mentioned in this question's answers and after testing this seemed to be an issue with OPcache settings. I disabled OPcache and the problem went away. After that I re-enabled OPcache and for me the

core notice: child pid exit signal Segmentation fault

and

zend_mm_heap corrupted

are apparently resolved with changes to

/etc/php.d/10-opcache.ini

I included the settings I changed here; opcache.revalidate_freq=2 remains commmented out, I did not change that value.

opcache.enable=1
opcache.enable_cli=0
opcache.fast_shutdown=0
opcache.memory_consumption=1024
opcache.interned_strings_buffer=128
opcache.max_accelerated_files=60000

This option has already been written above, but I want to walk you through the steps how I reproduced this error.

Briefly. It helped me:

opcache.fast_shutdown = 0

My legacy configuration:

  1. CentOS release 6.9 (Final)
  2. PHP 5.6.24 (fpm-fcgi) with Zend OPcache v7.0.6-dev
  3. Bitrix CMS

Step by step:

  1. Run phpinfo()
  2. Find "OPcache" in output. It should be enabled. If not, then this solution will definitely not help you.
  3. Execute opcache_reset() in any place (thanks to bug report, comment [2015-05-15 09:23 UTC] nax_hh at hotmail dot com). Load multiple pages on your site. If OPcache is to blame, then in the nginx logs will appear line with text

104: Connection reset by peer

and in the php-fpm logs

zend_mm_heap corrupted

and on the next line

fpm_children_bury()

  1. Set opcache.fast_shutdown=0 (for me in /etc/php.d/opcache.ini file)
  2. Restart php-fpm (e.g. service php-fpm restart)
  3. Load some pages of your site again. Execute opcache_reset() and load some pages again. Now there should be no mistakes.

By the way. In the output of phpinfo(), you can find the statistics of OPcache and then optimize the parameters (for example, increase the memory limit). Good instructions for tuning opcache (russian language, but you can use a translator)

I experienced this issue in local development while using docker & php's built in dev server with Craft CMS.

My solution was to use Redis for Craft's sessions.

PHP 7.4

In my case; Apache does not started becauase of zend_mm_heap corrupted problem. Apache itself had no problem; because disabling php;

sudo emacs /etc/apache2/mods-enabled/php7.2.load

comment the line

# LoadModule php7_module /usr/lib/apache2/modules/libphp7.2.so

get apache to work properly. So i know problem was in php. I had more than one php installed i.e. php 7.2 and php 8. My site was using php 7.2 (So i had to use php7.2). Individually single php had no problem at all. But installing other (later) version somehow changes some thing that causes this zend_mm_heap corrupted problem. Purging and installing doesn't solved.

Solution was I was dsabling the wrong php version. I was disabling php8.0 whereas I had installed php8.1.

sudo a2dismod php8.0

Changing php8.0 to php8.1 solved everything

sudo a2dismod php8.1
Related