php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58153 Inheritance/Property causing segfault in fcgi
Submitted: 2008-04-14 08:00 UTC Modified: 2008-06-26 08:21 UTC
From: shadda at gmail dot com Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5_3 CVS-2008-04-14 (dev) OS: Debian/Lenny
Private report: No CVE-ID: None
 [2008-04-14 08:00 UTC] shadda at gmail dot com
Description:
------------
I'm running lighttpd 1.4.19 and php-5.3 (latest snap) on Debian/Lenny with Fastcgi. 

Everything works expected until I enable APC.

If I declare an interface, and implement it in a class, as soon as I define any class properties it causes the (2nd) process to segfault. 

I can call php-cgi test.php from the shell and it will run perfectly fine. If I try php-cgi -T 2 test.php it segfaults on the second attempt.

Under lighty, my logs look like this:

2008-04-14 09:38:36: (mod_fastcgi.c.2489) unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: unix:/tmp/php.sock
2008-04-14 09:38:36: (mod_fastcgi.c.3299) response not received, request sent: 860 on socket: unix:/tmp/php.sock for /adk/invoke.php , closing connection

I ran gdb --args php-cgi -T 2 test.php

Here is the result:

Starting program: /usr/local/bin/php-cgi -T 2 test.php
Failed to read a valid object file image from memory.
[Thread debugging using libthread_db enabled]
[New Thread 0xb7c5b9e0 (LWP 21722)]
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

X-Powered-By: PHP/5.3.0-dev
Content-type: text/html


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7c5b9e0 (LWP 21722)]
0x083323bb in gc_remove_zval_from_buffer (zv=0x855eb50) at /root/php5.3-200804130830/Zend/zend_gc.h:189
189             root->next->prev = root->prev;
(gdb) bt
#0  0x083323bb in gc_remove_zval_from_buffer (zv=0x855eb50) at /root/php5.3-200804130830/Zend/zend_gc.h:189
#1  0x08300126 in _zval_ptr_dtor (zval_ptr=0x855eb20, __zend_filename=0x846eecc "/root/php5.3-200804130830/Zend/zend_variables.c",
    __zend_lineno=175) at /root/php5.3-200804130830/Zend/zend_execute_API.c:421
#2  0x0830ef16 in _zval_ptr_dtor_wrapper (zval_ptr=0x855eb20) at /root/php5.3-200804130830/Zend/zend_variables.c:175
#3  0x0831e20b in zend_hash_clean (ht=0x855e918) at /root/php5.3-200804130830/Zend/zend_hash.c:552
#4  0xb76b3ca3 in apc_free_class_entry_after_execution (src=0x855e8d0) at /root/pecl/apc/apc_compile.c:2118
#5  0xb76b7c6d in apc_request_shutdown () at /root/pecl/apc/apc_main.c:599
#6  0xb76afb72 in zm_deactivate_apc (type=1, module_number=26) at /root/pecl/apc/php_apc.c:308
#7  0x08318674 in module_registry_cleanup (module=0x84c2920) at /root/php5.3-200804130830/Zend/zend_API.c:2113
#8  0x0831e67e in zend_hash_apply (ht=0x8483840, apply_func=0x8318645 <module_registry_cleanup>)
    at /root/php5.3-200804130830/Zend/zend_hash.c:673
#9  0x08310602 in zend_deactivate_modules () at /root/php5.3-200804130830/Zend/zend.c:850
#10 0x082a6cdf in php_request_shutdown (dummy=0x0) at /root/php5.3-200804130830/main/main.c:1497
#11 0x0839f6f6 in main (argc=4, argv=0xbfb778f4) at /root/php5.3-200804130830/sapi/cgi/cgi_main.c:2009

I have tried APC version 3.0.18 and the latest CVS. This is occuring on two systems.


Reproduce code:
---------------
<?php

	interface I { 
	
	}
	
	class A implements I {
		
		public $a = 'foo';
		
	}
	
?>

Expected result:
----------------
Desired/expected result would be to have the code run without a segfault.

Actual result:
--------------
sin:/www# php-cgi -T 2 test.php
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

Segmentation fault


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-15 09:42 UTC] gopalv82 at yahoo dot com
Interesting GC issue.

Will pull 5_3 and re-test sometime soon.
 [2008-04-30 07:19 UTC] gopalv82 at yahoo dot com
Looks like it happens in all SAPIs, working out what the GC needs to work properly.
 [2008-04-30 09:24 UTC] gopalv82 at yahoo dot com
For the purpose of tracking (since this one's a doozy)

Zend GC changed the size of zval to accomodate the GC info, so all the data copied in/out of APC needs to use the larger struct size to work appropriately.

Look at the redefinition of ALLOC_ZVAL in zend_gc.h for more info
 [2008-05-23 18:33 UTC] gopalv82 at yahoo dot com
A hacked up/band-aid fix is in the 3.0.19 release.

Mind testing it?
 [2008-05-27 15:15 UTC] shadda at gmail dot com
Huzzah! It works. Thank you, sir :)
 [2008-06-26 08:21 UTC] gopalv82 at yahoo dot com
Fixed for real in apc-3.1.x-dev branch

Checkout APC cvs HEAD & test it, it probably has more bugs :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 10:01:33 2024 UTC