>Description:

Running a particular query, a REPLACE into a very large table (~2Gb)
causes MySQL to crash with a segmentation fault. I don't know whether the
destination table is corrupt, but myisamchk doesn't think so.

The query is rather long, I'm afraid, so I've elided some fields (also in 
the interests of privacy):

REPLACE DELAYED INTO sAll
SELECT  YEAR(      FROM_UNIXTIME(time)) AS YearNum,
        MONTH(     FROM_UNIXTIME(time)) AS MonthNum,
        DAYOFMONTH(FROM_UNIXTIME(time)) AS DayOfMonth,
        WEEK(      FROM_UNIXTIME(time)) AS WeekNum,
        DAYOFWEEK( FROM_UNIXTIME(time)) AS DayOfWeek,
        IFNULL(Category, 'NULL'),
        HOUR(FROM_UNIXTIME(time)),
        [... various fields ...]
FROM    pages200302,sessions200302,users200302
WHERE   sessions200302.sessionid = pages200302.sessionid 
AND     users200302.uid = sessions200302.uid
AND     time >= UNIX_TIMESTAMP('2003-02-05') 
AND     time <  UNIX_TIMESTAMP('2003-02-07') 
GROUP BY sAllHash

The table has abourt 4,400,000 rows, and is a MyISAM table. myisamchk does
not detect any errors even with the -e (extended-check) option. I'm
waiting for myisamchk -r to finish so that I can try this query on the
resulting table, but it takes 12 hours to repair.

I have reproduced this with the following MySQL versions:

        3.23.55
        4.0.10-gamma
        4.0.10-gamma-debug-debug
        (and 4.0.3 and 4.0.4, I think)

on two different ix86 (Athlons), running Red Hat 7.2 and 7.3 respectively, 
both machines well tested and reliable.

>How-To-Repeat:

I have a tarball of the necessary files to repeat this. However, it's 1.6 Gb
in size and contains a lot of private data, so I can't distribute it. I'd 
be happy to apply patches and follow any steps anyone can suggest to 
isolate this.

Stack trace of the segfault:

[root@chris mysql-debug-4.0.10-gamma-pc-linux-i686]# bin/resolve_stack_dump -s 
bin/mysqld.sym -n stackdump
0x80720da handle_segfault + 450
0x8295a58 pthread_sighandler + 184
0x806eda5 copy__6StringRC6String + 69
0x804afff copy__16Item_copy_string + 47
0x80a604f copy_fields__FP15TMP_TABLE_PARAM + 67
0x80a2a68 end_send_group__FP4JOINP13st_join_tableb + 676
0x80a14e6 sub_select__FP4JOINP13st_join_tableb + 258
0x80a1193 do_select__FP4JOINPt4List1Z4ItemP8st_tableP9Procedure + 651
0x80990f0 
mysql_select__FP3THDP13st_table_listRt4List1Z4ItemP4ItemP8st_orderT4T3T4UlP13select_result
 + 7744
0x8097276 handle_select__FP3THDP6st_lexP13select_result + 102
0x807efb6 mysql_execute_command__Fv + 7870
0x8081316 mysql_parse__FP3THDPcUi + 214
0x807c52a dispatch_command__F19enum_server_commandP3THDPcUi + 1594
0x807bee4 do_command__FP3THD + 420
0x807b54e handle_one_connection + 698
0x829320c pthread_start_thread + 220
0x82c8b1a thread_start + 4

GDB session:

/tmp/mysql-debug-4.0.10-gamma-pc-linux-i686/bin/mysqld: ready for connections.
Version: '4.0.10-gamma-debug-debug'  socket: '/tmp/mysql.sock'  port: 3306
---Type <return> to continue, or q <return> to quit---

Program received signal SIGSEGV, Segmentation fault.
String::copy (this=0x8908ff0, str=@0x88deba8) at sql_string.cc:202
202     sql_string.cc: No such file or directory.
        in sql_string.cc
Current language:  auto; currently c++
(gdb) info local
this = (String *) 0x35353331
str = (String &) @0x88d2c31: {Ptr = 0x0, str_length = 0, Alloced_length = 0,
  alloced = false}
(gdb) up
#1  0x0804afff in Item_copy_string::copy (this=0x8908ff0) at item.cc:294
294         str_value.copy(*res);
(gdb) p item
Cannot access memory at address 0x998abe2
(gdb) info local
this = (Item_copy_string *) 0x8908ff0
res = (class String *) 0xbfffeb2c
(gdb) p *res
$2 = {Ptr = 0x33383331 <Address 0x33383331 out of bounds>,
  str_length = 858860596, Alloced_length = 741619761, alloced = 49}
(gdb) p *this
Cannot access memory at address 0x998abe2
(gdb) up
#2  0x080a604f in copy_fields (param=0xbffff29c) at sql_select.cc:6981
6981        item->copy();
(gdb) info local
param = (TMP_TABLE_PARAM *) 0xbffff29c
ptr = (class Copy_field *) 0xbffff2b0
end = (Copy_field *) 0x8902444
it = (List_iterator_fast<Item> &) @0xbffff2b0: {<base_list_iterator> = {
    list = 0xbffff2a0, el = 0x8909024, prev = 0x0,
    current = 0x0}, <No data fields>}
item = (class Item_copy_string *) 0xbfffeb2c
(gdb) up
#3  0x080a2a68 in end_send_group (join=0xbfffee1c, join_tab=0x88ff644,
    end_of_records=false) at sql_select.cc:5237
5237          copy_fields(&join->tmp_table_param);
(gdb) bt
#0  String::copy (this=0x8908ff0, str=@0x88deba8) at sql_string.cc:202
#1  0x0804afff in Item_copy_string::copy (this=0x8908ff0) at item.cc:294
#2  0x080a604f in copy_fields (param=0xbffff29c) at sql_select.cc:6981
#3  0x080a2a68 in end_send_group (join=0xbfffee1c, join_tab=0x88ff644,
    end_of_records=false) at sql_select.cc:5237
#4  0x080a14e6 in sub_select (join=0xbfffee1c, join_tab=0x88ff528,
    end_of_records=false) at sql_select.cc:4550
#5  0x080a1193 in do_select (join=0xbfffee1c, fields=0x88e69d4, table=0x0,
    procedure=0x0) at sql_select.cc:4443
#6  0x080990f0 in mysql_select (thd=0x88e6820, tables=0x88e3f30,
    fields=@0x88e69d4, conds=0x88e4660, order=0x0, group=0x88e4728,
    having=0x0, proc_param=0x0, select_options=17339392, result=0x88e4758)
    at sql_select.cc:957
#7  0x08097276 in handle_select (thd=0x88e6820, lex=0x88e6950,
    result=0x88e4758) at sql_select.cc:191
#8  0x0807efb6 in mysql_execute_command () at sql_parse.cc:1949
#9  0x08081316 in mysql_parse (thd=0x88e6820,
    inBuf=0x88dd588 "REPLACE DELAYED INTO sAll SELECT  YEAR(      FROM_UNIXTIME(time)) 
AS YearNum, MONTH(     FROM_UNIXTIME(time)) AS MonthNum, 
DAYOFMONTH(FROM_UNIXTIME(time)) AS DayOfMonth, WEEK(      FROM_UNIXTIME(time)"..., 
length=1924)
    at sql_parse.cc:2822
#10 0x0807c52a in dispatch_command (command=COM_QUERY, thd=0x88e6820,
    packet=0x88e7859 "REPLACE DELAYED INTO sAll SELECT  YEAR(      
FROM_UNIXTIME---Type <return> to continue, or q <return> to quit---
(time)) AS YearNum, MONTH(     FROM_UNIXTIME(time)) AS MonthNum, 
DAYOFMONTH(FROM_UNIXTIME(time)) AS DayOfMonth, WEEK(      FROM_UNIXTIME(time)"...,
    packet_length=1924) at sql_parse.cc:1034
#11 0x0807bee4 in do_command (thd=0x88e6820) at sql_parse.cc:909
#12 0x0807b54e in handle_one_connection (arg=0x88e6820) at sql_parse.cc:702
#13 0x08073bc9 in create_new_thread (thd=0x88e6820) at mysqld.cc:2705
#14 0x0807421d in handle_connections_sockets (arg=0x0) at mysqld.cc:2964
#15 0x080735d0 in main (argc=5, argv=0x8474668) at mysqld.cc:2420
#16 0x082a5464 in __libc_start_main (main=0x80729c8 <main>, argc=5,
    ubp_av=0xbffffa34, init=0x80480b4 <_init>, fini=0x8329b00 <_fini>,
    rtld_fini=0, stack_end=0xbffffa2c) at ../sysdeps/generic/libc-start.c:129

>Fix:

None known at this time, desperately searching for a solution...

>Submitter-Id:  Chris Wilson <[EMAIL PROTECTED]>
>Originator:    ditto
>Organization:  NetServers Ltd, Cambridge, UK.
>MySQL support: none
>Synopsis:      MySQL crashes with segfault on query
>Severity:      serious 
>Priority:      high
>Category:      mysql
>Class:         sw-bug
>Release:       mysql-4.0.10-gamma-debug (Official MySQL-debug binary)

>C compiler:    2.95.3
>C++ compiler:  2.95.3
>Environment:
        
System: Linux chris.camcom.co.uk 2.4.18-19.7.x #1 Thu Dec 12 07:56:46 EST 2002 i686 
unknown
Architecture: i686

Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)
Compilation info: CC='gcc'  CFLAGS='-O2 -mcpu=pentiumpro'  CXX='gcc'  CXXFLAGS='-O2 
-mcpu=pentiumpro -felide-constructors'  LDFLAGS=''  ASFLAGS=''
LIBC: 
lrwxrwxrwx    1 root     root           13 Nov  8 00:07 /lib/libc.so.6 -> libc-2.2.5.so
-rwxr-xr-x    2 root     root      1260480 Oct 10 16:16 /lib/libc-2.2.5.so
-rw-r--r--    1 root     root      2312442 Oct 10 15:51 /usr/lib/libc.a
-rw-r--r--    1 root     root          178 Oct 10 15:46 /usr/lib/libc.so
Configure command: ./configure '--prefix=/usr/local/mysql' '--with-comment=Official 
MySQL-debug binary' '--with-extra-charsets=complex' '--with-server-suffix=-debug' 
'--enable-thread-safe-client' '--enable-local-infile' '--enable-assembler' 
'--disable-shared' '--with-client-ldflags=-all-static' '--with-debug' 
'--with-mysqld-ldflags=-all-static' '--with-innodb' 'CFLAGS=-O2 -mcpu=pentiumpro' 
'CXXFLAGS=-O2 -mcpu=pentiumpro -felide-constructors' 'CXX=gcc'


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to