[MDEV-25570] Use of RAND() in procedure crashes server Created: 2021-04-30  Updated: 2021-04-30  Resolved: 2021-04-30

Status: Closed
Project: MariaDB Server
Component/s: Stored routines
Affects Version/s: 10.5.9, 10.2, 10.3, 10.4, 10.5
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Thomas G. Jensen Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: crash
Environment:

Ubuntu


Issue Links:
Duplicate
duplicates MDEV-24383 SIGSEGV in heap_info from make_join_s... Closed
Relates
relates to MDEV-23202 Server crashes in maria_status and/or... Confirmed

 Description   

The following procedure, using the RAND() function, crashes the server when called more than once.

DELIMITER $$
 
DROP PROCEDURE IF EXISTS sp_test;
$$
CREATE PROCEDURE sp_test(
)
BEGIN
 
	SELECT x, y
	FROM (
		SELECT x, RAND() y
		FROM (
			SELECT 1 x
			UNION
			SELECT 2
		) SQ0
	) SQ1;
 
END;
$$
 
CALL sp_test();
CALL sp_test(); -- this call crashes the server



 Comments   
Comment by Alice Sherepa [ 2021-04-30 ]

Thank you for the report and the test case!
It looks like it is a duplicate of MDEV-24383:

before 10.3 it returns 1030: Got error 1 "Operation not permitted" from storage engine MEMORY,
on 10.3-10.5 server crashes,
no crash with optimizer_switch="derived_merge=OFF".

210430  8:39:25 [ERROR] mysqld got signal 11 ;
 
Server version: 10.3.29-MariaDB-debug-log
 
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f91336b6730]
heap/hp_info.c:34(heap_info)[0x55d122253d0e]
heap/ha_heap.cc:368(ha_heap::info(unsigned int))[0x55d122244e2e]
sql/table.cc:8561(TABLE_LIST::fetch_number_of_rows())[0x55d121855791]
sql/sql_select.cc:4557(make_join_statistics(JOIN*, List<TABLE_LIST>&, st_dynamic_array*))[0x55d1215ee90c]
sql/sql_select.cc:1973(JOIN::optimize_inner())[0x55d1215d4792]
sql/sql_select.cc:1515(JOIN::optimize())[0x55d1215cfb8b]
sql/sql_select.cc:4326(mysql_select(THD*, 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*))[0x55d1215ecd68]
sql/sql_select.cc:372(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55d1215c3830]
sql/sql_parse.cc:6342(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55d12152f53e]
sql/sql_parse.cc:3873(mysql_execute_command(THD*))[0x55d12151d547]
sql/sp_head.cc:3702(sp_instr_stmt::exec_core(THD*, unsigned int*))[0x55d1212edabe]
sql/sp_head.cc:3434(sp_lex_keeper::reset_lex_and_exec_core(THD*, unsigned int*, bool, sp_instr*))[0x55d1212ec3a6]
sql/sp_head.cc:3608(sp_instr_stmt::execute(THD*, unsigned int*))[0x55d1212ed28d]
sql/sp_head.cc:1377(sp_head::execute(THD*, bool))[0x55d1212de66d]
sql/sp_head.cc:2404(sp_head::execute_procedure(THD*, List<Item>*))[0x55d1212e4b11]
sql/sql_parse.cc:3019(do_execute_sp(THD*, sp_head*))[0x55d121516d9d]
sql/sql_parse.cc:3259(Sql_cmd_call::execute(THD*))[0x55d1215189f9]
sql/sql_parse.cc:6078(mysql_execute_command(THD*))[0x55d12152cfdf]
sql/sql_parse.cc:7873(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55d121539659]
sql/sql_parse.cc:1855(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55d12150fd17]
sql/sql_parse.cc:1398(do_command(THD*))[0x55d12150c452]
sql/sql_connect.cc:1403(do_handle_one_connection(CONNECT*))[0x55d1219006a7]
sql/sql_connect.cc:1309(handle_one_connection)[0x55d1218fff5f]
perfschema/pfs.cc:1871(pfs_spawn_thread)[0x55d12307d275]
nptl/pthread_create.c:487(start_thread)[0x7f91336abfa3]
x86_64/clone.S:97(clone)[0x7f91335dc4cf]
 
Query (0x62500010b990): SELECT x,y FROM (SELECT x, rand() y FROM (SELECT 1 x UNION SELECT 2) sq0) sq1

Generated at Thu Feb 08 09:38:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.