|  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: 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.
Bug Type:
From: wharmby at uk dot ibm dot com
New email:
PHP Version: OS:


 [2006-11-24 09:49 UTC] wharmby at uk dot ibm dot com
Using latest 5.2 snapshot (Nov24, 2006 0730 GMT) and 
building on Linux RHEL4 with the following basic 

     ./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 "" 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: 


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

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 =
		extension =

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:

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]

[Zend Modules]

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-24 10:29 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Sep 21 16:01:24 2023 UTC