php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62892 ReflectionClass::getTraitAliases crashes on importing trait methods as private
Submitted: 2012-08-22 12:17 UTC Modified: 2012-08-22 13:45 UTC
From: r dot wilczek at web-appz dot de Assigned: felipe (profile)
Status: Closed Package: Reflection related
PHP Version: 5.4.6 OS: Linux
Private report: No CVE-ID: None
 [2012-08-22 12:17 UTC] r dot wilczek at web-appz dot de
Description:
------------
When importing a traitmethod 'as private', ReflectionClass::getTraitAliases() segfaults.

Test script:
---------------
File testme.php:
<?php
trait myTrait {
    public function run() {}
}
class myClass {
    use myTrait {
        MyTrait::run as private;
    }
}
$class = new \ReflectionClass('myClass');
$class->getTraitAliases();
?>

Commandline:
/usr/bin/php testme.php

Expected result:
----------------
no segmentation fault 

Actual result:
--------------
Segmentation fault

gdb /usr/bin/php core

...
This GDB was configured as "x86_64-suse-linux".
...
Reading symbols from /usr/bin/php...done.
[New LWP 27460]
...
Core was generated by `php testme.php'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000000009c7c66 in zend_symtable_update (ht=0x7f907f86f918, arKey=0x0, nKeyLength=1515870811, pData=0x7ffff0ad0990, nDataSize=8, pDest=0x0)
    at /root/php-5.4.6/Zend/zend_hash.h:350
350     /root/php-5.4.6/Zend/zend_hash.h: Datei oder Verzeichnis nicht gefunden.
        in /root/php-5.4.6/Zend/zend_hash.h


bt

#0  0x00000000009c7c66 in zend_symtable_update (ht=0x7f907f86f918, arKey=0x0, nKeyLength=1515870811, pData=0x7ffff0ad0990, nDataSize=8, pDest=0x0)
    at /root/php-5.4.6/Zend/zend_hash.h:350
#1  0x00000000009ccc81 in add_assoc_stringl_ex (arg=0x7f907f86f1c0, key=0x0, key_len=1515870811, str=0x7f907f86f238 "MyTrait::run", length=12, duplicate=0)
    at /root/php-5.4.6/Zend/zend_API.c:1234
#2  0x000000000074373e in zim_reflection_class_getTraitAliases (ht=0, return_value=0x7f907f86f1c0, return_value_ptr=0x0, this_ptr=0x7f90855eeed0, 
    return_value_used=0) at /root/php-5.4.6/ext/reflection/php_reflection.c:4475
#3  0x0000000000a05c70 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f90855b20e8) at /root/php-5.4.6/Zend/zend_vm_execute.h:642
#4  0x0000000000a06b1d in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER (execute_data=0x7f90855b20e8) at /root/php-5.4.6/Zend/zend_vm_execute.h:752
#5  0x0000000000a0464f in execute (op_array=0x7f90855efec8) at /root/php-5.4.6/Zend/zend_vm_execute.h:410
#6  0x00000000009c792a in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /root/php-5.4.6/Zend/zend.c:1289
#7  0x000000000093c7e4 in php_execute_script (primary_file=0x7ffff0ad4290) at /root/php-5.4.6/main/main.c:2473
#8  0x0000000000b0d616 in do_cli (argc=2, argv=0x7ffff0ad4648) at /root/php-5.4.6/sapi/cli/php_cli.c:988
#9  0x0000000000b0e6be in main (argc=2, argv=0x7ffff0ad4648) at /root/php-5.4.6/sapi/cli/php_cli.c:1364

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-22 13:41 UTC] felipe@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7a56ac00a04d4fc72052bb679626e723da3eef44
Log: - Fixed bug #62892 (ReflectionClass::getTraitAliases crashes on importing trait methods as private)
 [2012-08-22 13:45 UTC] felipe@php.net
This bug has been fixed in SVN.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-08-22 13:45 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2014-10-07 23:22 UTC] stas@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=7a56ac00a04d4fc72052bb679626e723da3eef44
Log: - Fixed bug #62892 (ReflectionClass::getTraitAliases crashes on importing trait methods as private)
 [2014-10-07 23:33 UTC] stas@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=7a56ac00a04d4fc72052bb679626e723da3eef44
Log: - Fixed bug #62892 (ReflectionClass::getTraitAliases crashes on importing trait methods as private)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC