You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Anton Golubev <an...@engec.ru> on 2006/07/20 00:33:32 UTC

apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Hi all,

Apache  crashes at the start time in mod_dbd.c then AuthDBDUserPWQuery
is not empty. The crash triggered even with then AuthDBDUserPWQuery is
“1”. Isn’t it a bug in Apache? I would like to listen to some feedback
from  the  list  before  I  file  it  in  bug tracking system. I'm not
familiar  with  2.2  version and may be wrong in some aspects of using
it.

Crash dump:


Starting program: /usr/local/apache2_2/bin/httpd -M
[Thread debugging using libthread_db enabled]
[New Thread -1208748352 (LWP 19317)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208748352 (LWP 19317)]
ap_dbd_prepare (s=0x0, query=0x8608560 "select PASS from Users where LOGIN= %s", label=0x8608560 "select PASS from Users where LOGIN= %s") at mod_dbd.c:149
149         prepared->next = svr->prepared;
(gdb) bt
#0  ap_dbd_prepare (s=0x0, query=0x8608560 "select PASS from Users where LOGIN= %s", label=0x8608560 "select PASS from Users where LOGIN= %s")
    at mod_dbd.c:149
#1  0x08080415 in authn_dbd_prepare (cmd=0xbff80a40, cfg=0x8608558, query=0x8608560 "select PASS from Users where LOGIN= %s") at mod_authn_dbd.c:70
#2  0x0807880b in invoke_cmd (cmd=0x80d30a0, parms=0xbff80a40, mconfig=0x8608558, args=0x85daf70 "") at config.c:873
#3  0x08079075 in ap_walk_config (current=0x85daf28, parms=0xbff80a40, section_vector=0x8607f28) at config.c:1141
#4  0x08070d09 in dirsection (cmd=0xbff80a40, mconfig=0x8606918, arg=0x86081d6 "") at core.c:1865
#5  0x0807880b in invoke_cmd (cmd=0x80d0a80, parms=0xbff80a40, mconfig=0x8606918, args=0x85dacd0 "/home/ivc2/public_html>") at config.c:873
#6  0x08079075 in ap_walk_config (current=0x85dacb0, parms=0xbff80a40, section_vector=0x8606578) at config.c:1141
#7  0x08071553 in virtualhost_section (cmd=0xbff80a40, dummy=0x85adfe8, arg=0x85da7f0 "85.142.33.11>") at core.c:2206
#8  0x0807880b in invoke_cmd (cmd=0x80d0ab0, parms=0xbff80a40, mconfig=0x85adfe8, args=0x85da7f0 "85.142.33.11>") at config.c:873
#9  0x08079075 in ap_walk_config (current=0x85da7d0, parms=0xbff80a40, section_vector=0x85acf00) at config.c:1141
#10 0x08079ace in ap_process_config_tree (s=0x856d570, conftree=0x85b22b0, p=0x85620a8, ptemp=0x85aa240) at config.c:1743
#11 0x08067eeb in main (argc=2, argv=0xbff80ba4) at main.c:621
(gdb)

Relevant part of mod_dbd.c:

DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec *s, const char *query,
                                        const char *label)
{
    svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
    dbd_prepared *prepared = apr_pcalloc(s->process->pool, sizeof(dbd_prepared));
    prepared->label = label;
    prepared->query = query;
    prepared->next = svr->prepared;
    svr->prepared = prepared;
}

Software versions: apache 2.2.2, arp 1.2.7, linux kernel  2.6.9-34.0.1.EL.
Distribution: CentOS 4.3 on i386.

httpd compilation options: 

  $ ./configure --prefix=/usr/local/apache2_2 --sysconfdir=/usr/local/apache/conf --enable-so --enable-dav --enable-dav-fs --enable-dav-lock --enable-suexec --with-suexec-logfile=/usr/local/apache/logs/suexec_log --with-suexec-caller=nobody --with-suexec-uidmin=100 --with-suexec-gidmin=100 --with-suexec-docroot=/  --with-suexec-userdir=public_html --enable-logio --enable-ssl --enable-rewrite --enable-dbd --enable-authn-dbd

arp-utils configuration options:

"/home/cpeasyapache/work/cPanelEA/Apache2_2.pm.build/httpd-2.2.2/srclib/apr-util/configure" \
"--prefix=/usr/local/apache2_2" \
"--sysconfdir=/usr/local/apache/conf" \
"--enable-so" \
"--enable-dav" \
"--enable-dav-fs" \
"--enable-dav-lock" \
"--enable-suexec" \
"--with-suexec-logfile=/usr/local/apache/logs/suexec_log" \
"--with-suexec-caller=nobody" \
"--with-suexec-uidmin=100" \
"--with-suexec-gidmin=100" \
"--with-suexec-docroot=/" \
"--with-suexec-userdir=public_html" \
"--enable-logio" \
"--enable-ssl" \
"--enable-rewrite" \
"--enable-dbd" \
"--enable-authn-dbd" \
"--cache-file=/dev/null" \
"--srcdir=/home/cpeasyapache/work/cPanelEA/Apache2_2.pm.build/httpd-2.2.2/srclib/apr-util" \
"--with-apr=../apr" \
"--prefix=/usr/local/apache2_2" \
"--exec-prefix=/usr/local/apache2_2" \
"--libdir=/usr/local/apache2_2/lib" \
"--includedir=/usr/local/apache2_2/include" \
"--bindir=/usr/local/apache2_2/bin" \
"--with-mysql=/usr" \
"$@"


Relevant config section:

    <Directory /home/ivc2/public_html>
        AllowOverride All
        Options +Includes

        AuthType Basic
        AuthName 'ADMIN ZONE'
        AuthBasicProvider dbd

#       AuthDBDUserPWQuery "select PASS from Users where LOGIN= %s"
        AuthDBDUserPWQuery "1"

        require valid-user

    </Directory>


Thank you a lot,

Anton Golubev
ENGECON
St. Petersburg


Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Anton Golubev <an...@engec.ru>.
Hello Nick,

> What I'd like to see is dynamic loading of apr-util modules, and a
> build process as simple as apxs.  But that's another subject.

I  agree,  they  are  both important features to stimulate wider deployment and
courage users to write extensions for this relatively new module.

> That should work I think ... if you're connected to a database where
> that's valid.  What happens if you use apr_dbd syntax of
> "select PASS from Users where LOGIN=%s"?

I get the same error with '%s' style of statement (anyway it get
reduced to '?' form for argument by your code).

Strange thing. For testing I have two essentially identical apache builds on
freebsd and linux. They both share very close configs, but FreeBSD box
says:

[error] [client 127.0.0.1] No DBD Authn configured!

while linux:

(20014)Internal error: DBD: failed to initialise prepared SQL statements

I'll continue to research that tomorrow.

Anton Golubev
ENGECON
St. Petersburg


Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Friday 18 August 2006 12:35, paritosh wrote:

> recompiled everything with -O0, the new backtrace is:

> #2  0xb7d5626f in apr_hash_get (ht=0x813f270, key=0x0, klen=-1) at
> tables/apr_hash.c:330

Aha!  NULL key.  That should be the server name.

> #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

whereas that now makes sense.  The junk before was indeed optimisation.

> #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

That should be line 70, not 72.  Still slightly confusing.

Anyway, this traceback iidentifies the problem: we need to make a
special case of a null server name.

> 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 )

Yes, the fix in 2.2.3 over 2.2.2 was for a bug in handling of virtualhosts.
Thanks for the report, and for helping to fix it!

I'll commit a patch to /trunk/ shortly.

-- 
Nick Kew

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by paritosh <pa...@limewire.co.in>.
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 )




Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
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?)

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?


-- 
Nick Kew

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by paritosh <pa...@limewire.co.in>.
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

HTTPD.CONF:

DBDriver mysql
DBDParams "dbname=xxx user=xxx pass=xxx"

<Location /private>
  AuthType Digest
  AuthName "xxx"

  AuthDigestProvider dbd

  Require valid-user

  AuthDBDUserRealmQuery "SELECT pwhash FROM users WHERE name = %s and
realm = %s"
</Location>

GDB BACKTRACE:

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

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1212180800 (LWP 23469)]
apr_hashfunc_default (char_key=0x0, klen=0xbfc96c38) at
tables/apr_hash.c:228
/home/paritosh/limespot/apache2.2/srclib/apr/tables/apr_hash.c:228:7055:beg:0xb7daa3ce
(gdb) bt
#0  apr_hashfunc_default (char_key=0x0, klen=0xbfc96c38) at
tables/apr_hash.c:228
#1  0xb7daa437 in find_entry (ht=0x8128270, key=0x0, klen=-1, val=0x0)
at tables/apr_hash.c:260
#2  0xb7daa5f4 in apr_hash_get (ht=0xffffffff, key=0xbfc96c38, klen=-1)
at tables/apr_hash.c:330
#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
#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
#5  0x080747f9 in invoke_cmd (cmd=0x80b3398, parms=0xbfc9701c,
mconfig=0x812d190, args=0x810e58e "") at config.c:873
#6  0x080755d2 in ap_walk_config (current=0x810e4f0, parms=0xbfc9701c,
section_vector=0x812cba8) at config.c:1141
#7  0x0806bec4 in urlsection (cmd=0xbfc9701c, mconfig=0x810e198,
arg=0x812ce28 "") at core.c:1942
#8  0x080747f9 in invoke_cmd (cmd=0x80b0cd8, parms=0xbfc9701c,
mconfig=0x810e198, args=0x810e3c8 "/private>") at config.c:873
#9  0x080755d2 in ap_walk_config (current=0x81141f8, parms=0xbfc9701c,
section_vector=0x810d228) at config.c:1141
#10 0x080762b6 in ap_process_config_tree (s=0xbfc96c38,
conftree=0xffffffff, p=0x80cb0a8, ptemp=0xffffffff) at config.c:1743
#11 0x08062071 in main (argc=4, argv=0xbfc97174) at main.c:621

On Thu, 2006-08-17 at 15:21 +0100, Nick Kew wrote:
> On Thursday 17 August 2006 14:51, paritosh wrote:
> > Hi all,
> >
> >
> > I had a working installation of apache 2.2.2 with mod_dbd and
> > mod_authn_dbd configured. Recently I upgraded to 2.2.3 and the server
> > crashes with the same backtrace. ( it crashes in apr_hashfunc_default at
> > tables/apr_hash.c:228 ).
> 
> That is not a backtrace.
> 
> > Have there been any developments towards 
> > resolving this ?
> 
> http://svn.apache.org/viewvc?view=rev&revision=424798
> http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/database/mod_dbd.c?r1=421103&r2=425659
> 


Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Thursday 17 August 2006 14:51, paritosh wrote:
> Hi all,
>
>
> I had a working installation of apache 2.2.2 with mod_dbd and
> mod_authn_dbd configured. Recently I upgraded to 2.2.3 and the server
> crashes with the same backtrace. ( it crashes in apr_hashfunc_default at
> tables/apr_hash.c:228 ).

That is not a backtrace.

> Have there been any developments towards 
> resolving this ?

http://svn.apache.org/viewvc?view=rev&revision=424798
http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/database/mod_dbd.c?r1=421103&r2=425659

-- 
Nick Kew

Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by paritosh <pa...@limewire.co.in>.
Hi all,


I had a working installation of apache 2.2.2 with mod_dbd and
mod_authn_dbd configured. Recently I upgraded to 2.2.3 and the server
crashes with the same backtrace. ( it crashes in apr_hashfunc_default at
tables/apr_hash.c:228 ). Have there been any developments towards
resolving this ?

On Thu, 2006-07-27 at 21:21 +0400, Anton Golubev wrote:
> Hello Nick,
> 
> I did some tests again with mod_dbd, but now against trunk versions of
> httpd, apr, apr-utils. And it seems to me, that the problem persists.
> It crashes with the same symptoms as I posted last week.
> Function ap_dbd_prepare called with corrupted arguments (s=0x80e6ed0, query=0xffffffff,
> label=0xffffffff), which led to crash in apr_hashfunc_default
> (char_key=0x0, klen=0xbfbfe2c0).
> 
> My previous post about "soft" prepare problem looks to be irrelevant.
> "Internal error: DBD: failed to initialise prepared SQL statements"
> seems to be a back-side of corrupted but not crashed query handler.
> 
> I included httpd.conf, gdb output and my compilation options.
> 
> I would be glad to hear, that something is wrong with my environment
> (e.g. compilation, configuration etc), but I couldn't find anything I
> can fix.
> 
> Anton Golubev
> ENGECON
> St. Petersburg
> 
> P.S. Regarding autoconf for APR-Utils. Mysql detection has been fixed
> by Bojan a month ago in trunk version. So my patches are a bit outdated.
> Bojan also uses mysql-config to determine path to the libraries.
> The current status: it's broken in 1.2.7, but fixed in not yet
> released 1.3.0.


Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Anton Golubev <an...@engec.ru>.
Hello Nick,

I did some tests again with mod_dbd, but now against trunk versions of
httpd, apr, apr-utils. And it seems to me, that the problem persists.
It crashes with the same symptoms as I posted last week.
Function ap_dbd_prepare called with corrupted arguments (s=0x80e6ed0, query=0xffffffff,
label=0xffffffff), which led to crash in apr_hashfunc_default
(char_key=0x0, klen=0xbfbfe2c0).

My previous post about "soft" prepare problem looks to be irrelevant.
"Internal error: DBD: failed to initialise prepared SQL statements"
seems to be a back-side of corrupted but not crashed query handler.

I included httpd.conf, gdb output and my compilation options.

I would be glad to hear, that something is wrong with my environment
(e.g. compilation, configuration etc), but I couldn't find anything I
can fix.

Anton Golubev
ENGECON
St. Petersburg

P.S. Regarding autoconf for APR-Utils. Mysql detection has been fixed
by Bojan a month ago in trunk version. So my patches are a bit outdated.
Bojan also uses mysql-config to determine path to the libraries.
The current status: it's broken in 1.2.7, but fixed in not yet
released 1.3.0.

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Sunday 23 July 2006 19:41, Anton Golubev wrote:
> Hi Nick,
>
> I think you are right about crash reason. It probably was an
> incompatibility of http and apr-util, which I built separately to
> overcame configuration issues. Once I've had the clean build, the problem
> disappeared.

That's a relief :-)  So the underlying bug is indeed what I thought!

> There are three issues with the current 
> auto-configuration regarding activation mysql driver for DBD:

[chop]

Thanks for the patch.  Can someone @apache who groks
autoconf/tools properly review it, as I don't feel qualified in that area?

> Hope,  that  will  help other non-programmers like me to avoid linking
> clashes trying to build all manually.

What I'd like to see is dynamic loading of apr-util modules, and a
build process as simple as apxs.  But that's another subject.

> Besides that, I still can't get DBD authorization with mysql driver
> running. It is very hard to guess, what it behind the error:
> "Internal error: DBD: failed to initialise prepared SQL statements"
> when the query as simple as
> "select PASS from Users where LOGIN=?"

That should work I think ... if you're connected to a database where
that's valid.  What happens if you use apr_dbd syntax of
"select PASS from Users where LOGIN=%s"?

> I have been trying to implement mysql errno printing to get at least
> the direction of the problem, but I haven't found the proper way, how
> to do that.

I attach a patch that adds the error from mysql (note, the chunk
around line 300 is the only one that wasn't in the previous patch).

> I would be very-very grateful for the help with debugging this.

Me too.  Thanks for the very useful reports!

-- 
Nick Kew

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Henrik Nordstrom <hn...@squid-cache.org>.
sön 2006-07-23 klockan 00:10 +0100 skrev Nick Kew:

> But if you look at the full traceback and crossreference it to the
> source, I think that looks improbable.  Do you have sufficient gcc/gdb
> expertise to shed real light on this?

Not really, only experience..

From what I have seen the causes to significantly garbled/nonsense
arguments in stack traces is

  7 of 10 -O2 somehow messing with the arguments or otherwise making gdb
confused
  2 of 10 smashed stacks in the called function
  1 of 10 bugs in the calling function or earlier actually passing
non-sense data to the function.

The first and last can be identified by going up to the calling function
and inspecting what the arguments should have been.

The middle by hexdumping the stack contents, and looking at matching
usage of nearby local arrays.

Regards
Henrik

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Saturday 22 July 2006 22:34, Henrik Nordstrom wrote:
> lör 2006-07-22 klockan 18:00 +0100 skrev Nick Kew:
> > #3  0x08081d67 in ap_dbd_prepare (s=0x8daf5a0, query=0xffffffff <Address
> > 0xffffffff out of bounds>, label=0xffffffff <Address 0xffffffff out of
> > bounds>)
> >     at mod_dbd.c:150
>
> Note: Could maybe be -O2 or higher optimizing away the variables when
> they are no longer needed. Seen such things happen very often on many
> platforms. Does not need to indicate a bug or even a problem..

That was my thought with the first traceback, when I saw a potential
bug with mixing per-vhost and per-directory configuration, and Brian
(and coincidentally someone else yesterday on IRC) reported what
appeared to be the same bug.

But if you look at the full traceback and crossreference it to the
source, I think that looks improbable.  Do you have sufficient gcc/gdb
expertise to shed real light on this?

-- 
Nick Kew

Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Anton Golubev <an...@engec.ru>.
Hi Nick,

I think you are right about crash reason. It probably was an
incompatibility of http and apr-util, which I built separately to
overcame configuration issues. Once I've had the clean build, the problem
disappeared. There are three issues with the current
auto-configuration regarding activation mysql driver for DBD:

1.  Autoconf  doesn't  find mysqlclient library in default place and doesn't
allow user to point to it besides LDFLAGS.

3. It always fails to test existence of mysqlclient_r, since the test
doesn't include -lpthread, which it required.

2. apr_dbd_mysql.c has stale HAVE_MYSQL_H directives, which autoconf
doesn't set. Instead autoconf logic relies on includes dirs.

I  would  suggest  to  make  following  patches.  The  first  one will
automatically  provide  paths  for  includes  and  libs  by  utilizing
mysql_config, which is probably very portable. The second one will get
rid of stale directives from mysql driver.

Having them makes activating mysql driver as simple as:

./buildconf
./configure --with-mysql
./make install

Tested with mysql 5.0 on CentOS 4.3 and mysql 4.1 on FreeBSD 5.4.

--- dbd.m4.orig 2005-05-05 23:24:29.000000000 +0400
+++ dbd.m4      2006-07-23 23:32:03.000000000 +0400
@@ -75,50 +75,34 @@
   AC_ARG_WITH([mysql], [
   --with-mysql=DIR          **** SEE INSTALL.MySQL ****
   ], [
-    apu_have_mysql=0
-    if test "$withval" = "yes"; then
-      AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-      if test "$apu_have_mysql" == "0"; then
-        AC_CHECK_HEADER(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-        if test "$apu_have_mysql" != "0"; then
-          APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/myql])
-        fi
-      fi
-    elif test "$withval" = "no"; then
-      apu_have_mysql=0
-    else
-      CPPFLAGS="-I$withval/include"
-      LIBS="-L$withval/lib "

-      AC_MSG_NOTICE(checking for mysql in $withval)
-      AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-      if test "$apu_have_mysql" != "0"; then
-        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
-        APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
-      fi
+    if test "$withval" != "no"; then
+
+       AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, [$PATH:$withval/bin:$withval])
+        if test "$MYSQL_CONFIG" = "no"; then
+           AC_MSG_ERROR([Unable to find mysql_config])
+        else
+           dnl mysql_config found
+           AC_MSG_CHECKING([mysql ])
+           mysql_version=`$MYSQL_CONFIG --version`
+           MYSQL_LIBS=`$MYSQL_CONFIG --libs_r`
+           MYSQL_INCLUDE=`$MYSQL_CONFIG --include`
+           AC_MSG_RESULT([ version $mysql_version ])
+
+           AC_CHECK_LIB(mysqlclient_r, mysql_init, [ apu_have_mysql=1 ], AC_MSG_ERROR([Unable to find mysqlclient_r]), $MYSQL_LIBS)
+
+           APR_ADDTO(APRUTIL_INCLUDES, [$MYSQL_INCLUDE])
+           APR_ADDTO(APRUTIL_EXPORT_LIBS, [$MYSQL_LIBS])

-      if test "$apu_have_mysql" != "1"; then
-        AC_CHECK_HEADER(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
-        if test "$apu_have_mysql" != "0"; then
-          APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql])
-          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
-        fi
-      fi
+       fi
     fi
-  ], [
-    apu_have_mysql=0
-    AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
+
   ])

   AC_SUBST(apu_have_mysql)
-
-  dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
-  dnl we know the library is there.
-  if test "$apu_have_mysql" = "1"; then
-    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lmysqlclient_r])
-    APR_ADDTO(APRUTIL_LIBS,[-lmysqlclient_r])
-  fi
 ])
+
+
 dnl
 AC_DEFUN([APU_CHECK_DBD_SQLITE3], [
   apu_have_sqlite3=0



# diff -u apr_dbd_mysql.c apr_dbd_mysql.c.orig
--- apr_dbd_mysql.c     Sun Jul 23 21:03:25 2006
+++ apr_dbd_mysql.c.orig        Sun Jul 23 16:01:17 2006
@@ -45,13 +45,8 @@
 #include <ctype.h>
 #include <stdlib.h>

-#ifdef HAVE_MYSQL_H
 #include <mysql.h>
 #include <errmsg.h>
-#elif defined(HAVE_MYSQL_MYSQL_H)
-#include <mysql/mysql.h>
-#include <mysql/errmsg.h>
-#endif

 #include "apr_strings.h"
   

Hope,  that  will  help other non-programmers like me to avoid linking
clashes trying to build all manually.


Besides that, I still can't get DBD authorization with mysql driver running.
It is very hard to guess, what it behind the error:
"Internal error: DBD: failed to initialise prepared SQL statements"
when the query as simple as
"select PASS from Users where LOGIN=?"

I have been trying to implement mysql errno printing to get at least
the direction of the problem, but I haven't found the proper way, how
to do that. A text of the error must upraise through 3 layers of
driver, driver wrapper and mod_dbd, but now the is no enough
"infrastructure" around.

I would be very-very grateful for the help with debugging this.

Anton Golubev
ENGECON
St. Petersburg


Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Henrik Nordstrom <hn...@squid-cache.org>.
lör 2006-07-22 klockan 18:00 +0100 skrev Nick Kew:

> #3  0x08081d67 in ap_dbd_prepare (s=0x8daf5a0, query=0xffffffff <Address 
> 0xffffffff out of bounds>, label=0xffffffff <Address 0xffffffff out of 
> bounds>)
>     at mod_dbd.c:150

Note: Could maybe be -O2 or higher optimizing away the variables when
they are no longer needed. Seen such things happen very often on many
platforms. Does not need to indicate a bug or even a problem..

Regards
Henrik

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Saturday 22 July 2006 15:47, Anton Golubev wrote:
> Hello Nick,
>
> > No, you just cut too much before posting.
>
> Actually, I'm not. It was the full working minimal httpd.conf, which I
> cleaned up from unrelated options in order to proof myself with exact
> problem source. Other values are optional defaults.

Hmmm.  It looked less than complete (I had to hack it just to load
the relevant modules - then had to add a virtualhost to get a problem).

> > What happens when you apply the (second) patch I posted?
>
> It was a crash in apr_hashfunc_default() with char_key-0x0.
> You probably haven't seen the backtrace just few lines below the
> sentence you cited. It definitely came to the list, since I received a
> my post back from it in the same form as I sent.

Aha!   I missed that.

#3  0x08081d67 in ap_dbd_prepare (s=0x8daf5a0, query=0xffffffff <Address 
0xffffffff out of bounds>, label=0xffffffff <Address 0xffffffff out of 
bounds>)
    at mod_dbd.c:150

That's what your previous traceback had: screwed up arguments to
ap_dbd_prepare.  I really can't see how that comes from the code.
Are you on some unusual hardware or architecture?  Did you compile
both both httpd and apr/apr-util on the machine it's running on?

#4  0x0808042d in authn_dbd_prepare (cmd=0xbfea7a10, cfg=0x8e06628, 
query=0x8e06630 "sample query") at mod_authn_dbd.c:70

That (and below) looks fine.

> I'm a bit upset with this miscommunication. Should I send you traces
> privately?

Sorry, but a busy hack who has been staring at a screen too long may
miss things in your post!

Anyway, I don't see any reason for that, other than a build problem/
incompatibility (which could perhaps arise in the rather complex
APR_OPTIONAL macros).

Anyone else?

-- 
Nick Kew

Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Anton Golubev <an...@engec.ru>.
Hello Nick,

> No, you just cut too much before posting.

Actually, I'm not. It was the full working minimal httpd.conf, which I
cleaned up from unrelated options in order to proof myself with exact
problem source. Other values are optional defaults.

> What happens when you apply the (second) patch I posted?

It was a crash in apr_hashfunc_default() with char_key-0x0.
You probably haven't seen the backtrace just few lines below the
sentence you cited. It definitely came to the list, since I received a
my post back from it in the same form as I sent.

I'm a bit upset with this miscommunication. Should I send you traces
privately?

Anton Golubev
ENGECON
St. Petersburg



Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Saturday 22 July 2006 13:31, Anton Golubev wrote:
> Hello Nick,
>
> It doesn't crash for you with my config? Well, this might be a problem
> with my configuration/compilation options, but I can't remember
> anything special there. You can see my build details in my first post
> here about this issue.

No, you just cut too much before posting.

What happens when you apply the (second) patch I posted?

-- 
Nick Kew

Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Anton Golubev <an...@engec.ru>.
Hello Nick,

It doesn't crash for you with my config? Well, this might be a problem
with my configuration/compilation options, but I can't remember
anything special there. You can see my build details in my first post
here about this issue.

Here is another backtrace, which you may find interesting. It's with
your latest (post_config hook) applied against 2.2.2 release.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208523072 (LWP 1857)]
apr_hashfunc_default (char_key=0x0, klen=0xbfea7660) at tables/apr_hash.c:228
228             for (p = key; *p; p++) {
(gdb) bt
#0  apr_hashfunc_default (char_key=0x0, klen=0xbfea7660) at tables/apr_hash.c:228
#1  0x008c8e32 in find_entry (ht=0x8dfa268, key=0x0, klen=-1, val=0x0) at tables/apr_hash.c:260
#2  0x008c9006 in apr_hash_get (ht=0x8dfa268, key=0x0, klen=-1) at tables/apr_hash.c:330
#3  0x08081d67 in ap_dbd_prepare (s=0x8daf5a0, query=0xffffffff <Address 0xffffffff out of bounds>, label=0xffffffff <Address 0xffffffff out of bounds>)
    at mod_dbd.c:150
#4  0x0808042d in authn_dbd_prepare (cmd=0xbfea7a10, cfg=0x8e06628, query=0x8e06630 "sample query") at mod_authn_dbd.c:70
#5  0x08078823 in invoke_cmd (cmd=0x80d3140, parms=0xbfea7a10, mconfig=0x8e06628, args=0x8df46fe "") at config.c:873
#6  0x0807908d in ap_walk_config (current=0x8df46d0, parms=0xbfea7a10, section_vector=0x8df4e48) at config.c:1141
#7  0x08070d21 in dirsection (cmd=0xbfea7a10, mconfig=0x8deffe8, arg=0x8df50ee "") at core.c:1865
#8  0x08078823 in invoke_cmd (cmd=0x80d0b20, parms=0xbfea7a10, mconfig=0x8deffe8, args=0x8df45e8 "/home/ivc2/public_html>") at config.c:873
#9  0x0807908d in ap_walk_config (current=0x8df45c8, parms=0xbfea7a10, section_vector=0x8deef00) at config.c:1141
#10 0x08079ae6 in ap_process_config_tree (s=0x8daf5a0, conftree=0x8df4338, p=0x8da40a8, ptemp=0x8dec240) at config.c:1743
#11 0x08067f03 in main (argc=3, argv=0xbfea7b74) at main.c:621


ServerRoot /usr/local/apache

Listen 80

User nobody
Group nobody

ServerAdmin anton@virtweb.engec.ru
DocumentRoot /home/ivc2/public_html

DBDriver mysql
DBDParams "dbname=Users user=auther passreplace=xxxxxx"
DBDMin 1
DBDKeep 2
DBDMax 10
DBDExptime 60


<Directory /home/ivc2/public_html>

    AuthType Basic
    AuthName 'ADMIN ZONE'
    AuthBasicProvider dbd
    AuthDBDUserPWQuery "sample query"
#    require valid-user

</Directory>


Kind regards,

Anton Golubev
ENGECON


Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Saturday 22 July 2006 11:21, Nick Kew wrote:

> child_init?  Bah, lazy - just 'cos there's already a child_init hook.
> Should use post_config instead!

Another cuppa tea, another patch :-)

-- 
Nick Kew

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Saturday 22 July 2006 11:09, Nick Kew wrote:

> I've hacked a quick patch against trunk, that saves the definitions
> to a global hash and retrieves them at child_init, when the server_rec
> is known to be valid.  Will commit if it looks right after reflection:-)

child_init?  Bah, lazy - just 'cos there's already a child_init hook.
Should use post_config instead!

-- 
Nick Kew

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Thursday 20 July 2006 23:33, Anton Golubev wrote:

> This configuration (almost taken from documentation) also crashes the
> server:

Not for me it doesn't.  But putting your <Directory> inside a <VirtualHost>
gets the crash.

So the basic issue is that we're using the server_rec when we may not
have it.  In fact, a <Directory> might be valid within more than one
virtualhost, each having a different backend, so we really need to
expunge the server_rec from ap_dbd_prepare.

I've hacked a quick patch against trunk, that saves the definitions
to a global hash and retrieves them at child_init, when the server_rec
is known to be valid.  Will commit if it looks right after reflection:-)

-- 
Nick Kew

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Thursday 20 July 2006 22:12, Brian J. France wrote:
> I think this is the same issue I had:
>
> http://www.mail-archive.com/dev@httpd.apache.org/msg31299.html

Hmmm, looks similar.  Your patch is slightly problematic because it
changes the API, albeit not substantially.

> On Jul 20, 2006, at 3:52 PM, Anton Golubev wrote:
> > Hello Nick,
> >
> > Here is here the minimal complete config, which crashes the server:
> >
> > DBDriver mysql
> > DBDParams "dbname=Users user=auther passreplace=IrjkfN3"
> > DBDMin 1
> > DBDKeep 2
> > DBDMax 10
> > DBDExptime 60

That's at top-level in the config, is it?

> > NameVirtualHost 85.142.33.11
> >
> > <VirtualHost 85.142.33.11>
> > DocumentRoot /home/ivc2/public_html
> >
> >     <Directory /home/ivc2/public_html>
> >
> >         AuthType Basic
> >         AuthName 'ADMIN ZONE'
> >         AuthBasicProvider dbd
> >
> >         AuthDBDUserPWQuery "select PASS from Users where LOGIN= %s"
> >
> >     </Directory>
> >
> > </VirtualHost>

OK, I'll try and see if I can get a crash with that.  My guess yesterday was
was that your DBDriver/Params were in a virtualhost but your 
AuthDBDUserPWQuery was outside it, but I tried that and it didn't crash.

-- 
Nick Kew

Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Chris Darroch <ch...@pearsoncmg.com>.
Anton Golubev wrote:

> It's the same, but I don't agree it is Virtual Host specific, as you
> said.
> 
> This configuration (almost taken from documentation) also crashes the
> server:

> ServerRoot /usr/local/apache
> 
> Listen 80
> 
> User nobody
> Group nobody
> 
> DocumentRoot /home/ivc2/public_html
> 
> DBDriver mysql
> DBDParams "dbname=Users user=auther passreplace=xxxxxx"
> DBDMin 1
> DBDKeep 2
> DBDMax 10
> DBDExptime 60
> 
> <Directory /home/ivc2/public_html>
> 
>     AuthType Basic
>     AuthName 'ADMIN ZONE'
>     AuthBasicProvider dbd
>     AuthDBDUserPWQuery "select PASS from Users where LOGIN= %s"
>     require valid-user
> 
> </Directory>

   Yes, it seems to be caused by the <Directory> ... specifically,
authn_dbd_prepare(), which is called to handle the AuthDBDUserPWQuery
directive, calls ap_dbd_prepare() and passes cmd->server as the
server_rec *s argument.  Then ap_dbd_prepare() does:

    ap_get_module_config(s->module_config, &dbd_module);

and that returns NULL.  I quickly also tried running:

    ap_get_module_config(cmd->server->module_config, &authn_dbd_module);

inside authn_dbd_prepare(), and it too returns NULL.  And yet I feel
sure I'm seeing things that do effectively the same thing in other
directive handlers, like cmd_rewritelog() for mod_rewrite:

    ap_get_module_config(cmd->server->module_config, &rewrite_module);

Maybe something about that's being RSRC_CONF vs. ACCESS_CONF for
mod_authn_dbd?  I can't grok it tonight; maybe I'll catch some
time over the weekend.

Chris.

-- 
GPG Key ID: 366A375B
GPG Key Fingerprint: 485E 5041 17E1 E2BB C263  E4DE C8E3 FA36 366A 375B


Re[4]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Anton Golubev <an...@engec.ru>.
Hi Brian,

It's the same, but I don't agree it is Virtual Host specific, as you
said.

This configuration (almost taken from documentation) also crashes the
server:


httpd-mini.conf


ServerRoot /usr/local/apache

Listen 80

User nobody
Group nobody

DocumentRoot /home/ivc2/public_html

DBDriver mysql
DBDParams "dbname=Users user=auther passreplace=xxxxxx"
DBDMin 1
DBDKeep 2
DBDMax 10
DBDExptime 60


<Directory /home/ivc2/public_html>

    AuthType Basic
    AuthName 'ADMIN ZONE'
    AuthBasicProvider dbd
    AuthDBDUserPWQuery "select PASS from Users where LOGIN= %s"
    require valid-user

</Directory>


Regards,
Anton


Re: Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by "Brian J. France" <li...@firehawksystems.com>.
I think this is the same issue I had:

http://www.mail-archive.com/dev@httpd.apache.org/msg31299.html

Not sure if there was a fix committed into the code tree or not.

Brian


On Jul 20, 2006, at 3:52 PM, Anton Golubev wrote:

> Hello Nick,
>
> Here is here the minimal complete config, which crashes the server:
>
> DBDriver mysql
> DBDParams "dbname=Users user=auther passreplace=IrjkfN3"
> DBDMin 1
> DBDKeep 2
> DBDMax 10
> DBDExptime 60
>
> ServerRoot /usr/local/apache
>
> Listen 80
>
> User nobody
> Group nobody
>
> ServerAdmin anton@virtweb.engec.ru
> NameVirtualHost 85.142.33.11
>
> <VirtualHost 85.142.33.11>
> DocumentRoot /home/ivc2/public_html
>
>     <Directory /home/ivc2/public_html>
>
>         AuthType Basic
>         AuthName 'ADMIN ZONE'
>         AuthBasicProvider dbd
>
>         AuthDBDUserPWQuery "select PASS from Users where LOGIN= %s"
>
>     </Directory>
>
> </VirtualHost>
>
>
> Another backtrace:
>
> (gdb) run -f /usr/local/apache/conf/httpd-mini.conf
> Starting program: /usr/local/apache2_2/bin/httpd -f /usr/local/ 
> apache/conf/httpd-mini.conf
> [Thread debugging using libthread_db enabled]
> [New Thread -1208047936 (LWP 449)]
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1208047936 (LWP 449)]
> ap_dbd_prepare (s=0x0, query=0x9aa64f8 "select PASS from Users  
> where LOGIN= %s", label=0x9aa64f8 "select PASS from Users where  
> LOGIN= %s") at mod_dbd.c:149
> 149         prepared->next = svr->prepared;
> (gdb) bt
> #0  ap_dbd_prepare (s=0x0, query=0x9aa64f8 "select PASS from Users  
> where LOGIN= %s", label=0x9aa64f8 "select PASS from Users where  
> LOGIN= %s")
>     at mod_dbd.c:149
> #1  0x08080415 in authn_dbd_prepare (cmd=0xbfef6c70, cfg=0x9aa64f0,  
> query=0x9aa64f8 "select PASS from Users where LOGIN= %s") at  
> mod_authn_dbd.c:70
> #2  0x0807880b in invoke_cmd (cmd=0x80d30a0, parms=0xbfef6c70,  
> mconfig=0x9aa64f0, args=0x9a937a0 "") at config.c:873
> #3  0x08079075 in ap_walk_config (current=0x9a93758,  
> parms=0xbfef6c70, section_vector=0x9aa5fb0) at config.c:1141
> #4  0x08070d09 in dirsection (cmd=0xbfef6c70, mconfig=0x9aa5a88,  
> arg=0x9aa6256 "") at core.c:1865
> #5  0x0807880b in invoke_cmd (cmd=0x80d0a80, parms=0xbfef6c70,  
> mconfig=0x9aa5a88, args=0x9a93670 "/home/ivc2/public_html>") at  
> config.c:873
> #6  0x08079075 in ap_walk_config (current=0x9a93650,  
> parms=0xbfef6c70, section_vector=0x9aa56f0) at config.c:1141
> #7  0x08071553 in virtualhost_section (cmd=0xbfef6c70,  
> dummy=0x9a8efe8, arg=0x9a935e8 "85.142.33.11>") at core.c:2206
> #8  0x0807880b in invoke_cmd (cmd=0x80d0ab0, parms=0xbfef6c70,  
> mconfig=0x9a8efe8, args=0x9a935e8 "85.142.33.11>") at config.c:873
> #9  0x08079075 in ap_walk_config (current=0x9a935c8,  
> parms=0xbfef6c70, section_vector=0x9a8df00) at config.c:1141
> #10 0x08079ace in ap_process_config_tree (s=0x9a4e570,  
> conftree=0x9a932b8, p=0x9a430a8, ptemp=0x9a8b240) at config.c:1743
> #11 0x08067eeb in main (argc=3, argv=0xbfef6dd4) at main.c:621
> (gdb)
>
>
> I'm wondering how could I catch it with so many people luckily using
> this feature around? Otherwise I would be proud to be the first  
> one! :)
>
>
> Greets,
> Anton Golubev
> ENGECON
> St. Petersburg
> Russia
>


Re[2]: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Anton Golubev <an...@engec.ru>.
Hello Nick,

Here is here the minimal complete config, which crashes the server:

DBDriver mysql
DBDParams "dbname=Users user=auther passreplace=IrjkfN3"
DBDMin 1
DBDKeep 2
DBDMax 10
DBDExptime 60

ServerRoot /usr/local/apache

Listen 80

User nobody
Group nobody

ServerAdmin anton@virtweb.engec.ru
NameVirtualHost 85.142.33.11

<VirtualHost 85.142.33.11>
DocumentRoot /home/ivc2/public_html

    <Directory /home/ivc2/public_html>

        AuthType Basic
        AuthName 'ADMIN ZONE'
        AuthBasicProvider dbd

        AuthDBDUserPWQuery "select PASS from Users where LOGIN= %s"

    </Directory>

</VirtualHost>


Another backtrace:

(gdb) run -f /usr/local/apache/conf/httpd-mini.conf
Starting program: /usr/local/apache2_2/bin/httpd -f /usr/local/apache/conf/httpd-mini.conf
[Thread debugging using libthread_db enabled]
[New Thread -1208047936 (LWP 449)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208047936 (LWP 449)]
ap_dbd_prepare (s=0x0, query=0x9aa64f8 "select PASS from Users where LOGIN= %s", label=0x9aa64f8 "select PASS from Users where LOGIN= %s") at mod_dbd.c:149
149         prepared->next = svr->prepared;
(gdb) bt
#0  ap_dbd_prepare (s=0x0, query=0x9aa64f8 "select PASS from Users where LOGIN= %s", label=0x9aa64f8 "select PASS from Users where LOGIN= %s")
    at mod_dbd.c:149
#1  0x08080415 in authn_dbd_prepare (cmd=0xbfef6c70, cfg=0x9aa64f0, query=0x9aa64f8 "select PASS from Users where LOGIN= %s") at mod_authn_dbd.c:70
#2  0x0807880b in invoke_cmd (cmd=0x80d30a0, parms=0xbfef6c70, mconfig=0x9aa64f0, args=0x9a937a0 "") at config.c:873
#3  0x08079075 in ap_walk_config (current=0x9a93758, parms=0xbfef6c70, section_vector=0x9aa5fb0) at config.c:1141
#4  0x08070d09 in dirsection (cmd=0xbfef6c70, mconfig=0x9aa5a88, arg=0x9aa6256 "") at core.c:1865
#5  0x0807880b in invoke_cmd (cmd=0x80d0a80, parms=0xbfef6c70, mconfig=0x9aa5a88, args=0x9a93670 "/home/ivc2/public_html>") at config.c:873
#6  0x08079075 in ap_walk_config (current=0x9a93650, parms=0xbfef6c70, section_vector=0x9aa56f0) at config.c:1141
#7  0x08071553 in virtualhost_section (cmd=0xbfef6c70, dummy=0x9a8efe8, arg=0x9a935e8 "85.142.33.11>") at core.c:2206
#8  0x0807880b in invoke_cmd (cmd=0x80d0ab0, parms=0xbfef6c70, mconfig=0x9a8efe8, args=0x9a935e8 "85.142.33.11>") at config.c:873
#9  0x08079075 in ap_walk_config (current=0x9a935c8, parms=0xbfef6c70, section_vector=0x9a8df00) at config.c:1141
#10 0x08079ace in ap_process_config_tree (s=0x9a4e570, conftree=0x9a932b8, p=0x9a430a8, ptemp=0x9a8b240) at config.c:1743
#11 0x08067eeb in main (argc=3, argv=0xbfef6dd4) at main.c:621
(gdb)


I'm wondering how could I catch it with so many people luckily using
this feature around? Otherwise I would be proud to be the first one! :)


Greets,
Anton Golubev
ENGECON
St. Petersburg
Russia


Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery

Posted by Nick Kew <ni...@webthing.com>.
On Wednesday 19 July 2006 23:33, Anton Golubev wrote:
> Hi all,
>
> Apache  crashes at the start time in mod_dbd.c then AuthDBDUserPWQuery
> is not empty. The crash triggered even with then AuthDBDUserPWQuery is
> “1”. Isn’t it a bug in Apache? I would like to listen to some feedback
> from  the  list  before  I  file  it  in  bug tracking system. I'm not
> familiar  with  2.2  version and may be wrong in some aspects of using
> it.
>
> Crash dump:
>
>
> Starting program: /usr/local/apache2_2/bin/httpd -M
> [Thread debugging using libthread_db enabled]
> [New Thread -1208748352 (LWP 19317)]
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1208748352 (LWP 19317)]
> ap_dbd_prepare (s=0x0, query=0x8608560 "select PASS from Users where LOGIN=
> %s", label=0x8608560 "select PASS from Users where LOGIN= %s") at
> mod_dbd.c:149 149         prepared->next = svr->prepared;
> (gdb) bt
> #0  ap_dbd_prepare (s=0x0, query=0x8608560 "select PASS from Users where
> LOGIN= %s", label=0x8608560 "select PASS from Users where LOGIN= %s") at
> mod_dbd.c:149

s=0x0?  Yet it's been dereferenced earlier in the same function.
Smells fishy (as does the label value in that traceback).

> #1  0x08080415 in authn_dbd_prepare (cmd=0xbff80a40, cfg=0x8608558,
> query=0x8608560 "select PASS from Users where LOGIN= %s") at
> mod_authn_dbd.c:70

OK, that makes sense.


Could you post a minimal httpd.conf that generates this?  I'm particularly
Do you have just the one DBDriver/DBDParams configuration, and if so,
is it at top level or in a virtualhost?

> Relevant config section:
>
>     <Directory /home/ivc2/public_html>
>         AllowOverride All
>         Options +Includes
>
>         AuthType Basic
>         AuthName 'ADMIN ZONE'
>         AuthBasicProvider dbd
>
> #       AuthDBDUserPWQuery "select PASS from Users where LOGIN= %s"
>         AuthDBDUserPWQuery "1"
>
>         require valid-user
>
>     </Directory>

Can you also post the section of your httpd.conf with your DBDriver/DBDParams
configuration?  Is it at top level or in a virtualhost, or do you have both?
Does /home/ivc2/public_html belong to the relevant host?
And do you have any nonstandard virtualhosting configuration in effect?

-- 
Nick Kew