php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40794 ReflectionObject::getValue()
Submitted: 2007-03-13 16:59 UTC Modified: 2007-03-17 23:00 UTC
From: igor at webta dot net Assigned: helly (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.2.1 OS: FreeBSD 6.0-RELEASE
Private report: No CVE-ID: None
 [2007-03-13 16:59 UTC] igor at webta dot net
Description:
------------
The following example results in a segfault in PHP 5:

Reproduce code:
---------------
<?
    $obj = new stdClass();
    $obj->prop1 = '1';
    $obj->prop2 = '2';
     
    $reflect = new ReflectionObject($obj);

    $array = array();
    foreach($reflect->getProperties() as $prop)
    {
        $array[$prop->getName()] = $prop->getValue($obj);
    }
    
    print_r($array);
?>

Expected result:
----------------
Array
(
    [prop1] => 1
    [prop2] => 2
)

Actual result:
--------------
Segmentation fault (core dumped)

(gdb) backtrace
#0  0x0808a5fa in zim_reflection_property_getValue ()
#1  0x081501b6 in zend_do_fcall_common_helper_SPEC ()
#2  0x0814f915 in execute ()
#3  0x08137fcf in zend_execute_scripts ()
#4  0x08101f41 in php_execute_script ()
#5  0x081b0934 in main ()


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-13 19:11 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-03-14 17:04 UTC] igor at webta dot net
Sorry, I cannot test latest snapshot on FreeBSD system, I try it on WinXP with following results:

Test 1:

<?
    $obj = new stdClass();
    $obj->prop1 = '1';
    $obj->prop2 = '2';


    $reflect = new ReflectionObject($obj);
    $array = array();
    foreach($reflect->getProperties() as $prop)
    {
        $array[$prop->getName()] = $prop->getValue($obj);
    }

    print_r($array);
?>

Expected result:

Array
(
    [prop1] => 1
    [prop2] => 2
)

Actual result: 

Array
(
    [prop1] => 2
    [prop2] => 
)

Test 2:

<?
    $obj = new stdClass();
    $obj->prop1 = '1';
    $obj->prop2 = '2';
    $obj->prop3 = '3';



    $reflect = new ReflectionObject($obj);
    $array = array();
    foreach($reflect->getProperties() as $prop)
    {
        $array[$prop->getName()] = $prop->getValue($obj);
    }

    print_r($array);
?>

Expected result:

Array
(
    [prop1] => 1
    [prop2] => 2
    [prop3] => 3
)

Actual result: 

Fatal error: Cannot access property started with '\0' in C:\php\test.php on line 12

Still does not work property.
 [2007-03-14 18:09 UTC] tony2001@php.net
Marcus, please take a look at it.
We either need to use something like this:
http://tony2001.phpclub.net/dev/tmp/reflection_v1.diff
or add custom destructor for reflection_properties and store a copy of the property info.
 [2007-03-17 23:00 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC