Re: Empty cookies [Was Re: libapreq2 co-maintainer]

2012-06-21 Thread Joe Schaefer
apreq does the right thing now by both throwing an
exception (indicating a malformed cookie) and parsing
the header correctly.  This is a very old subject:
Thomas should be using eval like so:

   $apreq = APR::Request::Apache2-handle($r);
   my $jar = eval { $apreq-jar };
   $jar = $@-jar if $@;
   ...

IOW not a bug, please don't fix.



- Original Message -
 From: Issac Goldstand mar...@beamartyr.net
 To: j...@apache.org
 Cc: Thomas Busch tbu...@cpan.org; apreq-dev@httpd.apache.org
 Sent: Thursday, June 21, 2012 2:19 PM
 Subject: Empty cookies [Was Re: libapreq2 co-maintainer]
 
 On 20/06/2012 14:19, Thomas Busch wrote:
  On 20/06/2012 13:35, Thomas Busch wrote:
  The reason I'm asking is that the following bug
 
  https://rt.cpan.org/Public/Bug/Display.html?id=69866
 
  hasn't been solved and is still causing Internal Server 
 Error's on
  a lot of mod_perl installation.
 
  I see you've got a suggested patch there, so there's a good 
 chance that
  someone will pick that up - if noone does it by the weekend, I'll 
 try to
  pick it up myself.
 
 
 Joe, you seemingly addressed this in r748782 and then intentionally put
 it back in r748790 - you touched the exact test case which would deal
 with the a cookie that looked like Cookie: foo=bar;foo2=test;blabla. 
 
 Any recollections of why you put it back?
 
   Issac



How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya
Hi,

I am (still) working on a module that uses another commercial shared object 
library (.so).  I use the following to successfully build the module 
(currently, just tweaking mod_headers.c for testing):

/apps/httpd/bin/apxs -L /apps/netpoint/AccessServerSDK/oblix/lib/ -c -i -a 
mod_headers.c

The compile/link appears to work ok:


[root@apachemodule build-mod_headers]# ./compile-mod-headers.sh
/apps/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   
-DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/a   
pps/httpd/include  -I/apps/httpd/include   
-I/apps/httpd/include   -c -o mod_headers.lo mod_headers.c  touch mod_he  
 aders.slo
/apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la  
-L/apps/netpoint/AccessServerSDK/oblix/lib/ -rpath /app 
  s/httpd/modules -module -avoid-versionmod_headers.lo
/apps/httpd/build/instdso.sh SH_LIBTOOL='/apps/httpd/build/libtool' 
mod_headers.la /apps/httpd/modules
/apps/httpd/build/libtool --mode=install cp mod_headers.la 
/apps/httpd/modules/
cp .libs/mod_headers.so /apps/httpd/modules/mod_headers.so
cp .libs/mod_headers.lai /apps/httpd/modules/mod_headers.la
cp .libs/mod_headers.a /apps/httpd/modules/mod_headers.a
chmod 644 /apps/httpd/modules/mod_headers.a
ranlib /apps/httpd/modules/mod_headers.a
PATH=$PATH:/sbin ldconfig -n /apps/httpd/modules
--
Libraries have been installed in:
   /apps/httpd/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
 during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
 during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
--
chmod 755 /apps/httpd/modules/mod_headers.so
[activating module `headers' in /apps/httpd/conf/httpd.conf]


However, when I try to start Apache, I get an error:


[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 82 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected
[root@apachemodule build-mod_headers]#

I have LD_LIBRARY_PATH set to the path where the shared library is (same as the 
-L parameter above).

When I run ldd on the .so, I get:

[root@apachemodule build-mod_headers]# ldd -v 
/apps/httpd/modules/mod_headers.so
libc.so.6 = /lib64/tls/libc.so.6 (0x002a95673000)
/lib64/ld-linux-x86-64.so.2 (0x00552000)

Version information:
/apps/httpd/modules/mod_headers.so:
libc.so.6 (GLIBC_2.3) = /lib64/tls/libc.so.6
libc.so.6 (GLIBC_2.2.5) = /lib64/tls/libc.so.6
/lib64/tls/libc.so.6:
ld-linux-x86-64.so.2 (GLIBC_2.2.5) = 
/lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_2.3) = /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) = 
/lib64/ld-linux-x86-64.so.2


Shouldn't my shared library, libobaccess.so appear in the ldd output?


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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   
-DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/apps/httpd/include  
-I/apps/httpd/include   -I/apps/httpd/include   -c -o mod_headers.lo 
mod_headers.c  touch mod_headers.slo
/apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la  
-l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
/apps/httpd/modules -module -avoid-versionmod_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


At this point, I don't quite understand why Apache is failing to start...

Can anyone help?

Thanks,
Jim


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Sorin Manolache

On 2012-06-21 19:47, oh...@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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   -DLINUX=2 
-D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/apps/httpd/include  
-I/apps/httpd/include   -I/apps/httpd/include   -c -o mod_headers.lo 
mod_headers.c  touch mod_headers.slo
/apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la  
-l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
/apps/httpd/modules -module -avoid-versionmod_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


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Anthony Whitehead
Jim,

Have you looked at the LoadFile directive, sometime that can be of use for
third party libraries.
http://httpd.apache.org/docs/2.4/mod/mod_so.html#loadfile

/Ant

On 21 June 2012 20:19, oh...@cox.net wrote:


  Sorin Manolache sor...@gmail.com wrote:
  On 2012-06-21 19:47, oh...@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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic
   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread
 -I/apps/httpd/include  -I/apps/httpd/include
 -I/apps/httpd/include   -c -o mod_headers.lo mod_headers.c  touch
 mod_headers.slo
   /apps/httpd/build/libtool --silent --mode=link gcc -o
 mod_headers.la  -l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so
 -rpath /apps/httpd/modules -module -avoid-versionmod_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/httpd/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) =
 0x2a983c
 read(3, # Locale name alias data base.\n#..., 4096) = 2528
 read(3, , 4096)   = 0
 close(3)= 0
 munmap(0x2a983c, 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/httpd/bin/apachectl: l...,
 83/apps/httpd/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(0x)= 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



Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 oh...@cox.net wrote: 
 
  Sorin Manolache sor...@gmail.com wrote: 
  On 2012-06-21 19:47, oh...@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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   
   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread 
   -I/apps/httpd/include  -I/apps/httpd/include   
   -I/apps/httpd/include   -c -o mod_headers.lo mod_headers.c  touch 
   mod_headers.slo
   /apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la  
   -l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
   /apps/httpd/modules -module -avoid-versionmod_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/httpd/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) = 
 0x2a983c
 read(3, # Locale name alias data base.\n#..., 4096) = 2528
 read(3, , 4096)   = 0
 close(3)= 0
 munmap(0x2a983c, 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/httpd/bin/apachectl: l..., 
 83/apps/httpd/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(0x)= 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


Sorin,

I tried the apxs with both the -L pointing to the directory and -lobaccess, and 
the apxs worked, plus I don't need the LoadFile directive in Apache httpd.conf.

However, I still get a segfault when I try to start Apache :(...

Jim


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Ben Noordhuis
On Thu, Jun 21, 2012 at 8:43 PM,  oh...@cox.net wrote:
 I tried that, which allowed me to start Apache, but am getting a segfault.

Run it through gdb and inspect the backtrace. Compiling with debug
symbols and optimizations disabled (-g -O0) will help.


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 oh...@cox.net wrote: 
 
  Sorin Manolache sor...@gmail.com wrote: 
  On 2012-06-21 19:47, oh...@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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   
   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread 
   -I/apps/httpd/include  -I/apps/httpd/include   
   -I/apps/httpd/include   -c -o mod_headers.lo mod_headers.c  touch 
   mod_headers.slo
   /apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la  
   -l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
   /apps/httpd/modules -module -avoid-versionmod_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/httpd/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) = 
 0x2a983c
 read(3, # Locale name alias data base.\n#..., 4096) = 2528
 read(3, , 4096)   = 0
 close(3)= 0
 munmap(0x2a983c, 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/httpd/bin/apachectl: l..., 
 83/apps/httpd/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(0x)= 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


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 oh...@cox.net wrote: 
 
  oh...@cox.net wrote: 
  
   Sorin Manolache sor...@gmail.com wrote: 
   On 2012-06-21 19:47, oh...@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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   
-DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread 
-I/apps/httpd/include  -I/apps/httpd/include   
-I/apps/httpd/include   -c -o mod_headers.lo mod_headers.c  touch 
mod_headers.slo
/apps/httpd/build/libtool --silent --mode=link gcc -o 
mod_headers.la  
-l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
/apps/httpd/modules -module -avoid-versionmod_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/httpd/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) = 
  0x2a983c
  read(3, # Locale name alias data base.\n#..., 4096) = 2528
  read(3, , 4096)   = 0
  close(3)= 0
  munmap(0x2a983c, 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/httpd/bin/apachectl: l..., 
  83/apps/httpd/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(0x)= 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 

Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Sorin Manolache

On 2012-06-21 22:04, oh...@cox.net wrote:


 Ben Noordhuis i...@bnoordhuis.nl wrote:

On Thu, Jun 21, 2012 at 8:43 PM,  oh...@cox.net wrote:

I tried that, which allowed me to start Apache, but am getting a segfault.


Run it through gdb and inspect the backtrace. Compiling with debug
symbols and optimizations disabled (-g -O0) will help.



Sorin,

The apxs already has -g and -O2 looks like.  How do I change that to -O0? 
 Or, do I just run the gcc compile manually?


Try adding

-Wc,-O0 -Wc,-g -Wc,-fno-inline -Wl,-g

to your apxs command line.


Also how do I run it through gdb, since apachectl is a script?


You don't run apachectl, you run the apache binary.

gdb

Then in gdb type:
file /path/to/your/httpd_or_apache2
set args -d /path/to/your/server_root_dir -f /path/to/your/conf/file -X

If apachectl sets some environment variables first, which are then used 
in the conf file (as in the standard debian installation) then you'll 
have to set them manually in gdb, e.g.


set environment APACHE_RUN_USER www-data
set environment APACHE_RUN_GROUP www-data

Last, type

run

For example, on my debian I'd do

file /usr/sbin/apache2
set args -d /etc/apache2 -f /etc/apache2/apache2.conf -X
And a couple of set environments and then run.

S



Sorry for the questions, but not too familiar with this stuff :(...

Jim






Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Joe Lewis j...@joe-lewis.com wrote: 
 On 6/21/12 1:40 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   Sorin Manolachesor...@gmail.com  wrote:
  On 2012-06-21 19:47, oh...@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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   
  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread 
  -I/apps/httpd/include  -I/apps/httpd/include   
  -I/apps/httpd/include   -c -o mod_headers.lo mod_headers.c  touch 
  mod_headers.slo
  /apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la 
   -l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
  /apps/httpd/modules -module -avoid-versionmod_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/httpd/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) = 
  0x2a983c
  read(3, # Locale name alias data base.\n#..., 4096) = 2528
  read(3, , 4096)   = 0
  close(3)= 0
  munmap(0x2a983c, 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/httpd/bin/apachectl: l..., 
  83/apps/httpd/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(0x)= 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 

Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Sorin Manolache

On 2012-06-21 22:22, oh...@cox.net wrote:


[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/httpd/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
1026printf(In header_post_config\n);
(gdb) s
1025{
(gdb) s
1026printf(In header_post_config\n);
(gdb) n
In header_post_config
1027header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
(gdb) n
1029}
(gdb) n
0x004360c7 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.
0x003518d6c1e1 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



Navigate the help of gdb (help, help data, help running).

Check the bt (backtrace), up, and down commands. From your 
segfault point in libcrypto you can go up the stack until you reach in 
one of your functions.


When you reached your code after several ups, do a print of the 
variables (especially pointers that you suspect they are null but 
shouldn't be null) that could have triggered the error.


S


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Sorin Manolache sor...@gmail.com wrote: 
 On 2012-06-21 22:04, oh...@cox.net wrote:
 
   Ben Noordhuis i...@bnoordhuis.nl wrote:
  On Thu, Jun 21, 2012 at 8:43 PM,  oh...@cox.net wrote:
  I tried that, which allowed me to start Apache, but am getting a segfault.
 
  Run it through gdb and inspect the backtrace. Compiling with debug
  symbols and optimizations disabled (-g -O0) will help.
 
 
  Sorin,
 
  The apxs already has -g and -O2 looks like.  How do I change that to 
  -O0?  Or, do I just run the gcc compile manually?
 
 Try adding
 
 -Wc,-O0 -Wc,-g -Wc,-fno-inline -Wl,-g
 
 to your apxs command line.
 
  Also how do I run it through gdb, since apachectl is a script?
 
 You don't run apachectl, you run the apache binary.
 
 gdb
 
 Then in gdb type:
 file /path/to/your/httpd_or_apache2
 set args -d /path/to/your/server_root_dir -f /path/to/your/conf/file -X
 
 If apachectl sets some environment variables first, which are then used 
 in the conf file (as in the standard debian installation) then you'll 
 have to set them manually in gdb, e.g.
 
 set environment APACHE_RUN_USER www-data
 set environment APACHE_RUN_GROUP www-data
 
 Last, type
 
 run
 
 For example, on my debian I'd do
 
 file /usr/sbin/apache2
 set args -d /etc/apache2 -f /etc/apache2/apache2.conf -X
 And a couple of set environments and then run.
 
 S
 
 
  Sorry for the questions, but not too familiar with this stuff :(...
 
  Jim
 
 
 


Hi Sorin,

Thanks for that.  I did as you suggested (again, just to be sure) and got:


(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)
Function header_post_config not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (header_post_config) pending.
(gdb) run -d /apps/httpd -f /apps/httpd/conf/httpd.conf -X
Starting program: /apps/httpd/bin/httpd -d /apps/httpd -f 
/apps/httpd/conf/httpd.conf -X
[Thread debugging using libthread_db enabled]
[New Thread 182897612000 (LWP 9669)]
Breakpoint 3 at 0x2a97a69070: file mod_headers.c, line 1026.
Pending breakpoint header_post_config resolved
Note: breakpoint 3 also set at pc 0x2a97a69070.
Breakpoint 4 at 0x2a97a69070: 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 9669)]

Breakpoint 3, header_post_config (pconf=0x573138, plog=0x5a52c8, 
ptemp=0x5a72d8, s=0x59d3a8) at mod_headers.c:1026
1026printf(In header_post_config\n);
(gdb) s
1025{
(gdb) n
1026printf(In header_post_config\n);
(gdb) n
In header_post_config
1027header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
(gdb) n
1029}
(gdb) n
0x004360c7 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.
0x003518d6c1e1 in BN_num_bits () from /lib64/libcrypto.so.4


Looks like it blew up the same place as earlier...

Jim


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Sorin Manolache
And I forgot to say: run gdb in some sort of environment where you see 
your current source code line and a couple of surrounding lines. You 
could achieve this with the list command, but I prefer running gdb in 
emacs and let emacs do the nice listing of source code in a different panel.


S


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Sorin Manolache sor...@gmail.com wrote: 
 And I forgot to say: run gdb in some sort of environment where you see 
 your current source code line and a couple of surrounding lines. You 
 could achieve this with the list command, but I prefer running gdb in 
 emacs and let emacs do the nice listing of source code in a different panel.
 
 S


Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
  apr_pool_t *ptemp, server_rec *s)
{
printf(In header_post_config\n);
header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
return OK;
}

Jim


ap_run_log_transaction() appears to run prior to request finishing

2012-06-21 Thread Paul Stengel
Hello,

I am developing a module which extends mod_log_config and provides a
custom log format for CPU time elapsed per request. In order to do
this, once the request reaches the ap_run_log_transaction() hook, the
Apache worker must apr_proc_wait() for any child processes related to
the request to finish. Most of the time, the module functions without
a problem and requests are logged with accurate CPU time.

However, some requests hang. I have not been able to reproduce the
issue in testing, but I have been able to observe the deadlock on live
servers. For example, using mod_suphp, some PHP requests will launch
and begin processing, but prior to completing and writing out its
entire response, the Apache worker moves to the
ap_run_log_transaction() hook. The deadlock occurs when the logging
function that my module uses begins its apr_proc_wait(). The PHP
process will the be stuck in a write(), presumably waiting for Apache
to read() more data, and the Apache child will be stuck in a
waitpid(), waiting for the PHP process to terminate. Both processes
hang indefinitely. Their backtraces are as follows:

PHP process:

#0  0x63569ff13930 in __write_nocancel () from /lib64/libpthread.so.0
#1  0x0073cf48 in sapi_cgibin_single_write (str=value
optimized out, str_length=320) at
/home/cpeasyapache/src/php-5.2.17/sapi/cgi/cgi_main.c:270
#2  sapi_cgibin_ub_write (str=value optimized out, str_length=320)
at /home/cpeasyapache/src/php-5.2.17/sapi/cgi/cgi_main.c:286
#3  0x00688204 in php_ub_body_write_no_header (str=0x1
Address 0x1 out of bounds, str_length=18340616) at
/home/cpeasyapache/src/php-5.2.17/main/output.c:684
#4  0x006bb1b7 in zend_print_zval_ex (write_func=0x6771f0
php_body_write_wrapper, expr=0x11b7b78, indent=value optimized
out) at /home/cpeasyapache/src/php-5.2.17/Zend/zend.c:294
#5  0x006de48b in ZEND_ECHO_SPEC_CONST_HANDLER
(execute_data=0x718e57d8fc90) at
/home/cpeasyapache/src/php-5.2.17/Zend/zend_vm_execute.h:1500
#6  0x006d95bc in execute (op_array=0x1177198) at
/home/cpeasyapache/src/php-5.2.17/Zend/zend_vm_execute.h:92
#7  0x63569dda890f in zend_oe () from
/usr/local/Zend/lib/Optimizer-3.3.9/php-5.2.x/ZendOptimizer.so
#8  0x006b9b0d in zend_execute_scripts (type=8, retval=value
optimized out, file_count=3) at
/home/cpeasyapache/src/php-5.2.17/Zend/zend.c:1134
#9  0x00676e3d in php_execute_script
(primary_file=0x718e57d92430) at
/home/cpeasyapache/src/php-5.2.17/main/main.c:2036
#10 0x0073daff in main (argc=2, argv=0x718e57d92608) at
/home/cpeasyapache/src/php-5.2.17/sapi/cgi/cgi_main.c:1999

Apache thread:

#0  0x71742e3bf75f in waitpid () from /lib64/libpthread.so.0
#1  0x71742ec3d912 in apr_proc_wait () from
/usr/local/apache/lib/libapr-1.so.0
#2  0x71742bf0f9a6 in log_cpu_elapsed () from
/usr/local/apache/modules/mod_logcpu.so
#3  0x0046d754 in process_item ()
#4  0x0046d968 in config_log_transaction ()
#5  0x0046db03 in multi_log_transaction ()
#6  0x0043937d in ap_run_log_transaction ()
#7  0x004b44f8 in ap_process_request ()
#8  0x004b0ba2 in ap_process_http_async_connection ()
#9  0x0045238c in ap_run_process_connection ()
#10 0x004ddc50 in process_socket ()
#11 0x004de9c1 in worker_thread ()
#12 0x71742ec3e0a5 in dummy_worker () from
/usr/local/apache/lib/libapr-1.so.0
#13 0x71742e3b777d in start_thread () from /lib64/libpthread.so.0
#14 0x71742df2925d in clone () from /lib64/libc.so.6

Why is this occurring, and couldn't this be affecting other logging
functions such as those that count bytes communicated? Is there a way
to ensure that the request has completely finished, and if not, yield
to the PHP process and return to the logging function once it actually
has finished? I suspect this may be due to faulty logic in
check_pipeline_flush(), which is called prior to
ap_run_log_transaction() in ap_process_request()
(modules/http/http_request.c). This function appears to have been
completely removed in 2.4 and replaced with a similar
check_pipeline(). I've not yet tested my module with 2.4; I am
developing on 2.2 and need this module to be compatible with 2.2.

-Paul


Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolachesor...@gmail.com  wrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the list command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S


Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
   apr_pool_t *ptemp, server_rec *s)
{
 printf(In header_post_config\n);
 header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 return OK;
}

Jim


Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking ldconfig 
-p.  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those 
/etc/ld.so.conf.d files provide additional search directories for the 
linker to check in when loading a library.


Joe
--
http://www.silverhawk.net/


UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Joe Lewis j...@joe-lewis.com wrote: 
 On 6/21/12 5:49 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   Sorin Manolachesor...@gmail.com  wrote:
  And I forgot to say: run gdb in some sort of environment where you see
  your current source code line and a couple of surrounding lines. You
  could achieve this with the list command, but I prefer running gdb in
  emacs and let emacs do the nice listing of source code in a different 
  panel.
 
  S
 
  Here's the function from my source.  It's the original from mod_headers.c, 
  plus my printf:
 
 
  static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
 apr_pool_t *ptemp, server_rec *s)
  {
   printf(In header_post_config\n);
   header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
   return OK;
  }
 
  Jim
 
  Hi,
 
  I was able to get the segfault to go away.  Here's what I had to do:
 
  - Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
  libobaccess.so was
  - Run 'ldconfig' to activate.
  - In the apxs command, DON'T include the -L and -l arguments
 
  After that, Apache appears to start ok, without segfault :)!!
 
  Thanks for all of the great help, esp. the suggestion about checking 
  ldconfig -p.  I still don't understand why, but I'm just glad that I can 
  get past this piece so now I can debug my module :)...
 
  Later,
  Jim
 I'm just glad this list is as good as it is!
 
 FYI, the ldconfig is the dynamic linker control, and those 
 /etc/ld.so.conf.d files provide additional search directories for the 
 linker to check in when loading a library.
 
 Joe
 --
 http://www.silverhawk.net/


Hi,

Sorry to report, but my earlier report was a false positive :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
full code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get undefined symbol errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That ObResource_isProtected should be a symbol in libobaccess.so, and in 
fact, if I do nm --dynamic, I get:

[root@apachemodule build-mod_headers]# nm --dynamic 
/apps/netpoint/lib64/libobaccess.so | grep ObResource_isProtected
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the undefined symbol error is that 
libobaccess.so is actually not being loaded, but then when I try to load 
libobaccess.so, either via -L and -l in the apxs, or using LoadFile in 
httpd.conf, I get the segfault (same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim




Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 oh...@cox.net wrote: 
 
  Joe Lewis j...@joe-lewis.com wrote: 
  On 6/21/12 5:49 PM, oh...@cox.net wrote:
    oh...@cox.net wrote:
    Sorin Manolachesor...@gmail.com  wrote:
   And I forgot to say: run gdb in some sort of environment where you see
   your current source code line and a couple of surrounding lines. You
   could achieve this with the list command, but I prefer running gdb in
   emacs and let emacs do the nice listing of source code in a different 
   panel.
  
   S
  
   Here's the function from my source.  It's the original from 
   mod_headers.c, plus my printf:
  
  
   static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
  apr_pool_t *ptemp, server_rec *s)
   {
printf(In header_post_config\n);
header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
return OK;
   }
  
   Jim
  
   Hi,
  
   I was able to get the segfault to go away.  Here's what I had to do:
  
   - Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
   libobaccess.so was
   - Run 'ldconfig' to activate.
   - In the apxs command, DON'T include the -L and -l arguments
  
   After that, Apache appears to start ok, without segfault :)!!
  
   Thanks for all of the great help, esp. the suggestion about checking 
   ldconfig -p.  I still don't understand why, but I'm just glad that I 
   can get past this piece so now I can debug my module :)...
  
   Later,
   Jim
  I'm just glad this list is as good as it is!
  
  FYI, the ldconfig is the dynamic linker control, and those 
  /etc/ld.so.conf.d files provide additional search directories for the 
  linker to check in when loading a library.
  
  Joe
  --
  http://www.silverhawk.net/
 
 
 Hi,
 
 Sorry to report, but my earlier report was a false positive :)...
 
 I forgot that the mod_headers.c that I was doing the earlier testing with had 
 all references to the libobaccess.so removed :(!!
 
 So, I'm still stuck with basically the same problem, now, working with my 
 full code, with the calls in it:
 
 - If I compile with -L and -l, Apache segfaults when it starts
 
 - If I compile without -L and -l, then I get undefined symbol errors when I 
 try to start Apache, e.g.:
 
 [root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start 
 -X
 httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot 
 load /apps/httpd/modules/mod_headers.so into server: 
 /apps/httpd/modules/mod_headers.so: undefined symbol: 
 ObResource_isProtected
 
 That ObResource_isProtected should be a symbol in libobaccess.so, and in 
 fact, if I do nm --dynamic, I get:
 
 [root@apachemodule build-mod_headers]# nm --dynamic 
 /apps/netpoint/lib64/libobaccess.so | grep ObResource_isProtected
 000a6d80 T ObResource_isProtected
 [root@apachemodule build-mod_headers]#
 
 
 I'm *assuming* that the reason for the undefined symbol error is that 
 libobaccess.so is actually not being loaded, but then when I try to load 
 libobaccess.so, either via -L and -l in the apxs, or using LoadFile in 
 httpd.conf, I get the segfault (same gdb info, BTW).
 
 Catch-22?
 
 Sorry for the false alarm :(!!
 
 Jim
 
 

Hi,

Also, BTW, now that I have the ld.so.conf.d setup, I can do ldconfig -p and 
get:

[root@apachemodule build-mod_headers]# ldconfig -p | grep libob
libobaccess.so (libc6,x86-64) = /apps/netpoint/lib64/libobaccess.so

The library TYPE (libc6) is the same with other .so files that are use, e.g., 
the libssl*.so, when I list them with ldconfig.

Sill don't understand why loading that libobaccess.so causes Apache to segfault 
:(...

Jim


Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Joe Lewis j...@joe-lewis.com wrote: 
 On 6/21/12 6:46 PM, oh...@cox.net wrote:
   Joe Lewisj...@joe-lewis.com  wrote:
  On 6/21/12 5:49 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   Sorin Manolachesor...@gmail.com   wrote:
  And I forgot to say: run gdb in some sort of environment where you see
  your current source code line and a couple of surrounding lines. You
  could achieve this with the list command, but I prefer running gdb in
  emacs and let emacs do the nice listing of source code in a different 
  panel.
 
  S
  Here's the function from my source.  It's the original from 
  mod_headers.c, plus my printf:
 
 
  static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
  apr_pool_t *ptemp, server_rec *s)
  {
printf(In header_post_config\n);
header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
return OK;
  }
 
  Jim
  Hi,
 
  I was able to get the segfault to go away.  Here's what I had to do:
 
  - Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
  libobaccess.so was
  - Run 'ldconfig' to activate.
  - In the apxs command, DON'T include the -L and -l arguments
 
  After that, Apache appears to start ok, without segfault :)!!
 
  Thanks for all of the great help, esp. the suggestion about checking 
  ldconfig -p.  I still don't understand why, but I'm just glad that I 
  can get past this piece so now I can debug my module :)...
 
  Later,
  Jim
  I'm just glad this list is as good as it is!
 
  FYI, the ldconfig is the dynamic linker control, and those
  /etc/ld.so.conf.d files provide additional search directories for the
  linker to check in when loading a library.
 
  Joe
  --
  http://www.silverhawk.net/
 
  Hi,
 
  Sorry to report, but my earlier report was a false positive :)...
 
  I forgot that the mod_headers.c that I was doing the earlier testing with 
  had all references to the libobaccess.so removed :(!!
 
  So, I'm still stuck with basically the same problem, now, working with my 
  full code, with the calls in it:
 
  - If I compile with -L and -l, Apache segfaults when it starts
 
  - If I compile without -L and -l, then I get undefined symbol errors when 
  I try to start Apache, e.g.:
 
  [root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k 
  start -X
  httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot 
  load /apps/httpd/modules/mod_headers.so into server: 
  /apps/httpd/modules/mod_headers.so: undefined symbol: 
  ObResource_isProtected
 
  That ObResource_isProtected should be a symbol in libobaccess.so, and in 
  fact, if I do nm --dynamic, I get:
 
  [root@apachemodule build-mod_headers]# nm --dynamic 
  /apps/netpoint/lib64/libobaccess.so | grep ObResource_isProtected
  000a6d80 T ObResource_isProtected
  [root@apachemodule build-mod_headers]#
 
 
  I'm *assuming* that the reason for the undefined symbol error is that 
  libobaccess.so is actually not being loaded, but then when I try to load 
  libobaccess.so, either via -L and -l in the apxs, or using LoadFile in 
  httpd.conf, I get the segfault (same gdb info, BTW).
 
  Catch-22?
 
  Sorry for the false alarm :(!!
 
  Jim
 
 
 Not a catch-22.  The -L and -l specify linker options when assembling 
 the code.  The ldconfig is a run-time thing.  If you are getting the 
 stderr messages, you are making it all the way into your library.  I'd 
 suggest commenting out the following line and see if you get farther :
 
 header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 
 That should tell you if the problem is the ssl_var_lookup.
 
 Joe
 --
 http://www.silverhawk.net/


Hi,

Thanks for the suggestion.  I just tried what you suggested, and got a segfault 
when I started Apache with the modified module.

Jim




Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Ben Noordhuis
On Fri, Jun 22, 2012 at 3:32 AM,  oh...@cox.net wrote:
 Program received signal SIGSEGV, Segmentation fault.
 0x003518d6c1e1 in BN_num_bits () from /lib64/libcrypto.so.4

 So, it's actually blowing up in BN_num_bits() in /lib64/libcrypto.so.4?

Type `bt full` and you'll get a backtrace + locals. That should tell
you where the error originates from and maybe why it happens.


Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 7:32 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.com  wrote:

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.com   wrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolachesor...@gmail.comwrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the list command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S

Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
 apr_pool_t *ptemp, server_rec *s)
{
   printf(In header_post_config\n);
   header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
   return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking ldconfig 
-p.  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/

Hi,

Sorry to report, but my earlier report was a false positive :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
full code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get undefined symbol errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That ObResource_isProtected should be a symbol in libobaccess.so, and in fact, if I do 
nm --dynamic, I get:

[root@apachemodule build-mod_headers]# nm --dynamic /apps/netpoint/lib64/libobaccess.so | 
grep ObResource_isProtected
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the undefined symbol error is that 
libobaccess.so is actually not being loaded, but then when I try to load libobaccess.so, 
either via -L and -l in the apxs, or using LoadFile in httpd.conf, I get the segfault 
(same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim



Not a catch-22.  The -L and -l specify linker options when assembling
the code.  The ldconfig is a run-time thing.  If you are getting the
stderr messages, you are making it all the way into your library.  I'd
suggest commenting out the following line and see if you get farther :

header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/


Hi,

Thanks for the suggestion.  I just tried what you suggested, and got a segfault 
when I started Apache with the modified module.

Jim



Hi,

As a reminder, here's the gdb with the library loaded:


(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 -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
/apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
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 182897610272 (LWP 11317)]

Breakpoint 2, header_post_config (pconf=0x573138, plog=0x5a52c8, 
ptemp=0x5a72d8, s=0x59d3a8) at mod_headers.c:1121
1121printf(In header_post_config\n);
(gdb) n
1120{
(gdb) n
1121printf(In header_post_config\n);
(gdb) n
In header_post_config
1122header_ssl_lookup = 

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Joe Lewis j...@joe-lewis.com wrote: 
 On 6/21/12 7:32 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   Joe Lewisj...@joe-lewis.com  wrote:
  On 6/21/12 6:46 PM, oh...@cox.net wrote:
   Joe Lewisj...@joe-lewis.com   wrote:
  On 6/21/12 5:49 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   Sorin Manolachesor...@gmail.comwrote:
  And I forgot to say: run gdb in some sort of environment where you 
  see
  your current source code line and a couple of surrounding lines. You
  could achieve this with the list command, but I prefer running gdb 
  in
  emacs and let emacs do the nice listing of source code in a 
  different panel.
 
  S
  Here's the function from my source.  It's the original from 
  mod_headers.c, plus my printf:
 
 
  static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
   apr_pool_t *ptemp, server_rec *s)
  {
 printf(In header_post_config\n);
 header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 return OK;
  }
 
  Jim
  Hi,
 
  I was able to get the segfault to go away.  Here's what I had to do:
 
  - Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
  libobaccess.so was
  - Run 'ldconfig' to activate.
  - In the apxs command, DON'T include the -L and -l arguments
 
  After that, Apache appears to start ok, without segfault :)!!
 
  Thanks for all of the great help, esp. the suggestion about checking 
  ldconfig -p.  I still don't understand why, but I'm just glad that I 
  can get past this piece so now I can debug my module :)...
 
  Later,
  Jim
  I'm just glad this list is as good as it is!
 
  FYI, the ldconfig is the dynamic linker control, and those
  /etc/ld.so.conf.d files provide additional search directories for the
  linker to check in when loading a library.
 
  Joe
  --
  http://www.silverhawk.net/
  Hi,
 
  Sorry to report, but my earlier report was a false positive :)...
 
  I forgot that the mod_headers.c that I was doing the earlier testing 
  with had all references to the libobaccess.so removed :(!!
 
  So, I'm still stuck with basically the same problem, now, working with 
  my full code, with the calls in it:
 
  - If I compile with -L and -l, Apache segfaults when it starts
 
  - If I compile without -L and -l, then I get undefined symbol errors 
  when I try to start Apache, e.g.:
 
  [root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k 
  start -X
  httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: 
  Cannot load /apps/httpd/modules/mod_headers.so into server: 
  /apps/httpd/modules/mod_headers.so: undefined symbol: 
  ObResource_isProtected
 
  That ObResource_isProtected should be a symbol in libobaccess.so, and 
  in fact, if I do nm --dynamic, I get:
 
  [root@apachemodule build-mod_headers]# nm --dynamic 
  /apps/netpoint/lib64/libobaccess.so | grep ObResource_isProtected
  000a6d80 T ObResource_isProtected
  [root@apachemodule build-mod_headers]#
 
 
  I'm *assuming* that the reason for the undefined symbol error is that 
  libobaccess.so is actually not being loaded, but then when I try to load 
  libobaccess.so, either via -L and -l in the apxs, or using LoadFile in 
  httpd.conf, I get the segfault (same gdb info, BTW).
 
  Catch-22?
 
  Sorry for the false alarm :(!!
 
  Jim
 
 
  Not a catch-22.  The -L and -l specify linker options when assembling
  the code.  The ldconfig is a run-time thing.  If you are getting the
  stderr messages, you are making it all the way into your library.  I'd
  suggest commenting out the following line and see if you get farther :
 
  header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 
  That should tell you if the problem is the ssl_var_lookup.
 
  Joe
  --
  http://www.silverhawk.net/
 
  Hi,
 
  Thanks for the suggestion.  I just tried what you suggested, and got a 
  segfault when I started Apache with the modified module.
 
  Jim
 
 
  Hi,
 
  As a reminder, here's the gdb with the library loaded:
 
 
  (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 -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
  Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
  /apps/httpd/conf/httpd.conf
  [Thread debugging using libthread_db enabled]
  [New Thread 182897610272 (LWP 11317)]
  Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
  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 182897610272 (LWP 11317)]
 
  

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 oh...@cox.net wrote: 
 
  oh...@cox.net wrote: 
  
   Joe Lewis j...@joe-lewis.com wrote: 
   On 6/21/12 7:32 PM, oh...@cox.net wrote:
 oh...@cox.net wrote:
 Joe Lewisj...@joe-lewis.com  wrote:
On 6/21/12 6:46 PM, oh...@cox.net wrote:
 Joe Lewisj...@joe-lewis.com   wrote:
On 6/21/12 5:49 PM, oh...@cox.net wrote:
 oh...@cox.net wrote:
 Sorin Manolachesor...@gmail.comwrote:
And I forgot to say: run gdb in some sort of environment where 
you see
your current source code line and a couple of surrounding lines. 
You
could achieve this with the list command, but I prefer running 
gdb in
emacs and let emacs do the nice listing of source code in a 
different panel.
   
S
Here's the function from my source.  It's the original from 
mod_headers.c, plus my printf:
   
   
static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
 apr_pool_t *ptemp, server_rec *s)
{
   printf(In header_post_config\n);
   header_ssl_lookup = 
APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
   return OK;
}
   
Jim
Hi,
   
I was able to get the segfault to go away.  Here's what I had to 
do:
   
- Created /etc/ld.so.conf.d/my.conf, and added the directory where 
my libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments
   
After that, Apache appears to start ok, without segfault :)!!
   
Thanks for all of the great help, esp. the suggestion about 
checking ldconfig -p.  I still don't understand why, but I'm 
just glad that I can get past this piece so now I can debug my 
module :)...
   
Later,
Jim
I'm just glad this list is as good as it is!
   
FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for 
the
linker to check in when loading a library.
   
Joe
--
http://www.silverhawk.net/
Hi,
   
Sorry to report, but my earlier report was a false positive :)...
   
I forgot that the mod_headers.c that I was doing the earlier testing 
with had all references to the libobaccess.so removed :(!!
   
So, I'm still stuck with basically the same problem, now, working 
with my full code, with the calls in it:
   
- If I compile with -L and -l, Apache segfaults when it starts
   
- If I compile without -L and -l, then I get undefined symbol 
errors when I try to start Apache, e.g.:
   
[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl 
-k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: 
Cannot load /apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: 
ObResource_isProtected
   
That ObResource_isProtected should be a symbol in libobaccess.so, 
and in fact, if I do nm --dynamic, I get:
   
[root@apachemodule build-mod_headers]# nm --dynamic 
/apps/netpoint/lib64/libobaccess.so | grep ObResource_isProtected
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#
   
   
I'm *assuming* that the reason for the undefined symbol error is 
that libobaccess.so is actually not being loaded, but then when I 
try to load libobaccess.so, either via -L and -l in the apxs, or 
using LoadFile in httpd.conf, I get the segfault (same gdb info, 
BTW).
   
Catch-22?
   
Sorry for the false alarm :(!!
   
Jim
   
   
Not a catch-22.  The -L and -l specify linker options when assembling
the code.  The ldconfig is a run-time thing.  If you are getting the
stderr messages, you are making it all the way into your library.  I'd
suggest commenting out the following line and see if you get farther :
   
header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
   
That should tell you if the problem is the ssl_var_lookup.
   
Joe
--
http://www.silverhawk.net/
   
Hi,
   
Thanks for the suggestion.  I just tried what you suggested, and got a 
segfault when I started Apache with the modified module.
   
Jim
   
   
Hi,
   
As a reminder, here's the gdb with the library loaded:
   
   
(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 -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
/apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
Pending breakpoint header_post_config resolved
mod_headers-jl 

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 9:39 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.com  wrote:

On 6/21/12 7:32 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.com   wrote:

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.comwrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolachesor...@gmail.com wrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the list command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S

Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
  apr_pool_t *ptemp, server_rec *s)
{
printf(In header_post_config\n);
header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking ldconfig 
-p.  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/

Hi,

Sorry to report, but my earlier report was a false positive :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
full code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get undefined symbol errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That ObResource_isProtected should be a symbol in libobaccess.so, and in fact, if I do 
nm --dynamic, I get:

[root@apachemodule build-mod_headers]# nm --dynamic /apps/netpoint/lib64/libobaccess.so | 
grep ObResource_isProtected
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the undefined symbol error is that 
libobaccess.so is actually not being loaded, but then when I try to load libobaccess.so, 
either via -L and -l in the apxs, or using LoadFile in httpd.conf, I get the segfault 
(same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim



Not a catch-22.  The -L and -l specify linker options when assembling
the code.  The ldconfig is a run-time thing.  If you are getting the
stderr messages, you are making it all the way into your library.  I'd
suggest commenting out the following line and see if you get farther :

header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/

Hi,

Thanks for the suggestion.  I just tried what you suggested, and got a segfault 
when I started Apache with the modified module.

Jim



Hi,

As a reminder, here's the gdb with the library loaded:


(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 -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
/apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
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 182897610272 (LWP 11317)]

Breakpoint 2, header_post_config (pconf=0x573138, plog=0x5a52c8, 
ptemp=0x5a72d8, s=0x59d3a8) at mod_headers.c:1121
1121printf(In header_post_config\n);

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Joe Lewis j...@joe-lewis.com wrote: 
 On 6/21/12 9:39 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   oh...@cox.net wrote:
   Joe Lewisj...@joe-lewis.com  wrote:
  On 6/21/12 7:32 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   Joe Lewisj...@joe-lewis.com   wrote:
  On 6/21/12 6:46 PM, oh...@cox.net wrote:
   Joe Lewisj...@joe-lewis.comwrote:
  On 6/21/12 5:49 PM, oh...@cox.net wrote:
   oh...@cox.net wrote:
   Sorin Manolachesor...@gmail.com wrote:
  And I forgot to say: run gdb in some sort of environment where 
  you see
  your current source code line and a couple of surrounding lines. 
  You
  could achieve this with the list command, but I prefer running 
  gdb in
  emacs and let emacs do the nice listing of source code in a 
  different panel.
 
  S
  Here's the function from my source.  It's the original from 
  mod_headers.c, plus my printf:
 
 
  static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec 
  *s)
  {
  printf(In header_post_config\n);
  header_ssl_lookup = 
  APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
  return OK;
  }
 
  Jim
  Hi,
 
  I was able to get the segfault to go away.  Here's what I had to 
  do:
 
  - Created /etc/ld.so.conf.d/my.conf, and added the directory where 
  my libobaccess.so was
  - Run 'ldconfig' to activate.
  - In the apxs command, DON'T include the -L and -l arguments
 
  After that, Apache appears to start ok, without segfault :)!!
 
  Thanks for all of the great help, esp. the suggestion about 
  checking ldconfig -p.  I still don't understand why, but I'm 
  just glad that I can get past this piece so now I can debug my 
  module :)...
 
  Later,
  Jim
  I'm just glad this list is as good as it is!
 
  FYI, the ldconfig is the dynamic linker control, and those
  /etc/ld.so.conf.d files provide additional search directories for 
  the
  linker to check in when loading a library.
 
  Joe
  --
  http://www.silverhawk.net/
  Hi,
 
  Sorry to report, but my earlier report was a false positive :)...
 
  I forgot that the mod_headers.c that I was doing the earlier testing 
  with had all references to the libobaccess.so removed :(!!
 
  So, I'm still stuck with basically the same problem, now, working 
  with my full code, with the calls in it:
 
  - If I compile with -L and -l, Apache segfaults when it starts
 
  - If I compile without -L and -l, then I get undefined symbol 
  errors when I try to start Apache, e.g.:
 
  [root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl 
  -k start -X
  httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: 
  Cannot load /apps/httpd/modules/mod_headers.so into server: 
  /apps/httpd/modules/mod_headers.so: undefined symbol: 
  ObResource_isProtected
 
  That ObResource_isProtected should be a symbol in libobaccess.so, 
  and in fact, if I do nm --dynamic, I get:
 
  [root@apachemodule build-mod_headers]# nm --dynamic 
  /apps/netpoint/lib64/libobaccess.so | grep ObResource_isProtected
  000a6d80 T ObResource_isProtected
  [root@apachemodule build-mod_headers]#
 
 
  I'm *assuming* that the reason for the undefined symbol error is 
  that libobaccess.so is actually not being loaded, but then when I 
  try to load libobaccess.so, either via -L and -l in the apxs, or 
  using LoadFile in httpd.conf, I get the segfault (same gdb info, 
  BTW).
 
  Catch-22?
 
  Sorry for the false alarm :(!!
 
  Jim
 
 
  Not a catch-22.  The -L and -l specify linker options when assembling
  the code.  The ldconfig is a run-time thing.  If you are getting the
  stderr messages, you are making it all the way into your library.  I'd
  suggest commenting out the following line and see if you get farther :
 
  header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 
  That should tell you if the problem is the ssl_var_lookup.
 
  Joe
  --
  http://www.silverhawk.net/
  Hi,
 
  Thanks for the suggestion.  I just tried what you suggested, and got a 
  segfault when I started Apache with the modified module.
 
  Jim
 
 
  Hi,
 
  As a reminder, here's the gdb with the library loaded:
 
 
  (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 -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
  Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
  /apps/httpd/conf/httpd.conf
  [Thread debugging using libthread_db enabled]
  [New Thread 182897610272 (LWP 11317)]
  Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
  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 

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 10:02 PM, oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.com  wrote:

On 6/21/12 9:39 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.com   wrote:

On 6/21/12 7:32 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.comwrote:

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewisj...@joe-lewis.com wrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolachesor...@gmail.com  wrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the list command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S

Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
   apr_pool_t *ptemp, server_rec *s)
{
 printf(In header_post_config\n);
 header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking ldconfig 
-p.  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/

Hi,

Sorry to report, but my earlier report was a false positive :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
full code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get undefined symbol errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That ObResource_isProtected should be a symbol in libobaccess.so, and in fact, if I do 
nm --dynamic, I get:

[root@apachemodule build-mod_headers]# nm --dynamic /apps/netpoint/lib64/libobaccess.so | 
grep ObResource_isProtected
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the undefined symbol error is that 
libobaccess.so is actually not being loaded, but then when I try to load libobaccess.so, 
either via -L and -l in the apxs, or using LoadFile in httpd.conf, I get the segfault 
(same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim



Not a catch-22.  The -L and -l specify linker options when assembling
the code.  The ldconfig is a run-time thing.  If you are getting the
stderr messages, you are making it all the way into your library.  I'd
suggest commenting out the following line and see if you get farther :

header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/

Hi,

Thanks for the suggestion.  I just tried what you suggested, and got a segfault 
when I started Apache with the modified module.

Jim



Hi,

As a reminder, here's the gdb with the library loaded:


(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 -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
/apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
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 182897610272 (LWP 11317)]

Breakpoint 2, header_post_config (pconf=0x573138, plog=0x5a52c8, 

Re: md5crypt passwords

2012-06-21 Thread Ben Laurie
On Wed, Jun 20, 2012 at 1:25 PM, Nick Edwards nick.z.edwa...@gmail.com wrote:
 Hello,

 I posted this to users list last week but no-one bit, so I'm trying here.

 With md5crypt no longer recommended for use by its author, will Apache
 soon support sha256/sha512 in basic authentication via MySQL.

 I understand the apr version is different to plain md5crypt, but it is
 based on the same thing from what I can tell, so its pointless
 upgrading our database passwords to use sha512 if Apache's still the
 weak link.

 All admin scripts run in perl, and we are currently doing this with
 apache_md5_crypt($password); using Crypt::PasswdMD5

 For Mail and FTP, we are _now_ successfully using  crypt($password,
 '$6$' . $16charsalt) for sha512, be nice if Apache basic auth would
 too!

 Apache currently only offers SHA1 which is about as secure (can be
 read as , as hopeless as) MD5.

 Can the project devs/team leaders indicate if there are future plans
 to mnprove the basic auth security methods up to SHA512?

This thread is all over the place!

So, a summary...

* SHA-1 is not as broken as MD5 - no way to generate collisions has
been found that is practical.

* MD5 is still pre-image resistant even though it is possible to
generate collisions. This means that repeated applications of MD5 are
also pre-image resistant.

* The threat against md5crypt is the same as it has always been:
rainbow tables. The current attacks have not changed this.

* htpasswd uses an 8 byte salt with 6 bits per byte. So, a rainbow
table will have 2^48 entries per password. Assuming you can somehow
manage 1 byte per entry, that's still nearly 300 TB per password.

So, I'd say there's no need for panic, but there's also no reason that
I can see to not move to a more modern scheme.

Then the question is: what scheme? Here are some design criteria I
think would be useful.

1. Use something from the SHA-2 family - SHA-512 would seem fine to me.

2. Use a very large salt - disk space is not at a premium for password stores!

3. Use quite a lot of rounds,.

4. Use something that is hard to optimise in hardware (ideally).


Re: md5crypt passwords

2012-06-21 Thread Issac Goldstand
On 21/06/2012 12:40, Ben Laurie wrote:
 4. Use something that is hard to optimise in hardware (ideally). 
And what about massive sites that need the crypto HW to manage the
concurrent logins?

Yes, you're making it harder on the hackers, but also potentially on our
users. 

...Or did I just put my foot in my crypto-clueless-mouth?

  Issac



Re: md5crypt passwords

2012-06-21 Thread Ben Laurie
On Thu, Jun 21, 2012 at 10:53 AM, Issac Goldstand mar...@beamartyr.net wrote:
 On 21/06/2012 12:40, Ben Laurie wrote:
 4. Use something that is hard to optimise in hardware (ideally).
 And what about massive sites that need the crypto HW to manage the
 concurrent logins?

I have never come across a site where login causes significant load.
They may exist, but I figure they can do their own thing for
passwords...

 Yes, you're making it harder on the hackers, but also potentially on our
 users.

 ...Or did I just put my foot in my crypto-clueless-mouth?

  Issac



Re: md5crypt passwords

2012-06-21 Thread Noel Butler
On Thu, 2012-06-21 at 10:40 +0100, Ben Laurie wrote:


 
 4. Use something that is hard to optimise in hardware (ideally).


5.  Only hire web developers who know what they're doing, who know what
security is, and how to audit their code :)

If they cant get the database, then it wouldn't mater if they were in
*gulp* plain text

attachment: face-smile.png

signature.asc
Description: This is a digitally signed message part


Re: md5crypt passwords

2012-06-21 Thread Noel Butler
On Thu, 2012-06-21 at 10:57 +0100, Ben Laurie wrote:

 On Thu, Jun 21, 2012 at 10:53 AM, Issac Goldstand mar...@beamartyr.net 
 wrote:
  On 21/06/2012 12:40, Ben Laurie wrote:
  4. Use something that is hard to optimise in hardware (ideally).
  And what about massive sites that need the crypto HW to manage the
  concurrent logins?
 
 I have never come across a site where login causes significant load.


That's because all the commonly used methods are cryptographic hash's
that are designed for speed, unlike password hash's, designed to makes
things crawl for the norti peoples.




signature.asc
Description: This is a digitally signed message part


Re: md5crypt passwords

2012-06-21 Thread André Malo
* Reindl Harald wrote:

 i only needed to point out that weakhash(weakhash(weakhash()))
 does not result in stronghash() no matter how often you wrap

I'm not sure, why the topic drifted there anyway. md5crypt does not actually 
nest hashes like this.

nd
-- 
package Hacker::Perl::Another::Just;print
qq~@{[reverse split/::/ =__PACKAGE__]}~;

#  André Malo  #  http://www.perlig.de  #


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread ohaya

 Sorin Manolache sor...@gmail.com wrote: 
 On 2012-06-21 19:47, oh...@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/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   
  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread 
  -I/apps/httpd/include  -I/apps/httpd/include   
  -I/apps/httpd/include   -c -o mod_headers.lo mod_headers.c  touch 
  mod_headers.slo
  /apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la  
  -l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
  /apps/httpd/modules -module -avoid-versionmod_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/httpd/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) = 
0x2a983c
read(3, # Locale name alias data base.\n#..., 4096) = 2528
read(3, , 4096)   = 0
close(3)= 0
munmap(0x2a983c, 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/httpd/bin/apachectl: l..., 
83/apps/httpd/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(0x)= 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


Empty cookies [Was Re: libapreq2 co-maintainer]

2012-06-21 Thread Issac Goldstand
On 20/06/2012 14:19, Thomas Busch wrote:
 On 20/06/2012 13:35, Thomas Busch wrote:
 The reason I'm asking is that the following bug

 https://rt.cpan.org/Public/Bug/Display.html?id=69866

 hasn't been solved and is still causing Internal Server Error's on
 a lot of mod_perl installation.

 I see you've got a suggested patch there, so there's a good chance that
 someone will pick that up - if noone does it by the weekend, I'll try to
 pick it up myself.


Joe, you seemingly addressed this in r748782 and then intentionally put
it back in r748790 - you touched the exact test case which would deal
with the a cookie that looked like Cookie: foo=bar;foo2=test;blabla. 
Any recollections of why you put it back?

  Issac


Re: md5crypt passwords

2012-06-21 Thread Nick Edwards
Hi Stefan,

On 6/21/12, Stefan Fritsch s...@sfritsch.de wrote:
 On Wed, 20 Jun 2012, Nick Edwards wrote:
 I posted this to users list last week but no-one bit, so I'm trying here.

 With md5crypt no longer recommended for use by its author, will Apache
 soon support sha256/sha512 in basic authentication via MySQL.

 Note that it does not really matter that much which hash algorithm is
 used. The number of rounds is more important. APR-MD5 ($apr1$) does 1000
 times recursive md5 (which is 1000 times more secure in terms of brute
 forcing than plain md5). We should switch to something that needs more
 processing time so that it is more difficult to brute force.

 I understand the apr version is different to plain md5crypt, but it is
 based on the same thing from what I can tell, so its pointless
 upgrading our database passwords to use sha512 if Apache's still the
 weak link.

 All admin scripts run in perl, and we are currently doing this with
 apache_md5_crypt($password); using Crypt::PasswdMD5

 For Mail and FTP, we are _now_ successfully using  crypt($password,
 '$6$' . $16charsalt) for sha512, be nice if Apache basic auth would
 too!

 APR passes everything it doesn't know to the system's crypt() function. So
 chances are good that using $6$... already works for you. However, there
 is currently no way to create such hashes with htpasswd.



Thanks, it does work, I did not realise this, because some time ago I
tried to use our default md5cryprt password used for ftp and mail, but
Apache did not like it, after much googling I found reference saying
it was different and needed apr1, if it falls back why would that have
failed for us? or is this fallback only something new?



 I would be for importing some state of the art scheme from some BSD. Good
 schemes allow to change the number of rounds without loosing backward
 compatibility. I guess bcrypt is a candidate. This new algorithm should
 then be the new default.


Don't know much about bcrypt sorry.

Thanks again for your help, all is now happy


Re: LimitRequestFieldSize: spurious note about max value?

2012-06-21 Thread Bojan Smojver
On Tue, 2012-06-19 at 15:42 +1000, Bojan Smojver wrote:
 Docs contain this note for LimitRequestFieldSize directive:
 
 noteUnder normal conditions, the value should not be changed from
 the default. Also, you can't set this higher than 8190 without
 modifying the source code and rebuilding./note
 
 I was under the impression that the hardcoded upper limit was removed in
 r149269. No?

So, nobody will mind if I remove that comment from the docs then? I
think I have commit there, although never really tried...

-- 
Bojan