You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brandon Fosdick <bf...@bfoz.net> on 2006/12/28 07:19:13 UTC

DBD/MySQL crash

For the last week I've been fighting a weird segfault that I just couldn't pin down. I finally got a workable gdb (6.5 and 6.6) running on my FreeBSD box and now I'm even more confused. I'm not quite sure its an httpd problem, but you guys tend to be more helpful :)

This is all on a 6.2-PRE box rebuilt last night, fresh ports tree with fresh installs of www/apache22 and database/mysql50-client, both compiled with debugging. I'm working on a mod_log_dbd that for now only opens a connection to a different test machine running database/mysql50-server. The mysql client lib is segfaulting while trying to stat /usr/local/share/mysql/charsets/Index.xml, which doesn't exist and isn't installed by the client lib (not in pkg-plist). It is, however, installed on the server. If I touch Index.xml on the client, no more segfault.

Interestingly, running the mysql client from the command line doesn't segfault, which is why I think httpd/dbd is doing something odd.

Anyone else seen this? I'm probably missing something obvious, but I'm not seeing it.

Here's the backtrace...
---
#gdb httpd
GNU gdb 6.5 [GDB v6.x for FreeBSD]
Copyright (C) 2006 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 "i386-portbld-freebsd6.2"...
(gdb) r -X
Starting program: /usr/local/sbin/httpd -X
[Wed Dec 27 21:43:04 2006] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter

Program received signal SIGSEGV, Segmentation fault.
0x2811c9fe in my_stat (
    path=0xbfbfd370 "/usr/local/share/mysql/charsets/Index.xml", 
    stat_area=0xbfbfd2d0, my_flags=0) at my_lib.c:650
650       my_errno= errno;
(gdb) bt
#0  0x2811c9fe in my_stat (
    path=0xbfbfd370 "/usr/local/share/mysql/charsets/Index.xml", 
    stat_area=0xbfbfd2d0, my_flags=0) at my_lib.c:650
#1  0x28113868 in my_read_charset_file (
    filename=0xbfbfd370 "/usr/local/share/mysql/charsets/Index.xml", myflags=0)
    at charset.c:318
#2  0x28113c6c in init_available_charsets (myflags=0) at charset.c:422
#3  0x28114149 in get_charset_by_csname (cs_name=0x8186170 "latin1", 
    cs_flags=2, flags=16) at charset.c:558
#4  0x281283ee in mysql_init_character_set (mysql=0x8136800) at client.c:1704
#5  0x28129c8c in mysql_real_connect (mysql=0x8136800, 
    host=0x814e190 "bfoz.net", user=0x814e1a0 "logger", passwd=0x28135e38 "", 
    db=0x0, port=3306, unix_socket=0x0, client_flag=0) at client.c:2093
#6  0x280ed86c in dbd_mysql_open (pool=0x80b9018, 
    params=0x80eb60c "host=bfoz.net,user=logger")
    at /usr/tmp/usr/ports/www/apache22/work/httpd-2.2.3/srclib/apr-util/dbd/apr_dbd_mysql.c:728
#7  0x280ebc3c in apr_dbd_open (driver=0x280ef800, pool=0x80b9018, 
    params=0x80eb60c "host=bfoz.net,user=logger", handle=0x8175b9c)
    at /usr/tmp/usr/ports/www/apache22/work/httpd-2.2.3/srclib/apr-util/dbd/apr_dbd.c:163
#8  0x28652ab3 in log_dbd::ServerConfig::connect (this=0x8175b68)
    at src/apr_pool_base.h:66
#9  0x2864ff25 in child_init (p=0x818a018, s=0x8131cb8) at src/hooks.cc:40
#10 0x0807743e in ap_run_child_init (pchild=0x818a018, s=0x80baeb8)
    at config.c:153
#11 0x0808ae32 in child_main (child_num_arg=0) at prefork.c:513
#12 0x0808b178 in make_child (s=0x80baeb8, slot=0) at prefork.c:680
#13 0x0808b685 in ap_mpm_run (_pconf=0x80b9018, plog=0x80e7018, s=0x80baeb8)
    at prefork.c:956
#14 0x080623be in main (argc=2, argv=0xbfbfeb18) at main.c:717
(gdb) 
---


Re: DBD/MySQL crash

Posted by Nick Kew <ni...@webthing.com>.
On Thu, 28 Dec 2006 21:58:54 -0800
Brandon Fosdick <bf...@bfoz.net> wrote:


> For kicks I tried running mysql under gdb with a breakpoint on
> my_stat() and saw the following output. It seems that my_stat() has
> moved to a different line in my_lib.c. That seems odd to me. ---

That's what I meant about anything else linking MySQL.
Culprit could be something like Perl, PHP, Python, Ruby, ...
This is a regular problem with linking libraries from modules.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

Re: DBD/MySQL crash

Posted by Brandon Fosdick <bf...@bfoz.net>.
Nick Kew wrote:
> That 0x0 looks like dbname.  What happens if you pass
> it a dbname in the params string?

Sharp eyes, but no joy. The mysql docs say mysql_real_connect() is safe to call with db==NULL. But just in case, I checked it...
---
Program received signal SIGSEGV, Segmentation fault.
0x2811c9fe in my_stat (
    path=0xbfbfd1b0 "/usr/local/share/mysql/charsets/Index.xml", 
    stat_area=0xbfbfd110, my_flags=0) at my_lib.c:650
650       my_errno= errno;
(gdb) bt
#0  0x2811c9fe in my_stat (
    path=0xbfbfd1b0 "/usr/local/share/mysql/charsets/Index.xml", 
    stat_area=0xbfbfd110, my_flags=0) at my_lib.c:650
#1  0x28113868 in my_read_charset_file (
    filename=0xbfbfd1b0 "/usr/local/share/mysql/charsets/Index.xml", myflags=0)
    at charset.c:318
#2  0x28113c6c in init_available_charsets (myflags=0) at charset.c:422
#3  0x28114149 in get_charset_by_csname (cs_name=0x8186180 "latin1", 
    cs_flags=2, flags=16) at charset.c:558
#4  0x281283ee in mysql_init_character_set (mysql=0x8136800) at client.c:1704
#5  0x28129c8c in mysql_real_connect (mysql=0x8136800, 
    host=0x814e190 "bfoz.net", user=0x814e1a0 "logger", passwd=0x28135e38 "", 
    db=0x814e1a8 "httpd_log", port=3306, unix_socket=0x0, client_flag=0)
    at client.c:2093
#6  0x280ed86c in dbd_mysql_open (pool=0x80b9018, 
    params=0x80eb64c "host=bfoz.net,user=logger,dbname=httpd_log")
    at /usr/tmp/usr/ports/www/apache22/work/httpd-2.2.3/srclib/apr-util/dbd/apr_dbd_mysql.c:728
#7  0x280ebc3c in apr_dbd_open (driver=0x280ef800, pool=0x80b9018, 
    params=0x80eb64c "host=bfoz.net,user=logger,dbname=httpd_log", 
    handle=0x8175b9c)
    at /usr/tmp/usr/ports/www/apache22/work/httpd-2.2.3/srclib/apr-util/dbd/apr_dbd.c:163
<snip>
---

On the plus side, you led me to find a bug that was preventing dbname from being passed in the param string. :)

> Do you have anything else that links to MySQL in your apache?

Not that I know of. It's a default install with all the other dbd-related modules commented out.

For kicks I tried running mysql under gdb with a breakpoint on my_stat() and saw the following output. It seems that my_stat() has moved to a different line in my_lib.c. That seems odd to me.
---
Breakpoint 2, my_stat (path=0xbfbfe420 "/etc/my.cnf", stat_area=0xbfbfe425, 
    my_flags=0) at my_lib.c:639
639       DBUG_ENTER("my_stat");
---

A few more breakpoints later and we get something more familiar...
---
Breakpoint 2, my_stat (
    path=0xbfbfd650 "/usr/local/share/mysql/charsets/Index.xml", 
    stat_area=0x0, my_flags=0) at my_lib.c:639
639       DBUG_ENTER("my_stat");
---

But for some reason it doesn't segfault this time.

Re: DBD/MySQL crash

Posted by Nick Kew <ni...@webthing.com>.
On Wed, 27 Dec 2006 22:19:13 -0800
Brandon Fosdick <bf...@bfoz.net> wrote:


> Program received signal SIGSEGV, Segmentation fault.
> 0x2811c9fe in my_stat (
>     path=0xbfbfd370 "/usr/local/share/mysql/charsets/Index.xml", 
>     stat_area=0xbfbfd2d0, my_flags=0) at my_lib.c:650
> 650       my_errno= errno;
> (gdb) bt
> #0  0x2811c9fe in my_stat (
>     path=0xbfbfd370 "/usr/local/share/mysql/charsets/Index.xml", 
>     stat_area=0xbfbfd2d0, my_flags=0) at my_lib.c:650
> #1  0x28113868 in my_read_charset_file (
>     filename=0xbfbfd370 "/usr/local/share/mysql/charsets/Index.xml",
> myflags=0) at charset.c:318
> #2  0x28113c6c in init_available_charsets (myflags=0) at charset.c:422
> #3  0x28114149 in get_charset_by_csname (cs_name=0x8186170 "latin1", 
>     cs_flags=2, flags=16) at charset.c:558
> #4  0x281283ee in mysql_init_character_set (mysql=0x8136800) at
> client.c:1704 #5  0x28129c8c in mysql_real_connect (mysql=0x8136800, 
>     host=0x814e190 "bfoz.net", user=0x814e1a0 "logger",
> passwd=0x28135e38 "", db=0x0, port=3306, unix_socket=0x0,
> client_flag=0) at client.c:2093

That 0x0 looks like dbname.  What happens if you pass
it a dbname in the params string?

Do you have anything else that links to MySQL in your apache?

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/