|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62339 zend_mm_heap corrupted when trait is autoloaded after a class that uses it.
Submitted: 2012-06-16 22:06 UTC Modified: 2012-10-15 03:23 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: manchokapitancho at gmail dot com Assigned: laruence (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.4.5RC1 OS: win 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: manchokapitancho at gmail dot com
New email:
PHP Version: OS:


 [2012-06-16 22:06 UTC] manchokapitancho at gmail dot com
Bugs #61998 and #62234 seem to be really close to this:

PHP crashes after the script finishes. It echoes "zend_mm_heap corrupted".
Necessary components (ALL required):
1. A class that uses a trait. 
2. The trait should contain a method that also exists in the class. 
3. This trait method is loaded as an alias in the class.
4. The trait should be in a separate file that is loaded after the file that 
contains the class (__autoload)
5. There should be some other code loaded and parsed. The amount of code has some 
randomness but a class with 5000 methods usually works :)

Note: there is a serious randomness in the crash. Sometimes I get it constantly, 
sometimes it crashes when called from apache only and sometimes it may crash once 
and then start working fine.

Test script:
function __autoload ($class) {
    include 'trait.php';
include 'demo.php';
$demo = new demo;
echo $demo->someFunc0();
echo $demo->broken();

trait a {
    function broken() { return 'broken'; }

class demo { 
    use a { broken as private broken_old; } 
    function broken() { return "OK:" . $this->broken_old(); } 
    function someFunc0(){return 0;}
... //a small number of method may not trigger that crash.
    function someFunc5000(){return 5000;}

Expected result:

Actual result:
zend_mm_heap corrupted


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-17 04:12 UTC]
-Assigned To: +Assigned To: dmitry
 [2012-06-17 04:12 UTC]
Dmitry, could you please look at this? 
 [2012-06-17 05:11 UTC]
-Status: Assigned +Status: Feedback -Assigned To: dmitry +Assigned To: laruence
 [2012-06-17 05:11 UTC]
Please try using this snapshot:
For Windows:

I can not reproduce this in trunk, sorry, could you please try with trunk?
 [2012-06-17 05:21 UTC]
this bug is already fixed,  but seems the fix is not merged into 5.4.4

 [2012-06-17 08:38 UTC] manchokapitancho at gmail dot com
-Status: Feedback +Status: Assigned
 [2012-06-17 08:38 UTC] manchokapitancho at gmail dot com
Official snapshots are broken (

Based on 
I've tried to get a snapshot from
But this folder is also empty :)

Looks like I have no way to test it now??
 [2012-07-17 15:13 UTC]
please try with PHP-5.4.5RC1
 [2012-07-17 15:13 UTC]
-Status: Assigned +Status: Feedback
 [2012-07-17 17:16 UTC] manchokapitancho at gmail dot com
-Status: Feedback +Status: Assigned -PHP Version: 5.4.4 +PHP Version: 5.4.5RC1
 [2012-07-17 17:16 UTC] manchokapitancho at gmail dot com
Sorry, the bug is still reproduceable :(

Tried this:
 [2012-08-08 11:23 UTC] maciej dot sz at gmail dot com
Also related bug #62358
 [2012-10-14 12:44 UTC] jose dot zap at gmail dot com
I was having this problem with version 5.4.4 but after upgrading to 5.4.7 is 
gone. I think it can be marked as resolved.
 [2012-10-15 03:23 UTC]
okey, thanks , closed
 [2012-10-15 03:23 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Feb 04 10:04:08 2023 UTC