Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-27422

Server crashes, heap-buffer-overflow, table corruption, assertion failures upon DML on Aria table with SPATIAL

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL)
    • 10.5, 10.6, 10.11, 11.4
    • GIS, Storage Engine - Aria
    • None

    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
      

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.