From:             justo dot alonso at gmail dot com
Operating system: Linux (Suse 8.2)
PHP version:      4.3.11
PHP Bug Type:     LDAP related
Bug description:  Use of PHP functions when mod_ldap is loaded, hangs apache 
process

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


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

Reply via email to