Bug #61432 Crash (ERROR 2013 (HY000) )
Submitted: 7 Jun 2011 12:11 Modified: 7 Jul 2011 12:14
Reporter: Miranda Killz Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.41-3ubuntu12.10 OS:Linux
Assigned to: CPU Architecture:Any
Tags: crash

[7 Jun 2011 12:11] Miranda Killz
Description:
Either a specific command and the explain crashed MySQL.

Here is the error.log :

<<

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
110607 13:21:19 - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 346495 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x7f958ba65070
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7f9582881e58 thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace+0x29) [0x7f958a3d01a9]
/usr/sbin/mysqld(handle_segfault+0x404) [0x7f958a0dd884]
/lib/libpthread.so.0(+0xf8f0) [0x7f958994e8f0]
/lib/libc.so.6(gsignal+0x35) [0x7f95883c8a75]
/lib/libc.so.6(abort+0x180) [0x7f95883cc5c0]
/usr/lib/libstdc++.so.6(__gnu_cxx::__verbose_terminate_handler()+0x115) [0x7f9588c7e8e5]
/usr/lib/libstdc++.so.6(+0xcad16) [0x7f9588c7cd16]
/usr/lib/libstdc++.so.6(+0xcad43) [0x7f9588c7cd43]
/usr/lib/libstdc++.so.6(+0xcae3e) [0x7f9588c7ce3e]
/usr/lib/libstdc++.so.6(operator new(unsigned long)+0x7d) [0x7f9588c7d2cd]
/usr/lib/libstdc++.so.6(operator new[](unsigned long)+0x9) [0x7f9588c7d389]
/usr/lib/mysql/plugin/damlev.so(damlev_init+0xc8) [0x7f957fb9a864]
/usr/sbin/mysqld(udf_handler::fix_fields(THD*, Item_result_field*, unsigned int, Item**)+0x4c9) [0x7f958a04ac19]
/usr/sbin/mysqld(Item_udf_func::fix_fields(THD*, Item**)+0x1d) [0x7f958a0564fd]
/usr/sbin/mysqld(Item_func::fix_fields(THD*, Item**)+0x1bf) [0x7f958a04a42f]
/usr/sbin/mysqld(Item_cond::fix_fields(THD*, Item**)+0xbd) [0x7f958a05eadd]
/usr/sbin/mysqld(setup_conds(THD*, TABLE_LIST*, TABLE_LIST*, Item**)+0x150) [0x7f958a1269b0]
/usr/sbin/mysqld(JOIN:repare(Item***, TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*)+0x2f0) [0x7f958a14dac0]
/usr/sbin/mysqld(mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*)+0x7e5) [0x7f958a15a9a5]
/usr/sbin/mysqld(mysql_explain_union(THD*, st_select_lex_unit*, select_result*)+0x1a7) [0x7f958a15ab77]
/usr/sbin/mysqld(+0x36db23) [0x7f958a0ebb23]
/usr/sbin/mysqld(mysql_execute_command(THD*)+0x526) [0x7f958a0ef806]
/usr/sbin/mysqld(mysql_parse(THD*, char const*, unsigned int, char const**)+0x35f) [0x7f958a0f4cbf]
/usr/sbin/mysqld(dispatch_command(enum_server_command, THD*, char*, unsigned int)+0xd69) [0x7f958a0f5a39]
/usr/sbin/mysqld(do_command(THD*)+0xea) [0x7f958a0f661a]
/usr/sbin/mysqld(handle_one_connection+0x23d) [0x7f958a0e864d]
/lib/libpthread.so.0(+0x69ca) [0x7f95899459ca]
/lib/libc.so.6(clone+0x6d) [0x7f958847b70d]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x7f958bb639a0 = explain SELECT null, `Diff_2_0`.`id`, `Tabex`.`id`

FROM `Diff_2_0` inner join `Tabex`

on damlev(`Tabex`.`Dm`,`Diff_2_0`.`Dm`)<2 and `Diff_2_0`.`Value_a`=`Tabex`.`Value_a` where substring(`Diff_2_0`.`Dm`, 1, 1)=substring(`Tabex`.`Dm`, 1, 1)
thd->thread_id=85
thd->killed=NOT_KILLED
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
110607 13:21:19 [Note] Plugin 'FEDERATED' is disabled.
110607 13:21:19 InnoDB: Started; log sequence number 0 44243
110607 13:21:19 [Note] Event Scheduler: Loaded 0 events
110607 13:21:19 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.41-3ubuntu12.10' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)

>>

Please note that damlev is a UDF function that works properly.

Do you have any suggestion ?
Should I recompile MySQL to debug ?

Thanks in advance.

How to repeat:
I use my command preceded by explain and I get the following message : "ERROR 2013 (HY000): Lost connection to MySQL server during query".
If I use phpMyAdmin, I get the login screen with the two following messages :
"#2002 Cannot log in to the MySQL server"
"/!\ Connection for control user as defined in your configuration failed.".
[7 Jun 2011 12:15] MySQL Verification Team
Try latest version 5.1.57 and comment the results here. Thanks.
[7 Jul 2011 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Jul 2011 4:48] MySQL Verification Team
well the crash is not in mysqld, but rather in your udf function damlev.
so, you have to debug that yourself.