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

ASAN errors in Field::set_image / print_range_for_non_indexed_field with optimizer trace and CSV

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.11, 11.1, 10.9(EOL), 10.10(EOL), 11.0(EOL)
    • 10.5, 10.6, 10.11
    • Optimizer
    • None

    Description

      Notes:

      • may be related to MDEV-27483 (or not).
      • in 11.x the test case doesn't even require INSERT – that is, it fails on 11.x both with and without table contents. In 10.5-10.11 it only fails on a non-empty table. Please check after fixing that the patch also solves the problem on 11.0+ when the table is empty.

      CREATE TABLE t (c char(120) NOT NULL) ENGINE=CSV CHARACTER SET utf8;
      INSERT INTO t VALUES ('foo'),('bar');
      SET optimizer_trace = 'enabled=on';
      ANALYZE TABLE t PERSISTENT FOR ALL;
      SELECT c FROM t WHERE c = 'qux';
       
      # Cleanup
      DROP TABLE t;
      

      10.5 caeff135

      ==11382==ERROR: AddressSanitizer: use-after-poison on address 0x621000118260 at pc 0x7fd7e584814b bp 0x7fd7dd3f7530 sp 0x7fd7dd3f6ce0
      READ of size 360 at 0x621000118260 thread T5
          #0 0x7fd7e584814a in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
          #1 0x5573145521d1 in Field::set_image(unsigned char const*, unsigned int, charset_info_st const*) /data/src/11.1/sql/field.h:1549
          #2 0x5573145522e1 in Field::set_key_image(unsigned char const*, unsigned int) (/mnt8t/bld/11.1-asan/bin/mariadbd+0x20872e1)
          #3 0x5573149a8045 in Field::print_key_part_value(String*, unsigned char const*, unsigned int) /data/src/11.1/sql/field.cc:11478
          #4 0x557313dd2096 in print_range_for_non_indexed_field /data/src/11.1/sql/opt_range.cc:16988
          #5 0x557313d76c79 in records_in_column_ranges /data/src/11.1/sql/opt_range.cc:3349
          #6 0x557313d793b5 in calculate_cond_selectivity_for_table(THD*, TABLE*, Item**) /data/src/11.1/sql/opt_range.cc:3693
          #7 0x55731420d039 in make_join_statistics /data/src/11.1/sql/sql_select.cc:5985
          #8 0x5573141ea2a2 in JOIN::optimize_inner() /data/src/11.1/sql/sql_select.cc:2576
          #9 0x5573141e3238 in JOIN::optimize() /data/src/11.1/sql/sql_select.cc:1902
          #10 0x557314204e92 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/11.1/sql/sql_select.cc:5143
          #11 0x5573141d4a85 in handle_select(THD*, LEX*, select_result*, unsigned long long) /data/src/11.1/sql/sql_select.cc:611
          #12 0x5573140fd980 in execute_sqlcom_select /data/src/11.1/sql/sql_parse.cc:6024
          #13 0x5573140ee4c2 in mysql_execute_command(THD*, bool) /data/src/11.1/sql/sql_parse.cc:3944
          #14 0x557314108339 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/11.1/sql/sql_parse.cc:7760
          #15 0x5573140e0ab0 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/11.1/sql/sql_parse.cc:1892
          #16 0x5573140dd7ee in do_command(THD*, bool) /data/src/11.1/sql/sql_parse.cc:1405
          #17 0x5573145956e1 in do_handle_one_connection(CONNECT*, bool) /data/src/11.1/sql/sql_connect.cc:1416
          #18 0x5573145950a2 in handle_one_connection /data/src/11.1/sql/sql_connect.cc:1318
          #19 0x55731518ea3b in pfs_spawn_thread /data/src/11.1/storage/perfschema/pfs.cc:2201
          #20 0x7fd7e4ea7fd3 in start_thread nptl/pthread_create.c:442
          #21 0x7fd7e4f285bb in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
       
      0x621000118260 is located 352 bytes inside of 4112-byte region [0x621000118100,0x621000119110)
      allocated by thread T5 here:
          #0 0x7fd7e58b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x557315d5c8af in my_malloc /data/src/11.1/mysys/my_malloc.c:91
          #2 0x557315d37ec3 in root_alloc /data/src/11.1/mysys/my_alloc.c:71
          #3 0x557315d39619 in alloc_root /data/src/11.1/mysys/my_alloc.c:337
          #4 0x557313d75dfa in create_key_parts_for_pseudo_indexes /data/src/11.1/sql/opt_range.cc:3215
          #5 0x557313d78d66 in calculate_cond_selectivity_for_table(THD*, TABLE*, Item**) /data/src/11.1/sql/opt_range.cc:3641
          #6 0x55731420d039 in make_join_statistics /data/src/11.1/sql/sql_select.cc:5985
          #7 0x5573141ea2a2 in JOIN::optimize_inner() /data/src/11.1/sql/sql_select.cc:2576
          #8 0x5573141e3238 in JOIN::optimize() /data/src/11.1/sql/sql_select.cc:1902
          #9 0x557314204e92 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/11.1/sql/sql_select.cc:5143
          #10 0x5573141d4a85 in handle_select(THD*, LEX*, select_result*, unsigned long long) /data/src/11.1/sql/sql_select.cc:611
          #11 0x5573140fd980 in execute_sqlcom_select /data/src/11.1/sql/sql_parse.cc:6024
          #12 0x5573140ee4c2 in mysql_execute_command(THD*, bool) /data/src/11.1/sql/sql_parse.cc:3944
          #13 0x557314108339 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/11.1/sql/sql_parse.cc:7760
          #14 0x5573140e0ab0 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/11.1/sql/sql_parse.cc:1892
          #15 0x5573140dd7ee in do_command(THD*, bool) /data/src/11.1/sql/sql_parse.cc:1405
          #16 0x5573145956e1 in do_handle_one_connection(CONNECT*, bool) /data/src/11.1/sql/sql_connect.cc:1416
          #17 0x5573145950a2 in handle_one_connection /data/src/11.1/sql/sql_connect.cc:1318
          #18 0x55731518ea3b in pfs_spawn_thread /data/src/11.1/storage/perfschema/pfs.cc:2201
          #19 0x7fd7e4ea7fd3 in start_thread nptl/pthread_create.c:442
       
      Thread T5 created by T0 here:
          #0 0x7fd7e5849726 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:207
          #1 0x55731518a776 in my_thread_create /data/src/11.1/storage/perfschema/my_thread.h:52
          #2 0x55731518ee2a in pfs_spawn_thread_v1 /data/src/11.1/storage/perfschema/pfs.cc:2252
          #3 0x557313d2277a in inline_mysql_thread_create /data/src/11.1/include/mysql/psi/mysql_thread.h:1139
          #4 0x557313d3a6c0 in create_thread_to_handle_connection(CONNECT*) /data/src/11.1/sql/mysqld.cc:6134
          #5 0x557313d3acd1 in create_new_thread(CONNECT*) /data/src/11.1/sql/mysqld.cc:6193
          #6 0x557313d3afbc in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/11.1/sql/mysqld.cc:6255
          #7 0x557313d3b940 in handle_connections_sockets() /data/src/11.1/sql/mysqld.cc:6379
          #8 0x557313d39f3d in mysqld_main(int, char**) /data/src/11.1/sql/mysqld.cc:6029
          #9 0x557313d218e8 in main /data/src/11.1/sql/main.cc:34
          #10 0x7fd7e4e46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
       
      SUMMARY: AddressSanitizer: use-after-poison ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827 in __interceptor_memcpy
      Shadow bytes around the buggy address:
        0x0c428001aff0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c428001b000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c428001b010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c428001b020: 00 00 00 00 00 00 f7 00 00 00 00 f7 00 00 00 00
        0x0c428001b030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c428001b040: 00 00 00 00 00 00 00 00 00 00 00 00[f7]00 00 00
        0x0c428001b050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c428001b060: 00 00 00 00 00 00 00 00 00 00 00 00 00 f7 00 f7
        0x0c428001b070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c428001b080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c428001b090: f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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
      ==11382==ABORTING
      230607 15:24:20 [ERROR] mysqld got signal 6 ;
      This could be because you hit a bug. It is also possible that this binary
      or one of the libraries it was linked against is corrupt, improperly built,
      or misconfigured. This error can also be caused by malfunctioning hardware.
       
      To report this bug, see https://mariadb.com/kb/en/reporting-bugs
       
      We will try our best to scrape up some info that will hopefully help
      diagnose the problem, but since we have already crashed, 
      something is definitely wrong and this may fail.
       
      Server version: 11.1.0-MariaDB-debug-log source revision: 4e5b771e980edfdad5c5414aa62c81d409d585a4
      key_buffer_size=1048576
      read_buffer_size=131072
      max_used_connections=1
      max_threads=153
      thread_count=1
      It is possible that mysqld could use up to 
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 63925 K  bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.
       
      Thread pointer: 0x62b00007e218
      Attempting backtrace. You can use the following information to find out
      where mysqld died. If you see no messages after this, something went
      terribly wrong...
      stack_bottom = 0x7fd7dd3fbc10 thread_stack 0x100000
      sanitizer_common/sanitizer_common_interceptors.inc:4277(__interceptor_backtrace.part.0)[0x7fd7e5851f31]
      mysys/stacktrace.c:215(my_print_stacktrace)[0x557315d6d9cc]
      sql/signal_handler.cc:238(handle_fatal_signal)[0x5573149ddd5c]
      libc_sigaction.c:0(__restore_rt)[0x7fd7e4e5af90]
      nptl/pthread_kill.c:44(__pthread_kill_implementation)[0x7fd7e4ea9ccc]
      posix/raise.c:27(__GI_raise)[0x7fd7e4e5aef2]
      stdlib/abort.c:81(__GI_abort)[0x7fd7e4e45472]
      sanitizer_common/sanitizer_posix_libcdep.cpp:137(__sanitizer::Abort())[0x7fd7e58d650f]
      sanitizer_common/sanitizer_termination.cpp:59(__sanitizer::Die())[0x7fd7e58e2ba1]
      asan/asan_report.cpp:190(__asan::ScopedInErrorReport::~ScopedInErrorReport())[0x7fd7e58c1f5e]
      asan/asan_report.cpp:479(__asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool))[0x7fd7e58c14c6]
      sanitizer_common/sanitizer_common_interceptors.inc:827(memcpy)[0x7fd7e584816a]
      sql/field.h:1549(Field::set_image(unsigned char const*, unsigned int, charset_info_st const*))[0x5573145521d2]
      sql/field.h:1586(Field::set_key_image(unsigned char const*, unsigned int))[0x5573145522e2]
      sql/field.cc:11479(Field::print_key_part_value(String*, unsigned char const*, unsigned int))[0x5573149a8046]
      sql/opt_range.cc:16989(print_range_for_non_indexed_field(String*, Field*, st_key_multi_range*))[0x557313dd2097]
      sql/opt_range.cc:3350(records_in_column_ranges(PARAM*, unsigned int, SEL_ARG*))[0x557313d76c7a]
      sql/opt_range.cc:3693(calculate_cond_selectivity_for_table(THD*, TABLE*, Item**))[0x557313d793b6]
      sql/sql_select.cc:5987(make_join_statistics(JOIN*, List<TABLE_LIST>&, st_dynamic_array*))[0x55731420d03a]
      sql/sql_select.cc:2576(JOIN::optimize_inner())[0x5573141ea2a3]
      sql/sql_select.cc:1902(JOIN::optimize())[0x5573141e3239]
      sql/sql_select.cc:5143(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*))[0x557314204e93]
      sql/sql_select.cc:611(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x5573141d4a86]
      sql/sql_parse.cc:6024(execute_sqlcom_select(THD*, TABLE_LIST*))[0x5573140fd981]
      sql/sql_parse.cc:3944(mysql_execute_command(THD*, bool))[0x5573140ee4c3]
      sql/sql_parse.cc:7760(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x55731410833a]
      sql/sql_parse.cc:1894(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x5573140e0ab1]
      sql/sql_parse.cc:1405(do_command(THD*, bool))[0x5573140dd7ef]
      sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x5573145956e2]
      sql/sql_connect.cc:1320(handle_one_connection)[0x5573145950a3]
      perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55731518ea3c]
      nptl/pthread_create.c:442(start_thread)[0x7fd7e4ea7fd4]
      x86_64/clone3.S:83(clone3)[0x7fd7e4f285bc]
       
      Trying to get some variables.
      Some pointers may be invalid and cause the dump to abort.
      Query (0x6290000e6238): SELECT c FROM t WHERE c = 'qux'
       
      Connection ID (thread ID): 4
      Status: NOT_KILLED
       
      Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
       
      The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
      information that should help you find out what is causing the crash.
      Writing a core file...
      Working directory at /dev/shm/var_auto_FKUS/mysqld.1/data
      Resource Limits:
      Limit                     Soft Limit           Hard Limit           Units     
      Max cpu time              unlimited            unlimited            seconds   
      Max file size             unlimited            unlimited            bytes     
      Max data size             unlimited            unlimited            bytes     
      Max stack size            8388608              unlimited            bytes     
      Max core file size        unlimited            unlimited            bytes     
      Max resident set          unlimited            unlimited            bytes     
      Max processes             385793               385793               processes 
      Max open files            65536                65536                files     
      Max locked memory         12649951232          12649951232          bytes     
      Max address space         unlimited            unlimited            bytes     
      Max file locks            unlimited            unlimited            locks     
      Max pending signals       385793               385793               signals   
      Max msgqueue size         819200               819200               bytes     
      Max nice priority         0                    0                    
      Max realtime priority     0                    0                    
      Max realtime timeout      unlimited            unlimited            us        
      Core pattern: core
       
      Kernel version: Linux version 6.1.0-3-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.8-1 (2023-01-29)
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.