php.net |  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
Votes:2
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: manchokapitancho at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-16 22:06 UTC] manchokapitancho at gmail dot com
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



Patches

Pull Requests

History

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

  http://snaps.php.net/php-trunk-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

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

http://news.php.net/php.internals/60865

thanks
 [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 (http://windows.php.net/snapshots/)

Based on https://bugs.php.net/bug.php?id=61712 
I've tried to get a snapshot from 
http://windows.php.net/downloads/snaps/php-trunk/
But this folder is also empty :)

Looks like I have no way to test it now??
 [2012-07-17 15:13 UTC] laruence@php.net
please try with PHP-5.4.5RC1  http://qa.php.net/
 [2012-07-17 15:13 UTC] laruence@php.net
-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:
http://downloads.php.net/stas/php-5.4.5RC1.tar.gz
 [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] laruence@php.net
okey, thanks , closed
 [2012-10-15 03:23 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 17:01:31 2024 UTC