From:             wharmby at uk dot ibm dot com
Operating system: Linux RHEL4 
PHP version:      5CVS-2006-11-24 (snap)
PHP Bug Type:     Reproducible crash
Bug description:  Segmentation fault in imap initialization due to missing 
module dependency 

Description:
------------
Using latest 5.2 snapshot (Nov24, 2006 0730 GMT) and 
building on Linux RHEL4 with the following basic 
configuration: 

     ./configure --disable-all --with-imap=/opt/imap-2004g
      --with-imap-ssl --enable-shared 
      --enable-session=shared  --enable-debug 
      --enable-maintainer-zts --enable-cli --disable-cgi

with "extension=session.so" added to php.ini the resulting CLI fails on
startup, i.e. something as simple as "php -m" seg faults. 

Looking at the core produced on the seg fault with GDB gives
the following back trace: 

                http://pastebin.ca/256507

The reason for the fault is that imap initialization assumes
that standard/file initialization has already completed and 
acquired and initialized "file globals". Unfortunately imap 
does not have a defined module  dependency on standard so
the module initialization order is not guaranteed to be
correct.

The reason for the crash in this case is that PHP 5.2 has 
defined a new dependency between standard and session so the
order of session and standard in the startup order will be 
flipped by zend_sort_modules() when it sorts the module_registry. 

With session defined as shared and imap statically linked 
the resulting module initialization order will be 

   session .......imap.....standard 

and we fail due to the unspecified dependency between imap 
and standard

I get same seg fault if imap is also compiled as a shared module; the key
to reproducing the problem is configuring PHP with imap support with
session defined as shared and ZTS enabled.  

If both session and imap are defined as shared the problem 
can be resolved by ordering the php.ini entries as follows: 

                extension = session.so
                extension = imap.so

as this results in a initialization order of 

   session..... standard ...imap 

and all is OK. But with imap linked statically there is no
workaround to the issue

The problem is easily resolved by defining the missing
dependency between imap and standard. 

The following patch adds the necessary dependency:

          http://pastebin.ca/256510


Reproduce code:
---------------
Build with above config on Linux and "php -m" fails with 
a seg fault.

Expected result:
----------------
[EMAIL PROTECTED] php5.2-200611240730]# php -m
[PHP Modules]
date
imap
Reflection
session
standard

[Zend Modules]


Actual result:
--------------
[EMAIL PROTECTED] php5.2-200611240730]# php -m
Segmentation fault (core dumped)

-- 
Edit bug report at http://bugs.php.net/?id=39613&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39613&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39613&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39613&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39613&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39613&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39613&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39613&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39613&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39613&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39613&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39613&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39613&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39613&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39613&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39613&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39613&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39613&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39613&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39613&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39613&r=mysqlcfg

Reply via email to