php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40647 ldap_connect() fails when restarting Apache 2.0.55 via restart or graceful
Submitted: 2007-02-26 18:10 UTC Modified: 2007-03-05 10:26 UTC
From: csi92 at yahoo dot com Assigned:
Status: Not a bug Package: LDAP related
PHP Version: 4.4.5 OS: Red Hat Enterprise Linux AS rele
Private report: No CVE-ID: None
 [2007-02-26 18:10 UTC] csi92 at yahoo dot com
Description:
------------
I am connecting to an iPlanet LDAP. After starting Apache via ./apachectl start, the ldap_connect() function works fine.

If I stop and start Apache via ./apachectl stop, ./apachectl start, the ldap_connect function works fine.

If I restart Apache via ./apachectl restart OR ./apachectl graceful, the ldap_connect function fails and the page is blank. The page source is blank. With error reporting -- ini_set('error_reporting', E_ALL); -- No errors are reported.

If I stop/start Apache again via ./apachectl stop, ./apachectl start, the ldap_connect function works fine again.

Reproduce code:
---------------
<?php
ini_set('error_reporting', E_ALL);

$ds=ldap_connect("directory.fedex.com");  // prepare to connect to ldap
	
if ($ds) {
	echo "<p>LDAP Connection Successful<p>";
	$r=ldap_bind($ds);    // this is an "anonymous" bind
	$sr=ldap_search($ds, "o=fedex, c=US", "uid=322049"); // Search for "ovis" UID
	$info = ldap_get_entries($ds, $sr); // Get entries
	ldap_close($ds); // Close connection
}else{
	echo "<h4>Unable to connect to LDAP server</h4>";
}

?> 

Expected result:
----------------
LDAP Connection Successful

Actual result:
--------------
When I stop and start Apache using ./apachectl stop and then ./apachectl startssl I get "LDAP Connection Successful".

When us stop and start Apache using either ./apachectl restart or ./apachectl graceful I get a blank page. When I view source, it is blank also.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-26 18:22 UTC] tony2001@php.net
Check your error_log.
 [2007-02-26 18:31 UTC] csi92 at yahoo dot com
When I restart Apache via .apachectl restart I get the following in the Apache error log:

[Mon Feb 26 12:26:08 2007] [notice] SIGHUP received.  Attempting to restart
[Mon Feb 26 12:26:10 2007] [warn] RSA server certificate CommonName (CN) `viplabser14.intranet.XXXXXX.com' does NOT match server name!?
[Mon Feb 26 12:26:11 2007] [notice] Apache configured -- resuming normal operations

When I then execute the code in a browser, I get the following notice in the Apache error log:

[Mon Feb 26 12:26:26 2007] [notice] child pid 28463 exit signal Segmentation fault (11)
 [2007-02-26 18:32 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2007-02-26 19:09 UTC] csi92 at yahoo dot com
Where is the core file supposed to be generated?

Also, the instructions are referring to 1.x.x of Apache instead of 2.0.x. There is no sbin directory in our Apache 2.0.55 installation.
 [2007-02-26 19:26 UTC] csi92 at yahoo dot com
After running the script in the browser and it did NOT work, I tried running the same script from the command line (php zzz.php) and it worked at the command line.
 [2007-02-26 19:34 UTC] tony2001@php.net
>Where is the core file supposed to be generated?

Set CoreDumpDirectory directive in httpd.conf
 [2007-02-26 19:58 UTC] csi92 at yahoo dot com
(gdb) bt
#0  0x04bcf104 in ?? ()
#1  0x06046e48 in nzdst_terminate ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libnnz10.so
#2  0x06046b48 in nzdsi_initialize ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libnnz10.so
#3  0x03af45c1 in gsluinit ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#4  0x03af4920 in gsluizgcGetContext ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#5  0x03af84e3 in gslutcTraceWithCtx ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#6  0x03ac4520 in ldap_init ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#7  0x0108ac16 in zif_ldap_connect (ht=1, return_value=0xb73c752c, 
    this_ptr=0x0, return_value_used=1)
    at /opt/12345/software/php-4.4.5/ext/ldap/ldap.c:389
#8  0x0118a192 in execute (op_array=0xb73c283c)
    at /opt/12345/software/php-4.4.5/Zend/zend_execute.c:1681
#9  0x0117803d in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /opt/12345/software/php-4.4.5/Zend/zend.c:935
#10 0x011464ed in php_execute_script (primary_file=0xbfffc570)
    at /opt/12345/software/php-4.4.5/main/main.c:1757
#11 0x0118ff99 in php_handler (r=0xb72f7c50)
    at /opt/12345/software/php-4.4.5/sapi/apache2handler/sapi_apache2.c:581
---Type <return> to continue, or q <return> to quit---
#12 0x08088b7b in ap_run_handler ()
#13 0xb72f8ff8 in ?? ()
#14 0x00000000 in ?? ()
(gdb)
 [2007-02-26 20:03 UTC] csi92 at yahoo dot com
(gdb) frame 8
#8  0x0118a192 in execute (op_array=0xb73c283c)
    at /opt/12345/software/php-4.4.5/Zend/zend_execute.c:1681
1681                                                            ((zend_internal_function *) EX(function_state).function)->handler(EX(opline)->extended_value, EX(Ts)[EX(opline)->result.u.var].var.ptr, EX(object).ptr, return_value_used TSRMLS_CC);
(gdb)
 [2007-02-26 20:06 UTC] tony2001@php.net
A segfault somewhere deep inside the Oracle Instant Client doesn't seem PHP related to me.
Did you try reporting this to Oracle developers?
 [2007-02-27 16:06 UTC] csi92 at yahoo dot com
I've rebuilt php without the Oracle component and the problem indeed has gone away. I will follow up with Oracle. Thanks for the help.
 [2007-02-27 16:34 UTC] tony2001@php.net
Ok, feel free to reopen the report when/if you have any additional information.
 [2007-02-28 20:25 UTC] csi92 at yahoo dot com
Can you explain what exactly indicates to you that the Oracle instant client is the problem?
 [2007-02-28 20:37 UTC] tony2001@php.net
Sure. Just look at your backtrace, everything there points to the Oracle Instant Client.

#0  0x04bcf104 in ?? ()
#1  0x06046e48 in nzdst_terminate ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libnnz10.so
#2  0x06046b48 in nzdsi_initialize ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libnnz10.so
#3  0x03af45c1 in gsluinit ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#4  0x03af4920 in gsluizgcGetContext ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#5  0x03af84e3 in gslutcTraceWithCtx ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#6  0x03ac4520 in ldap_init ()
   from /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
#7  0x0108ac16 in zif_ldap_connect (ht=1, return_value=0xb73c752c, 
    this_ptr=0x0, return_value_used=1)
 [2007-03-02 20:43 UTC] csi92 at yahoo dot com
Here is the information I got from Oracle on this. It looks like an issue in the LDAP API implementation:

Bug 4944940
Problem statement:

INCORRECT USE OF NZ API, NZDSI_INITIALIZE, CAUSES CRASH 

The nz API nzdsi_initialize is thread-unsafe and should be used only during startup/initialization. In the OCI stack the ldap API calls this API for each thread which causes the app to crash. As a temporary fix we have made some changes in nz to resolve that issue (see bug 4405452). But this needs to be fixed in ldap API implementation. The nzctx context should be created just once. 

The stack when nzdsi_initialize is invoked - 
@ start_thread 
@ thread_main 
@ oci_connect 
@ OCIServerAttach 
@ kpuatch 
@ kwfcinit 
@ kwfnran 
@ niqname 
@ nnfsn2a 
@ nnfun2a 
@ nlolgobj 
@ nnfgrne 
@ nnflboot 
@ nnflcgc 
@ nnflobc 
@ nnflgcp 
@ nnfloiddisco 
@ ora_create_discov_hdl 
@ gslccx_Getgsluctx 
@ gsluizgcGetContext 
@ gsluinit 
@ nzdsi_initialize        # initializes nz context
 [2007-03-05 10:26 UTC] tony2001@php.net
>The nz API nzdsi_initialize is thread-unsafe and should be used 
>only during startup/initialization. 

PHP uses ldap_init() function knows nothing about NZ, nzdsi_initialize() etc.
Function ldap_init() opens a connection to LDAP server, so there is no way to avoid it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 16:01:31 2024 UTC