php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56820 SegFault or Bus Error
Submitted: 2006-02-05 00:47 UTC Modified: 2006-02-12 11:38 UTC
From: zefram at zefram dot net Assigned: val (profile)
Status: Closed Package: bcompiler (PECL)
PHP Version: 5.1.1 OS: FreeBSD 5.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zefram at zefram dot net
New email:
PHP Version: OS:

 

 [2006-02-05 00:47 UTC] zefram at zefram dot net
Description:
------------
I've installed bcompiler .7 using PECL on FreeBSD. I've        
written a script to compile all of my PHP code into        
separate files.. either based off of the original file, or        
alternatively compiled a class into it's own file. In       
order to load the compiled code, I simple have a       
include_once in an __autoload, which loads the correct       
file.       
        
When I compile the original file, I receive a Segmentation        
Fault. When I compile the classes, I receive a Bus Error.       
       
Here's my configure line:  
  
./configure  --with-apache=../apache_1.3.33/ --with-mysql  
--with-gd --enable-sockets  
--with-png-dir=/usr/include/libpng  
--with-zlib-dir=/usr/include  
--with-jpeg-dir=/usr/include/libjpeg --with-mhash  
--with-pdflib --disable-ipv6 --with-dom --with-openssl  

Reproduce code:
---------------
Here's the class compiler excerpt:

$fh = fopen("/usr/www/compiled/" . $out . ".class.phpb", "w");
bcompiler_write_header($fh);
bcompiler_write_class($fh, $out);
bcompiler_write_footer($fh);
fclose($fh);


And to load, I tried both:

$fh = fopen("/usr/www/compiled/" . $file,"r");
bcompiler_read($fh);
fclose($fh);

And:

include_once($file);

Actual result:
--------------
Here's the BUS ERROR:      
      
#0  0x080aa733 in _efree ()     
#1  0x080b62d2 in destroy_zend_class ()     
#2  0x080c60a8 in zend_hash_clean ()     
#3  0x080c6191 in zend_hash_apply ()     
#4  0x080b2ef9 in shutdown_executor ()     
#5  0x080bdf45 in zend_deactivate ()     
#6  0x08091b11 in php_request_shutdown ()     
#7  0x081336c2 in apache_php_module_main ()     
#8  0x0808a78b in ap_get_server_built ()     
#9  0x0808a7e9 in ap_get_server_built ()     
#10 0x082cccda in ap_invoke_handler ()     
#11 0x082e1a9d in ap_some_auth_required ()     
#12 0x082e1afc in ap_process_request ()     
#13 0x082d8bc3 in ap_child_terminate ()     
#14 0x082d8dd0 in ap_child_terminate ()     
#15 0x082d8f37 in ap_child_terminate ()     
#16 0x082d9586 in ap_child_terminate ()     
#17 0x082d9d9f in main ()     
    
Here's the SIGSEGV:    
    
#0  0x080aa733 in _efree ()   
#1  0x080b62d2 in destroy_zend_class ()   
#2  0x080c60a8 in zend_hash_clean ()   
#3  0x080c6191 in zend_hash_apply ()   
#4  0x080b2ef9 in shutdown_executor ()   
#5  0x080bdf45 in zend_deactivate ()   
#6  0x08091b11 in php_request_shutdown ()   
#7  0x081336c2 in apache_php_module_main ()   
#8  0x0808a78b in ap_get_server_built ()   
#9  0x0808a7e9 in ap_get_server_built ()   
#10 0x082cccda in ap_invoke_handler ()   
#11 0x082e1a9d in ap_some_auth_required ()   
#12 0x082e1afc in ap_process_request ()   
#13 0x082d8bc3 in ap_child_terminate ()   
#14 0x082d8dd0 in ap_child_terminate ()   
#15 0x082d8f37 in ap_child_terminate ()   
#16 0x082d9586 in ap_child_terminate ()   
#17 0x082d9d9f in main ()   
 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-05 00:53 UTC] zefram at zefram dot net
Forgot to include the interesting bits from apache's log.  
Apparently, PHP is eating up a lot of memory before  
coring. I get errors such as these, usually before a  
SIGSEGV instead of SIGBUS.  
  
FATAL:  emalloc():  Unable to allocate 2099249153 bytes 
[Sat Feb  4 22:38:25 2006] [notice] child pid 30643 exit 
signal Segmentation fault (11)
 [2006-02-07 03:19 UTC] zefram at zefram dot net
This seems to be the same bug as #5356... downgrading to  
5.0.4 fixed it.  
  
And bcompiler shaved 20% off the run time. ;) Thanks  
guys!!!
 [2006-02-07 04:06 UTC] val@php.net
It might be not the same bug. Can you please use bcompiler_write_file() call, not the bcompiler_write_class()? bcompiler_write_class() was written for PHP4 and should be considered as deprecated for PHP5. Also, please use bcompiler.c and php_bcompiler.h from CVS (you can get these files and replace ones you get in the .tar.gz package). If the problem won't perish, please report.
 [2006-02-07 15:26 UTC] zefram at zefram dot net
A couple of things... sorry, this comment will be messy.  
If you would like me to email anything, please ask.     
      
I stopped using bcompiler_write_class, because it wouldn't      
work.. and used _write_file. That's how I got it to work..     
     
I installed the CVS, and first tried to get it to work     
with 5.0.4. It didn't... Here's a udiff that gets it to     
compile:     
     
--- bcompiler.c.orig    Tue Feb  7 15:07:59 2006     
+++ bcompiler.c Tue Feb  7 15:10:10 2006     
@@ -2807,7 +2807,11 @@     
        /* new for 0.12 */     
        if (BCOMPILERG(current_write) >= 0x000c) {     
                    
BCOMPILER_DEBUG(("-----------------------------\nDEFAULT     
STATIC MEMBERS:\n"));     
+#ifdef ZEND_ENGINE_2_1     
                    
apc_serialize_hashtable(&zce->default_static_members,     
apc_serialize_zval_ptr TSRMLS_CC);     
+#else     
+                   
apc_serialize_hashtable(&zce->static_members,     
apc_serialize_zval_ptr TSRMLS_CC);     
+#endif     
        }     
        /* not sure if statics should be dumped... (val:     
surely not for ZE v2.1) */     
            
BCOMPILER_DEBUG(("-----------------------------\nSTATICS?:    
\n"));     
@@ -2994,7 +2998,11 @@     
                    
BCOMPILER_DEBUG(("-----------------------------\nDEFAULT     
STATIC MEMBERS:\n"));     
                DESERIALIZE_SCALAR(&exists, char);     
                apc_deserialize_hashtable(     
+#ifdef ZEND_ENGINE_2_1     
                        &zce->default_static_members,     
+#else     
+                       &zce->static_members,     
+#endif     
                        (void*) apc_create_zval,     
                        (void*) NULL,     
                        (int) sizeof(zval *),     
 
 
It compiles and works, but I get the following errors:    
    
/usr/local/src/bcompiler-0.7/bcompiler.c:1334:8: warning:        
extra tokens at end of #endif directive        
/usr/local/src/bcompiler-0.7/bcompiler.c: In function        
`apc_serialize_zend_class_entry':        
/usr/local/src/bcompiler-0.7/bcompiler.c:2813: warning:        
passing arg 1 of `apc_serialize_hashtable' from        
incompatible pointer type        
/usr/local/src/bcompiler-0.7/bcompiler.c: In function        
`apc_deserialize_zend_class_entry':        
/usr/local/src/bcompiler-0.7/bcompiler.c:3009: warning:        
passing arg 1 of `apc_deserialize_hashtable' from        
incompatible pointer type        
    
    
Then I upgraded to 5.1.2, it compiled fine... the only  
error was about the extra tokens at the end of #endif. I  
had to recompile the PHP files with bcompiler, however,  
but then it worked fine.  
  
I'll let you close this out, in case there's any more  
testing you would like me to do.
 [2006-02-12 11:37 UTC] val@php.net
Thank you for your diff, I made a mistake when fixing a bug. I fixed building with PHP5.0.x, although it's different from your diff (and resulting bytecode files will be different too - if you want bytecode compatibility, please update bcompiler.c from CVS and re-compile your bytecodes).
 [2006-02-12 11:38 UTC] val@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 07:01:29 2024 UTC