Steve Waltner wrote:http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21719
Since my submitted bug hasn't been resolved in the 9 months since I first reported it, I figure it's about time I try and resolve this problem myself since I do have the source code. I've done a partial debug on the failure but can't get everything figured out since I can't get DDD/gdb to debug some of the code (coming from apr_ldap_url.c).
I'm currently using the 2.0.49 source tree for my testing. The problem starts in mod_auth_ldap.c. When I load the source in ddd, I get an error stating:
Line 1 of "mod_auth_ldap.c" is at address 0x2ebd4 <derive_codepage_from_lang> but contains no code.
You need two things:
1) compile with debug symbols retained which you get when building apache with --enable-maintainer-mode
2) make sure to load the library from gdb (or DDD's gdb console):
gdb> sharedlib apr
or whichever lib it is.
You may find some useful notes here:
http://perl.apache.org/docs/2.0/devel/debug/c.html
There are for debugging mod_perl 2.0, but most of it applies to any other shared C library.
Thanks for the information but it still doesn't seem to be working correctly. If this is a topic that I should take over to a gdb mailing list, let me know. I started with a clean unpack of the Apache 2.0.49 source tarball and configure it with the following command:
./configure --enable-maintainer-mode --with-ldap --enable-ldap --enable-auth-ldap --prefix=/tmp/apache-test
make
make install
cp /tmp/httpd.conf /tmp/apache-test/conf/httpd.conf
I made the following changes to the httpd.conf file. This go into the cgi-bin Directory block since I'm trying to protect the cgi-bin directory:
=================
dumbo:/tmp/apache-test> diff -c /tmp/apache-test/conf/httpd-std.conf /tmp/httpd.conf
*** /tmp/apache-test/conf/httpd-std.conf Thu May 6 10:10:55 2004
--- /tmp/httpd.conf Wed May 5 09:15:22 2004
***************
*** 609,614 ****
--- 609,621 ----
Options None
Order allow,deny
Allow from all
+
+ AuthName "Admin Page"
+ AuthType Basic
+ AuthLDAPEnabled on
+ AuthLDAPAuthoritative on
+ AuthLDAPURL ldap://ldap.lsil.com/ou=lsil.com,o=LSI%20Logic?uid
+ require valid-user
</Directory>
# dumbo:/tmp/apache-test> =================
Trying this with straight gdb instead of ddd/gdb, I get the following:
=====================
dumbo:/tmp/apache-test> gdb bin/httpd
GNU gdb 6.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.9"...
(gdb) info shared
No shared libraries loaded at this time.
(gdb) b mod_auth_ldap.c:702
Breakpoint 1 at 0x2fec8: file mod_auth_ldap.c, line 702.
(gdb) run -k start
Starting program: /tmp/apache-test/bin/httpd -k start
Breakpoint 1, mod_auth_ldap_parse_url (cmd=0xffbffb78, config=0xea998,
url=0xeaa80 "ldap://ldap.lsil.com/ou=lsil.com,o=LSI%20Logic?uid")
at mod_auth_ldap.c:702
702 result = apr_ldap_url_parse(url, &(urld));
(gdb) info shared
From To Syms Read Shared Object Library
0xff3847f4 0xff3929d0 Yes /tmp/apache-test/lib/libaprutil-0.so.0
0xff20d5a0 0xff2cb564 Yes /usr/lib/libldap.so.5
0xff342638 0xff35aa48 Yes /tmp/apache-test/lib/libexpat.so.0
0xff1c8064 0xff1dd4e4 Yes /tmp/apache-test/lib/libapr-0.so.0
0xff3104bc 0xff310634 Yes /usr/lib/libsendfile.so.1
0xff1a2494 0xff1a51b8 Yes /usr/lib/librt.so.1
0xff171a40 0xff180f24 Yes /usr/lib/libm.so.1
0xff1535e0 0xff1595a4 Yes /usr/lib/libsocket.so.1
0xff0940f8 0xff10098c Yes /usr/lib/libnsl.so.1
0xff028ab8 0xff057134 Yes /usr/lib/libresolv.so.2
0xff0039f4 0xff003ffc Yes /usr/lib/libpthread.so.1
0xff3b0704 0xff3b075c Yes /usr/lib/libdl.so.1
0xfef1ca08 0xfef9f038 Yes /usr/lib/libc.so.1
0xfefd04f4 0xfefd1510 Yes /usr/lib/libmd5.so.1
0xfeee1a8c 0xfeee7dd4 Yes /usr/lib/libaio.so.1
0xfeec09a0 0xfeec2950 Yes /usr/lib/libmp.so.2
0xfeeb0420 0xfeeb34e8 Yes /usr/platform/SUNW,Ultra-Enterprise/lib/libc_psr.so.1
0xfee873b0 0xfee96100 Yes /usr/lib/libthread.so.1
(gdb) b apr_ldap_url.c:255
No line 255 in file "apr_ldap_url.c".
(gdb) b ldap_url_parse_ext
Function "ldap_url_parse_ext" not defined.
Make breakpoint pending on future shared library load? (y or [n])
(gdb) quit
The program is running. Exit anyway? (y or n) y
dumbo:/tmp/apache-test>
=====================
I haven't turned off the autoload shared libraries, so gdb does try to load debug symbols from the libaprutil file, but it still appears as though it's not working properly since I can't set a breakpoint in apr_ldap_url.c or step into the function.
Looking at the output of make, it appears as though the build process does the needed debugging flags...
=====================
make[4]: Entering directory `/tmp/httpd-2.0.49/srclib/apr-util/ldap'
/bin/bash /tmp/httpd-2.0.49/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthreads -DHAVE_CONFIG_H -DSOLARIS2=9 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -I/tmp/httpd-2.0.49/srclib/apr-util/include -I/tmp/httpd-2.0.49/srclib/apr-util/include/private -I/tmp/httpd-2.0.49/srclib/apr/include -I/tmp/httpd-2.0.49/srclib/apr-util/xml/expat/lib -c apr_ldap_compat.c && touch apr_ldap_compat.lo
/bin/bash /tmp/httpd-2.0.49/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthreads -DHAVE_CONFIG_H -DSOLARIS2=9 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -I/tmp/httpd-2.0.49/srclib/apr-util/include -I/tmp/httpd-2.0.49/srclib/apr-util/include/private -I/tmp/httpd-2.0.49/srclib/apr/include -I/tmp/httpd-2.0.49/srclib/apr-util/xml/expat/lib -c apr_ldap_url.c && touch apr_ldap_url.lo
make[4]: Leaving directory `/tmp/httpd-2.0.49/srclib/apr-util/ldap'
[snip]
make[3]: Entering directory `/tmp/httpd-2.0.49/srclib/apr-util'
/bin/bash /tmp/httpd-2.0.49/srclib/apr/libtool --silent --mode=link gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthreads -DHAVE_CONFIG_H -DSOLARIS2=9 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -I/tmp/httpd-2.0.49/srclib/apr-util/include -I/tmp/httpd-2.0.49/srclib/apr-util/include/private -I/tmp/httpd-2.0.49/srclib/apr/include -I/tmp/httpd-2.0.49/srclib/apr-util/xml/expat/lib -version-info 9:5:9 -o libaprutil-0.la -rpath /tmp/apache-test/lib buckets/apr_buckets_refcount.lo buckets/apr_buckets_pool.lo buckets/apr_buckets_simple.lo buckets/apr_buckets.lo buckets/apr_buckets_flush.lo buckets/apr_buckets_heap.lo buckets/apr_buckets_file.lo buckets/apr_buckets_eos.lo buckets/apr_buckets_mmap.lo buckets/apr_buckets_socket.lo buckets/apr_buckets_pipe.lo buckets/apr_buckets_alloc.lo buckets/apr_brigade.lo crypto/uuid.lo crypto/getuuid.lo crypto/apr_md4.lo crypto/apr_md5.lo crypto/apr_sha1.lo dbm/sdbm/sdbm_hash.lo dbm/sdbm/sdbm_lock.lo dbm/sdbm/sdbm_pair.lo dbm/sdbm/sdbm.lo dbm/apr_dbm_berkeleydb.lo dbm/apr_dbm_gdbm.lo dbm/apr_dbm_ndbm.lo dbm/apr_dbm_sdbm.lo dbm/apr_dbm.lo encoding/apr_base64.lo hooks/apr_hooks.lo ldap/apr_ldap_compat.lo ldap/apr_ldap_url.lo uri/apr_uri.lo xml/apr_xml.lo misc/apu_version.lo misc/apr_reslist.lo misc/apr_queue.lo misc/apr_rmm.lo misc/apr_date.lo strmatch/apr_strmatch.lo xlate/xlate.lo
=====================
I posted a screen capture out the DDD output after apr_ldap_url_parse returns at http://homepage.mac.com/swaltner/corrupted.gif. You can see that the structure that is returned is corrupted with many values placed in the wrong location as well as a char* in the lud_attrs pointing off into space which is causing my segmentation fault a couple lines of code later on.
Is it possible to easily statically link httpd and libaprutil.so? This might be a way to workaround the problem I'm having debugging the apr_ldap_url.c file.
Steve
