[MDEV-29895] prepared view crash server (unit.conc_view) Created: 2022-10-27  Updated: 2022-11-11  Resolved: 2022-11-06

Status: Closed
Project: MariaDB Server
Component/s: Optimizer, Views
Affects Version/s: N/A
Fix Version/s: 10.6.11, 10.7.7, 10.8.6, 10.9.4, 10.10.2

Type: Bug Priority: Critical
Reporter: Oleksandr Byelkin Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-29662 same values in `IN` set vs equal comp... Closed
Relates
relates to MDEV-17869 AddressSanitizer: use-after-poison in... Closed

 Description   

Reduced test case (reproducable only with first solution of MDEV-29662):

CREATE TABLE LTDX (
 USERNAME varchar(12) NOT NULL,
 SRTF2 int(11) NOT NULL);
CREATE VIEW V_LTDX AS
  select T0001.USERNAME AS USERNAME
    from LTDX T0001 where (T0001.SRTF2 = 0);
 
set @a1="1";
set @a2="1";
 
prepare stmt from
"select username from V_LTDX where username in ( ? , ? )";
 
execute stmt using @a1,@a2;
 
deallocate prepare stmt;
 
DROP VIEW V_LTDX;
DROP TABLE LTDX;

caused by 5027cb2b74a0b37cbdd3ad190cb8b2bf738c0cde



 Comments   
Comment by Oleksandr Byelkin [ 2022-10-27 ]

it does not matter if parameters are strings or numeric

Comment by Elena Stepanova [ 2022-10-27 ]

Stack trace from buildbot, for reference:

10.6 18a0f0c17

==240900==ERROR: AddressSanitizer: use-after-poison on address 0x62b000421570 at pc 0x563bd170060a bp 0x7ff49fbb7d40 sp 0x7ff49fbb7d30
WRITE of size 8 at 0x62b000421570 thread T16
    #0 0x563bd1700609 in Item_change_list::rollback_item_tree_changes() /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_class.cc:3016
    #1 0x563bd189c5ce in Prepared_statement::cleanup_stmt(bool) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_prepare.cc:4222
    #2 0x563bd18a47ae in Prepared_statement::execute(String*, bool) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_prepare.cc:5239
    #3 0x563bd189f601 in Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_prepare.cc:4635
    #4 0x563bd18981d4 in mysql_stmt_execute_common /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_prepare.cc:3574
    #5 0x563bd189733b in mysqld_stmt_execute(THD*, char*, unsigned int) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_prepare.cc:3345
    #6 0x563bd18234e9 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_parse.cc:1821
    #7 0x563bd1820968 in do_command(THD*, bool) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_parse.cc:1409
    #8 0x563bd1c8ee38 in do_handle_one_connection(CONNECT*, bool) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_connect.cc:1416
    #9 0x563bd1c8e79a in handle_one_connection /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_connect.cc:1318
    #10 0x563bd29c3127 in pfs_spawn_thread /home/buildbot/buildbot/build/mariadb-10.6.11/storage/perfschema/pfs.cc:2201
    #11 0x7ff4ac62b608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608)
    #12 0x7ff4ac1ff292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
 
0x62b000421570 is located 880 bytes inside of 24624-byte region [0x62b000421200,0x62b000427230)
allocated by thread T16 here:
    #0 0x7ff4ac922bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x563bd35d3857 in my_malloc /home/buildbot/buildbot/build/mariadb-10.6.11/mysys/my_malloc.c:90
    #2 0x563bd35aef2f in reset_root_defaults /home/buildbot/buildbot/build/mariadb-10.6.11/mysys/my_alloc.c:148
    #3 0x563bd16f3c58 in THD::init_for_queries() /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_class.cc:1405
    #4 0x563bd1c8e0cf in prepare_new_connection_state(THD*) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_connect.cc:1246
    #5 0x563bd1c8e814 in thd_prepare_connection(THD*) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_connect.cc:1339
    #6 0x563bd1c8ed5e in do_handle_one_connection(CONNECT*, bool) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_connect.cc:1406
    #7 0x563bd1c8e79a in handle_one_connection /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_connect.cc:1318
    #8 0x563bd29c3127 in pfs_spawn_thread /home/buildbot/buildbot/build/mariadb-10.6.11/storage/perfschema/pfs.cc:2201
    #9 0x7ff4ac62b608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608)
 
Thread T16 created by T0 here:
    #0 0x7ff4ac84f805 in pthread_create (/lib/x86_64-linux-gnu/libasan.so.5+0x3a805)
    #1 0x563bd29bed0e in my_thread_create /home/buildbot/buildbot/build/mariadb-10.6.11/storage/perfschema/my_thread.h:52
    #2 0x563bd29c351a in pfs_spawn_thread_v1 /home/buildbot/buildbot/build/mariadb-10.6.11/storage/perfschema/pfs.cc:2252
    #3 0x563bd1506d48 in inline_mysql_thread_create /home/buildbot/buildbot/build/mariadb-10.6.11/include/mysql/psi/mysql_thread.h:1139
    #4 0x563bd151e93a in create_thread_to_handle_connection(CONNECT*) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/mysqld.cc:5993
    #5 0x563bd151efb6 in create_new_thread(CONNECT*) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/mysqld.cc:6052
    #6 0x563bd151f323 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/mysqld.cc:6114
    #7 0x563bd151fd42 in handle_connections_sockets() /home/buildbot/buildbot/build/mariadb-10.6.11/sql/mysqld.cc:6238
    #8 0x563bd151e13b in mysqld_main(int, char**) /home/buildbot/buildbot/build/mariadb-10.6.11/sql/mysqld.cc:5888
    #9 0x563bd150606c in main /home/buildbot/buildbot/build/mariadb-10.6.11/sql/main.cc:34
    #10 0x7ff4ac1040b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
 
SUMMARY: AddressSanitizer: use-after-poison /home/buildbot/buildbot/build/mariadb-10.6.11/sql/sql_class.cc:3016 in Item_change_list::rollback_item_tree_changes()
Shadow bytes around the buggy address:
  0x0c568007c250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c568007c260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c568007c270: 00 00 00 00 00 00 f7 00 00 00 00 00 f7 00 00 00
  0x0c568007c280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c568007c290: 00 00 00 00 00 00 00 00 00 00 00 00 00 f7 00 00
=>0x0c568007c2a0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7[f7]f7
  0x0c568007c2b0: f7 f7 f7 00 00 00 00 00 f7 00 00 00 00 00 00 00
  0x0c568007c2c0: 00 00 00 00 00 00 00 00 f7 00 f7 00 00 00 00 00
  0x0c568007c2d0: 00 00 f7 00 00 00 f7 00 00 00 00 00 00 00 00 00
  0x0c568007c2e0: 00 00 00 00 f7 00 00 00 00 00 00 00 00 00 00 00
  0x0c568007c2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==240900==ABORTING

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