Subject: pkg/16198: php4-imap and php4-mcrypt (libmcrypt 2.4.x) clash
To: None <gnats-bugs@gnats.netbsd.org>
From: None <netbsd@precedence.co.uk>
List: netbsd-bugs
Date: 04/04/2002 17:50:56
>Number:         16198
>Category:       pkg
>Synopsis:       If php4-imap and php4-mcrypt (based on libmcrypt 2.4.x), httpd SEGVs
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 04 08:52:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Stephen Borrill
>Release:        NetBSD 1.5.2
>Organization:
Precedence Technologies Ltd
>Environment:
	
System: NetBSD netmanager 1.5.2 NetBSD 1.5.2 (phil) #1: Thu Jan 31 11:08:49 GMT 2002 root@netmanager:/usr/src/sys/arch/i386/compile/phil i386


>Description:
On i386, with a plain 1.5.2 installation and a -current pkgsrc, attempting to use
php4-imap and php4-mcrypt together in conjunction with ap-php4 will cause
the Apache httpd child process to SEGV with errors like:

Invalid shared object handle 0x480c2400
[Thu Apr  4 15:53:41 2002] [notice] child pid 29440 exit signal
   Segmentation fault (11)

Removing the mcrypt.so line from php.ini allows imap to work again.
Statically linking the mcrypt and imap php modules into libphp4.so gives
pretty much the same error:

[Thu Apr  4 16:09:16 2002] [notice] child pid 20482 exit signal
  Segmentation fault (11)
[Thu Apr  4 16:09:26 2002] [notice] child pid 20483 exit signal
  Bus error (10)
 
Building a non-pkgsrc version of libmcrypt-2.2.7 and then hacking
php4-mcrypt/Makefile to use that instead of the libmcrypt package gives a
working system, therefore the problem appears to be libmcrypt-2.4.x specific.

>How-To-Repeat:
On i386:
Compile up ap-php4 and dependencies. Compile php4-mcrypt and php4-imap and
dependencies. Edit /usr/pkg/etc/php.ini and add:
extension=mcrypt.so
extension=imap.so

Run a piece of HTML with something like:

$mbox=imap_open("{localhost:143/notls}INBOX","username","password",OP_HALFOPEN);

httpd will give a segmentation fault. 
>Fix:
It's a nasty workaround and not a fix, but:

Download:

ftp://mcrypt.hellug.gr/pub/mcrypt/libmcrypt/old/libmcrypt-2.2.7.tar.gz
Extract, configure and make install.

Alter security/php4-mcrypt/Makefile:
--- Makefile.orig       Fri Mar  1 15:58:38 2002
+++ Makefile    Thu Apr  4 17:41:48 2002
@@ -7,7 +7,8 @@

 .include "../../www/php4/Makefile.module"

-CONFIGURE_ARGS+=       --with-${MODNAME}=shared,${BUILDLINK_DIR}
+#CONFIGURE_ARGS+=      --with-${MODNAME}=shared,${BUILDLINK_DIR}
+CONFIGURE_ARGS+=       --with-${MODNAME}=shared,/usr/local

-.include "../../security/libmcrypt/buildlink.mk"
+#.include "../../security/libmcrypt/buildlink.mk"
 .include "../../mk/bsd.pkg.mk"

Make php4-mcrypt and install. imap functions in PHP will now work.

A slightly neater temporary solution would be to add a libmcrypt22 package
which installs 2.2.7 instead of 2.4.x and then make php4-mcrypt depend on
that (and register a clash with libmcrypt).

None of these workarounds solve the core problem: PHP mcrypt module based on
libmcrypt 2.4 doesn't work with imap PHP module.
>Release-Note:
>Audit-Trail:
>Unformatted: