httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <oh...@cox.net>
Subject Re: How to compiling/link/use Apache module that uses shared library?
Date Thu, 21 Jun 2012 20:22:35 GMT

---- ohaya@cox.net wrote: 
> 
> ---- ohaya@cox.net wrote: 
> > 
> > ---- Sorin Manolache <sorinm@gmail.com> wrote: 
> > > On 2012-06-21 19:47, ohaya@cox.net wrote:
> > > 
> > > > I've tried using "-l" pointing directly to the .so, libobaccess.so, but
when I do that, it says it can't find the .so:
> > > >
> > > > [root@apachemodule build-mod_headers]# ./compile-mod-headers.sh
> > > > /apps/httpd2222/build/libtool --silent --mode=compile gcc -prefer-pic
  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/apps/httpd2222/include  -I/apps/httpd2222/include
  -I/apps/httpd2222/include   -c -o mod_headers.lo mod_headers.c && touch mod_headers.slo
> > > > /apps/httpd2222/build/libtool --silent --mode=link gcc -o mod_headers.la
 -l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath /apps/httpd2222/modules
-module -avoid-version    mod_headers.lo
> > > > /usr/bin/ld: cannot find -l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so
> > > > collect2: ld returned 1 exit status
> > > > apxs:Error: Command failed with rc=65536
> > > 
> > > Try -lobaccess
> > > 
> > > S
> > 
> > 
> > Sorin,
> > 
> > I was able to get Apache to start, kind of, using the apxs I posted, but adding
LoadFile directives to the Apache httpd.conf, to load libobaccess.so.
> > 
> > Now, when I run "apachectl -t", it says "OK", but when I try to actually start Apache,
I get a segfault (see below).  The thing is, I have a bunch of printfs in almost every function
in mod_headers.c, so I could see what functions are being called, and it looks like the segfault
is occurring even before it gets to any of the code parts that I've tweaked (vs. original
mod_headers.c):
> > 
> > 
> > [root@apachemodule build-mod_headers]# /apps/httpd2222/bin/apachectl -k start -X
> > mod_headers-jl V0.09 - start calling OAM API
> > In register_hooks
> > In create_headers_dir_config
> > In create_headers_dir_config
> > In header_cmd
> > In header_inout_cmd
> > In parse_format_tag
> > In parse_misc_string
> > In create_headers_dir_config
> > In header_cmd
> > In header_inout_cmd
> > In parse_format_tag
> > In parse_misc_string
> > In header_post_config
> > 
> > I tried running strace, and got (the ending of the strace):
> > 
> > 
> > In register_hooks
> > In create_headers_dir_config
> > In create_headers_dir_config
> > In header_cmd
> > In header_inout_cmd
> > In parse_format_tag
> > In parse_misc_string
> > In create_headers_dir_config
> > In header_cmd
> > In header_inout_cmd
> > In parse_format_tag
> > In parse_misc_string
> > In header_post_config
> > rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> > rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
> > rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> > rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
> > rt_sigaction(SIGINT, {0x432cc0, [], SA_RESTORER, 0x351432e300}, {SIG_DFL}, 8) =
0
> > wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV}], 0, NULL) = 11711
> > fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
> > mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2a983bf000
> > open("/usr/share/locale/locale.alias", O_RDONLY) = 3
> > fstat(3, {st_mode=S_IFREG|0644, st_size=2528, ...}) = 0
> > mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2a983c0000
> > read(3, "# Locale name alias data base.\n#"..., 4096) = 2528
> > read(3, "", 4096)                       = 0
> > close(3)                                = 0
> > munmap(0x2a983c0000, 4096)              = 0
> > open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT
(No such file or directory)
> > open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No
such file or directory)
> > open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such
file or directory)
> > open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No
such file or directory)
> > open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No
such file or directory)
> > open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such
file or directory)
> > write(2, "/apps/httpd2222/bin/apachectl: l"..., 83/apps/httpd2222/bin/apachectl:
line 78: 11711 Segmentation fault      $HTTPD $ARGV
> > ) = 83
> > rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> > --- SIGCHLD (Child exited) @ 0 (0) ---
> > wait4(-1, 0x7fbfffed64, WNOHANG, NULL)  = -1 ECHILD (No child processes)
> > rt_sigreturn(0xffffffffffffffff)        = 0
> > rt_sigaction(SIGINT, {SIG_DFL}, {0x432cc0, [], SA_RESTORER, 0x351432e300}, 8) =
0
> > rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
> > read(255, "\nexit $ERROR\n\n", 3420)    = 14
> > rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
> > rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> > exit_group(139)                         = ?
> > 
> > 
> > I'll try to do the apxs with -lobccess and post back...
> > 
> > Jim
> 
> 
> Hi, 
> 
> It looks like just including the .so in the apxs command is enough to cause the segfault,
even if I remove all references to the functions in the .so from my module code.
> 
> Is there something else I need to do when using my module that uses "external" .so files?
> 
> Jim

Hi,

I think I did the gdb thing at least (still not sure how to set -O0):

[root@apachemodule bin]# gdb httpd
GNU gdb Red Hat Linux (6.3.0.0-1.162.el4rh)
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 "x86_64-redhat-linux-gnu"...Using host libthread_db library "/lib64/tls/libthread_db.so.1".

(gdb) b header_post_config
Function "header_post_config" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (header_post_config) pending.
(gdb) run -X
Starting program: /apps/httpd2222/bin/httpd -X
[Thread debugging using libthread_db enabled]
[New Thread 182897612000 (LWP 8741)]
Breakpoint 2 at 0x2a97a69060: file mod_headers.c, line 1026.
Pending breakpoint "header_post_config" resolved
mod_headers-jl V0.09 - start calling OAM API
In register_hooks
In create_headers_dir_config
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
[Switching to Thread 182897612000 (LWP 8741)]

Breakpoint 2, header_post_config (pconf=0x573138, plog=0x5a52c8, ptemp=0x5a72d8, s=0x59d3a8)
at mod_headers.c:1026
1026        printf("In header_post_config\n");
(gdb) s
1025    {
(gdb) s
1026        printf("In header_post_config\n");
(gdb) n
In header_post_config
1027        header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
(gdb) n
1029    }
(gdb) n
0x00000000004360c7 in ap_run_post_config (pconf=0x573138, plog=0x5a52c8, ptemp=0x5a72d8, s=0x59d3a8)
at config.c:91
91      AP_IMPLEMENT_HOOK_RUN_ALL(int, post_config,
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x0000003518d6c1e1 in BN_num_bits () from /lib64/libcrypto.so.4
(gdb)


I have no idea what the above means :(....  But it looks like something blew up in libcrypto?

Jim


Mime
View raw message