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

Assertion `trn' failed in ha_maria::start_stmt, ASAN heap-after-free in maria_status




      CREATE TABLE t1 (a INT) ENGINE=Aria;
      CREATE TABLE t2 (b INT);
      # Cleanup
      DROP TABLE t1, t2;

      10.5 6532b100

      mariadbd: /data/src/10.5/storage/maria/ha_maria.cc:2878: virtual int ha_maria::start_stmt(THD*, thr_lock_type): Assertion `trn' failed.
      200524 15:56:08 [ERROR] mysqld got signal 6 ;
      #7  0x00007f5818018f12 in __GI___assert_fail (assertion=0x55613c8de0f6 "trn", file=0x55613c8dd590 "/data/src/10.5/storage/maria/ha_maria.cc", line=2878, function=0x55613c8dee60 <ha_maria::start_stmt(THD*, thr_lock_type)::__PRETTY_FUNCTION__> "virtual int ha_maria::start_stmt(THD*, thr_lock_type)") at assert.c:101
      #8  0x000055613bead298 in ha_maria::start_stmt (this=0x7f5800008b30, thd=0x7f5800000b18, lock_type=TL_READ) at /data/src/10.5/storage/maria/ha_maria.cc:2878
      #9  0x000055613b824fd0 in check_lock_and_start_stmt (thd=0x7f5800000b18, prelocking_ctx=0x7f5800004a70, table_list=0x7f5800014740) at /data/src/10.5/sql/sql_base.cc:4887
      #10 0x000055613b826895 in restart_trans_for_tables (thd=0x7f5800000b18, table=0x7f5800014740) at /data/src/10.5/sql/sql_base.cc:5528
      #11 0x000055613b9ba701 in create_table_impl (thd=0x7f5800000b18, orig_db=..., orig_table_name=..., db=..., table_name=..., path=0x7f5812bb3ee0 "./test/t2", options=..., create_info=0x7f5812bb5b00, alter_info=0x7f5812bb5a30, create_table_mode=1, is_trans=0x0, key_info=0x7f5812bb3ec0, key_count=0x7f5812bb3eb4, frm=0x7f5812bb3ed0) at /data/src/10.5/sql/sql_table.cc:5086
      #12 0x000055613b9bafd5 in mysql_create_table_no_lock (thd=0x7f5800000b18, db=0x7f5800013a88, table_name=0x7f5800013a98, create_info=0x7f5812bb5b00, alter_info=0x7f5812bb5a30, is_trans=0x0, create_table_mode=1, table_list=0x7f5800013a70) at /data/src/10.5/sql/sql_table.cc:5259
      #13 0x000055613b882f38 in select_create::create_table_from_items (this=0x7f58000158d0, thd=0x7f5800000b18, items=0x7f5812bb55c0, lock=0x7f5812bb55b0, hooks=0x7f5812bb5600) at /data/src/10.5/sql/sql_insert.cc:4457
      #14 0x000055613b883777 in select_create::prepare (this=0x7f58000158d0, _values=..., u=0x7f5800004b30) at /data/src/10.5/sql/sql_insert.cc:4654
      #15 0x000055613b910346 in JOIN::prepare (this=0x7f58000159d0, tables_init=0x7f5800014740, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7f5800014148, unit_arg=0x7f5800004b30) at /data/src/10.5/sql/sql_select.cc:1485
      #16 0x000055613b91bdfa in mysql_select (thd=0x7f5800000b18, tables=0x7f5800014740, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201171004160, result=0x7f58000158d0, unit=0x7f5800004b30, select_lex=0x7f5800014148) at /data/src/10.5/sql/sql_select.cc:4633
      #17 0x000055613b90bab4 in handle_select (thd=0x7f5800000b18, lex=0x7f5800004a68, result=0x7f58000158d0, setup_tables_done_option=0) at /data/src/10.5/sql/sql_select.cc:429
      #18 0x000055613b9ce7e7 in Sql_cmd_create_table_like::execute (this=0x7f5800013a10, thd=0x7f5800000b18) at /data/src/10.5/sql/sql_table.cc:11832
      #19 0x000055613b8cfc7b in mysql_execute_command (thd=0x7f5800000b18) at /data/src/10.5/sql/sql_parse.cc:5950
      #20 0x000055613b8d5f89 in mysql_parse (thd=0x7f5800000b18, rawbuf=0x7f5800013950 "CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1", length=46, parser_state=0x7f5812bb6520, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7991
      #21 0x000055613b8c2335 in dispatch_command (command=COM_QUERY, thd=0x7f5800000b18, packet=0x7f58001b0409 "CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1", packet_length=46, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1875
      #22 0x000055613b8c0a6d in do_command (thd=0x7f5800000b18) at /data/src/10.5/sql/sql_parse.cc:1356
      #23 0x000055613ba64531 in do_handle_one_connection (connect=0x55613fdeb508, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1411
      #24 0x000055613ba64299 in handle_one_connection (arg=0x55613fdfd658) at /data/src/10.5/sql/sql_connect.cc:1313
      #25 0x000055613bf9ad10 in pfs_spawn_thread (arg=0x55613fd86888) at /data/src/10.5/storage/perfschema/pfs.cc:2201
      #26 0x00007f5819fa14a4 in start_thread (arg=0x7f5812bb7700) at pthread_create.c:456
      #27 0x00007f58180d5d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

      10.5 6532b100 non-debug ASAN

      ==28800==ERROR: AddressSanitizer: heap-use-after-free on address 0x60e000017368 at pc 0x555aa3e95832 bp 0x7f3a343d79e0 sp 0x7f3a343d79d8
      READ of size 8 at 0x60e000017368 thread T5
          #0 0x555aa3e95831 in maria_status /data/src/10.5/storage/maria/ma_info.c:63
          #1 0x555aa3eb4b0c in ha_maria::info(unsigned int) /data/src/10.5/storage/maria/ha_maria.cc:2546
          #2 0x555aa358596e in make_join_statistics /data/src/10.5/sql/sql_select.cc:4891
          #3 0x555aa358596e in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2260
          #4 0x555aa358c93c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1606
          #5 0x555aa358cbf9 in 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*) /data/src/10.5/sql/sql_select.cc:4655
          #6 0x555aa358f2ab in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:429
          #7 0x555aa3630974 in Sql_cmd_create_table_like::execute(THD*) /data/src/10.5/sql/sql_table.cc:11832
          #8 0x555aa3486a63 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:5950
          #9 0x555aa3497e44 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:7991
          #10 0x555aa347bd44 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1875
          #11 0x555aa3477ec1 in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1356
          #12 0x555aa3726b57 in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1411
          #13 0x555aa3727866 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1313
          #14 0x555aa402e763 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #15 0x7f3a3e9704a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
          #16 0x7f3a3caa4d0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)
      0x60e000017368 is located 40 bytes inside of 160-byte region [0x60e000017340,0x60e0000173e0)
      freed by thread T5 here:
          #0 0x7f3a3ec47a10 in free (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1a10)
          #1 0x555aa3e9b25b in _ma_trnman_end_trans_hook /data/src/10.5/storage/maria/ma_state.c:550
      previously allocated by thread T5 here:
          #0 0x7f3a3ec47d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x555aa4932c83 in my_malloc /data/src/10.5/mysys/my_malloc.c:88
      Thread T5 created by T0 here:
          #0 0x7f3a3ebb6f59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
          #1 0x555aa402e9da in my_thread_create /data/src/10.5/storage/perfschema/my_thread.h:34
          #2 0x555aa402e9da in pfs_spawn_thread_v1 /data/src/10.5/storage/perfschema/pfs.cc:2252
      SUMMARY: AddressSanitizer: heap-use-after-free /data/src/10.5/storage/maria/ma_info.c:63 in maria_status
      Shadow bytes around the buggy address:
        0x0c1c7fffae10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1c7fffae20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1c7fffae30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1c7fffae40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1c7fffae50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0c1c7fffae60: fa fa fa fa fa fa fa fa fd fd fd fd fd[fd]fd fd
        0x0c1c7fffae70: fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa
        0x0c1c7fffae80: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1c7fffae90: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
        0x0c1c7fffaea0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1c7fffaeb0: fd fd fd fa fa fa fa fa fa fa fa fa fd fd fd fd
      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
        Heap right redzone:      fb
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack partial redzone:   f4
        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

      The failure started happening after the recent big push of Aria changes, I didn't bisect for the specific commit.




            monty Michael Widenius
            elenst Elena Stepanova
            0 Vote for this issue
            3 Start watching this issue



                Git Integration

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