Bug 125476

Summary: lang/php5 segmentation fault after running any command line php script
Product: Ports & Packages Reporter: Nick Barkas <snb>
Component: Individual Port(s)Assignee: Alex Dupre <ale>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Nick Barkas 2008-07-10 17:00:12 UTC
PHP seg faults whenever I run a command line script, no matter what the script
is. It seems to properly execute everything in the script and just crashes when
it finishes up. I'm also using mod_php with Apache to serve MediaWiki on this
same machine, and that seems to work just fine as well. It's just the PHP CLI
that appears to have trouble. Here is a backtrace from gdb of the core file 
created:

snb@wiki1> gdb -c /var/cores/10038-6112-php.core /usr/local/bin/php
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging symbols found)...
Core was generated by `php'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libcrypt.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypt.so.3
Reading symbols from /lib/libm.so.4...(no debugging symbols found)...done.
Loaded symbols for /lib/libm.so.4
Reading symbols from /usr/local/lib/libxml2.so.5...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libxml2.so.5
Reading symbols from /lib/libz.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libz.so.3
Reading symbols from /usr/local/lib/libiconv.so.3...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libiconv.so.3
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /usr/local/lib/libsasl2.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libsasl2.so.2
Reading symbols from /usr/local/lib/libldap-2.3.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libldap-2.3.so.2
Reading symbols from /usr/local/lib/liblber-2.3.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/liblber-2.3.so.2
Reading symbols from /usr/lib/libssl.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libssl.so.4
Reading symbols from /lib/libcrypto.so.4...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypto.so.4
Reading symbols from /usr/local/lib/php/20060613/session.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/20060613/session.so
Reading symbols from /usr/local/lib/nss_ldap.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/nss_ldap.so.1
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000804343ba7 in __do_global_dtors_aux ()
   from /usr/local/lib/php/20060613/session.so
#2  0x000000080434a861 in _fini () from /usr/local/lib/php/20060613/session.so
#3  0x000000000076c8c0 in zval_used_for_init ()
#4  0x000000080071b3d4 in elf_hash () from /libexec/ld-elf.so.1
#5  0x000000080071e2d7 in dlclose () from /libexec/ld-elf.so.1
#6  0x0000000000518406 in zend_hash_apply_deleter ()
#7  0x000000000051849e in zend_hash_graceful_reverse_destroy ()
#8  0x000000000050c037 in zend_shutdown ()
#9  0x00000000004c950a in php_module_shutdown ()
#10 0x000000000059f001 in main ()

I don't know how useful this will be since PHP was not built with debugging
symbols. If I reinstall the port with WITH_DEBUG=true, strangely enough the
problem goes away--the PHP CLI no longer crashes.

How-To-Repeat: Even a very simple script can trigger this. For example:

snb@wiki1> cat foo.php
<?php echo "hello world\n"; ?>
snb@wiki1> php foo.php
hello world
zsh: segmentation fault (core dumped)  php foo.php
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2008-07-10 17:00:23 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ale

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Alex Dupre freebsd_committer freebsd_triage 2008-07-11 10:01:38 UTC
State Changed
From-To: open->feedback

This could be a 'faulty' order of extensions in extensions.ini. 
Try to change it until you find a working one (or see the order of debug build).
Comment 3 Nick Barkas 2008-07-11 12:31:25 UTC
Thanks, it looks like my extensions.ini somehow got a couple of  
extensions in it that I don't have installed. I removed those and the  
CLI no longer seg faults on my "hello world" script.

Since yesterday when I opened this PR, I have discovered that the  
problem was in fact also causing mod_php to crash Apache, but only  
once every few hours. I have restarted Apaache since fixing my  
extensions.ini, so hopefully those crashes will stop as well.
Comment 4 Alex Dupre freebsd_committer freebsd_triage 2008-07-11 13:11:01 UTC
State Changed
From-To: feedback->closed

Closed as submitter request.