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

UBSAN: runtime error: applying zero offset to null pointer in my_copy_fix_mb on SHOW COLLATION

    XMLWordPrintable

Details

    Description

      SHOW COLLATION;
      

      Leads to:

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Optimized, UBASAN, Clang)

      /test/11.8_opt_san/strings/ctype-mb.c:337:66: runtime error: applying zero offset to null pointer
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/11.8_opt_san/strings/ctype-mb.c:337:66 
          #0 0x55b4aaa81b56 in my_copy_fix_mb /test/11.8_opt_san/strings/ctype-mb.c:337:66
          #1 0x55b4a832d13d in charset_info_st::copy_fix(char*, unsigned long, char const*, unsigned long, unsigned long, MY_STRCOPY_STATUS*) const /test/11.8_opt_san/include/m_ctype.h:1046:12
          #2 0x55b4a832d13d in String_copier::well_formed_copy(charset_info_st const*, char*, unsigned long, charset_info_st const*, char const*, unsigned long, unsigned long) /test/11.8_opt_san/sql/sql_string.cc:1123:26
          #3 0x55b4a8ee40c0 in Field_longstr::well_formed_copy_with_check(char*, unsigned long, charset_info_st const*, char const*, unsigned long, unsigned long, bool, unsigned int*) /test/11.8_opt_san/sql/field.h:2295:26
          #4 0x55b4a8eef232 in Field_varstring::store(char const*, unsigned long, charset_info_st const*) /test/11.8_opt_san/sql/field.cc:8078:7
          #5 0x55b4a8278048 in Field::store(st_mysql_const_lex_string const&, charset_info_st const*) /test/11.8_opt_san/sql/field.h:1008:12
          #6 0x55b4a8278048 in fill_schema_collation(THD*, TABLE_LIST*, Item*) /test/11.8_opt_san/sql/sql_show.cc:6780:28
          #7 0x55b4a82a12c1 in get_schema_tables_result(JOIN*, enum_schema_table_state) /test/11.8_opt_san/sql/sql_show.cc:9689:11
          #8 0x55b4a80cca35 in JOIN::exec_inner() /test/11.8_opt_san/sql/sql_select.cc:4998:7
          #9 0x55b4a80cae21 in JOIN::exec() /test/11.8_opt_san/sql/sql_select.cc:4820:8
          #10 0x55b4a8027a2b 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*) /test/11.8_opt_san/sql/sql_select.cc:5353:21
          #11 0x55b4a8025c4d in handle_select(THD*, LEX*, select_result*, unsigned long long) /test/11.8_opt_san/sql/sql_select.cc:633:10
          #12 0x55b4a7ed9dac in execute_sqlcom_select(THD*, TABLE_LIST*) /test/11.8_opt_san/sql/sql_parse.cc:6177:12
          #13 0x55b4a7ebefc7 in mysql_execute_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:3966:12
          #14 0x55b4a7e87c92 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_opt_san/sql/sql_parse.cc:7901:18
          #15 0x55b4a7e7cb9e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_opt_san/sql/sql_parse.cc:1903:7
          #16 0x55b4a7e8aa6e in do_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:1416:17
          #17 0x55b4a866be38 in do_handle_one_connection(CONNECT*, bool) /test/11.8_opt_san/sql/sql_connect.cc:1415:11
          #18 0x55b4a866b280 in handle_one_connection /test/11.8_opt_san/sql/sql_connect.cc:1327:5
          #19 0x55b4a77b3b0c in asan_thread_start(void*) asan_interceptors.cpp.o
          #20 0x1514f629ca93 in start_thread nptl/pthread_create.c:447:8
          #21 0x1514f6329c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/11.8_opt_san/strings/ctype-mb.c:337:66 
      

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18:
           # Note: llvm-17-linker-tools installs /usr/lib/llvm-17/lib/LLVMgold.so, which is needed for compilation, and LLVMgold.so is no longer included in LLVM 18
           sudo apt install clang llvm-18 llvm-18-linker-tools llvm-18-runtime llvm-18-tools llvm-18-dev libstdc++-14-dev llvm-dev llvm-17-linker-tools
           sudo ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
      Compiled with: '-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++' and:
          -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWSREP_LIB_WITH_ASAN=ON
      Set before execution:
          export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1   # And you may also want to supress UBSAN startup issues using 'suppressions=UBSAN.filter'. For an example of UBSAN.filter, which includes current startup issues see: https://github.com/mariadb-corporation/mariadb-qa/blob/master/UBSAN.filter
      

      Bug confirmed present in:
      MariaDB: 10.11.11 (dbg), 10.11.11 (opt), 11.4.5 (dbg), 11.4.5 (opt), 11.7.1 (dbg), 11.7.1 (opt), 11.8.0 (dbg), 11.8.0 (opt)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.5.28 (dbg), 10.5.28 (opt), 10.6.21 (dbg), 10.6.21 (opt)

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              Roel Roel Van de Paar
              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.