php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56536 Class related problems when loading a PHP bytecoded file.
Submitted: 2005-09-10 09:05 UTC Modified: 2005-12-20 13:42 UTC
From: st_hermansson at spray dot se Assigned: val (profile)
Status: Closed Package: bcompiler (PECL)
PHP Version: 5_1 CVS-2005-09-10 (dev) OS: Windows XP Home
Private report: No CVE-ID: None
 [2005-09-10 09:05 UTC] st_hermansson at spray dot se
Description:
------------
BCompiler version: 0.7
PHP version: 5.1.0RC1
ZEND version: 2.1.0-dev

Configure line:
cscript /nologo configure.js --enable-sockets --without-dom --without-libxml --with-bz2 --enable-bz2-filter --enable-soap --enable-bcompiler

Class names starting with a capital letter in a PHP bytecode file seems to create a ghost-class when loading it.
It exists in get_defined_classes() but not in the actual PHP script.

Also, creating new classes inside classes starting with capital letters crashes PHP.

There seems to be another problem relating to a crash when the PHP script has ended. Im still looking into though.

I usually run Linux but i figured that i need to test the Windows NT platform aswell.

Reproduce code:
---------------
---- The PHP file to be compiled ----
<?php

class ABC_abc {
    function createNew() {
        $a = &new ABC_abc;
        return $a;
    }
}

class DEF_def extends ABC_abc {
    public $empty = NULL;
}

?>

Expected result:
----------------
Creating a new instance of DEF_def class will fail,
"could not extend class 'ABC_abc'".

Visible in var_dump(get_defined_classes()) though.

Creating a new instance of ABC_abc, when it works, and calling the createNew() method results in a crash.

Also, another thing is that PHP crashes when the scripts ends. This might not be this actual code but im looking into that problem.

Actual result:
--------------
None.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-08 11:58 UTC] info at tcknetwork dot com
With the PHP 5.1.1 it seems that the bcompiler is not working any more with classes (at least on Win32 plateforms) : encoding the following code will generate an apache crash (i use php as module) :

<? class test {}; ?>

Has something changed with the class handling ?
I used all the win32 binaries provided.
 [2005-12-09 03:09 UTC] r dot vanicek at seznam dot cz
I confirm this. 

I have tested it both on Windows, Apache2, PHP5.1 and 5.1.1 and on Linux, Apache1.3, PHP5.1. 

The problem is the same, the PHP script encoding works fine, but when the encoded script is loaded, Apache crashes and in the log file is a message like "Cannot allocate 10210245454 bytes of memory". PHP4.4 works just fine with the same scripts and setup.

I have used version 0.7 of bcompiler on Linux (compiled from sources) and the dll bundled with PHP5.1.1 on Windows.
 [2005-12-09 03:35 UTC] alan at akbkhome dot com
it may help if someone can do a backtrace on this - I dont have time to look at it at present, but perhaps val does.

http://bugs.php.net/bugs-generating-backtrace.php
 [2005-12-20 13:42 UTC] val@php.net
Due to changes in Zend Engine bcompiler crashed for PHP 5.1 (and, I'm sure, 6.0). Now it should be fixed on CVS. The script I used to test this bug:

<?php
class ABC_abc {
    function createNew() {
        $a = &new ABC_abc;
        return $a;
    }
}

class DEF_def extends ABC_abc {
    public $empty = NULL;
}

echo "#1\n";
$a = new ABC_abc();
var_dump($a);
echo "#2\n";
$b = $a->createNew();
var_dump($b);
echo "#3\n";
$c = new DEF_def();
var_dump($c);
echo "#4\n";
$d = $c->createNew();
var_dump($d);

?>
 [2006-02-16 22:22 UTC] mike at blueroot dot co dot uk
Here is a backtrace for this bug with php-5.1.2 on Linux.  Is there any chance of a new release for this?


_efree (ptr=0x0) at /usr/src/php-5.1.2/Zend/zend_alloc.c:286
286             CALCULATE_REAL_SIZE_AND_CACHE_INDEX(p->size);
(gdb) bt
#0  _efree (ptr=0x0) at /usr/src/php-5.1.2/Zend/zend_alloc.c:286
#1  0xb774fff2 in destroy_zend_class (pce=0x0) at /usr/src/php-5.1.2/Zend/zend_opcode.c:170
#2  0xb775d20c in zend_hash_apply_deleter (ht=0x80f2650, p=0x823c468) at /usr/src/php-5.1.2/Zend/zend_hash.c:574
#3  0xb775d30a in zend_hash_apply (ht=0x80f2650, apply_func=0xb774c918 <is_not_internal_class>)
    at /usr/src/php-5.1.2/Zend/zend_hash.c:665
#4  0xb774cf26 in shutdown_executor () at /usr/src/php-5.1.2/Zend/zend_execute_API.c:262
#5  0xb7756483 in zend_deactivate () at /usr/src/php-5.1.2/Zend/zend.c:846
#6  0xb772564a in php_request_shutdown (dummy=0x0) at /usr/src/php-5.1.2/main/main.c:1284
#7  0xb77ad6d6 in apache_php_module_main (r=0x81aa0e4, display_source_mode=0)
    at /usr/src/php-5.1.2/sapi/apache/sapi_apache.c:59
#8  0xb77adf82 in send_php (r=0x81aa0e4, display_source_mode=0, filename=0x0)
    at /usr/src/php-5.1.2/sapi/apache/mod_php5.c:643
#9  0xb77ae0ea in send_parsed_php (r=0x81aa0e4) at /usr/src/php-5.1.2/sapi/apache/mod_php5.c:658
#10 0x080748a7 in ap_invoke_handler ()
#11 0x08089b2b in process_request_internal ()
#12 0x08089f74 in ap_internal_redirect ()
#13 0x08067d48 in mod_gzip_redir1_handler ()
#14 0x080662f6 in mod_gzip_handler ()
#15 0x080748a7 in ap_invoke_handler ()
#16 0x08089b2b in process_request_internal ()
#17 0x08089b8a in ap_process_request ()
#18 0x080809d9 in child_main ()
#19 0x08080b79 in make_child ()
#20 0x08080cdf in startup_children ()
#21 0x08081396 in standalone_main ()
#22 0x08081bb4 in main ()
 [2006-06-06 23:16 UTC] phoenixsnake at hotmail dot com
Now this package still does't work.
Can anyone tell me when this bug should be done.

Is the new version of bcompiler support Zend Optimizer 3.

I will looking for it.

Thank you
 [2006-08-21 05:13 UTC] spesa at flexmod dot com
Hi there,

My configuration is as follows : WinXP (SP2), Apache 2.0.x, PHP5.1.2 and I donwloaded the latest bcompiler version for PHP 5.1.2 from http://pecl4win.php.net/
I updated my PHP.ini to reference bcompiler.dll and restarted Apache.

I compiled my source code as  follows : 
$fh = fopen("example.phb", "w");
bcompiler_write_header($fh);
bcompiler_write_file($fh, "example.php");
bcompiler_write_footer($fh);
fclose($fh);


The compilation process runs just fine.
But when trying to view my pages, all the compiled code seems not to be parsed and is displayed right on the page....

Unlike previous versions, the very last version of bcompiler for PHP5.1.2 does not crash Apache any more... but the code is not parsed... any idea ?

Raph
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 15:03:14 2021 UTC