From:             
Operating system: Linux (Ubuntu)
PHP version:      5.4.0
Package:          Reflection related
Bug Type:         Bug
Bug description:ReflectionObject:getProperties called on ArrayObject throws 
Segmentation Fault

Description:
------------
When ReflectionObject::getProperty() method is called over ArrayObject
instance the Segmentation Fault is thrown.

The problem appears only when getting public properties from the instance
which was filled using simple brackets call (ex. $x[] = 'something') or
numeric access (ex. $x[0] = 'something'). The problem will not appear when
you use associative access (ex. $x['test'] = 'something').
Problem was seen on nginx+php_fpm but was also confirmed on the cli
version.
Additionally the same code was working correctly from years - even on the
last 5.3.10 version.

Some additional data:
* Php 5.4.0-1 for Ubuntu oneiric x86_64 was installed from Ondrej's
launchpad https://launchpad.net/~ondrej/+archive/php5
The problem is reproducible in the default configuration.

Test script:
---------------
$x=new ArrayObject();
$x[] = 'test string'; //will cause reflectionobject segfault
$x[0] = 'test string'; //will cause reflectionobject segfault
$x['test'] = 'test string'; //will work
    
$refl = new ReflectionClass($x);
print_r($refl->getProperties()); //works (but returns nothing)

$reflObj = new ReflectionObject($x);
print_r($reflObj->getProperties(
        ReflectionProperty::IS_PRIVATE 
        | ReflectionProperty::IS_PROTECTED 
        | ReflectionProperty::IS_STATIC
    )); //works (but returns nothing)
print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
//SEGFAULT
print_r($reflObj->getProperties()); //SEGFAULT


Expected result:
----------------
For shown example it should simply pass without SEGFAULT or throw an
Exception / Fatal Error if something is wrong on my side.

I am using this method for analysing complicated objects (in this case it
was a PropelObjectCollection object from Propel ORM).

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
0x000000000052e94d in _adddynproperty (pptr=0x7fffffffb830, num_args=40,
args=0x7fffffffb738, 
    hash_key=0x7fffffffb720) at
/build/buildd/php5-5.4.0/ext/reflection/php_reflection.c:3835
3835    /build/buildd/php5-5.4.0/ext/reflection/php_reflection.c: No such file
or directory.
        in /build/buildd/php5-5.4.0/ext/reflection/php_reflection.c
(gdb) bt
#0  0x000000000052e94d in _adddynproperty (pptr=0x7fffffffb830,
num_args=40, 
    args=0x7fffffffb738, hash_key=0x7fffffffb720)
    at /build/buildd/php5-5.4.0/ext/reflection/php_reflection.c:3835
#1  0x00000000006a9a2c in zend_hash_apply_with_arguments
(ht=0x7ffff7fdabc8, 
    apply_func=0x52e900 <_adddynproperty>, num_args=2)
    at /build/buildd/php5-5.4.0/Zend/zend_hash.c:772
#2  0x000000000052d938 in zim_reflection_class_getProperties
(ht=-134371384, 
    return_value=0x7ffff7fda970, return_value_ptr=0x7fffffffb738,
this_ptr=0x7ffff7fda8c8, 
    return_value_used=-134370960)
    at /build/buildd/php5-5.4.0/ext/reflection/php_reflection.c:3876
#3  0x0000000000742b89 in zend_do_fcall_common_helper_SPEC
(execute_data=0x7ffff7f9e060)
    at /build/buildd/php5-5.4.0/Zend/zend_vm_execute.h:642
#4  0x00000000006fcbef in execute (op_array=0x7ffff7fd2540)
    at /build/buildd/php5-5.4.0/Zend/zend_vm_execute.h:410
#5  0x000000000069ce90 in zend_execute_scripts (type=0, retval=0x8f7fd2448,
file_count=3)
    at /build/buildd/php5-5.4.0/Zend/zend.c:1272
#6  0x000000000063c743 in php_execute_script (primary_file=0x0)
    at /build/buildd/php5-5.4.0/main/main.c:2473
#7  0x0000000000745221 in do_cli (argc=0, argv=0x7fffffffe50b)
    at /build/buildd/php5-5.4.0/sapi/cli/php_cli.c:983
#8  0x000000000042c843 in main (argc=32767, argv=0xd341f0)
    at /build/buildd/php5-5.4.0/sapi/cli/php_cli.c:1356
(gdb) frame 4
#4  0x00000000006fcbef in execute (op_array=0x7ffff7fd2540)
    at /build/buildd/php5-5.4.0/Zend/zend_vm_execute.h:410
410     /build/buildd/php5-5.4.0/Zend/zend_vm_execute.h: No such file or
directory.
        in /build/buildd/php5-5.4.0/Zend/zend_vm_execute.h
(gdb) frame 3
#3  0x0000000000742b89 in zend_do_fcall_common_helper_SPEC
(execute_data=0x7ffff7f9e060)
    at /build/buildd/php5-5.4.0/Zend/zend_vm_execute.h:642
642     in /build/buildd/php5-5.4.0/Zend/zend_vm_execute.h
(gdb) frame 2
#2  0x000000000052d938 in zim_reflection_class_getProperties
(ht=-134371384, 
    return_value=0x7ffff7fda970, return_value_ptr=0x7fffffffb738,
this_ptr=0x7ffff7fda8c8, 
    return_value_used=-134370960)
    at /build/buildd/php5-5.4.0/ext/reflection/php_reflection.c:3876
3876    /build/buildd/php5-5.4.0/ext/reflection/php_reflection.c: No such file
or directory.
        in /build/buildd/php5-5.4.0/ext/reflection/php_reflection.c
(gdb) 


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

Reply via email to