Edit report at https://bugs.php.net/bug.php?id=65291&edit=1

 ID:                 65291
 Patch added by:     re...@php.net
 Reported by:        gregbenner1 at gmail dot com
 Summary:            get_defined_constants() causes PHP to crash in a
                     very limited case.
 Status:             Verified
 Type:               Bug
 Package:            Reproducible crash
 Operating System:   CentOS 6.4
 PHP Version:        5.4.17
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: Patch-for-65291
Revision:   1374292240
URL:        
https://bugs.php.net/patch-display.php?bug=65291&patch=Patch-for-65291&revision=1374292240


Previous Comments:
------------------------------------------------------------------------
[2013-07-18 20:27:16] ar...@php.net

Program received signal SIGSEGV, Segmentation fault.
add_assoc_zval_ex (arg=0x7ffff7fbe4e8, key=0x0, key_len=0, 
value=0x7ffff69a7398) at /home/arpad/w/php/php-src/Zend/zend_API.c:1275
1275            return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, 
(void *) &value, sizeof(zval *), NULL);
(gdb) bt
#0  add_assoc_zval_ex (arg=0x7ffff7fbe4e8, key=0x0, key_len=0, 
value=0x7ffff69a7398)
    at /home/arpad/w/php/php-src/Zend/zend_API.c:1275
#1  0x0000000000588a38 in add_constant_info (constant=0xa8df70, 
arg=0x7ffff7fbe4e8)
    at /home/arpad/w/php/php-src/Zend/zend_builtin_functions.c:1933
#2  0x0000000000585e8a in zend_hash_apply_with_argument (ht=0x99ccb0, 
apply_func=0x5889b0 <add_constant_info>, 
    argument=0x7ffff7fbe4e8) at /home/arpad/w/php/php-src/Zend/zend_hash.c:740
#3  0x000000000058b0b4 in zif_get_defined_constants (ht=<optimised out>, 
return_value=0x7ffff7fbe4e8, 
    return_value_ptr=<optimised out>, this_ptr=<optimised out>, 
return_value_used=<optimised out>)
    at /home/arpad/w/php/php-src/Zend/zend_builtin_functions.c:2023
#4  0x000000000061a51d in zend_do_fcall_common_helper_SPEC 
(execute_data=0x7ffff7f8b060)
    at /home/arpad/w/php/php-src/Zend/zend_vm_execute.h:643
#5  0x00000000005d69dc in execute (op_array=0x7ffff7fc0c90) at 
/home/arpad/w/php/php-src/Zend/zend_vm_execute.h:410
#6  0x0000000000579a69 in zend_execute_scripts (type=8, retval=0x0, 
file_count=3) at /home/arpad/w/php/php-src/Zend/zend.c:1315
#7  0x000000000051a6b8 in php_execute_script (primary_file=0x7fffffffcee0) at 
/home/arpad/w/php/php-src/main/main.c:2497
#8  0x000000000061cc44 in do_cli (argc=2, argv=0x7fffffffe2d8) at 
/home/arpad/w/php/php-src/sapi/cli/php_cli.c:989
#9  0x0000000000418ab3 in main (argc=2, argv=0x7fffffffe2d8) at 
/home/arpad/w/php/php-src/sapi/cli/php_cli.c:1365

------------------------------------------------------------------------
[2013-07-18 17:54:29] gregbenner1 at gmail dot com

Description:
------------
The function get_defined_constants(); (with or without the bool parameter) 
causes 
PHP to segfault when used in the same script as a Class that uses a Trait which 
has the __CLASS__ magic constant somewhere in it.

If you replace __CLASS__ with get_called_class() it works fine.

Test script:
---------------
<?php

trait TestTrait
{
    public static function testStaticFunction()
    {
        return __CLASS__;
    }
}
class Tester
{
    use TestTrait;
}
$tester = Tester::testStaticFunction();

get_defined_constants();
echo "It Worked!";

Expected result:
----------------
The text "It Worked!" output.

Actual result:
--------------
PHP crashes and the following is left in my Apache error log:
[Thu Jul 18 13:22:33 2013] [notice] child pid ##### exit signal Segmentation 
fault 
(11)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65291&edit=1

Reply via email to