On Fri, 2006-08-18 at 10:23 +0100, Nick Kew wrote:
> On Friday 18 August 2006 08:19, paritosh wrote:
> > Hi Nick,
> >
> > I'm using the latest revision of mod_dbd.c and I still get a segfault on
> > startup. My setup:
> >
> > CONFIGURE FLAGS:
> > ./configure --enable-so --enable-auth-digest --enable-dbd
> > --enable-authn-dbd --with-mysql=/usr
> 
> So that's static compilation ...
> >
> > HTTPD.CONF:
> 
> Looks fine, but
> 
> >   AuthDBDUserRealmQuery "SELECT pwhash FROM users WHERE name = %s and
> > realm = %s"
> 
> doesn't look much like
> 
> > #4  0x0807dedb in authn_dbd_prepare (cmd=0xbfc9701c, cfg=0x812d190,
> > query=0x812d198 "SELECT pwhash FROM principals INNER JOIN users ON
> > principals.resource_id = users.principal_id WHERE name = %s and name !=
> > %s") at mod_authn_dbd.c:72
> 
> 
> > GDB BACKTRACE:
> 
> OK, here we have a problem at:
> 
> > #3  0x08082a96 in ap_dbd_prepare (s=0x80d3ab0, query=0xffffffff <Address
> > 0xffffffff out of bounds>, label=0xffffffff <Address 0xffffffff out of
> > bounds>) at mod_dbd.c:152
> 
> where the query and label pointers are garbage.  That's the kind of
> thing I'd expect if one or more of your modules was compiled on a
> slightly different architecture.  But I guess we can rule that out
> since you compiled statically (assuming you compiled on the same
> machine it's running on?)
> 
Yes, it's the same machine.

> Can you compile mod_dbd (and perhaps also mod_authn_dbd) with
> -O0 rather than the default -O2, so we don't get that kind of report
> as an artifact of compilation optimisation?
> 
> 

recompiled everything with -O0, the new backtrace is:

(gdb) run -X -d ..
[Thread debugging using libthread_db enabled]
[New Thread -1212528960 (LWP 10335)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1212528960 (LWP 10335)]
0xb7d55f2d in apr_hashfunc_default (char_key=0x0, klen=0xbf94b1d8) at
tables/apr_hash.c:228
/home/paritosh/limespot/apache2.2.3/srclib/apr/tables/apr_hash.c:228:7055:beg:0xb7d55f2d
(gdb) bt
#0  0xb7d55f2d in apr_hashfunc_default (char_key=0x0, klen=0xbf94b1d8)
at tables/apr_hash.c:228
#1  0xb7d55fad in find_entry (ht=0x813f270, key=0x0, klen=-1, val=0x0)
at tables/apr_hash.c:260
#2  0xb7d5626f in apr_hash_get (ht=0x813f270, key=0x0, klen=-1) at
tables/apr_hash.c:330
#3  0x0808c433 in ap_dbd_prepare (s=0x80eaab0, query=0x8144178 "SELECT
pwhash FROM users WHERE name = %s and realm = %s", label=0x81441b8
"authn_dbd_1") at mod_dbd.c:152
#4  0x08086243 in authn_dbd_prepare (cmd=0xbf94b76c, cfg=0x8144170,
query=0x8144178 "SELECT pwhash FROM users WHERE name = %s and realm = %
s") at mod_authn_dbd.c:72
#5  0x0807a59e in invoke_cmd (cmd=0x80c9218, parms=0xbf94b76c,
mconfig=0x8144170, args=0x8125541 "") at config.c:768
#6  0x0807b70a in ap_walk_config_sub (current=0x81254e8,
parms=0xbf94b76c, section_vector=0x8143ba8) at config.c:1141
#7  0x0807b7a4 in ap_walk_config (current=0x81254e8, parms=0xbf94b76c,
section_vector=0x8143ba8) at config.c:1174
#8  0x0806fbc4 in urlsection (cmd=0xbf94b76c, mconfig=0x8125198,
arg=0x8143e28 "") at core.c:1942
#9  0x0807a3f6 in invoke_cmd (cmd=0x80c67f8, parms=0xbf94b76c,
mconfig=0x8125198, args=0x81253c8 "/private>") at config.c:735
#10 0x0807b70a in ap_walk_config_sub (current=0x812b1f8,
parms=0xbf94b76c, section_vector=0x8124228) at config.c:1141
#11 0x0807b7a4 in ap_walk_config (current=0x812b1f8, parms=0xbf94b76c,
section_vector=0x8124228) at config.c:1174
#12 0x0807c7b3 in ap_process_config_tree (s=0x80eaab0,
conftree=0x812a308, p=0x80e20a8, ptemp=0x8122220) at config.c:1743
#13 0x08062507 in main (argc=4, argv=0xbf94b8f4) at main.c:621

The problem is that s->server_hostname is sent as 'key' to
apr_hash_get(). But it is NULL if ServerName directive is not set in the
httpd.conf. Simply adding following to httpd.conf solved the problem:

SeverName 127.0.0.1:80

( I should mention that 2.2.2 with similar setup did not crash even
without the ServerName directive )



Reply via email to