Procedure for Debugging?

Procedure for Debugging?

am 29.03.2005 17:45:22 von Matthew Boehm

Hello,
I hope this is the right list for this. The developers list isn't very
active and seems more for patch notifications.

I've got a module for an app (all RedHat9 btw) and the module links against
the libmysqlclient. The module connectes to mysql and provides mysql
database connectivity for the main app.

My app recently crashed when I issued a "mysql status" command. That
command was passed to the module and what "should" have happened was that
the module should have ping'd the mysql server (using mysql_ping) and
responded back with the time that the module has been connected. Well,
instead it seg faulted.

Thankfully I compiled the libmysqlclient with --with-debug and got some
info:

#0 0x404fffa6 in my_strcasecmp_8bit (cs=0x4051ad80, s=0x1

of bounds>, t=0x8134038 "latin1") at ctype-simple.c:158
#1 0x404f565a in get_charset_number (charset_name=0x8134038 "latin1",
cs_flags=32) at charset.c:444
#2 0x404f5aa9 in get_charset_by_csname (cs_name=0x8134038 "latin1",
cs_flags=32, flags=16) at charset.c:551
#3 0x4050bb28 in mysql_real_connect (mysql=0x40e1c3fc, host=0x813a600
"64.88.47.55", user=0x813a668 "astdev",
passwd=0x813a698 "devast", db=0x813a6c8 "ast", port=3306,
unix_socket=0x0, client_flag=2147525261) at client.c:1854
#4 0x4050c694 in mysql_reconnect (mysql=0x404cea00) at client.c:2154
#5 0x405093ea in cli_advanced_command (mysql=0x404cea00, command=COM_PING,
header=0x0, header_length=0, arg=0x0, arg_length=0,
skip_check=0 '\0') at client.c:674
#6 0x404e4726 in mysql_ping (mysql=0x404cea00) at libmysql.c:1378
#7 0x404cc08d in key () from /usr/lib/ast/modules/res_config_mysql.so
#8 0x404cc1c6 in key () from /usr/lib/ast/modules/res_config_mysql.so

How can I identify this (if it truly is) as a bug? It seems that my module
(at #8) is correctly calling the mysql_ping command and then somewhere
inside all the MySQL-coded code something is being screwed up.

The true problem here is that this crash is random. I don't have steps to
reproduce it. In fact, I just relaunched the app, loaded the module and
issued the status command it worked correctly.

Hopefully what I have pasted above is a "good start" for someone.

Let me know if anyone needs anything.

Cheers,
Matthew


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: Procedure for Debugging?

am 31.03.2005 22:08:26 von Matthew Boehm

Ben Johnson wrote:

> looks like the app died during a mysql_reconnect(). maybe it does
> this during every ping, but I doubt it. I think the reason the
> problem is intermittent is that it only happens after your app has
> lost its connection to the database.

I've got two things here. First, I didn't realize mysql_reconnect was a
real function in the mysql library. I had written my own function for my
module called mysql_reconnect. Shouldn't this have cause some kind of
compiler warning?

Secondly, yes, this crash is happening after a loss of connection to the
database. I started my app yesterday morning, didn't do anything with it and
this morning I tried to check the status of its connection to mysql and it
segfaulted again.

> What's causing it isn't entirely clear, but it should be fairly easy
> to track down. my_strcasecomp_8bit() is being passed a pointer

Here is the code segment from get_charset_number which calls
my_strcasecmp, which then calls my_strcasecomp_8bit:

444 if ( cs[0] && cs[0]->csname && (cs[0]->state & cs_flags) &&
445 !my_strcasecmp(&my_charset_latin1, cs[0]->csname,
charset_name))

my_strcasecmp is just an alias:

include/m_ctype.h:#define my_strcasecmp(s, a, b)
((s)->coll->strcasecmp((s), (a), (b)))

Somehow, "cs[0]->csname" has a value of 1, which is bad.

Seeing as how my module only calls mysql_ping, I don't see how this segfault
is being cause by my app. Any ideas?

> oh... btw, you just showed everyone your password, so you better change
it.

I had changed it and the IP before I posted, so everyone saw a fake one.
;)

Thanks,
Matthew


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org