[MDEV-27422] Server crashes, heap-buffer-overflow, table corruption, assertion failures upon DML on Aria table with SPATIAL Created: 2022-01-04  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: GIS, Storage Engine - Aria
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-24257 innodb_gis.rtree_purge failed in bb,... Open

 Description   

It looks like all bad things start from the UPDATE, which really should fail with ER_CANT_CREATE_GEOMETRY_OBJECT, but it doesn't.

CREATE TABLE t (c POINT NOT NULL, SPATIAL(c)) ENGINE=Aria;
REPLACE INTO t (c) VALUES (POINT(0,0));
UPDATE t SET c = '';
 
# Cleanup
DROP TABLE t;

10.4 a48d2ec8

mysqld: /data/src/10.4/storage/maria/ma_rt_index.c:832: maria_rtree_insert_level: Assertion `0' failed.
220105  1:10:39 [ERROR] mysqld got signal 6 ;
 
#7  0x00007ff7ba5c0662 in __GI___assert_fail (assertion=0x55af550a0364 "0", file=0x55af550a0278 "/data/src/10.4/storage/maria/ma_rt_index.c", line=832, function=0x55af550a0550 <__PRETTY_FUNCTION__.0> "maria_rtree_insert_level") at assert.c:101
#8  0x000055af547cfe6a in maria_rtree_insert_level (info=0x7ff7a40d5a70, key=0x7ff7b4591140, ins_level=-1, root=0x7ff7b4591060) at /data/src/10.4/storage/maria/ma_rt_index.c:832
#9  0x000055af547cff50 in maria_rtree_insert (info=0x7ff7a40d5a70, key=0x7ff7b4591140) at /data/src/10.4/storage/maria/ma_rt_index.c:862
#10 0x000055af547a0256 in maria_update (info=0x7ff7a40d5a70, oldrec=0x7ff7a4187720 "\031", newrec=0x7ff7a4187710 "") at /data/src/10.4/storage/maria/ma_update.c:133
#11 0x000055af547201fb in ha_maria::update_row (this=0x7ff7a4195908, old_data=0x7ff7a4187720 "\031", new_data=0x7ff7a4187710 "") at /data/src/10.4/storage/maria/ha_maria.cc:2356
#12 0x000055af544ecc32 in handler::ha_update_row (this=0x7ff7a4195908, old_data=0x7ff7a4187720 "\031", new_data=0x7ff7a4187710 "") at /data/src/10.4/sql/handler.cc:6817
#13 0x000055af542bac22 in mysql_update (thd=0x7ff7a4000d90, table_list=0x7ff7a4014868, fields=..., values=..., conds=0x0, order_num=0, order=0x0, limit=18446744073709551615, ignore=false, found_return=0x7ff7b4591e20, updated_return=0x7ff7b4591ee0) at /data/src/10.4/sql/sql_update.cc:1081
#14 0x000055af541a673f in mysql_execute_command (thd=0x7ff7a4000d90) at /data/src/10.4/sql/sql_parse.cc:4434
#15 0x000055af541b265e in mysql_parse (thd=0x7ff7a4000d90, rawbuf=0x7ff7a4014798 "UPDATE t SET c = ''", length=19, parser_state=0x7ff7b4592550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
#16 0x000055af5419ead7 in dispatch_command (command=COM_QUERY, thd=0x7ff7a4000d90, packet=0x7ff7a400abf1 "UPDATE t SET c = ''", packet_length=19, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#17 0x000055af5419d364 in do_command (thd=0x7ff7a4000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#18 0x000055af5432b3ed in do_handle_one_connection (connect=0x55af56c6f030) at /data/src/10.4/sql/sql_connect.cc:1420
#19 0x000055af5432b095 in handle_one_connection (arg=0x55af56c6f030) at /data/src/10.4/sql/sql_connect.cc:1316
#20 0x000055af54846517 in pfs_spawn_thread (arg=0x55af56cb6320) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#21 0x00007ff7baa8cea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#22 0x00007ff7ba689def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

mysqld: /data/src/10.4/storage/maria/ma_pagecache.c:3363: pagecache_read: Assertion `pageno < ((1ULL) << 40)' failed.
220105  1:11:54 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f17b69a4662 in __GI___assert_fail (assertion=0x55cb3d0ff872 "pageno < ((1ULL) << 40)", file=0x55cb3d0feff8 "/data/src/10.4/storage/maria/ma_pagecache.c", line=3363, function=0x55cb3d101598 <__PRETTY_FUNCTION__.12> "pagecache_read") at assert.c:101
#8  0x000055cb3c7bd6e7 in pagecache_read (pagecache=0x55cb3d9c7680 <maria_pagecache_var>, file=0x7f17a01959c0, pageno=1457046938266925, level=3, buff=0x7f17b0964cc0 "", type=PAGECACHE_LSN_PAGE, lock=PAGECACHE_LOCK_WRITE, page_link=0x7f17b0964c50) at /data/src/10.4/storage/maria/ma_pagecache.c:3363
#9  0x000055cb3c7e6001 in _ma_fetch_keypage (page=0x7f17b0974ea0, info=0x7f17a0188320, keyinfo=0x55cb3ce33a89 <DoTrace+150>, pos=11936128518282651045, lock=PAGECACHE_LOCK_WRITE, level=3, buff=0x7f17b0964cc0 "", return_buffer=0 '\000') at /data/src/10.4/storage/maria/ma_page.c:110
#10 0x000055cb3c83e28f in maria_rtree_insert_req (info=0x7f17a0188320, key=0x7f17b0975140, page_pos=11936128518282651045, new_page=0x7f17b0974f40, ins_level=-1, level=0) at /data/src/10.4/storage/maria/ma_rt_index.c:618
#11 0x000055cb3c83ea41 in maria_rtree_insert_level (info=0x7f17a0188320, key=0x7f17b0975140, ins_level=-1, root=0x7f17b0975060) at /data/src/10.4/storage/maria/ma_rt_index.c:758
#12 0x000055cb3c83ef50 in maria_rtree_insert (info=0x7f17a0188320, key=0x7f17b0975140) at /data/src/10.4/storage/maria/ma_rt_index.c:862
#13 0x000055cb3c80f256 in maria_update (info=0x7f17a0188320, oldrec=0x7f17a0043090 "\031", newrec=0x7f17a0043080 "") at /data/src/10.4/storage/maria/ma_update.c:133
#14 0x000055cb3c78f1fb in ha_maria::update_row (this=0x7f17a0185d08, old_data=0x7f17a0043090 "\031", new_data=0x7f17a0043080 "") at /data/src/10.4/storage/maria/ha_maria.cc:2356
#15 0x000055cb3c55bc32 in handler::ha_update_row (this=0x7f17a0185d08, old_data=0x7f17a0043090 "\031", new_data=0x7f17a0043080 "") at /data/src/10.4/sql/handler.cc:6817
#16 0x000055cb3c329c22 in mysql_update (thd=0x7f17a0000d90, table_list=0x7f17a0014868, fields=..., values=..., conds=0x0, order_num=0, order=0x0, limit=18446744073709551615, ignore=false, found_return=0x7f17b0975e20, updated_return=0x7f17b0975ee0) at /data/src/10.4/sql/sql_update.cc:1081
#17 0x000055cb3c21573f in mysql_execute_command (thd=0x7f17a0000d90) at /data/src/10.4/sql/sql_parse.cc:4434
#18 0x000055cb3c22165e in mysql_parse (thd=0x7f17a0000d90, rawbuf=0x7f17a0014798 "UPDATE t SET c = ''", length=19, parser_state=0x7f17b0976550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
#19 0x000055cb3c20dad7 in dispatch_command (command=COM_QUERY, thd=0x7f17a0000d90, packet=0x7f17a000abf1 "UPDATE t SET c = ''", packet_length=19, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#20 0x000055cb3c20c364 in do_command (thd=0x7f17a0000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#21 0x000055cb3c39a3ed in do_handle_one_connection (connect=0x55cb3fe05030) at /data/src/10.4/sql/sql_connect.cc:1420
#22 0x000055cb3c39a095 in handle_one_connection (arg=0x55cb3fe05030) at /data/src/10.4/sql/sql_connect.cc:1316
#23 0x000055cb3c8b5517 in pfs_spawn_thread (arg=0x55cb3fe4c320) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#24 0x00007f17b6e70ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x00007f17b6a6ddef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

==1819789==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x620000045068 at pc 0x5569a559914e bp 0x7f99453c6aa0 sp 0x7f99453c6a98
READ of size 8 at 0x620000045068 thread T5
    #0 0x5569a559914d in maria_rtree_insert /data/src/10.4/storage/maria/ma_rt_index.c:860
    #1 0x5569a55368e4 in maria_update /data/src/10.4/storage/maria/ma_update.c:133
    #2 0x5569a4e811f4 in handler::ha_update_row(unsigned char const*, unsigned char const*) /data/src/10.4/sql/handler.cc:6817
    #3 0x5569a4a48be0 in mysql_update(THD*, TABLE_LIST*, List<Item>&, List<Item>&, Item*, unsigned int, st_order*, unsigned long long, bool, unsigned long long*, unsigned long long*) /data/src/10.4/sql/sql_update.cc:1081
    #4 0x5569a47bf5af in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:4434
    #5 0x5569a47cbe6e in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.4/sql/sql_parse.cc:7995
    #6 0x5569a47d2c58 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.4/sql/sql_parse.cc:1857
    #7 0x5569a47d7b8d in do_command(THD*) /data/src/10.4/sql/sql_parse.cc:1373
    #8 0x5569a4b23158 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1420
    #9 0x5569a4b2361a in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1316
    #10 0x5569a5682614 in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1869
    #11 0x7f994ee84ea6 in start_thread nptl/pthread_create.c:477
    #12 0x7f994ea81dee in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xfddee)
 
0x620000045068 is located 24 bytes to the left of 3544-byte region [0x620000045080,0x620000045e58)
allocated by thread T5 here:
    #0 0x7f994f3f3e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5569a5eff492 in my_malloc /data/src/10.4/mysys/my_malloc.c:101
    #2 0x5569a465efb8 in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/src/10.4/sql/sql_base.cc:2092
    #3 0x5569a4668cc9 in open_and_process_table /data/src/10.4/sql/sql_base.cc:3890
    #4 0x5569a4668cc9 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /data/src/10.4/sql/sql_base.cc:4371
    #5 0x5569a466ae7e in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /data/src/10.4/sql/sql_base.cc:5317
    #6 0x5569a467b7d9 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/src/10.4/sql/sql_base.h:503
    #7 0x5569a467b7d9 in open_system_tables_for_read(THD*, TABLE_LIST*, Open_tables_backup*) /data/src/10.4/sql/sql_base.cc:9124
    #8 0x5569a49890aa in open_stat_tables /data/src/10.4/sql/sql_statistics.cc:243
    #9 0x5569a499c5b3 in read_statistics_for_tables(THD*, TABLE_LIST*) /data/src/10.4/sql/sql_statistics.cc:3212
    #10 0x5569a466af8e in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /data/src/10.4/sql/sql_base.cc:5329
    #11 0x5569a47123fe in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/src/10.4/sql/sql_base.h:503
    #12 0x5569a47123fe in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) /data/src/10.4/sql/sql_insert.cc:764
    #13 0x5569a47c3cfd in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:4598
    #14 0x5569a47cbe6e in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.4/sql/sql_parse.cc:7995
    #15 0x5569a47d2c58 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.4/sql/sql_parse.cc:1857
    #16 0x5569a47d7b8d in do_command(THD*) /data/src/10.4/sql/sql_parse.cc:1373
    #17 0x5569a4b23158 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1420
    #18 0x5569a4b2361a in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1316
    #19 0x5569a5682614 in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1869
    #20 0x7f994ee84ea6 in start_thread nptl/pthread_create.c:477
 
Thread T5 created by T0 here:
    #0 0x7f994f39f2a2 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:214
    #1 0x5569a5686c6a in spawn_thread_v1 /data/src/10.4/storage/perfschema/pfs.cc:1919
    #2 0x5569a4542cbb in inline_mysql_thread_create /data/src/10.4/include/mysql/psi/mysql_thread.h:1275
    #3 0x5569a4542cbb in create_thread_to_handle_connection(CONNECT*) /data/src/10.4/sql/mysqld.cc:6243
    #4 0x5569a454eedf in create_new_thread(CONNECT*) /data/src/10.4/sql/mysqld.cc:6313
    #5 0x5569a454f51a in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.4/sql/mysqld.cc:6411
    #6 0x5569a4550629 in handle_connections_sockets() /data/src/10.4/sql/mysqld.cc:6569
    #7 0x5569a4552070 in mysqld_main(int, char**) /data/src/10.4/sql/mysqld.cc:5901
    #8 0x7f994e9aad09 in __libc_start_main ../csu/libc-start.c:308
 
SUMMARY: AddressSanitizer: heap-buffer-overflow /data/src/10.4/storage/maria/ma_rt_index.c:860 in maria_rtree_insert
Shadow bytes around the buggy address:
  0x0c40800009b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c40800009c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa
  0x0c40800009d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c40800009e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c40800009f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c4080000a00: fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]fa fa
  0x0c4080000a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4080000a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4080000a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4080000a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4080000a50: 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
==1819789==ABORTING

mysqltest: At line 3: query 'UPDATE t SET c = ''' failed: 1034: Index for table 't' is corrupt; try to repair it

All the above is from the same test case. Here is a slightly different one, with a slightly different stack trace:

CREATE TABLE t (c POINT NOT NULL, d DATE, INDEX(d), SPATIAL(c)) ENGINE=Aria;
INSERT INTO t (c) VALUES (POINT(0,0));
UPDATE IGNORE t SET c = NULL;
DELETE FROM t LIMIT 4;
 
# Cleanup
DROP TABLE t;

#3  <signal handler called>
#4  0x000055e0c16a883d in maria_rtree_delete (info=0x7f37bc0d59b0, key=0x0) at /data/src/10.4/storage/maria/ma_rt_index.c:1095
#5  0x000055e0c168061e in maria_delete (info=0x7f37bc0d59b0, record=0x7f37bc1879f0 "\377") at /data/src/10.4/storage/maria/ma_delete.c:88
#6  0x000055e0c15f8277 in ha_maria::delete_row (this=0x7f37bc1a4858, buf=0x7f37bc1879f0 "\377") at /data/src/10.4/storage/maria/ha_maria.cc:2363
#7  0x000055e0c13c524a in handler::ha_delete_row (this=0x7f37bc1a4858, buf=0x7f37bc1879f0 "\377") at /data/src/10.4/sql/handler.cc:6894
#8  0x000055e0c158536d in TABLE::delete_row (this=0x7f37bc1a39f0) at /data/src/10.4/sql/sql_delete.cc:292
#9  0x000055e0c1582210 in mysql_delete (thd=0x7f37bc000d90, table_list=0x7f37bc014868, conds=0x0, order_list=0x7f37bc005760, limit=4, options=0, result=0x0) at /data/src/10.4/sql/sql_delete.cc:821
#10 0x000055e0c107fcca in mysql_execute_command (thd=0x7f37bc000d90) at /data/src/10.4/sql/sql_parse.cc:4797
#11 0x000055e0c108a65e in mysql_parse (thd=0x7f37bc000d90, rawbuf=0x7f37bc014798 "DELETE FROM t LIMIT 4", length=21, parser_state=0x7f37cc33c550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
#12 0x000055e0c1076ad7 in dispatch_command (command=COM_QUERY, thd=0x7f37bc000d90, packet=0x7f37bc00abf1 "DELETE FROM t LIMIT 4", packet_length=21, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#13 0x000055e0c1075364 in do_command (thd=0x7f37bc000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#14 0x000055e0c12033ed in do_handle_one_connection (connect=0x55e0c34e6030) at /data/src/10.4/sql/sql_connect.cc:1420
#15 0x000055e0c1203095 in handle_one_connection (arg=0x55e0c34e6030) at /data/src/10.4/sql/sql_connect.cc:1316
#16 0x000055e0c171e517 in pfs_spawn_thread (arg=0x55e0c352d320) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#17 0x00007f37d2836ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#18 0x00007f37d2433def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95



 Comments   
Comment by Elena Stepanova [ 2022-02-06 ]

With some intermediate versions of the test cases based on the same idea, also getting this:

10.2 e53199e7

mysqld: /data/src/10.2/storage/maria/ma_delete.c:1487: _ma_log_delete: Assertion `move_length <= ma_page->org_size - share->keypage_header' failed.
220207  1:58:03 [ERROR] mysqld got signal 6 ;
 
#5  <signal handler called>
#6  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#7  0x00007fe8e2ce7537 in __GI_abort () at abort.c:79
#8  0x00007fe8e2ce740f in __assert_fail_base (fmt=0x7fe8e2e50128 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5599bd422c48 "move_length <= ma_page->org_size - share->keypage_header", file=0x5599bd4226f0 "/data/src/10.2/storage/maria/ma_delete.c", line=1487, function=<optimized out>) at assert.c:92
#9  0x00007fe8e2cf6662 in __GI___assert_fail (assertion=0x5599bd422c48 "move_length <= ma_page->org_size - share->keypage_header", file=0x5599bd4226f0 "/data/src/10.2/storage/maria/ma_delete.c", line=1487, function=0x5599bd422ce8 <__PRETTY_FUNCTION__.0> "_ma_log_delete") at assert.c:101
#10 0x00005599bcfe0729 in _ma_log_delete (ma_page=0x7fe8dce50a90, key_pos=0x7fe8dce4e0b1 "", changed_length=130, move_length=4294967269, append_length=0, debug_marker=KEY_OP_DEBUG_LOG_DEL_CHANGE_1) at /data/src/10.2/storage/maria/ma_delete.c:1487
#11 0x00005599bcfdcd1c in d_search (info=0x7fe8cc04ec10, key=0x7fe8dce510f0, comp_flag=4, anc_page=0x7fe8dce50a90) at /data/src/10.2/storage/maria/ma_delete.c:439
#12 0x000000000105ba0a in ?? ()
#13 0x2aeb821a08000000 in ?? ()
#14 0x009801010000e600 in ?? ()
#15 0x000105ba0a8100f7 in ?? ()
#16 0x1a08000000000000 in ?? ()
#17 0x010000e6002aeb82 in ?? ()
#18 0xc20083525f689801 in ?? ()
#19 0x0000000072644042 in ?? ()
#20 0x0000000000000000 in ?? ()

10.3 efdbb3cf

==2991160==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f5fbfba82a6 at pc 0x55f6899fbfc5 bp 0x7f5fbfba79b0 sp 0x7f5fbfba79a8
WRITE of size 1 at 0x7f5fbfba82a6 thread T5
    #0 0x55f6899fbfc4 in remove_key /data/src/10.3/storage/maria/ma_delete.c:1353
    #1 0x55f689a02f8a in d_search /data/src/10.3/storage/maria/ma_delete.c:423
    #2 0x55f689a04365 in _ma_ck_real_delete /data/src/10.3/storage/maria/ma_delete.c:228
    #3 0x55f689a04fed in _ma_ck_delete /data/src/10.3/storage/maria/ma_delete.c:178
    #4 0x55f6899fc665 in maria_delete /data/src/10.3/storage/maria/ma_delete.c:88
    #5 0x55f688ccb9e1 in handler::ha_delete_row(unsigned char const*) /data/src/10.3/sql/handler.cc:6581
    #6 0x55f68915dead in TABLE::delete_row() /data/src/10.3/sql/sql_delete.cc:245
    #7 0x55f68915dead in mysql_delete(THD*, TABLE_LIST*, Item*, SQL_I_List<st_order>*, unsigned long long, unsigned long long, select_result*) /data/src/10.3/sql/sql_delete.cc:735
    #8 0x55f688663a47 in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:4707
    #9 0x55f68866e6c7 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:7870
    #10 0x55f688673209 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1852
    #11 0x55f688678fad in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1398
    #12 0x55f688996d26 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1403
    #13 0x55f68899758a in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
    #14 0x55f689bdcdb4 in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1869
    #15 0x7f5fca5cfea6 in start_thread nptl/pthread_create.c:477
    #16 0x7f5fca4ffdee in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xfddee)
 
Address 0x7f5fbfba82a6 is located in stack of thread T5 at offset 1894 in frame
    #0 0x55f689a026ef in d_search /data/src/10.3/storage/maria/ma_delete.c:284
 
  This frame has 11 object(s):
    [32, 33) 'last_key' (line 287)
    [48, 56) 'keypos' (line 288)
    [80, 88) 'root' (line 336)
    [112, 120) 'kpos' (line 337)
    [144, 152) 'next_block' (line 421)
    [176, 208) 'tmp_key' (line 338)
    [240, 272) 'word_key' (line 359)
    [304, 336) 'last_key' (line 470)
    [368, 424) 'leaf_page' (line 293)
    [464, 544) 's_temp' (line 290)
    [576, 1791) 'lastkey' (line 289) <== Memory access at offset 1894 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
Thread T5 created by T0 here:
    #0 0x7f5fcae1d2a2 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:214
    #1 0x55f689be140a in spawn_thread_v1 /data/src/10.3/storage/perfschema/pfs.cc:1919
    #2 0x55f68840602b in inline_mysql_thread_create /data/src/10.3/include/mysql/psi/mysql_thread.h:1275
    #3 0x55f68840602b in create_thread_to_handle_connection(CONNECT*) /data/src/10.3/sql/mysqld.cc:6668
    #4 0x55f68841633d in create_new_thread /data/src/10.3/sql/mysqld.cc:6738
    #5 0x55f68841633d in handle_connections_sockets() /data/src/10.3/sql/mysqld.cc:6996
    #6 0x55f6884182e5 in mysqld_main(int, char**) /data/src/10.3/sql/mysqld.cc:6290
    #7 0x7f5fca428d09 in __libc_start_main ../csu/libc-start.c:308
 
SUMMARY: AddressSanitizer: stack-buffer-overflow /data/src/10.3/storage/maria/ma_delete.c:1353 in remove_key
Shadow bytes around the buggy address:
  0x0fec77f6d000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d040: 00 00 00 00 00 00 00 07 f3 f3 f3 f3 f3 f3 f3 f3
=>0x0fec77f6d050: f3 f3 f3 f3[f3]f3 f3 f3 00 00 00 00 00 00 00 00
  0x0fec77f6d060: ca ca ca ca 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fec77f6d0a0: 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

10.9 4a164364

mariadbd: /data/src/10.9/storage/maria/ma_delete.c:1522: _ma_log_delete: Assertion `offset + changed_length <= ma_page->size' failed.
220701  0:27:08 [ERROR] mysqld got signal 6 ;
 
#9  0x00007fd21b8e7662 in __GI___assert_fail (assertion=0x5624adb8c7a0 "offset + changed_length <= ma_page->size", file=0x5624adb8c2c0 "/data/src/10.9/storage/maria/ma_delete.c", line=1522, function=0x5624adb8c8b8 <__PRETTY_FUNCTION__.0> "_ma_log_delete") at assert.c:101
No locals.
#10 0x00005624ad218105 in _ma_log_delete (ma_page=0x7fd2162900f0, key_pos=0x200007fd204000c <error: Cannot access memory at address 0x200007fd204000c>, changed_length=153, move_length=4294967157, append_length=0, debug_marker=KEY_OP_DEBUG_LOG_DEL_CHANGE_1) at /data/src/10.9/storage/maria/ma_delete.c:1522
        lsn = 140540291637209
        log_data = "\260\335(\026\322\177\000\000h!!\004\322\177\000\000\a\000\000\000\005", '\000' <repeats 11 times>, "\240\335(\026\322\177"
        log_pos = 0x7fd21628e9a5 ""
        log_array = {{str = 0x7fd21628ddb0 "\230\037B", length = 140540291637062}, {str = 0x0, length = 140539989139816}, {str = 0xffffff751628dd20 <error: Cannot access memory at address 0xffffff751628dd20>, length = 152}, {str = 0x7fd200000001 "", length = 94715529582591}, {str = 0x7fd21628dd30 "\321\337(\026\322\177", length = 94715529582967}, {str = 0x7fd21628dd50 "\n", length = 140539919859864}, {str = 0x7fd21628dfd1 "", length = 140540291637202}, {str = 0x5624adb8c417 "d_search", length = 94715533378240}, {str = 0x5c38000000a <error: Cannot access memory at address 0x5c38000000a>, length = 140540291636928}}
        translog_parts = 32722
        current_size = 2910771199
        extra_length = 5
        offset = 3151700044
        info = 0x7fd2040f9008
        share = 0x7fd204211348
        page = 1
        _db_stack_frame_ = {func = 0x5624adb8c417 "d_search", file = 0x5624adb8c2c0 "/data/src/10.9/storage/maria/ma_delete.c", level = 2147483658, line = -1, prev = 0x7fd21628dec0}
        __PRETTY_FUNCTION__ = "_ma_log_delete"
#11 0x00005624ad214089 in d_search (info=0x7fd2040f9008, key=0x7fd216290310, comp_flag=4, anc_page=0x7fd2162900f0) at /data/src/10.9/storage/maria/ma_delete.c:447
        tmp = 4294967157
        anc_buff_length = 181
        anc_page_flag = 0
        next_block = 140540291637152
        flag = 0
        ret_value = 32722
        save_flag = -1380424361
        nod_flag = 0
        page_flag = 0
        last_key = 0 '\000'
        buff_alloced = 0 '\000'
        lastkey_alloced = 0 '\000'
        leaf_buff = 0x0
        keypos = 0x7fd21628dfd1 ""
        lastkey = 0x7fd21628ddb0 "\230\037B"
        s_temp = {key = 0x9800000000000064 <error: Cannot access memory at address 0x9800000000000064>, prev_key = 0x421f <error: Cannot access memory at address 0x421f>, next_key_pos = 0xe000007fd2000200 <error: Cannot access memory at address 0xe000007fd2000200>, key_pos = 0x200007fd204000c <error: Cannot access memory at address 0x200007fd204000c>, ref_length = 3523215616, key_length = 268435583, n_ref_length = 3524667614, n_length = 1224736895, totlength = 615350733, part_of_prev_key = 704643158, prev_length = 0, pack_marker = 3221225472, changed_length = 153, move_length = -139, store_not_null = -60 '\304'}
        share = 0x7fd204211348
        keyinfo = 0x7fd204212168
        leaf_page = {info = 0x0, keyinfo = 0x400000003, buff = 0x2000 <error: Cannot access memory at address 0x2000>, pos = 140539989139816, size = 68128776, org_size = 32722, node = 371785968, flag = 32722, link_offset = 0}
        _db_stack_frame_ = {func = 0x5624adb8c391 "_ma_ck_real_delete", file = 0x5624adb8c2c0 "/data/src/10.9/storage/maria/ma_delete.c", level = 2147483657, line = -1, prev = 0x7fd2162900d0}
        __PRETTY_FUNCTION__ = "d_search"
#12 0x0000007fd2162900 in ?? ()
No symbol table info available.
#13 0x1000000004ae53cc in ?? ()
No symbol table info available.

Comment by Alice Sherepa [ 2023-02-01 ]

230201 13:50:41 [ERROR] mysqld got signal 11 ;
Server version: 10.6.12-MariaDB-log source revision: 0e737f78980fcfe83b05c27215eb3f5ede1ea473
 
sql/signal_handler.cc:238(handle_fatal_signal)[0x5590b9656605]
maria/ma_rt_index.c:1114(maria_rtree_delete)[0x5590b985dd1b]
maria/ma_delete.c:88(maria_delete)[0x5590b98431bb]
sql/handler.cc:7721(handler::ha_delete_row(unsigned char const*))[0x5590b966477f]
sql/sql_insert.cc:2107(write_record(THD*, TABLE*, st_copy_info*, select_result*))[0x5590b940c19f]
sql/sql_insert.cc:4118(select_insert::send_data(List<Item>&))[0x5590b940ca10]
sql/sql_select.cc:22649(end_send(JOIN*, st_join_table*, bool))[0x5590b9490c6c]
sql/sql_select.cc:21644(evaluate_join_record(JOIN*, st_join_table*, int))[0x5590b946e286]
sql/sql_select.cc:29864(AGGR_OP::end_send())[0x5590b949b9db]
sql/sql_select.cc:21122(sub_select_postjoin_aggr(JOIN*, st_join_table*, bool))[0x5590b949bc30]
sql/sql_select.cc:20958(do_select)[0x5590b94a48d7]
sql/sql_select.cc:4573(JOIN::exec())[0x5590b94a4d60]
sql/sql_select.cc:5053(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*))[0x5590b94a3094]
sql/sql_select.cc:554(handle_select(THD*, LEX*, select_result*, unsigned long))[0x5590b94a381e]
sql/sql_parse.cc:4721(mysql_execute_command(THD*, bool))[0x5590b944c0eb]
sql/sql_parse.cc:8036(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x5590b943a3c0]
sql/sql_parse.cc:1955(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x5590b94452e0]
sql/sql_parse.cc:1409(do_command(THD*, bool))[0x5590b9446810]
sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x5590b953d68f]
sql/sql_connect.cc:1318(handle_one_connection)[0x5590b953d9cd]
perfschema/pfs.cc:2204(pfs_spawn_thread)[0x5590b987b765]
nptl/pthread_create.c:487(start_thread)[0x7f40e5c47fa3]

also after the crash - repair fails:

MariaDB [test]> repair table t;
+--------+--------+----------+---------------------------+
| Table  | Op     | Msg_type | Msg_text                  |
+--------+--------+----------+---------------------------+
| test.t | repair | error    | 158 for record at pos 256 |
| test.t | repair | status   | Operation failed          |
+--------+--------+----------+---------------------------+
2 rows in set (0,020 sec)
 
MariaDB [test]> analyze table t;
+--------+---------+----------+--------------------------------------------------------------------------+
| Table  | Op      | Msg_type | Msg_text                                                                 |
+--------+---------+----------+--------------------------------------------------------------------------+
| test.t | analyze | Error    | Got error '144 "Table is crashed and last repair failed"' for './test/t' |
| test.t | analyze | error    | Corrupt                                                                  |
+--------+---------+----------+--------------------------------------------------------------------------+
2 rows in set (0,001 sec)

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