[MDEV-19788] Interplay between function based default and lock tables Created: 2019-06-17  Updated: 2019-06-17  Resolved: 2019-06-17

Status: Closed
Project: MariaDB Server
Component/s: Locking
Affects Version/s: 10.3.15
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: SGC IT Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

CentOS 7
Windows 10 1803


Attachments: Text File seqfault.sql     Text File without_default.sql     Text File without_lock.sql    
Issue Links:
Duplicate
duplicates MDEV-16039 Crash when selecting virtual columns ... Closed

 Description   

When you lock a table which has a column set to get a default value from a function and insert into that table after locking MariaDB segfaults.

Attached File Name Includes function based default Includes lock statement Causes Segfault
seqfault.sql Yes Yes Yes
without_lock.sql Yes No No
without_default No Yes No


 Comments   
Comment by Alice Sherepa [ 2019-06-17 ]

Thanks for the report!
It seems to be the same problem as MDEV-16039:

--source include/have_innodb.inc
CREATE TABLE `allele` (
  `pkey` int(11) NOT NULL AUTO_INCREMENT,
  `person` varchar(30) DEFAULT substring_index(user(),'@',1),
  PRIMARY KEY (`pkey`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
LOCK TABLES `allele` WRITE;
INSERT INTO `allele` VALUES (1,null);
UNLOCK TABLES;

10.2 2b660fb4c212973ba0f11

==27447==ERROR: AddressSanitizer: use-after-poison on address 0x62b000000ef0 at pc 0x000000717a8e bp 0x7f6498b1a230 sp 0x7f6498b1a220
READ of size 8 at 0x62b000000ef0 thread T27
    #0 0x717a8d in Item_args::walk_args(bool (Item::*)(void*), bool, void*) /10.2/sql/item.h:4026
    #1 0x718558 in Item_func_or_sum::walk(bool (Item::*)(void*), bool, void*) /10.2/sql/item.h:4311
    #2 0xa81b06 in fix_session_vcol_expr(THD*, Virtual_column_info*) /10.2/sql/table.cc:2796
    #3 0x6fe1e6 in fix_all_session_vcol_exprs /10.2/sql/sql_base.cc:4952
    #4 0x6ff1fb in lock_tables(THD*, TABLE_LIST*, unsigned int, unsigned int) /10.2/sql/sql_base.cc:5130
    #5 0x6fd415 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /10.2/sql/sql_base.cc:4819
    #6 0x6dea66 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /10.2/sql/sql_base.h:509
    #7 0x7a51d6 in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) /10.2/sql/sql_insert.cc:758
    #8 0x8066e7 in mysql_execute_command(THD*) /10.2/sql/sql_parse.cc:4169
    #9 0x81d564 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /10.2/sql/sql_parse.cc:7754
    #10 0x7f9e38 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /10.2/sql/sql_parse.cc:1833
    #11 0x7f6f2e in do_command(THD*) /10.2/sql/sql_parse.cc:1387
    #12 0xb2d0b3 in do_handle_one_connection(CONNECT*) /10.2/sql/sql_connect.cc:1335
    #13 0xb2caac in handle_one_connection /10.2/sql/sql_connect.cc:1241
    #14 0x1d14b45 in pfs_spawn_thread /10.2/storage/perfschema/pfs.cc:1862
    #15 0x7f64b00bc6b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
    #16 0x7f64af55141c in clone (/lib/x86_64-linux-gnu/libc.so.6+0x10741c)

Generated at Thu Feb 08 08:54:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.