PHP :: Bug #60809 :: TRAITS

Bug #60809 TRAITS - PHPDoc Comment Style Bug
Submitted: 2012-01-19 18:41 UTC Modified: 2012-01-20 12:48 UTC
From: micronix at gmx dot net Assigned: pierrick (profile)
Status: Closed Package: *General Issues
PHP Version: 5.4.0RC5 OS: Windows
Private report: No CVE-ID: None

 [2012-01-19 18:41 UTC] micronix at gmx dot net

Description:
------------
Hello,

if you created in an separated file a trait with phpdoc inside. The apache server reset the connection immediatly.

Test script:
---------------
/// Example.php
class Example
   use ExampleTrait;

   public function __construct()
   {
       echo $this->hello_world;
   }
}
/// END OF Example.php

/// ExampleTrait.php
trait ExampleTrait {
    /**
     *
     */
    public $hello_world = 'hello World ^^';
}
/// END OF ExampleTrait.php

Expected result:
----------------
The Apache server can not load the output of the page.
the connection was reset while the page was loading.


Patches

bug60809.phpt (last revision 2012-01-20 02:39 UTC by pierrick@php.net)
60809.diff (last revision 2012-01-20 02:19 UTC by pierrick@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2012-01-19 18:48 UTC] gron@php.net

-Status: Open +Status: Critical

 [2012-01-19 18:48 UTC] gron@php.net

I can confirm that.

smarr:~/svn/trunk$ sapi/cli/php  doctest.php 
[Thu Jan 19 19:45:13 2012]  Script:  'doctest.php'
---------------------------------------
/Users/smarr/Projects/PHP-Traits/svn/trunk/Zend/zend_compile.c(131) : Block 
0x1007c60e8 status:
Beginning:  	Cached
Freed (invalid)
    Start:	OK
      End:	OK
---------------------------------------


Looks like zend_destroy_property_info thinks it should free something, which might 
already have been freed.

Won't have time to look into that before the weekend.
Sorry.

 [2012-01-19 23:43 UTC] stas@php.net

Could you post what's in your doctest.php exactly?

 [2012-01-19 23:49 UTC] gron@php.net

Micronix was just a bit sloppy with typos etc.
I tested on a trunk from 14th of Jan.:

//doc.php
<?php
trait ExampleTrait {
   /**
    *
    */
   public $hello_world = 'hello World ^^';
}


//doctest.php
<?php
include('doc.php');
class Example {
  use ExampleTrait;

  public function __construct()
  {
      echo $this->hello_world;
  }
}

 [2012-01-20 02:21 UTC] pierrick@php.net

Problem is because zend_do_traits_property_binding use zend_declare_property_ex 
without doing a estrndup of the doc_comment. I attached a patch please Stas or 
dsp confirm that I can commit it :)

 [2012-01-20 02:26 UTC] laruence@php.net

pierrick, I suggest doing like:
char *doccomment = NULL;

if () {
   doccomment = estrndup();
}

thanks :)

 [2012-01-20 02:26 UTC] laruence@php.net

pierrick, I suggest doing like:
char *doccomment = NULL;

if () {
   doccomment = estrndup();
}

thanks :)

 [2012-01-20 02:28 UTC] pierrick@php.net

I can do it like that yes. I'll just have to declare the variable inside the loop 
to make sure the doc_comment is reinitialized and NULL if no doc_comment is 
there.

 [2012-01-20 12:48 UTC] dmitry@php.net

-Status: Critical +Status: Closed