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

ASAN: unknown-crash in check_ulonglong (sql/sql_analyse.cc) on SELECT ... FROM ... PROCEDURE ANALYSE()

    XMLWordPrintable

Details

    Description

      While the testcases look somewhat similar to MDEV-28345, the unknown-crash is in a different location (sql/sql_analyse.cc), and is generated by ASAN as unknown-crash. Note that MDEV-28345 also has an unknown-crash however that one is in my_strtod_int (strings/dtoa.c). Also, this testcase does not crash regular (i.e. non-ASAN) opt/dbg builds.

      SET sql_mode='';
      CREATE TABLE t (a INT, b CHAR(10));
      INSERT INTO t VALUES (CONCAT (REPEAT (0,1)),REPEAT (0,200));
      SELECT * FROM t PROCEDURE ANALYSE();
      

      Leads to:

      11.2.0 e81fa345020ec6a067583db6a7019d6404b26f93 (Optimized, UBASAN)

      ==1112626==ERROR: AddressSanitizer: unknown-crash on address 0x6190000938d7 at pc 0x5650a919e7ed bp 0x149b009e1010 sp 0x149b009e1000
      READ of size 1 at 0x6190000938d7 thread T11
          #0 0x5650a919e7ec in check_ulonglong(char const*, unsigned int) /data/11.2_opt_san/sql/sql_analyse.cc:1214
          #1 0x5650a919eb54 in get_ev_num_info(st_extreme_value_number_info*, st_number_info*, char const*) /data/11.2_opt_san/sql/sql_analyse.cc:289
          #2 0x5650a919eb54 in get_ev_num_info(st_extreme_value_number_info*, st_number_info*, char const*) /data/11.2_opt_san/sql/sql_analyse.cc:277
          #3 0x5650a91a07e4 in field_str::add() /data/11.2_opt_san/sql/sql_analyse.cc:339
          #4 0x5650a9177141 in analyse::send_row(List<Item>&) /data/11.2_opt_san/sql/sql_analyse.cc:669
          #5 0x5650a706746d in end_send /data/11.2_opt_san/sql/sql_select.cc:24683
          #6 0x5650a6f0b129 in evaluate_join_record /data/11.2_opt_san/sql/sql_select.cc:23671
          #7 0x5650a6f9dfce in sub_select(JOIN*, st_join_table*, bool) /data/11.2_opt_san/sql/sql_select.cc:23438
          #8 0x5650a71845ee in do_select /data/11.2_opt_san/sql/sql_select.cc:22955
          #9 0x5650a71845ee in JOIN::exec_inner() /data/11.2_opt_san/sql/sql_select.cc:4935
          #10 0x5650a71897d3 in JOIN::exec() /data/11.2_opt_san/sql/sql_select.cc:4712
          #11 0x5650a7176c8d 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/11.2_opt_san/sql/sql_select.cc:5243
          #12 0x5650a717a890 in handle_select(THD*, LEX*, select_result*, unsigned long long) /data/11.2_opt_san/sql/sql_select.cc:628
          #13 0x5650a6cf60a0 in execute_sqlcom_select /data/11.2_opt_san/sql/sql_parse.cc:6056
          #14 0x5650a6d584aa in mysql_execute_command(THD*, bool) /data/11.2_opt_san/sql/sql_parse.cc:3944
          #15 0x5650a6d66fc2 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/11.2_opt_san/sql/sql_parse.cc:7800
          #16 0x5650a6d725e5 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/11.2_opt_san/sql/sql_parse.cc:1892
          #17 0x5650a6d7e1f8 in do_command(THD*, bool) /data/11.2_opt_san/sql/sql_parse.cc:1405
          #18 0x5650a769f4ac in do_handle_one_connection(CONNECT*, bool) /data/11.2_opt_san/sql/sql_connect.cc:1445
          #19 0x5650a76a1aac in handle_one_connection /data/11.2_opt_san/sql/sql_connect.cc:1347
          #20 0x149b22694b42 in start_thread nptl/pthread_create.c:442
          #21 0x149b227269ff  (/lib/x86_64-linux-gnu/libc.so.6+0x1269ff)
       
      0x6190000938d7 is located 87 bytes inside of 1040-byte region [0x619000093880,0x619000093c90)
      allocated by thread T11 here:
          #0 0x5650a64c5857 in __interceptor_malloc (/test/UBASAN_MD030823-mariadb-11.2.0-linux-x86_64-opt/bin/mariadbd+0x7c40857)
          #1 0x5650aa969454 in my_malloc /data/11.2_opt_san/mysys/my_malloc.c:89
          #2 0x5650aa944e4c in root_alloc /data/11.2_opt_san/mysys/my_alloc.c:71
          #3 0x5650aa944e4c in alloc_root /data/11.2_opt_san/mysys/my_alloc.c:339
          #4 0x5650aa946e3f in strmake_root /data/11.2_opt_san/mysys/my_alloc.c:598
          #5 0x5650a751a1f0 in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /data/11.2_opt_san/sql/table.cc:4259
          #6 0x5650a69369fc in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/11.2_opt_san/sql/sql_base.cc:2218
          #7 0x5650a694d739 in open_and_process_table /data/11.2_opt_san/sql/sql_base.cc:4148
          #8 0x5650a694d739 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /data/11.2_opt_san/sql/sql_base.cc:4635
          #9 0x5650a69518bc in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /data/11.2_opt_san/sql/sql_base.cc:5609
          #10 0x5650a6b622d2 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/11.2_opt_san/sql/sql_base.h:525
          #11 0x5650a6b622d2 in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /data/11.2_opt_san/sql/sql_insert.cc:767
          #12 0x5650a6d4bb5e in mysql_execute_command(THD*, bool) /data/11.2_opt_san/sql/sql_parse.cc:4449
          #13 0x5650a6d66fc2 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/11.2_opt_san/sql/sql_parse.cc:7800
          #14 0x5650a6d725e5 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/11.2_opt_san/sql/sql_parse.cc:1892
          #15 0x5650a6d7e1f8 in do_command(THD*, bool) /data/11.2_opt_san/sql/sql_parse.cc:1405
          #16 0x5650a769f4ac in do_handle_one_connection(CONNECT*, bool) /data/11.2_opt_san/sql/sql_connect.cc:1445
          #17 0x5650a76a1aac in handle_one_connection /data/11.2_opt_san/sql/sql_connect.cc:1347
          #18 0x149b22694b42 in start_thread nptl/pthread_create.c:442
       
      Thread T11 created by T0 here:
          #0 0x5650a6469675 in pthread_create (/test/UBASAN_MD030823-mariadb-11.2.0-linux-x86_64-opt/bin/mariadbd+0x7be4675)
          #1 0x5650a651e34e in create_thread_to_handle_connection(CONNECT*) /data/11.2_opt_san/sql/mysqld.cc:6169
          #2 0x5650a65312af in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/11.2_opt_san/sql/mysqld.cc:6293
          #3 0x5650a6532207 in handle_connections_sockets() /data/11.2_opt_san/sql/mysqld.cc:6417
          #4 0x5650a65351ed in mysqld_main(int, char**) /data/11.2_opt_san/sql/mysqld.cc:6064
          #5 0x149b22629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
       
      SUMMARY: AddressSanitizer: unknown-crash /data/11.2_opt_san/sql/sql_analyse.cc:1214 in check_ulonglong(char const*, unsigned int)
      Shadow bytes around the buggy address:
        0x0c328000a6c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000a6d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000a6e0: 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa
        0x0c328000a6f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c328000a700: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0c328000a710: 00 00 00 00 00 00 f7 02 f7 00[07]00 07 f7 00 00
        0x0c328000a720: 00 f7 f7 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000a730: 00 00 00 00 00 00 00 00 00 00 00 00 00 f7 00 00
        0x0c328000a740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000a750: 00 00 00 00 00 00 00 00 00 00 f7 00 00 00 04 f7
        0x0c328000a760: 00 00 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      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
      ==1112626==ABORTING
      230809 13:42:44 [ERROR] mysqld got signal 6 ;
      
      

      11.2.0 e81fa345020ec6a067583db6a7019d6404b26f93 (Debug, UBASAN)

      ==1112659==ERROR: AddressSanitizer: unknown-crash on address 0x6190000730d7 at pc 0x5573e9e75e89 bp 0x14849b1f8330 sp 0x14849b1f8320
      READ of size 1 at 0x6190000730d7 thread T35
          #0 0x5573e9e75e88 in check_ulonglong(char const*, unsigned int) /data/11.2_dbg_san/sql/sql_analyse.cc:1214
          #1 0x5573e9e7630a in get_ev_num_info(st_extreme_value_number_info*, st_number_info*, char const*) /data/11.2_dbg_san/sql/sql_analyse.cc:289
          #2 0x5573e9e77a8f in field_str::add() /data/11.2_dbg_san/sql/sql_analyse.cc:339
          #3 0x5573e9e4e1d1 in analyse::send_row(List<Item>&) /data/11.2_dbg_san/sql/sql_analyse.cc:669
          #4 0x5573e79a9cd4 in end_send /data/11.2_dbg_san/sql/sql_select.cc:24683
          #5 0x5573e77fe28a in evaluate_join_record /data/11.2_dbg_san/sql/sql_select.cc:23671
          #6 0x5573e78ca03b in sub_select(JOIN*, st_join_table*, bool) /data/11.2_dbg_san/sql/sql_select.cc:23438
          #7 0x5573e7a7aae4 in do_select /data/11.2_dbg_san/sql/sql_select.cc:22955
          #8 0x5573e7a7aae4 in JOIN::exec_inner() /data/11.2_dbg_san/sql/sql_select.cc:4935
          #9 0x5573e7a7c22c in JOIN::exec() /data/11.2_dbg_san/sql/sql_select.cc:4712
          #10 0x5573e7a6a432 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/11.2_dbg_san/sql/sql_select.cc:5243
          #11 0x5573e7a6e943 in handle_select(THD*, LEX*, select_result*, unsigned long long) /data/11.2_dbg_san/sql/sql_select.cc:628
          #12 0x5573e75e21a8 in execute_sqlcom_select /data/11.2_dbg_san/sql/sql_parse.cc:6056
          #13 0x5573e7642bca in mysql_execute_command(THD*, bool) /data/11.2_dbg_san/sql/sql_parse.cc:3944
          #14 0x5573e766dc10 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/11.2_dbg_san/sql/sql_parse.cc:7800
          #15 0x5573e767d986 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/11.2_dbg_san/sql/sql_parse.cc:1892
          #16 0x5573e768b8cd in do_command(THD*, bool) /data/11.2_dbg_san/sql/sql_parse.cc:1405
          #17 0x5573e8065577 in do_handle_one_connection(CONNECT*, bool) /data/11.2_dbg_san/sql/sql_connect.cc:1445
          #18 0x5573e8066a92 in handle_one_connection /data/11.2_dbg_san/sql/sql_connect.cc:1347
          #19 0x1484c0294b42 in start_thread nptl/pthread_create.c:442
          #20 0x1484c03269ff  (/lib/x86_64-linux-gnu/libc.so.6+0x1269ff)
       
      0x6190000730d7 is located 87 bytes inside of 1040-byte region [0x619000073080,0x619000073490)
      allocated by thread T35 here:
          #0 0x5573e6d31367 in __interceptor_malloc (/test/UBASAN_MD030823-mariadb-11.2.0-linux-x86_64-dbg/bin/mariadbd+0x7b96367)
          #1 0x5573eb506af8 in my_malloc /data/11.2_dbg_san/mysys/my_malloc.c:89
          #2 0x5573eb4e5336 in root_alloc /data/11.2_dbg_san/mysys/my_alloc.c:71
          #3 0x5573eb4e677a in alloc_root /data/11.2_dbg_san/mysys/my_alloc.c:339
          #4 0x5573eb4e8194 in strmake_root /data/11.2_dbg_san/mysys/my_alloc.c:598
          #5 0x5573e7ea758e in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /data/11.2_dbg_san/sql/table.cc:4259
          #6 0x5573e71ff439 in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/11.2_dbg_san/sql/sql_base.cc:2218
          #7 0x5573e7216f6a in open_and_process_table /data/11.2_dbg_san/sql/sql_base.cc:4148
          #8 0x5573e7216f6a in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /data/11.2_dbg_san/sql/sql_base.cc:4635
          #9 0x5573e721dd43 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /data/11.2_dbg_san/sql/sql_base.cc:5609
          #10 0x5573e7441a89 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/11.2_dbg_san/sql/sql_base.h:525
          #11 0x5573e7441a89 in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /data/11.2_dbg_san/sql/sql_insert.cc:767
          #12 0x5573e764b90e in mysql_execute_command(THD*, bool) /data/11.2_dbg_san/sql/sql_parse.cc:4449
          #13 0x5573e766dc10 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/11.2_dbg_san/sql/sql_parse.cc:7800
          #14 0x5573e767d986 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/11.2_dbg_san/sql/sql_parse.cc:1892
          #15 0x5573e768b8cd in do_command(THD*, bool) /data/11.2_dbg_san/sql/sql_parse.cc:1405
          #16 0x5573e8065577 in do_handle_one_connection(CONNECT*, bool) /data/11.2_dbg_san/sql/sql_connect.cc:1445
          #17 0x5573e8066a92 in handle_one_connection /data/11.2_dbg_san/sql/sql_connect.cc:1347
          #18 0x1484c0294b42 in start_thread nptl/pthread_create.c:442
       
      Thread T35 created by T0 here:
          #0 0x5573e6cd5185 in __interceptor_pthread_create (/test/UBASAN_MD030823-mariadb-11.2.0-linux-x86_64-dbg/bin/mariadbd+0x7b3a185)
          #1 0x5573e6d89c4e in create_thread_to_handle_connection(CONNECT*) /data/11.2_dbg_san/sql/mysqld.cc:6169
          #2 0x5573e6d9b40f in create_new_thread(CONNECT*) /data/11.2_dbg_san/sql/mysqld.cc:6231
          #3 0x5573e6d9bc8f in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/11.2_dbg_san/sql/mysqld.cc:6293
          #4 0x5573e6d9ccd6 in handle_connections_sockets() /data/11.2_dbg_san/sql/mysqld.cc:6417
          #5 0x5573e6da17e9 in mysqld_main(int, char**) /data/11.2_dbg_san/sql/mysqld.cc:6064
          #6 0x5573e6d76f0a in main /data/11.2_dbg_san/sql/main.cc:34
          #7 0x1484c0229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
       
      SUMMARY: AddressSanitizer: unknown-crash /data/11.2_dbg_san/sql/sql_analyse.cc:1214 in check_ulonglong(char const*, unsigned int)
      Shadow bytes around the buggy address:
        0x0c32800065c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c32800065d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c32800065e0: 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa
        0x0c32800065f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c3280006600: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0c3280006610: 00 00 00 00 00 00 f7 02 f7 00[07]00 07 f7 00 00
        0x0c3280006620: 00 f7 f7 f7 f7 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280006630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f7
        0x0c3280006640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280006650: 00 00 00 00 00 00 00 00 00 00 00 00 f7 00 00 00
        0x0c3280006660: 04 f7 00 00 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      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
      ==1112659==ABORTING
      230809 13:42:44 [ERROR] mysqld got signal 6 ;
      
      

      Summarized stacks/UniqueID's:

      ASAN|unknown-crash|sql/sql_analyse.cc|check_ulonglong|get_ev_num_info|get_ev_num_info|field_str::add (opt)
      ASAN|unknown-crash|sql/sql_analyse.cc|check_ulonglong|get_ev_num_info|field_str::add|analyse::send_row (dbg)
      

      Setup:

      Compiled with GCC >=7.5.0 (I use GCC 11.4.0) and:
          -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWITH_RAPID=OFF -DWSREP_LIB_WITH_ASAN=ON
      Set before execution:
          export ASAN_OPTIONS=quarantine_size_mb=512:atexit=0:detect_invalid_pointer_pairs=3:dump_instruction_bytes=1:abort_on_error=1:allocator_may_return_null=1
      

      Bug confirmed present in:
      MariaDB: 10.4.31 (dbg), 10.4.31 (opt), 10.5.22 (dbg), 10.5.22 (opt), 10.6.15 (dbg), 10.6.15 (opt), 10.9.8 (dbg), 10.9.8 (opt), 10.10.6 (dbg), 10.10.6 (opt), 10.11.5 (dbg), 10.11.5 (opt), 11.0.3 (dbg), 11.0.3 (opt), 11.1.2 (dbg), 11.1.2 (opt), 11.2.0 (dbg), 11.2.0 (opt)

      Attachments

        Activity

          People

            bar Alexander Barkov
            Roel Roel Van de Paar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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