php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39613 Segmentation fault in imap initialization due to missing module dependency
Submitted: 2006-11-24 09:49 UTC Modified: 2006-11-24 10:29 UTC
From: wharmby at uk dot ibm dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5CVS-2006-11-24 (snap) OS: Linux RHEL4
Private report: No CVE-ID:
 [2006-11-24 09:49 UTC] wharmby at uk dot ibm dot com
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:
----------------
[root@rhel4 php5.2-200611240730]# php -m
[PHP Modules]
date
imap
Reflection
session
standard

[Zend Modules]


Actual result:
--------------
[root@rhel4 php5.2-200611240730]# php -m
Segmentation fault (core dumped)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-24 10:29 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 20:02:01 2014 UTC