Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Dec 2000 17:11:57 -0800
From:      Matthew Reimer <mreimer@vpop.net>
To:        freebsd-stable@freebsd.org
Subject:   Mysql segfaults; is the culprit libstdc++, pthread, regex ...?
Message-ID:  <3A2C40DD.3E0E5746@vpop.net>

next in thread | raw e-mail | index | archive | help
We've been having problems with mysql segfaulting. It seems to occur
when it tries to return from a function, so maybe the stack is getting
stomped.

This problem occurs with mysql 3.23.2[678] (we haven't tested other
versions), and with FreeBSD 4.2 from Nov 21, 24, 28 (and presumably
newer) but it does not occur under FreeBSD 4.0 or Linux.

Strangely, what seems to fix the problem for FreeBSD 4.2 is to compile
mysql with gcc and g++ (instead of cc and c++), by setting CC=gcc and
CXX=g++. I'm not sure what happens differently, other than that the
binary compiled with gcc/g++ does not depend on libstdc++, whereas the
binary compiled with cc/c++ does:

/usr/local/mysql/libexec/mysqld:
        libc_r.so.4 => /usr/lib/libc_r.so.4 (0x28176000)
        libm.so.2 => /usr/lib/libm.so.2 (0x28228000)
        libcrypt.so.2 => /usr/lib/libcrypt.so.2 (0x28243000)

/usr/local/mysql-broken/libexec/mysqld:
        libc_r.so.4 => /usr/lib/libc_r.so.4 (0x281d8000)
        libz.so.2 => /usr/lib/libz.so.2 (0x2828a000)
        libcrypt.so.2 => /usr/lib/libcrypt.so.2 (0x28297000)
        libstdc++.so.3 => /usr/lib/libstdc++.so.3 (0x282ac000)
        libm.so.2 => /usr/lib/libm.so.2 (0x282f2000)

Why does compiling mysql this way fix the problem?

One way I've found to reproduce the problem is to perform the following
query on a large table (50M):

        select * from dict where word regexp '^house';


Here are two backtraces from about 27 core dumps we have; these two
backtraces represent the large majority of those dumps. We still have
these dumps for help in debugging.

#0  0x80b2936 in mysql_select (thd=0x9299800, tables=0x92ad108, 
    fields=@0x9299a4c, conds=0x92ad1c8, ftfuncs=@0x9299a80, order=0x0, 
    group=0x0, having=0x0, proc_param=0x0, select_options=9999360, 
    result=0x92ad238) at sql_select.cc:769
769       DBUG_RETURN(error);
(gdb) bt
#0  0x80b2936 in mysql_select (thd=0x9299800, tables=0x92ad108, 
    fields=@0x9299a4c, conds=0x92ad1c8, ftfuncs=@0x9299a80, order=0x0, 
    group=0x0, having=0x0, proc_param=0x0, select_options=9999360, 
    result=0x92ad238) at sql_select.cc:769
#1  0x80862cc in mysql_execute_command () at sql_parse.cc:941
#2  0x808b749 in mysql_parse (thd=0x9299800, 
    inBuf=0x92ad010 "SELECT COUNT(*) FROM tellit WHERE origid = 119776", 
    length=49) at sql_parse.cc:2017
#3  0x80853df in do_command (thd=0x9299800) at sql_parse.cc:652
#4  0x8084a00 in handle_one_connection (arg=0x9299800) at
sql_parse.cc:403
#5  0x281f09a7 in _thread_start () from /usr/lib/libc_r.so.4
#6  0xbfa98ffc in ?? ()
#7  0x80807fc in create_new_thread (thd=0x0) at mysqld.cc:1867

-----

#0  0x8059504 in Item_func_regex::val_int (this=0x93663c0)
    at item_cmpfunc.cc:1285
1285      return regexec(&preg,res->c_ptr(),0,(regmatch_t*) 0,0) ? 0 :
1;
(gdb) bt
#0  0x8059504 in Item_func_regex::val_int (this=0x93663c0)
    at item_cmpfunc.cc:1285
#1  0x805a9ba in Item_cond_or::val_int (this=0x9367a90) at
item_cmpfunc.cc:1133
#2  0x805a932 in Item_cond_and::val_int (this=0x9367a38)
    at item_cmpfunc.cc:1113
#3  0x80bf422 in sub_select (join=0xbf9cc5ec, join_tab=0x9367638, 
    end_of_records=false) at sql_select.cc:4023
#4  0x80bf455 in sub_select (join=0xbf9cc5ec, join_tab=0x9367520, 
    end_of_records=false) at sql_select.cc:4025
#5  0x80bef4a in do_select (join=0xbf9cc5ec, fields=0x0,
table=0x9351800, 
    procedure=0x0) at sql_select.cc:3917
#6  0x80b1ebd in mysql_select (thd=0x93c3800, tables=0x93dd9d8, 
    fields=@0x93c3a4c, conds=0x9367140, ftfuncs=@0x93c3a80,
order=0x93671f0, 
    group=0x0, having=0x0, proc_param=0x0, select_options=9999360, 
    result=0x9367210) at sql_select.cc:602
#7  0x80862cc in mysql_execute_command () at sql_parse.cc:941
#8  0x808b749 in mysql_parse (thd=0x93c3800, 
    inBuf=0x93dd010 "select category_id, item_id from items,
category_items where (title rlike '[[:<:]][Ss][Tt][Aa][Rr][ 
][Tt][Rr][Ee][Kk][[:>:]]' or copy rlike '[[:<:]][Ss][Tt][Aa][Rr][ 
][Tt][Rr][Ee][Kk][[:>:]]' or tit"..., length=2280)
    at sql_parse.cc:2017
#9  0x80853df in do_command (thd=0x93c3800) at sql_parse.cc:652
#10 0x8084a00 in handle_one_connection (arg=0x93c3800) at
sql_parse.cc:403
#11 0x281f09a7 in _thread_start () from /usr/lib/libc_r.so.4
#12 0x0 in ?? ()



Thanks in advance for any help.

Matt


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A2C40DD.3E0E5746>