Bug #2470 mysqld crash (error 2013) on signaling an error by returning 1 from UDF_init
Submitted: 21 Jan 2004 9:08 Modified: 17 Mar 2004 3:34
Reporter: Thomas Seidel Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S2 (Serious)
Version:4.1.2 OS:Linux (Linux/intel)
Assigned to: Sergei Glukhov CPU Architecture:Any

[21 Jan 2004 9:08] Thomas Seidel
Description:
Returning 1 to signal an error in an UDF init function causes the mysqld to crash and the connection is lost (error 2013). If no error (e.g. parameters are valid, ...) in UDF init is encountered (returning 0) everything is fine. The problem occurs only with mysql releases 4.x, release 3.23 for example works as it should.

How to repeat:
example 'always fail' init function which caused error 2013:

extern "C" my_bool xxx_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
   strcpy(message, "Test Error in xxx_init()");
   return 1;
}
[22 Jan 2004 10:14] Dean Ellis
I cannot repeat this using 4.0.18.  You might try looking at the mysqld error log for more information.
[5 Feb 2004 2:37] Thomas Seidel
We have made some additional tests with specific 4.x versions
and here are the results:

mysql-4.0.17  _works_
mysql-4.1.1a  _error_

>> resolve_stack_dump -s /tmp/mysqld.sym -n

mysql.stack
0x81442fd handle_segfault + 669
0x40048f18 _end + 935151012
0x9b (?)
0x401e4a0b _end + 936837271
0x83aac68 my_printf_error + 40
0x80e9128
_ZN11udf_handler10fix_fieldsEP3THDP13st_table_listP17Item_result_fieldjPP4Item + 1048
0x80f0757 _ZN13Item_udf_func10fix_fieldsEP3THDP13st_table_listPP4Item +
55
0x8174e8d _Z12setup_fieldsP3THDPP4ItemP13st_table_listR4ListIS1_EbPS7_b
+ 109
0x8179ca9
_ZN4JOIN7prepareEPPP4ItemP13st_table_listjS1_jP8st_orderS7_S1_S7_P13st_select_lexP18st_select_lex_unit + 281
0x817d395
_Z12mysql_selectP3THDPPP4ItemP13st_table_listjR4ListIS1_ES2_jP8st_orderSB_S2_SB_mP13select_resultP18st_select_lex_unitP13st_sel + 741
0x8179a99 _Z13handle_selectP3THDP6st_lexP13select_result + 313
0x8155951 _Z21mysql_execute_commandP3THD + 801
0x815bbc4 _Z11mysql_parseP3THDPcj + 260
0x81545ed _Z16dispatch_command19enum_server_commandP3THDPcj + 1037
0x815418a _Z10do_commandP3THD + 122
0x81539d8 handle_one_connection + 840
0x4004279c _end + 935124520
0x4025f27a _end + 937339142

4.1.2-alpha-nightly-20040128 _error_
[5 Feb 2004 9:07] Dean Ellis
Verified against 4.1.2.  Thank you for the update.
[15 Mar 2004 3:09] Sergei Glukhov
Fix on dev-bugs

subj:[Fwd: Fix for bug#2470 mysqld crash (error 2013) on signaling an error by returning 1 from UDF_init]
date: 2004-03-10
[17 Mar 2004 3:16] Sergei Glukhov
Verified on latest tree. Can't repeat
[17 Mar 2004 3:34] Sergei Glukhov
Can't repeat using the latest 4.1 tree