Bug 31366

Summary: Stopping Apache2 service causes libapr.dll to crash twice when mod_auth_ldap and util_ldap modules are loaded and caching is enabled (LDAPSharedCacheSize <> 0)
Product: Apache httpd-2 Reporter: Alex Yu <ayu168>
Component: mod_authn_ldapAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED INVALID    
Severity: critical CC: rolf.baenziger, taffy-tyler6464
Priority: P3    
Version: 2.0.52   
Target Milestone: ---   
Hardware: PC   
OS: Windows Server 2003   

Description Alex Yu 2004-09-22 16:11:55 UTC
Apache 2.0.51 running on a Windows Server 2003 machine.

In Apache Service Monitor, two crash windows appear after the log displays "The
Apache2 service is stopping."

Faulting application Apache.exe, version 2.0.51.0, faulting module libapr.dll,
version 0.0.0.0, fault address 0x00004ae0.

Faulting application Apache.exe, version 2.0.51.0, faulting module libapr.dll,
version 0.0.0.0, fault address 0x00004ae0.

No problem starting the servie.  Only sees this problem when these two modules
are loaded.

LoadModule ldap_module modules/util_ldap.so
LoadModule auth_ldap_module modules/mod_auth_ldap.so
Comment 1 Graham Leggett 2004-10-17 18:51:09 UTC
Can you check if this problem still appears in either v2.0.52 or the latest
snapshot?

There have been some fixes which have affected crashes on shutdown.
Comment 2 Zerox Millienium 2004-10-19 14:56:14 UTC
I have the same problem with v2.0.52 running on Windows XP Professional with
Service Pack 2. The problem is exactly the same as described earlier that the
dll will report a application fault when attempt to shutdown the Apache2 web
service.
Comment 3 Jeff Rollette 2004-10-20 20:14:35 UTC
I am having the same symptoms.  I am runnging Win2K3 with Apache 2.0.52.
The problem occurs with both a precompiled and complied version of Apache.
I have mod_auth_ldap and util_ldap modules loaded.  The have tired compiling 
with and without the 2.0.52 "util_ldap_cache_mgr.c.patch".

If LDAPSharedCacheSize is set to 0 (disable caching) I can successfully stop 
the Apache service.  If is set at the default of 102400 (enable caching) the 
libapr.dll crashes twice as reported by otheres.

Authentication works with and without the cache enabled.  The service just will 
not stop or restart without the libapr.dll crashes.

I don't know what else to try.
Comment 4 Jeff Rollette 2004-10-21 12:10:59 UTC
I have been able to reproduce this bug on two different servers.  I have tried 
using the LDAPSharedCacheFile directive to specify a file.  LDAP functions 
normally using memory or a file for caching but the libapr.dll still crashes 
twice when the Apache service stops.  I am currently running with caching 
disabled on two servers while I try to resolve this.  While LDAP caching works 
fine, the danger is that should some other excpetion trigger the Apache 
service to restart, the service will be down.

Can any anyone else verify that disabling caching is a workaround for this bug?
Comment 5 Benjamin 2004-12-15 22:16:58 UTC
i have the same problem at Win2K3 with Apache 2.0.52. with a normal precompiled .msi

to reproduce the crash i only had to change in httpd.conf:

LoadModule ldap_module modules/util_ldap.so 
LDAPSharedCacheSize 1000000

and without caching (LDAPSharedCacheSize 0) it seems to work, but its very very
slow (i use svn with authn_ldap) so i decided to leave the cach working and i
hope that someone fixes the bug ;-)
Comment 6 Graham Leggett 2005-01-21 22:32:32 UTC
Can you test for me whether this bug exists in the latest version of httpd v2.1?

The code in httpd v2.0 is impractical to fix without major changes to APR v0.9,
so the focus has instead shifted to make httpd v2.1 work with APR v1.1 or later.
Comment 7 Paul Querna 2005-06-03 01:50:28 UTC
Looking for feedback from the reporter.
Comment 8 William A. Rowe Jr. 2005-09-07 18:06:55 UTC
  There were many LDAP cache bugs in Apache 2.0.53 and prior, I'd strongly
  suggest you upgrade to Apache 2.0.55 once it becomes available.

  If your LDAP server is sitting on the same local LAN, you are much better
  off simply turning off the LDAP cache.  I even suspect that wldap32 (the
  Microsoft LDAP client) has some internal caching, making the Apache
  cache redundant.

  In Apache 2.1 this code has been nearly completely refactored, and is much,
  much cleaner.  That's why ldap is experimental in 2.0, and will be supported
  (release quality) in Apache 2.2.
Comment 9 Vadim Chekan 2005-10-23 01:32:04 UTC
This buf is still actual for 2.0.55
I think I've fixed it.

It's util_ldap_cache.c:util_ldap_cache_module_kill()
...
if (st->cache_shm != NULL) {
   apr_status_t result = apr_shm_destroy(st->cache_shm);
       st->cache_shm = NULL;
       apr_file_remove(st->cache_file, st->pool);

It should be checked either we do have cache file befor attempt to delete it.
Because initially it is NULL and it remains null unless
LDAPSharedCacheFile is set in config. And if shared memory has been
initialized it does not mean that file has been created.
This bug appears only on Win because Win attempts to recode the string
(file name) to Unicode and null reference fails in this function.

This works for me:
if (st->cache_shm != NULL) {
   apr_status_t result = apr_shm_destroy(st->cache_shm);
       st->cache_shm = NULL;
       if(st->cache_file != NULL) {
           apr_file_remove(st->cache_file, st->pool);
               st->cache_file = NULL;


This works for the situation when there is no LDAPSharedCacheFile
attribute in config.
But when there is one, it still crashes. I'm looking ito it. There is something
wrong with releasing nodes.
Comment 10 Michael A. McAngus 2005-11-10 20:59:18 UTC
This error still occurs while using:
    Apache 2.0.55 - apache_2.0.55-win32-x86-no_ssl.msi binary installation
    SunONE Directory Server v5.1 SP2 
    Windows XP Professional SP2
    Windows 2003 Standard Server SP1

Windows Event Message (both OSs):
    Faulting application Apache.exe, version 2.0.55.0, faulting module 
    libapr.dll, version 0.9.7.0, fault address 0x00004902.

This message occurs twice in the Event log for each shutdown event, approx 5
seconds between the two messages.

I do not have any of the LDAP Cache directives set in the httpd.conf file.  The
Apache2 error.log contains the following (timestamps removed) for one
startup/shutdown cycle:
    [notice] LDAP: Built with Microsoft LDAP SDK
    [notice] LDAP: SSL support available
    [notice] Apache/2.0.55 (Win32) configured -- resuming normal operations
    [notice] Server built: Oct  9 2005 19:16:56
    [notice] Parent: Created child process 3392
    [notice] LDAP: Built with Microsoft LDAP SDK
    [notice] LDAP: SSL support available
    [notice] Child 3392: Child process is running
    [notice] Child 3392: Acquired the start mutex.
    [notice] Child 3392: Starting 250 worker threads.
    [notice] Parent: Received shutdown signal -- Shutting down the server.
    [notice] Child 3392: Exit event signaled. Child process is ending.
    [notice] Child 3392: Released the start mutex
    [notice] Child 3392: Waiting for 250 worker threads to exit.
    [notice] Child 3392: All worker threads have exited.
    [notice] Child 3392: Child process is exiting
    [notice] Parent: Child process exited successfully.
Comment 11 photto35 2006-04-14 10:10:33 UTC
This is still in 2.2.0

Last month i had it on W Server2003, now i have it on W XP Sp2.

http://www.otto.net/img/failure.gif

Fixes in the httpd.conf didnt help me.. 

So.. is there a solution or workaround..? 
Comment 12 photto35 2006-04-14 10:13:55 UTC
(In reply to comment #11)
> This is still in 2.2.0
> Last month i had it on W Server2003, now i have it on W XP Sp2.
> http://www.otto.net/img/failure.gif
> Fixes in the httpd.conf didnt help me.. 
> So.. is there a solution or workaround..? 

[Edit] Sorry it's :
http://www.otto2.net/img/failure.gif


Comment 13 William A. Rowe Jr. 2008-06-05 13:31:19 UTC
Obtaining and Unpacking into the installed program files\apache group\apache2
directory the corresponding -symbols.zip file for your installed Apache version
from;

http://archive.apache.org/dist/httpd/binaries/win32/symbols/

and following directions about capturing the crash dump with dr. watson that are
posted at

http://httpd.apache.org/dev/debugging.html

you will greatly help isolate this error.  Providing specifics of how you
invoked ab would also help (command line options).

Please do this for httpd 2.2.9 when it is released in the coming week or so and
report back, there are a host of fixes applied to the sources and ldap support.
Comment 14 Jeff Trawick 2012-08-20 00:01:47 UTC
bug in NEEDINFO state for years...

If still reproducible with latest 2.2.x, follow the debugging instructions posted previously.