Bug #62339 [NEW]: zend_mm_heap corrupted when trait is autoloaded after a class that uses it.

From: Date: Sat, 16 Jun 2012 22:06:01 +0000
Subject: Bug #62339 [NEW]: zend_mm_heap corrupted when trait is autoloaded after a class that uses it.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-171308@lists.php.net to get a copy of this message
From:             manchokapitancho at gmail dot com
Operating system: win 7
PHP version:      5.4.4
Package:          Reproducible crash
Bug Type:         Bug
Bug description:zend_mm_heap corrupted when trait is autoloaded after a class that uses it.

Description:
------------
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:
---------------
main.php
---------
function __autoload ($class) {
    include 'trait.php';
}
include 'demo.php';
$demo = new demo;
echo $demo->someFunc0();
echo $demo->broken();

trait.php
----------
trait a {
    function broken() { return 'broken'; }
}

demo.php
---------
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:
----------------
OK:broken

Actual result:
--------------
OK:broken
zend_mm_heap corrupted



-- 
Edit bug report at https://bugs.php.net/bug.php?id=62339&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=62339&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=62339&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=62339&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=62339&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62339&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=62339&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=62339&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=62339&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=62339&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=62339&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=62339&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=62339&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=62339&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=62339&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=62339&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62339&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=62339&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=62339&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=62339&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=62339&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=62339&r=mysqlcfg



Thread (10 messages)

« previous php.bugs (#171308) next »