php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32834 Use of PHP functions when mod_ldap is loaded, hangs apache process
Submitted: 2005-04-26 12:22 UTC Modified: 2005-05-21 00:10 UTC
From: justo dot alonso at gmail dot com Assigned:
Status: Not a bug Package: LDAP related
PHP Version: 4.3.11 OS: Linux (Suse 8.2)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: justo dot alonso at gmail dot com
New email:
PHP Version: OS:

 

 [2005-04-26 12:22 UTC] justo dot alonso at gmail dot com
Description:
------------
I have an Apache 2.0.54 server with mod_ldap and mod_auth_ldap modules loaded. The PHP is a module of Apache. When I use the code below, the first 2 times it works, but the third, the apache server process hangs.

I've tried it with Apache 1.3.27 and hungs, too. It seems like there's some kind of conflict between mod_ldap and the php module, because when I disable mod_ldap all works fine.

Openldap library: openldap2-client-2.1.12-44 (Suse release)
PHP config.nice file:

CFLAGS='-O2 -march=i486 -mcpu=i686 -fPIC -DHAVE_LIBDL=1 -I/usr/include/ucd-snmp -I/usr/lib/SunJava2-1.4/include -I/usr/lib/SunJava2-1.4/include/linux' \
'./configure' \
'--prefix=/usr/share' \
'--datadir=/usr/share/php' \
'--bindir=/usr/bin' \
'--libdir=/usr/share' \
'--includedir=/usr/include' \
'--with-_lib=lib' \
'--with-config-file-path=/etc' \
'--with-exec-dir=/usr/lib/php/bin' \
'--disable-debug' \
'--enable-bcmath' \
'--enable-calendar' \
'--enable-ctype' \
'--enable-dbase' \
'--enable-discard-path' \
'--enable-exif' \
'--enable-filepro' \
'--enable-force-cgi-redirect' \
'--enable-ftp' \
'--enable-gd-imgstrttf' \
'--enable-gd-native-ttf' \
'--enable-inline-optimization' \
'--enable-magic-quotes' \
'--enable-mbstr-enc-trans' \
'--enable-mbstring' \
'--enable-mbregex' \
'--enable-memory-limit' \
'--enable-safe-mode' \
'--enable-shmop' \
'--enable-sigchild' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-track-vars' \
'--enable-trans-sid' \
'--enable-versioning' \
'--enable-wddx' \
'--enable-yp' \
'--with-bz2' \
'--with-dom=/usr/include/libxml2' \
'--with-ftp' \
'--with-gdbm' \
'--with-gettext' \
'--with-gmp' \
'--with-imap=yes' \
'--with-jpeg-dir=/usr' \
'--with-ldap=yes' \
'--with-mcal=/usr' \
'--with-mcrypt' \
'--with-mysql=/usr' \
'--with-ndbm' \
'--with-png-dir=/usr' \
'--with-readline' \
'--with-snmp' \
'--with-t1lib' \
'--with-tiff-dir=/usr' \
'--with-ttf' \
'--with-freetype-dir=yes' \
'--with-xml' \
'--with-xpm-dir=/usr/X11R6' \
'--with-zlib=yes' \
'--with-qtdom=/usr/lib/qt3' \
'--with-gd' \
'--with-openssl=/usr' \
'--with-imap-ssl' \
'--enable-xslt' \
'--with-xslt-sablot' \
'--with-iconv' \
'--with-mm' \
'i386-suse-linux' \
"$@"




Reproduce code:
---------------
<?php
echo "<!-- before connect to LDAP -->\n";
$conn = ldap_connect( $LDAP_ACTIVE_SERVER );
if ($conn) {
  if( ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3)
      && ldap_set_option($conn, LDAP_OPT_DEREF, 0) 
      && ldap_set_option($conn,LDAP_OPT_REFERRALS,FALSE)) {
      if( ($r = ldap_bind($conn, $LDAP_ACTIVE_BINDDN,
           $LDAP_ACTIVE_BINDPA )) ) {
         echo "<!-- before the search -->\n";
         flush();

         $sr = ldap_search($conn, $LDAP_ACTIVE_BASEDN,
               $LDAP_ACTIVE_FILTER, $LDAP_ACTIVE_ATTRIB, 
               0, 2, 5, LDAP_DEREF_NEVER );

         if( ldap_count_entries($conn, $sr) == 1 ) {
             $entry = ldap_first_entry( $conn, $sr );
             $dn = ldap_get_dn( $conn, $entry );

             echo "<!-- the DN: $dn -->\n";
             flush();

             if( $dn ) {
                 $auth = ldap_bind( $conn,$dn, 
                         $_SERVER["PHP_AUTH_PW"] );

                 if( $auth ) {
                     $is_ok = 1;
                     echo "<!-- bind success -->\n";
                     flush();
                  }
              }
         }
         ldap_free_result( $sr );
      }
  } else {
     echo "<!-- unable to set options -->\n";
  }
  ldap_close($conn);
}
?>


Expected result:
----------------
HTTP/1.1 200 OK
Date: Tue, 26 Apr 2005 09:15:35 GMT
Server: Apache
X-Powered-By: PHP/4.3.11
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
Content-Language: es

<!-- before connect to LDAP -->
<!-- before the search -->
<!-- the DN: CN=Justo Alonso  Achaques -->
<!-- bind success -->


Actual result:
--------------
A backtrace with gdb, with a ctrl-C because the server don't crash

#0  0x4026df0d in malloc_consolidate () from /lib/libc.so.6
#1  0x4026da93 in _int_malloc () from /lib/libc.so.6
#2  0x4026c898 in malloc () from /lib/libc.so.6
#3  0x4071b177 in _emalloc () from /usr/lib/apache2-prefork/libphp4.so
#4  0x4071b824 in _estrndup () from /usr/lib/apache2-prefork/libphp4.so
#5  0x40707233 in php_register_variable_safe () from /usr/lib/apache2-prefork/libphp4.so
#6  0x407071ac in php_register_variable () from /usr/lib/apache2-prefork/libphp4.so
#7  0x40707b36 in _php_import_environment_variables () from /usr/lib/apache2-prefork/libphp4.so
#8  0x406fd03f in php_hash_environment () from /usr/lib/apache2-prefork/libphp4.so
#9  0x406fbb7a in php_request_startup () from /usr/lib/apache2-prefork/libphp4.so
#10 0x40740e01 in php_apache_request_ctor () from /usr/lib/apache2-prefork/libphp4.so
#11 0x4074146d in php_handler () from /usr/lib/apache2-prefork/libphp4.so
#12 0x08069d38 in ap_run_handler ()
#13 0x0806a449 in ap_invoke_handler ()
#14 0x080665da in ap_process_request ()
#15 0x0806100e in _start ()
#16 0x080753d8 in ap_run_process_connection ()
#17 0x080757be in ap_process_connection ()
#18 0x08067ff4 in ap_graceful_stop_signalled ()
#19 0x080681a2 in ap_graceful_stop_signalled ()
#20 0x080682bc in ap_graceful_stop_signalled ()
#21 0x08068b1d in ap_mpm_run ()
#22 0x0806feaf in main ()
#23 0x4020b8ae in __libc_start_main () from /lib/libc.so.6


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-27 12:27 UTC] sniper@php.net
Get the latest snapshot here: 

  http://snaps.php.net/php4-STABLE-latest.tar.gz

And compile that with this configure line: (And EXACTLY THIS!)

# ./configure --disable-all --with-ldap --with-apxs2 --enable-debug
# make 

The one you pasted here is definately NOT the one
used to configure the libphp4.so you have since that one
will only build CGI binary. And that one is also trying to outsmart the PHP configure -> not supported!

 [2005-05-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-05-20 17:17 UTC] opencms at aleph-null dot tv
I am having the same problem on Debain Sarge (testing).

Apache version: 2.0.54-3
PHP version: 4.3.10-13
OpenLDAP version: 2.2.23-5

My case is similar to the above. I am using mod_ldap and mod_auth_ldap in Apache. I can usually make between 2 and 5 connections to LDAP through PHP before Apache hangs.

'Apache hangs' == it uses around 99% of the CPU for 30 seconds (or whatever the maximum time is set for a PHP script to execute), then the process stops. The client receives no notification (i.e. it sits there waiting for a response), but the log file shows an error that the script exceded the maximum execution time.

Config (from phpinfo):
'../configure' '--prefix=/usr' '--with-apxs2=/usr/bin/apxs2' '--with-config-file-path=/etc/php4/apache2' '--enable-memory-limit' '--disable-debug' '--with-regex=php' '--disable-rpath' '--disable-static' '--with-pic' '--with-layout=GNU' '--with-pear=/usr/share/php' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db4' '--with-iconv' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--disable-xml' '--with-expat-dir=/usr' '--with-xmlrpc' '--enable-yp' '--with-zlib' '--without-pgsql' '--with-kerberos=/usr' '--with-openssl=/usr' '--with-zip=/usr' '--enable-dbx' '--with-mime-magic=/usr/share/misc/file/magic.mime' '--with-exec-dir=/usr/lib/php4/libexec' '--without-mm' '--without-mysql' '--without-sybase-ct'

LDAP info (again, from phpinfo):
LDAP Support 	enabled
RCS Version 	$Id: ldap.c,v 1.130.2.11 2005/01/19 00:28:49 sniper Exp $
Total Links 	0/10
API Version 	2004
Vendor Name 	OpenLDAP
Vendor Version 	20130
 [2005-05-20 23:25 UTC] justo dot alonso at gmail dot com
Please refer to http://issues.apache.org/bugzilla/show_bug.cgi?id=34618 for the solution... the bug is in mod_ldap module of apache, not in the php module.

I'm using apache 2.0.53 to solve the problem.
 [2005-05-21 00:10 UTC] tony2001@php.net
No PHP bug -> bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 20:01:29 2024 UTC