php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59912 Apache crashes while loading bcompiled class (mod_php)
Submitted: 2011-08-26 22:04 UTC Modified: 2017-01-10 07:57 UTC
Votes:13
Avg. Score:4.9 ± 0.3
Reproduced:12 of 13 (92.3%)
Same Version:7 (58.3%)
Same OS:7 (58.3%)
From: sjaillet at gmail dot com Assigned:
Status: Suspended Package: bcompiler (PECL)
PHP Version: 5.3.2 OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-08-26 22:04 UTC] sjaillet at gmail dot com
Description:
------------
Apache crashes with loading bcompiled class.
php -f works well and load the class as expected

In the php.ini the only loaded module is:
extension=bcompiler.so


Reproduce code:
---------------
lib.phb (the compiled class)
<?php
class Test {
     static function hello(){
	echo "Class test using bcompiler";
     }
}
?>

test.php (a normal php file)
<?php
require('lib.phb');
Test::hello();
?>

http://localhost/test.php (Bug: empty page)
php -f test.php (works fine)

Expected result:
----------------
http://localhost/test.php should display : "Class test using bcompiler"

Actual result:
--------------
Bug: empty page

Patches

suhosin-class-destructor-fix (last revision 2012-06-25 14:08 UTC by icukeng at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-28 22:29 UTC] alan at akbkhome dot com
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PECL.



 [2011-08-29 10:32 UTC] sjaillet at gmail dot com
I did extra tests on another computer.
I install Ubuntu 10.4 LTS (a fresh install)

I install the minimal package
> aptitude install apache php5 php-pear php5-dev ...
> pecl install bcompiler

I add "extension=bcompiler.so" in both php5/apache/php.ini php5/cli/php.ini

PHP info :
PHP Version 5.3.2-1ubuntu4.9
bcompiler version 1.0.2s

php -f test.php works fine and display : "Class test using bcompiler" on the console.

Apache crash with the following url:
http://localhost/test.php 

tail /var/log/apache2/error.log
[Mon Aug 29 16:14:50 2001] [notice] child pid 32238 exit Signal Segmentation fault (11)
 [2011-08-29 10:38 UTC] sjaillet at gmail dot com
P.S.:
using for lib.phb:
<?php
function hello(){
    echo "Function test using bcompiler";
}
?>

and for test.php :
<?php
require('lib.phb');
hello();
?>

works fine with apache and no segmentation fault occur.
 [2011-08-30 03:53 UTC] alan at akbkhome dot com
Can you add a backtrace, 
https://bugs.php.net/bugs-generating-backtrace.php

Also test with the subversion version.

#svn co http://svn.php.net/repository/pecl/bcompiler/trunk 
bcompiler
 [2011-08-30 15:28 UTC] sjaillet at gmail dot com
Hi!
Same behavior using the last trunk.
Here the backtrace :

Program terminated with signal 11, Segmentation fault.
#0  0x012b5d07 in _zend_hash_add_or_update (ht=0x4e2dbc5f, arKey=0x22f9c1f0 "REMOTE_ADDR", nKeyLength=<error type>, pData=0xbfd88fc8, 
    nDataSize=<error type>, pDest=0xbfd88fc4, flag=1) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:413
413	/build/buildd/php5-5.3.2/Zend/zend_hash.c: Aucun fichier ou dossier de ce type.
	in /build/buildd/php5-5.3.2/Zend/zend_hash.c
(gdb) bt
#0  0x012b5d07 in _zend_hash_add_or_update (ht=0x4e2dbc5f, arKey=0x22f9c1f0 "REMOTE_ADDR", nKeyLength=<error type>, pData=0xbfd88fc8, 
    nDataSize=<error type>, pDest=0xbfd88fc4, flag=1) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:413
#1  0x0125d18c in php_register_variable_ex (var_name=0x22f9c608 "REMOTE_ADDR", val=0xbfd8904c, track_vars_array=0x22f9ad48)
    at /build/buildd/php5-5.3.2/Zend/zend_hash.h:348
#2  0x0108e54d in php_sapi_filter (arg=4, var=0x1687c0a "REMOTE_ADDR", val=0xbfd890ac, val_len=<error type>, new_val_len=0x0)
    at /build/buildd/php5-5.3.2/ext/filter/filter.c:482
#3  0x01256964 in sapi_getenv (name=0x1687c0a "REMOTE_ADDR", name_len=<error type>) at /build/buildd/php5-5.3.2/main/SAPI.c:944
#4  0x012634c7 in php_security_log (loglevel=1, fmt=0x16b4604 "possible memory corruption detected - unknown Hashtable destructor")
    at /build/buildd/php5-5.3.2/main/suhosin_patch.c:229
#5  0x012b39b5 in zend_hash_check_destructor (pDestructor=0) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:316
#6  0x012b3e02 in zend_hash_destroy (ht=0x22fa0324) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:721
#7  0x0129f03d in destroy_zend_class (pce=0x2301c564) at /build/buildd/php5-5.3.2/Zend/zend_opcode.c:185
#8  0x012b3aaa in zend_hash_apply_deleter (ht=0x22fa02b8, p=0x2301c558) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:813
#9  0x012b3bcc in zend_hash_reverse_apply (ht=0x22e1b418, apply_func=0x1299a30 <clean_non_persistent_class>)
    at /build/buildd/php5-5.3.2/Zend/zend_hash.c:962
#10 0x0129a928 in shutdown_executor () at /build/buildd/php5-5.3.2/Zend/zend_execute_API.c:310
#11 0x012a784f in zend_deactivate () at /build/buildd/php5-5.3.2/Zend/zend.c:962
#12 0x0124c0d8 in php_request_shutdown (dummy=0x0) at /build/buildd/php5-5.3.2/main/main.c:1649
#13 0x0133946c in php_handler (r=0x22fd5ef8) at /build/buildd/php5-5.3.2/sapi/apache2handler/sapi_apache2.c:512
#14 0x00f89031 in ap_run_handler (r=0x22fd5ef8) at /build/buildd/apache2-2.2.14/server/config.c:159
#15 0x00f8ce17 in ap_invoke_handler (r=0x22fd5ef8) at /build/buildd/apache2-2.2.14/server/config.c:373
#16 0x00f9c728 in ap_process_request (r=0x22fd5ef8) at /build/buildd/apache2-2.2.14/modules/http/http_request.c:282
#17 0x00f99258 in ap_process_http_connection (c=0x22fcfeb8) at /build/buildd/apache2-2.2.14/modules/http/http_core.c:190
#18 0x00f918a1 in ap_run_process_connection (c=0x22fcfeb8) at /build/buildd/apache2-2.2.14/server/connection.c:43
#19 0x00fa1bea in child_main (child_num_arg=<value optimized out>) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:662
#20 0x00fa1f6e in make_child (s=<value optimized out>, slot=2) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:758
#21 0x00fa2342 in startup_children (_pconf=0x22c880a8, plog=0x22cba170, s=0x22c8c8e8) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:776
#22 ap_mpm_run (_pconf=0x22c880a8, plog=0x22cba170, s=0x22c8c8e8) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:997
#23 0x00f73a92 in main (argc=3, argv=0xbfd8dca4) at /build/buildd/apache2-2.2.14/server/main.c:742
 [2011-08-30 15:30 UTC] sjaillet at gmail dot com
Sorry, i did a mistake during the previous copy paste..

#0  0x012b5d07 in _zend_hash_add_or_update (ht=0x4e2dbc5f, arKey=0x22f9c1f0 "REMOTE_ADDR", nKeyLength=<error type>, pData=0xbfd88fc8, 
    nDataSize=<error type>, pDest=0xbfd88fc4, flag=1) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:413
#1  0x0125d18c in php_register_variable_ex (var_name=0x22f9c608 "REMOTE_ADDR", val=0xbfd8904c, track_vars_array=0x22f9ad48)
    at /build/buildd/php5-5.3.2/Zend/zend_hash.h:348
#2  0x0108e54d in php_sapi_filter (arg=4, var=0x1687c0a "REMOTE_ADDR", val=0xbfd890ac, val_len=<error type>, new_val_len=0x0)
    at /build/buildd/php5-5.3.2/ext/filter/filter.c:482
#3  0x01256964 in sapi_getenv (name=0x1687c0a "REMOTE_ADDR", name_len=<error type>) at /build/buildd/php5-5.3.2/main/SAPI.c:944
#4  0x012634c7 in php_security_log (loglevel=1, fmt=0x16b4604 "possible memory corruption detected - unknown Hashtable destructor")
    at /build/buildd/php5-5.3.2/main/suhosin_patch.c:229
#5  0x012b39b5 in zend_hash_check_destructor (pDestructor=0) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:316
#6  0x012b3e02 in zend_hash_destroy (ht=0x22fa0324) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:721
#7  0x0129f03d in destroy_zend_class (pce=0x2301c564) at /build/buildd/php5-5.3.2/Zend/zend_opcode.c:185
#8  0x012b3aaa in zend_hash_apply_deleter (ht=0x22fa02b8, p=0x2301c558) at /build/buildd/php5-5.3.2/Zend/zend_hash.c:813
#9  0x012b3bcc in zend_hash_reverse_apply (ht=0x22e1b418, apply_func=0x1299a30 <clean_non_persistent_class>)
    at /build/buildd/php5-5.3.2/Zend/zend_hash.c:962
#10 0x0129a928 in shutdown_executor () at /build/buildd/php5-5.3.2/Zend/zend_execute_API.c:310
#11 0x012a784f in zend_deactivate () at /build/buildd/php5-5.3.2/Zend/zend.c:962
#12 0x0124c0d8 in php_request_shutdown (dummy=0x0) at /build/buildd/php5-5.3.2/main/main.c:1649
#13 0x0133946c in php_handler (r=0x22fd5ef8) at /build/buildd/php5-5.3.2/sapi/apache2handler/sapi_apache2.c:512
#14 0x00f89031 in ap_run_handler (r=0x22fd5ef8) at /build/buildd/apache2-2.2.14/server/config.c:159
#15 0x00f8ce17 in ap_invoke_handler (r=0x22fd5ef8) at /build/buildd/apache2-2.2.14/server/config.c:373
#16 0x00f9c728 in ap_process_request (r=0x22fd5ef8) at /build/buildd/apache2-2.2.14/modules/http/http_request.c:282
#17 0x00f99258 in ap_process_http_connection (c=0x22fcfeb8) at /build/buildd/apache2-2.2.14/modules/http/http_core.c:190
#18 0x00f918a1 in ap_run_process_connection (c=0x22fcfeb8) at /build/buildd/apache2-2.2.14/server/connection.c:43
#19 0x00fa1bea in child_main (child_num_arg=<value optimized out>) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:662
#20 0x00fa1f6e in make_child (s=<value optimized out>, slot=2) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:758
#21 0x00fa2342 in startup_children (_pconf=0x22c880a8, plog=0x22cba170, s=0x22c8c8e8) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:776
#22 ap_mpm_run (_pconf=0x22c880a8, plog=0x22cba170, s=0x22c8c8e8) at /build/buildd/apache2-2.2.14/server/mpm/prefork/prefork.c:997
#23 0x00f73a92 in main (argc=3, argv=0xbfd8dca4) at /build/buildd/apache2-2.2.14/server/main.c:742
 [2011-08-30 22:14 UTC] alan at akbkhome dot com
Thanks,

It might be worth  disabling the suhosin_patch via ini 
settings

-->    at /build/buildd/php5-5.3.2/main/suhosin_patch.c:229
 [2011-10-30 10:13 UTC] sjaillet at gmail dot com
Sorry for my late reply,
Trying to disable using : suhosin.simulation = on in the php.ini, but with no more success.
Suhosin is compliled with the php package directly and can't be easily disabled w/o recompiled it.
 [2012-04-12 13:42 UTC] tit dot petric at monotek dot net
Like Alan said, this originates in PHP internals / Suhosin. Disabling Suhosin is problematic as it is compiled in, but looking at the code for it, it is also possible to disable this specific _exit(1) with an environment variable:

SUHOSIN_HT_IGNORE_INVALID_DESTRUCTOR=1

I am getting the same errors in CLI / CGI. So far it is 100% reproducible on my side. There are no references to REMOTE_ADDR in my code, but I have the same error from Suhosin. The only issue is that exit(1) is not exit(0) and lighttpd fastcgi bugs out in my case. I could live with it if I was only working in CLI.

The error occurs for me only in bcompiled files - the plain text files work as expected without any changes to environment variables.

We'll look at the problem over the next days since we want to upgrade from our internal 0.9.2s version, which, apart from one unrelated bug, is still working in a stable-er way for us. We would appreciate any feedback also.

Best,
Tit
 [2012-06-25 14:37 UTC] icukeng at gmail dot com
I've investigated this problem and found that this bug concerns previously described https://bugs.php.net/bug.php?id=57727. 
There are two functions: while first is registered, second is used in destructor. When program is ran in apache, suhosin fails to record potential problem information. If program is ran in console, then it completely works out and returns 1 on exit.
I corrected this bug in my patch. Please check.
 [2013-02-18 20:31 UTC] warrior_knight_ at hotmail dot com
The problem continues. Why not be resolved.?
In this way, impossible to use.
 [2013-02-19 10:11 UTC] icukeng at gmail dot com
With my patch I have no problems =)
 [2013-03-04 21:01 UTC] hmmvieira at gmail dot com
I believe that your patch works, but for example, in my case I'm using Ubuntu Server and compiling stuff by hand is not an option.

Bcompiler is a very useful tool but unknown by the majority of the PHP developers. Maybe that is why latest version of bcompiler is from July, 2011.

My business relies on bcompiler. I kindly ask the developers of bcompiler to please release a new version with this fix.

Many thanks
 [2017-01-10 07:57 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-01-10 07:57 UTC] kalle@php.net
Suspending this report as the extension have not had a release for almost 6 years.  Please revive this if the extension once again shows life
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jun 25 00:01:26 2019 UTC