[MDEV-28566] Assertion `!expr->is_fixed()' failed in bool Virtual_column_info::fix_session_expr(THD*) Created: 2022-05-14  Updated: 2023-11-28  Resolved: 2023-11-28

Status: Closed
Project: MariaDB Server
Component/s: Virtual Columns
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3

Type: Bug Priority: Major
Reporter: Ramesh Sivaraman Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: debug, not-10.3

Issue Links:
Relates
relates to MDEV-29932 Invalid expr in cleanup_session_expr(... Closed

 Description   

CREATE TABLE t (c1 CHAR AS (CONCAT (0,DAYNAME (0))));
FLUSH TABLES WITH READ LOCK;
UPDATE t SET c1=1;
SELECT * FROM t;

Leads to:

10.4.25 16cebed54065ad9e18953aa86d48f6007d53c2d3 (Debug)

mysqld: /test/10.4_dbg/sql/table.cc:3324: bool Virtual_column_info::fix_session_expr(THD*): Assertion `!expr->is_fixed()' failed.

10.4.25 16cebed54065ad9e18953aa86d48f6007d53c2d3 (Debug)

Core was generated by `/test/GAL_MD140522-mariadb-10.4.25-linux-x86_64-dbg/bin/mysqld --no-defaults --'.
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 0x154d35bf4700 (LWP 2047289))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x0000557a14b46741 in my_write_core (sig=sig@entry=6) at /test/10.4_dbg/mysys/stacktrace.c:386
#2  0x0000557a14335b95 in handle_fatal_signal (sig=6) at /test/10.4_dbg/sql/signal_handler.cc:356
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000154d506c0859 in __GI_abort () at abort.c:79
#6  0x0000154d506c0729 in __assert_fail_base (fmt=0x154d50856588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x557a14ce404b "!expr->is_fixed()", file=0x557a14ce3fa4 "/test/10.4_dbg/sql/table.cc", line=3324, function=<optimized out>) at assert.c:92
#7  0x0000154d506d1f36 in __GI___assert_fail (assertion=assertion@entry=0x557a14ce404b "!expr->is_fixed()", file=file@entry=0x557a14ce3fa4 "/test/10.4_dbg/sql/table.cc", line=line@entry=3324, function=function@entry=0x557a14ce4a90 "bool Virtual_column_info::fix_session_expr(THD*)") at assert.c:101
#8  0x0000557a1419dae4 in Virtual_column_info::fix_session_expr (this=0x154cf0037f80, thd=thd@entry=0x154cf0000d90) at /test/10.4_dbg/sql/table.cc:3324
#9  0x0000557a1419dda3 in TABLE::vcol_fix_expr (this=<optimized out>, thd=thd@entry=0x154cf0000d90) at /test/10.4_dbg/sql/table.cc:3408
#10 0x0000557a14038808 in open_table (thd=thd@entry=0x154cf0000d90, table_list=table_list@entry=0x154cf0013700, ot_ctx=ot_ctx@entry=0x154d35bf16f0) at /test/10.4_dbg/sql/sql_base.cc:2232
#11 0x0000557a1403ceee in open_and_process_table (ot_ctx=0x154d35bf16f0, has_prelocking_list=false, prelocking_strategy=0x154d35bf17f0, flags=0, counter=0x154d35bf178c, tables=0x154cf0013700, thd=0x154cf0000d90) at /test/10.4_dbg/sql/sql_base.cc:3907
#12 open_tables (thd=thd@entry=0x154cf0000d90, options=@0x154cf0006010: {m_options = DDL_options_st::OPT_NONE}, start=start@entry=0x154d35bf1778, counter=counter@entry=0x154d35bf178c, flags=flags@entry=0, prelocking_strategy=prelocking_strategy@entry=0x154d35bf17f0) at /test/10.4_dbg/sql/sql_base.cc:4388
#13 0x0000557a1403e38d in open_and_lock_tables (thd=thd@entry=0x154cf0000d90, options=@0x154cf0006010: {m_options = DDL_options_st::OPT_NONE}, tables=<optimized out>, tables@entry=0x154cf0013700, derived=derived@entry=true, flags=flags@entry=0, prelocking_strategy=prelocking_strategy@entry=0x154d35bf17f0) at /test/10.4_dbg/sql/sql_base.cc:5335
#14 0x0000557a140a79a2 in open_and_lock_tables (flags=0, derived=true, tables=0x154cf0013700, thd=0x154cf0000d90) at /test/10.4_dbg/sql/sql_base.h:503
#15 execute_sqlcom_select (thd=thd@entry=0x154cf0000d90, all_tables=0x154cf0013700) at /test/10.4_dbg/sql/sql_parse.cc:6386
#16 0x0000557a140b227d in mysql_execute_command (thd=thd@entry=0x154cf0000d90) at /test/10.4_dbg/sql/sql_parse.cc:3979
#17 0x0000557a140bc677 in mysql_parse (thd=thd@entry=0x154cf0000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x154d35bf3520, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:8011
#18 0x0000557a140bf250 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x154cf0000d90, packet=packet@entry=0x154cf001a1d1 "SELECT * FROM t", packet_length=packet_length@entry=15, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_class.h:1201
#19 0x0000557a140c1d2c in do_command (thd=0x154cf0000d90) at /test/10.4_dbg/sql/sql_parse.cc:1378
#20 0x0000557a141e409c in do_handle_one_connection (connect=<optimized out>) at /test/10.4_dbg/sql/sql_connect.cc:1420
#21 0x0000557a141e415c in handle_one_connection (arg=<optimized out>) at /test/10.4_dbg/sql/sql_connect.cc:1316
#22 0x0000154d50bcf609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x0000154d507bd293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.25 (dbg), 10.5.16 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.35 (dbg), 10.3.35 (opt), 10.4.25 (opt), 10.5.16 (opt), 10.6.8 (opt), 10.7.4 (opt), 10.8.3 (opt), 10.9.0 (opt)



 Comments   
Comment by Shunsuke Tokunaga [ 2022-05-22 ]

I made a PR in order to fix the problem https://github.com/MariaDB/server/pull/2128
After the PR is tested correctly, could you please review it @nikita.malyavin ?

Comment by Alice Sherepa [ 2022-11-11 ]

also with SELECT FOR UPDATE

CREATE TABLE t (f TIMESTAMP DEFAULT FROM_UNIXTIME(1));
FLUSH TABLES WITH READ LOCK;
--error ER_CANT_UPDATE_WITH_READLOCK
select * from t for update;
SELECT * FROM  t;

I'm getting smth related in tests:

10.11 d186cb180e424fb4e1669

mysqld: /git/10.11/sql/table.cc:3650: bool Virtual_column_info::fix_session_expr(THD*): Assertion `!expr->fixed()' failed.
221111 15:35:47 [ERROR] mysqld got signal 6 ;
 
Server version: 10.11.1-MariaDB-debug-log
 
??:0(gsignal)[0x7f653eb3f00b]
??:0(abort)[0x7f653eb1e859]
sql/table.cc:3651(Virtual_column_info::fix_session_expr(THD*))[0x5605a3fb19fc]
sql/table.cc:3732(TABLE::vcol_fix_expr(THD*))[0x5605a3fb23ef]
sql/sql_base.cc:2313(open_table(THD*, TABLE_LIST*, Open_table_context*))[0x5605a3a37399]
sql/sql_base.cc:4108(open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*))[0x5605a3a41668]
sql/sql_base.cc:4595(open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*))[0x5605a3a442da]
sql/sql_base.h:268(open_tables(THD*, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*))[0x5605a3a2b31b]
sql/sql_base.cc:5633(open_normal_and_derived_tables(THD*, TABLE_LIST*, unsigned int, unsigned int))[0x5605a3a49a4b]
sql/sql_base.cc:5683(open_tables_only_view_structure(THD*, TABLE_LIST*, bool))[0x5605a3a49fda]
sql/sql_show.cc:4712(fill_schema_table_by_open(THD*, st_mem_root*, bool, TABLE*, st_schema_table*, st_mysql_const_lex_string*, st_mysql_const_lex_string*, Open_tables_backup*, bool))[0x5605a3e0a7f0]
sql/sql_show.cc:5383(get_all_tables(THD*, TABLE_LIST*, Item*))[0x5605a3e0e6ec]
sql/sql_show.cc:9036(get_schema_tables_result(JOIN*, enum_schema_table_state))[0x5605a3e42ebf]
sql/sql_select.cc:4768(JOIN::exec_inner())[0x5605a3d0dbf6]
sql/sql_select.cc:4591(JOIN::exec())[0x5605a3d0b9ae]
sql/sql_select.cc:5072(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x5605a3d0ff1d]
sql/sql_select.cc:581(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x5605a3cdfd37]
sql/sql_parse.cc:6263(execute_sqlcom_select(THD*, TABLE_LIST*))[0x5605a3c03d27]
sql/sql_parse.cc:3947(mysql_execute_command(THD*, bool))[0x5605a3bf26fb]
sql/sql_prepare.cc:5225(Prepared_statement::execute(String*, bool))[0x5605a3ca3ef8]
sql/sql_prepare.cc:4648(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*))[0x5605a3c9effa]
sql/sql_prepare.cc:3578(mysql_stmt_execute_common(THD*, unsigned long, unsigned char*, unsigned char*, unsigned long, bool, bool))[0x5605a3c97af7]
sql/sql_prepare.cc:3349(mysqld_stmt_execute(THD*, char*, unsigned int))[0x5605a3c96c5e]
sql/sql_parse.cc:1821(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x5605a3be4765]
sql/sql_parse.cc:1407(do_command(THD*, bool))[0x5605a3be1bdd]
sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x5605a409e682]
sql/sql_connect.cc:1320(handle_one_connection)[0x5605a409dfdf]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x5605a4ccf31e]
nptl/pthread_create.c:478(start_thread)[0x7f653f04a609]
??:0(clone)[0x7f653ec1b133]
 
Query (0x62d007334110): SELECT * FROM information_schema.columns 

Comment by Aleksey Midenkov [ 2023-09-18 ]

Not duplicate of MDEV-29932

Comment by Michael Widenius [ 2023-11-28 ]

Pushed to 10.4
Sergei Golubchik did suggest a better fix, used that one.

Generated at Thu Feb 08 10:01:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.