|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-20 11:53 UTC] php at sea-incorporated dot com
Description:
------------
If you declare class A with a member variable in one file, then require_once() that file from another file where you declare class B as extending class A, you cannot declare a member variable in class B. Note this bug only occurs when classes are in two separate files.
Compile files below with normal bcompiler_write_header(), bcompiler_write_file(), bcompiler_write_footer().
Symptom is PHP trying/failing to allocate ~1.5G of memory
and is reported on the line where class B extends class A.
Reproduce code:
---------------
File a.php:
<?php
class A {
var $attr_a;
}
?>
File b.php:
<?php
require_once('a.php');
class B extends class A {
var $attr_b;
}
?>
Expected result:
----------------
(no output expected)
Actual result:
--------------
Fatal error: Allowed memory size of 134217728 bytes exhausted at /tmp/ports/usr/ports/lang/php5/work/php-5.2.1/Zend/zend_compile.c:46 (tried to allocate 1515870811 bytes) in b.php on line 3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Whoops... line 3 in file b.php should obviously be: class B extends A { and not: class B extends class A { as shown in the original submission.Ok.. I'll look at CVS... This is the fix.. The behavior only occurs on PHP5 (new structures...) and there was something uninitialized... It would be really nice if at least this were released asap, as people will thing it doesn't work for php5... Great work! diff -uNr bcompiler-0.8-orig/bcompiler.c bcompiler-0.8-zobo/bcompiler.c --- bcompiler-0.8-orig/bcompiler.c 2006-10-04 10:45:28.000000000 +0200 +++ bcompiler-0.8-zobo/bcompiler.c 2007-07-05 10:32:43.000000000 +0200 @@ -2687,6 +2687,8 @@ void apc_create_zend_property_info(zend_property_info** zf TSRMLS_DC) { *zf = (zend_property_info*) emalloc(sizeof(zend_property_info)); + memset(*zf, 0, sizeof(zend_property_info)); apc_deserialize_zend_property_info(*zf TSRMLS_CC); }