|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-08 03:35 UTC] danhen at web dot de
[2007-04-09 10:40 UTC] intel352 at gmail dot com
[2007-05-25 13:14 UTC] intel352 at gmail dot com
[2007-07-16 02:19 UTC] zobo at scene-si dot org
[2009-11-30 07:28 UTC] val@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
Description: ------------ Declaring class attributes as protected results in attributes either not being accessible to the class's own constructor and/or causes a bus error. If you access the first declared attribute, PHP incorrectly produces a fatal error. If you access the second attribute, PHP dumps core with a bus error. Can reproduce with stock bcompiler 0.8, as well as with current bcompile.c from CVS (bcompiler.c,v 1.109 2006/12/20 22:51:15 val). Example code below is compiled with standard bcompiler_write_header(), bcompiler_write_file(), bcompiler_write_footer() sequence. Reproduce code: --------------- class A { protected $prop_a; protected $prop_b; function __construct() { # comment following line for bus error $this->prop_a = NULL; $this->prop_b = NULL; } } $o = new A(); Expected result: ---------------- (no output expected) Actual result: -------------- As shown above: Fatal error: Cannot access protected property A::$prop_a in protected.php on line 8 If that line is commented out: zsh: bus error (core dumped) php protected.php.phb (gdb) bt #0 0x0000000000585872 in zend_check_protected (ce=0x5a5a5a5a5a5a5a5a, scope=0x7d13b0) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/Zend/zend_object_handlers.c:733 #1 0x0000000000583c2a in zend_verify_property_access (property_info=0x7d26a8, ce=0x7d13b0) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/Zend/zend_object_handlers.c:153 #2 0x0000000000583d6c in zend_get_property_info (ce=0x7d13b0, member=0x7d1a30, silent=0) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/Zend/zend_object_handlers.c:201 #3 0x0000000000584641 in zend_std_write_property (object=0x7ce090, member=0x7d1a30, value=0x7cf5c8) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/Zend/zend_object_handlers.c:389 #4 0x00000000005a55f5 in zend_assign_to_object (result=0x7d19e8, object_ptr=0x7b0858, op2=0x7d1a28, value_op=0x7d1a80, Ts=0x7fffffffccc0, opcode=136) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/Zend/zend_execute.c:602 #5 0x00000000005ba85e in ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_HANDLER (execute_data=0x7fffffffcd00) at zend_vm_execute.h:15366 #6 0x0000000000589260 in execute (op_array=0x7d1f58) at zend_vm_execute.h:92 #7 0x000000000058998b in zend_do_fcall_common_helper_SPEC (execute_data=0x7fffffffcfb0) at zend_vm_execute.h:234 #8 0x000000000058a575 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER (execute_data=0x7fffffffcfb0) at zend_vm_execute.h:322 #9 0x0000000000589260 in execute (op_array=0x7d1790) at zend_vm_execute.h:92 #10 0x0000000000560a0c in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/Zend/zend.c:1135 #11 0x0000000000503bca in php_execute_script (primary_file=0x7fffffffe9d0) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/main/main.c:1784 #12 0x00000000005dde40 in main (argc=2, argv=0x7fffffffea90) at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/sapi/cli/php_cli.c:1114 (gdb)