[MDEV-25484] Crash when parsing query using derived table containing TVC Created: 2021-04-22  Updated: 2021-07-27  Resolved: 2021-07-27

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.3
Fix Version/s: 10.3.31

Type: Bug Priority: Major
Reporter: Ramesh Sivaraman Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-17894 Assertion `(thd->lex)->current_select... Closed

 Description   

SELECT * FROM ( ( (VALUES (3),(7),(1) LIMIT 2) ORDER BY 1 DESC)) AS dt;

Leads to:

10.3.29 eb7c5530eccb7d6782077e5562f5a471d2ccbc01 (Debug)

mysqld: /test/10.3_dbg/sql/sql_yacc.yy:17546: int MYSQLparse(THD*): Assertion `lex->current_select->linkage != GLOBAL_OPTIONS_TYPE' failed.

10.3.29 eb7c5530eccb7d6782077e5562f5a471d2ccbc01 (Debug)

Core was generated by `/test/MD160321-mariadb-10.3.29-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x14c2fc0d7700 (LWP 2581077))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055f825558b86 in my_write_core (sig=sig@entry=6) at /test/10.3_dbg/mysys/stacktrace.c:386
#2  0x000055f824d03b91 in handle_fatal_signal (sig=6) at /test/10.3_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x000014c314189859 in __GI_abort () at abort.c:79
#6  0x000014c314189729 in __assert_fail_base (fmt=0x14c31431f588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55f825656548 "lex->current_select->linkage != GLOBAL_OPTIONS_TYPE", file=0x55f825656028 "/test/10.3_dbg/sql/sql_yacc.yy", line=17546, function=<optimized out>) at assert.c:92
#7  0x000014c31419af36 in __GI___assert_fail (assertion=assertion@entry=0x55f825656548 "lex->current_select->linkage != GLOBAL_OPTIONS_TYPE", file=file@entry=0x55f825656028 "/test/10.3_dbg/sql/sql_yacc.yy", line=line@entry=17546, function=function@entry=0x55f825650631 "int MYSQLparse(THD*)") at assert.c:101
#8  0x000055f824c8bae8 in MYSQLparse (thd=thd@entry=0x14c2b4000d90) at /test/10.3_dbg/sql/sql_yacc.yy:17546
#9  0x000055f824a80e44 in parse_sql (thd=thd@entry=0x14c2b4000d90, parser_state=parser_state@entry=0x14c2fc0d6540, creation_ctx=creation_ctx@entry=0x0, do_pfs_digest=do_pfs_digest@entry=true) at /test/10.3_dbg/sql/sql_parse.cc:10178
#10 0x000055f824a812b3 in mysql_parse (thd=thd@entry=0x14c2b4000d90, rawbuf=<optimized out>, length=70, parser_state=parser_state@entry=0x14c2fc0d6540, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_parse.cc:7819
#11 0x000055f824a83c32 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14c2b4000d90, packet=packet@entry=0x14c2b40198f1 "SELECT * FROM ( ( (VALUES (3),(7),(1) LIMIT 2) ORDER BY 1 DESC)) AS dt", packet_length=packet_length@entry=70, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_class.h:1139
#12 0x000055f824a86ddf in do_command (thd=0x14c2b4000d90) at /test/10.3_dbg/sql/sql_parse.cc:1398
#13 0x000055f824bac7db in do_handle_one_connection (connect=connect@entry=0x55f82774ccd0) at /test/10.3_dbg/sql/sql_connect.cc:1403
#14 0x000055f824baca12 in handle_one_connection (arg=0x55f82774ccd0) at /test/10.3_dbg/sql/sql_connect.cc:1308
#15 0x000014c31468f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x000014c314286293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.3.29 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.38 (dbg), 10.4.19 (dbg), 10.5.10 (dbg), 10.6.0 (dbg)



 Comments   
Comment by Oleksandr Byelkin [ 2021-07-23 ]

OK to push

Comment by Igor Babaev [ 2021-07-27 ]

The fix has to be applied only to 10.3. The test case is to be merged upstream.

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