Edit report at http://bugs.php.net/bug.php?id=40479&edit=1
ID: 40479 Comment by: sht dot alien at gmx dot net Reported by: rrossi at maggioli dot it Summary: zend_mm_heap corrupted Status: No Feedback Type: Bug Package: Reproducible crash Operating System: Suse Linux 9.0 PHP Version: 5.2.1 Block user comment: N New Comment: I had it coming when I started my unittests. But it happened out of nowhere ^^ Wehen I set USE_ZEND_ALLOC=0 it didn't go away, but instead I got a debug backtrace (as seen below). But I came up with a solution: ZendDebugger was the root of all evil. I'll check out if there's a newer version available... FAILURES! Tests: 284, Assertions: 1911, Errors: 4, Incomplete: 10, Skipped: 9. *** glibc detected *** /usr/local/zend/bin/php: free(): invalid pointer: 0x00000000035b5a8f *** ======= Backtrace: ========= /lib/libc.so.6(+0x775b6)[0x7f56f13105b6] /lib/libc.so.6(cfree+0x73)[0x7f56f1316e53] /usr/local/zend/bin/php(zend_hash_destroy+0x7b)[0x656b7b] /usr/local/zend/bin/php(destroy_zend_class+0x55)[0x641845] /usr/local/zend/bin/php[0x656822] /usr/local/zend/bin/php(zend_hash_reverse_apply+0x59)[0x656929] /usr/local/zend/bin/php[0x63e486] /usr/local/zend/bin/php[0x64a8b2] /usr/local/zend/bin/php(php_request_shutdown+0x1ae)[0x5f9cce] /usr/local/zend/bin/php[0x6d2be4] /lib/libc.so.6(__libc_start_main+0xfd)[0x7f56f12b7c4d] /usr/local/zend/bin/php[0x45ffaa] ======= Memory map: ======== 00400000-009d8000 r-xp 00000000 08:01 12588460 /usr/local/zend/bin/php 00ad8000-00b5f000 rwxp 005d8000 08:01 12588460 /usr/local/zend/bin/php 00b5f000-00b7f000 rwxp 00000000 00:00 0 02b4e000-04999000 rwxp 00000000 00:00 0 [heap] 7f56e0000000-7f56e0021000 rwxp 00000000 00:00 0 7f56e0021000-7f56e4000000 ---p 00000000 00:00 0 7f56e5309000-7f56e530e000 r-xp 00000000 08:01 15842 /lib/libnss_dns-2.11.1.so 7f56e530e000-7f56e550d000 ---p 00005000 08:01 15842 /lib/libnss_dns-2.11.1.so 7f56e550d000-7f56e550e000 r-xp 00004000 08:01 15842 /lib/libnss_dns-2.11.1.so 7f56e550e000-7f56e550f000 rwxp 00005000 08:01 15842 /lib/libnss_dns-2.11.1.so 7f56e550f000-7f56e5511000 r-xp 00000000 08:01 41397 /lib/libnss_mdns4_minimal.so.2 7f56e5511000-7f56e5710000 ---p 00002000 08:01 41397 /lib/libnss_mdns4_minimal.so.2 7f56e5710000-7f56e5711000 r-xp 00001000 08:01 41397 /lib/libnss_mdns4_minimal.so.2 7f56e5711000-7f56e5712000 rwxp 00002000 08:01 41397 /lib/libnss_mdns4_minimal.so.2 7f56e5712000-7f56e5714000 rwxp 00000000 00:00 0 7f56e5794000-7f56e58f7000 r-xp 00000000 08:01 12582939 /usr/local/zend/lib/debugger/php-5.3.x/ZendDebugger.so 7f56e58f7000-7f56e59f7000 ---p 00163000 08:01 12582939 /usr/local/zend/lib/debugger/php-5.3.x/ZendDebugger.so 7f56e59f7000-7f56e5a21000 rwxp 00163000 08:01 12582939 /usr/local/zend/lib/debugger/php-5.3.x/ZendDebugger.so 7f56e5a21000-7f56e5a27000 rwxp 00000000 00:00 0 7f56e5a27000-7f56e5a69000 r-xp 00000000 08:01 12583569 /usr/local/zend/lib/optimizerplus/php-5.3.x/ZendOptimizerPlus.so 7f56e5a69000-7f56e5b69000 ---p 00042000 08:01 12583569 /usr/local/zend/lib/optimizerplus/php-5.3.x/ZendOptimizerPlus.so 7f56e5b69000-7f56e5b6b000 rwxp 00042000 08:01 12583569 /usr/local/zend/lib/optimizerplus/php-5.3.x/ZendOptimizerPlus.so 7f56e5b6b000-7f56e5b76000 rwxp 00000000 00:00 0 7f56e5b76000-7f56e5cd3000 r-xp 00000000 08:01 12583576 /usr/local/zend/lib/utils/php-5.3.x/ZendUtils.so 7f56e5cd3000-7f56e5dd3000 ---p 0015d000 08:01 12583576 /usr/local/zend/lib/utils/php-5.3.x/ZendUtils.so 7f56e5dd3000-7f56e5ddb000 rwxp 0015d000 08:01 12583576 /usr/local/zend/lib/utils/php-5.3.x/ZendUtils.so 7f56e5ddb000-7f56e5dde000 rwxp 00000000 00:00 0 7f56e5dde000-7f56e5f50000 r-xp 00000000 08:01 12583528 /usr/local/zend/lib/datacache/php-5.3.x/ZendDataCache.so 7f56e5f50000-7f56e604f000 ---p 00172000 08:01 12583528 /usr/local/zend/lib/datacache/php-5.3.x/ZendDataCache.so 7f56e604f000-7f56e6058000 rwxp 00171000 08:01 12583528 /usr/local/zend/lib/datacache/php-5.3.x/ZendDataCache.so 7f56e6058000-7f56e605b000 rwxp 00000000 00:00 0 7f56e605b000-7f56e605e000 r-xp 00000000 08:01 537567 /usr/lib/gconv/UTF-16.so 7f56e605e000-7f56e625d000 ---p 00003000 08:01 537567 /usr/lib/gconv/UTF-16.so 7f56e625d000-7f56e625e000 r-xp 00002000 08:01 537567 /usr/lib/gconv/UTF-16.so 7f56e625e000-7f56e625f000 rwxp 00003000 08:01 537567 /usr/lib/gconv/UTF-16.so 7f56e625f000-7f56e6269000 r-xp 00000000 08:01 15845 /lib/libnss_nis-2.11.1.so 7f56e6269000-7f56e6468000 ---p 0000a000 08:01 15845 /lib/libnss_nis-2.11.1.so 7f56e6468000-7f56e6469000 r-xp 00009000 08:01 15845 /lib/libnss_nis-2.11.1.so 7f56e6469000-7f56e646a000 rwxp 0000a000 08:01 15845 /lib/libnss_nis-2.11.1.so 7f56e646a000-7f56e6472000 r-xp 00000000 08:01 15841 /lib/libnss_compat-2.11.1.so 7f56e6472000-7f56e6671000 ---p 00008000 08:01 15841 /lib/libnss_compat-2.11.1.so 7f56e6671000-7f56e6672000 r-xp 00007000 08:01 15841 /lib/libnss_compat-2.11.1.so 7f56e6672000-7f56e6673000 rwxp 00008000 08:01 15841 /lib/libnss_compat-2.11.1.so 7f56e6673000-7f56e6b9c000 r-xp 00000000 08:01 36700 /usr/lib/libociicus.so 7f56e6b9c000-7f56e6c9b000 ---p 00529000 08:01 36700 /usr/lib/libociicus.so 7f56e6c9b000-7f56e6c9c000 rwxp 00528000 08:01 36700 /usr/lib/libociicus.so 7f56e6c9c000-7f56e6cbf000 rwxp 00000000 00:00 0 7f56e6cbf000-7f56e6ccb000 r-xp 00000000 08:01 15843 /lib/libnss_files-2.11.1.so 7f56e6ccb000-7f56e6eca000 ---p 0000c000 08:01 15843 /lib/libnss_files-2.11.1.so 7f56e6eca000-7f56e6ecb000 r-xp 0000b000 08:01 15843 /lib/libnss_files-2.11.1.so 7f56e6ecb000-7f56e6ecc000 rwxp 0000c000 08:01 15843 /lib/libnss_files-2.11.1.so 7f56e6ecc000-7f56e6ede000 r-xp 00000000 08:01 12583643 /usr/local/zend/lib/php_extensions/zip.so 7f56e6ede000-7f56e6fde000 ---p 00012000 08:01 12583643 /usr/local/zend/lib/php_extensions/zip.so 7f56e6fde000-7f56e6fe0000 rwxp 00012000 08:01 12583643 /usr/local/zend/lib/php_extensions/zip.so 7f56e6fe0000-7f56e702a000 r-xp 00000000 08:01 12583581 /usr/local/zend/lib/php_extensions/xsl.so 7f56e702a000-7f56e712a000 ---p 0004a000 08:01 12583581 /usr/local/zend/lib/php_extensions/xsl.so 7f56e712a000-7f56e712c000 rwxp 0004a000 08:01 12583581 /usr/local/zend/lib/php_extensions/xsl.so 7f56e712c000-7f56e7264000 r-xp 00000000 08:01 12583656 /usr/local/zend/lib/php_extensions/xmlwriter.so 7f56e7264000-7f56e7364000 ---p 00138000 08:01 12583656 /usr/local/zend/lib/php_extensions/xmlwriter.so 7f56e7364000-7f56e7372000 rwxp 00138000 08:01 12583656 /usr/local/zend/lib/php_extensions/xmlwriter.so Previous Comments: ------------------------------------------------------------------------ [2010-05-26 12:33:20] contact at peterfrankjohnson dot co dot uk Problem: ---------- I had this problem when importing an xml file with over 4200 items which all needed inserting as individual records into a database. I was using doctrine to insert the records and was creating a new object for each record, but each time I ran the script it crashed with this error after inserting exactly 3,579 records each time. Solution: ----------- I then decided to try cleaning up the code I had written by using unset() to destroy the object after it had been finished with. All of the records were then inserted without any problems. I would advise anyone receiving this error to check that variables and objects are being destroyed with unset, because if you think about it the error is telling you that the zend memory managers heap is corrupted. ------------------------------------------------------------------------ [2010-04-30 10:41:31] php at foxteck dot org Just for history/logging purposes, I got this same error on PHP 5.2.6 + MySQL 5.1 + Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.7a DAV/2 + SuPHP on RHEL 4 today. It was related to mysql_* calls, phpinfo() worked fine, no errors. Any mysql_* call crashed. Code: --------------- [erom...@roll tmp]$ cat /tmp/test.php <?php echo "Hola"; $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); Reproducing --------------- [erom...@roll tmp]$ /usr/local/php5-cgi/bin/php-cgi /tmp/test.php zend_mm_heap corrupted Worked fine with USE_ZEND_ALLOC=0 --------------- [erom...@roll tmp]$ export USE_ZEND_ALLOC=0 [erom...@roll tmp]$ /usr/local/php5-cgi/bin/php-cgi /tmp/test.php PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql- connect</a>]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /tmp/test.php on line 2 X-Powered-By: PHP/5.2.6 Content-type: text/html HolaCould not connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Updating to 5.3.2 fixed the issue. Here's the config line I used in BOTH 5.2.6 and 5.3.2, everything compiled fine both times. Disregard the unused flags: './configure' \ '--prefix=/usr/local/php5-cgi' \ '--with-curl' \ '--with-freetype-dir=/usr' \ '--with-png-dir=/usr' \ '--enable-gd-native-ttf' \ '--with-jpeg-dir=/usr' \ '--with-png' \ '--enable-magic-quotes' \ '--enable-sockets' \ '--enable-sysvsem' \ '--enable-sysvshm' \ '--enable-sysvmsg' \ '--enable-track-vars' \ '--enable-trans-sid' \ '--enable-yp' \ '--enable-wddx' \ '--with-pear=/usr/share/pear' \ '--with-kerberos' \ '--with-mysql=/usr/local/mysql' \ '--with-mysqli' \ '--with-pcre-regex' \ '--disable-cli' \ '--enable-cgi' \ '--enable-mbstring' \ '--enable-fastcgi' \ '--enable-force-cgi-redirect' \ '--enable-discard-path' \ '--with-oci8=instantclient,/usr/lib/oracle/11.1.0.1/client/lib' \ '--with-gd' \ '--with-zlib' Cheers, Eduardo Romero http://foxteck.org ------------------------------------------------------------------------ [2009-11-16 19:16:03] gfmailweb at gmail dot com Adding export USE_ZEND_ALLOC=0 to apache2ctl on Ubuntu Hardy worked for me too. ------------------------------------------------------------------------ [2009-11-12 13:38:31] astehlik at intera dot de I can confirm, that my apache crashed with the error "zend_mm_heap corrupted" under heavy load. After that I get a lot of Segmentation faults (11). OS: CentOS 5.4 PHP: 5.2.11 Apache: 2.2.14 The server is running as a virtual machine in an ESXi 3.5 Server. I'm now testing the "export USE_ZEND_ALLOC=0" workaround in my apachectl. I'll provide more feedback as soon as I know if this helps. ------------------------------------------------------------------------ [2009-10-27 14:54:49] mike at blueroot dot co dot uk I see this error all the time on my complicated application. I am using php-fcgi + nginx + mongodb so I am fairly sure it is something in core. I find that even a small change can fix the problem, output buffering seems to be the culprit for me (ob_end_flush() seems to fix it) which is maybe why people can only reproduce on production servers? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=40479 -- Edit this bug report at http://bugs.php.net/bug.php?id=40479&edit=1