php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60369 Crash with static property in trait
Submitted: 2011-11-23 20:35 UTC Modified: 2011-11-23 21:25 UTC
From: vrana@php.net Assigned: gron (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.4.0RC1 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vrana@php.net
New email:
PHP Version: OS:

 

 [2011-11-23 20:35 UTC] vrana@php.net
Description:
------------
PHP crashes when there is a static property defined in a trait plus there is a normal property of the same name in a class using this trait.

Test script:
---------------
<?php
trait PropertiesTrait {
    static $same = true;
}

class Properties {
    use PropertiesTrait;
    public $same = true;
}
?>


Expected result:
----------------
Exit code: 0

Actual result:
--------------
Exit code: -1073741819

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-23 20:37 UTC] gron@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: gron
 [2011-11-23 20:38 UTC] vrana@php.net
Backtrace:

Entry point   php!mainCRTStartup 
Create time   11/23/2011 12:31:14 PM 
Time spent in user mode   0 Days 0:0:0.15 
Time spent in kernel mode   0 Days 0:0:0.0 

Function     Arg 1     Arg 2     Arg 3   Source 
ntdll!ZwRaiseException+12     009ce3c4     009ce414     00000000    
ntdll!KiUserExceptionDispatcher+2a     00000023     009cfb08     0000002b    
php5!_php_import_environment_variables+39f     00000023     009cfb08     0000002b    
php5!_php_import_environment_variables+39f     00000000     00000000     00000000    

PHP5!ZEND_DO_BEGIN_CATCH+244In php__PID__8020__Date__11_23_2011__Time_12_31_24PM__22__Second_Chance_Exception_C0000005.dmp the assembly instruction at php5!zend_do_begin_catch+244 in C:\Program Files (x86)\PHP 5.4\php5.dll from The PHP Group has caused an access violation exception (0xC0000005) when trying to read from memory location 0x00000000 on thread 0
 [2011-11-23 20:55 UTC] gron@php.net
Thanks. I just missed the statics here.

Patch below, svn commit coming as soon as the tests have completed.

Thanks for the catch.

Index: Zend/zend_compile.c
===================================================================
--- Zend/zend_compile.c	(revision 319492)
+++ Zend/zend_compile.c	(working copy)
@@ -4271,10 +4286,11 @@
 					/* this one is inherited, lets look it up in its own class */
 					zend_hash_quick_find(&coliding_prop->ce->properties_info, prop_name, prop_name_length+1, 
prop_hash, (void **) &coliding_prop);
 				}
-				if ((coliding_prop->flags & ZEND_ACC_PPP_MASK) == (property_info->flags & ZEND_ACC_PPP_MASK)) {
+				if (   (coliding_prop->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))
+					== (property_info->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) {
 					/* flags are identical, now the value needs to be checked */
 					if (property_info->flags & ZEND_ACC_STATIC) {
-            not_compatible = (FAILURE == compare_function(&compare_result,
+						not_compatible = (FAILURE == compare_function(&compare_result,
                                           ce->default_static_members_table[coliding_prop->offset],
                                           ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC))
                               || (Z_LVAL(compare_result) != 0);
 [2011-11-23 21:24 UTC] gron@php.net
Automatic comment from SVN on behalf of gron
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=319727
Log: Fixed Bug #60369	Crash with static property in trait
 [2011-11-23 21:25 UTC] gron@php.net
-Status: Verified +Status: Closed
 [2011-11-23 21:25 UTC] gron@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.

Fixed in svn rev. 319727.
 [2012-04-18 09:47 UTC] laruence@php.net
Automatic comment on behalf of gron
Revision: http://git.php.net/?p=php-src.git;a=commit;h=35d38e4772c4c6c0f92475471252fc08659ac84f
Log: Fixed Bug #60369	Crash with static property in trait
 [2012-07-24 23:38 UTC] rasmus@php.net
Automatic comment on behalf of gron
Revision: http://git.php.net/?p=php-src.git;a=commit;h=35d38e4772c4c6c0f92475471252fc08659ac84f
Log: Fixed Bug #60369	Crash with static property in trait
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of gron
Revision: http://git.php.net/?p=php-src.git;a=commit;h=35d38e4772c4c6c0f92475471252fc08659ac84f
Log: Fixed Bug #60369	Crash with static property in trait
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 07 23:01:27 2024 UTC