|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57536 protected attributes cause problems
Submitted: 2007-02-19 16:56 UTC Modified: 2009-11-30 07:28 UTC
From: php at sea-incorporated dot com Assigned: val (profile)
Status: Closed Package: bcompiler (PECL)
PHP Version: 5.2.1 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: php at sea-incorporated dot com
New email:
PHP Version: OS:


 [2007-02-19 16:56 UTC] php at sea-incorporated dot com
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-08 03:35 UTC] danhen at web dot de
It seems to deal with some changes since 5.2.x (I dont exactly know when *zend_class_entry->properties_info was introduced) which bcompiler doesn't handle. Maybe one of the apc-developers could help out with it or confirm that this is the reason? IMHO that could also be the reason for the inheritance-issues when classes are spreaded over more then one file.
 [2007-04-09 10:40 UTC] intel352 at gmail dot com
I'm having the same problem in 5.2.1, built a class, initialized protected vars, accessed protected vars in constructor, started seeing core dumps & fatal errors.

Note, this was working fine for an hour or two, THEN it started dumping out errors. If I comment out the line that is currently erroring, then the script will output properly as it is supposed to (the first time), all subsequent times will fail with a Fatal error.

Interesting eh?

Looks like I'll have to resort to public declarations... ridiculous
 [2007-05-25 13:14 UTC] intel352 at gmail dot com
Looks like this could have been an eAccelerator issue:
 [2007-07-16 02:19 UTC] zobo at scene-si dot org
Yup.. Definitely properties_info (ce property to be exact). I have this one fixed already and am about to submit a patch...
 [2009-11-30 07:28 UTC]
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 18:01:30 2024 UTC