Bug #67315 | Crashing server by stored function referencing user defined variable in query | ||
---|---|---|---|
Submitted: | 21 Oct 2012 15:32 | Modified: | 12 Nov 2012 17:51 |
Reporter: | Shlomi Noach (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S2 (Serious) |
Version: | 5.6.7-rc/5.7 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | crash, stored function, stored routines, user defined variable |
[21 Oct 2012 15:32]
Shlomi Noach
[21 Oct 2012 15:34]
Shlomi Noach
For completeness, the function I've described is of course a simplified form of a real function; I've simplified as best I can; you can see traces of the original function there.
[21 Oct 2012 16:00]
Valeriy Kravchuk
Works with 5.5.28, so it seems this is a regression bug: mysql> DELIMITER $$ mysql> mysql> DROP FUNCTION IF EXISTS weird $$ Query OK, 0 rows affected, 1 warning (2.69 sec) mysql> CREATE FUNCTION weird(param1 TEXT CHARSET utf8, param2 VARCHAR(255) CHARS ET utf8) -> RETURNS TEXT CHARSET utf8 -> DETERMINISTIC -> NO SQL -> SQL SECURITY INVOKER -> COMMENT 'Return value of option in JS options format' -> -> begin -> declare internal_var INT UNSIGNED DEFAULT 0; -> -> set internal_var := ifnull(@zzz, 0); -> return NULL; -> end $$ Query OK, 0 rows affected (0.53 sec) mysql> DELIMITER ; mysql> select weird('', 'z') = '3' or weird('', 'z') is null; +------------------------------------------------+ | weird('', 'z') = '3' or weird('', 'z') is null | +------------------------------------------------+ | 1 | +------------------------------------------------+ 1 row in set (0.27 sec) mysql> select version(); +-----------+ | version() | +-----------+ | 5.5.28 | +-----------+ 1 row in set (0.02 sec)
[21 Oct 2012 16:59]
MySQL Verification Team
Whoever verifies this - you need --log-bin enabled to repeat it!
[21 Oct 2012 19:05]
MySQL Verification Team
Thank you for the bug report. d:\dbs>d:\dbs\5.7\bin\mysql -uroot --port=3540 --prompt="mysql 5.7 >" Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.7.0-m10-log Source distribution Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql 5.7 >use test Database changed mysql 5.7 >select weird('', 'z') = '3' or weird('', 'z') is null; ERROR 2013 (HY000): Lost connection to MySQL server during query mysql 5.7 > 121021 17:00:48 [Note] 5.7\bin\mysqld: ready for connections. Version: '5.7.0-m10-log' socket: '' port: 3540 Source distribution 20:01:02 UTC - mysqld got exception 0xc0000005 ; 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=8388608 read_buffer_size=131072 max_used_connections=1 max_threads=151 thread_count=1 connection_count=1 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68024 K bytes of memory Hope that's ok; if not, decrease some variables in the equation. Thread pointer: 0x711a9d0 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... 13fb38398 mysqld.exe!alloc_root()[my_alloc.c:203] 13f925969 mysqld.exe!get_var_with_binlog()[item_func.cc:5448] 13f925a95 mysqld.exe!Item_func_get_user_var::fix_length_and_dec()[item_func.cc:5497] 13f91ffc1 mysqld.exe!Item_func::fix_fields()[item_func.cc:232] 13f91fed6 mysqld.exe!Item_func::fix_fields()[item_func.cc:203] 13fa22e98 mysqld.exe!sp_prepare_func_item()[sp.cc:2633] 13fa24262 mysqld.exe!sp_eval_expr()[sp.cc:2666] 13faad0a7 mysqld.exe!sp_instr_set::exec_core()[sp_instr.cc:904] 13faaddcf mysqld.exe!sp_lex_instr::reset_lex_and_exec_core()[sp_instr.cc:352] 13faaf250 mysqld.exe!sp_lex_instr::validate_lex_and_execute_core()[sp_instr.cc:612] 13fa29592 mysqld.exe!sp_head::execute()[sp_head.cc:645] 13fa2a062 mysqld.exe!sp_head::execute_function()[sp_head.cc:1089] 13f9265c9 mysqld.exe!Item_func_sp::execute_impl()[item_func.cc:6807] 13f927657 mysqld.exe!Item_func_sp::execute()[item_func.cc:6736] 13f9278b7 mysqld.exe!Item_func_sp::val_str()[item_func.h:2122] 13f88e170 mysqld.exe!Arg_comparator::compare_string()[item_cmpfunc.cc:1370] 13f88f591 mysqld.exe!Item_func_eq::val_int()[item_cmpfunc.cc:2199] 13f908cb1 mysqld.exe!Item::val_bool()[item.cc:203] 13f89d3cc mysqld.exe!Item_cond_or::val_int()[item_cmpfunc.cc:5122] 13f904a1f mysqld.exe!Item::send()[item.cc:6786] 13f8b3abe mysqld.exe!Protocol::send_result_set_row()[protocol.cc:847] 13f8abe31 mysqld.exe!select_send::send_data()[sql_class.cc:2446] 13fa99bf7 mysqld.exe!JOIN::exec()[sql_executor.cc:148] 13fa10829 mysqld.exe!mysql_execute_select()[sql_select.cc:1088] 13fa1718b mysqld.exe!handle_select()[sql_select.cc:110] 13f8bb07e mysqld.exe!execute_sqlcom_select()[sql_parse.cc:4947] 13f8bf47d mysqld.exe!mysql_execute_command()[sql_parse.cc:2560] 13f8c50ea mysqld.exe!mysql_parse()[sql_parse.cc:6081] 13f8c6041 mysqld.exe!dispatch_command()[sql_parse.cc:1318] 13f8c72c7 mysqld.exe!do_command()[sql_parse.cc:1035] 13f953fc9 mysqld.exe!do_handle_one_connection()[sql_connect.cc:969] 13f95406a mysqld.exe!handle_one_connection()[sql_connect.cc:887] 13fd5c5fe mysqld.exe!pfs_spawn_thread()[pfs.cc:1856] 13fb467be mysqld.exe!pthread_start()[my_winthread.c:63] 13fe02f57 mysqld.exe!_callthreadstartex()[threadex.c:348] 13fe0300b mysqld.exe!_threadstartex()[threadex.c:326] 770f652d kernel32.dll!BaseThreadInitThunk() 777ec521 ntdll.dll!RtlUserThreadStart() Trying to get some variables.
[12 Nov 2012 17:51]
Paul DuBois
Noted in 5.6.9, 5.7.0 changelogs. Execution of a stored program that included the ISNULL() function and a user-defined variable could cause a server crash.