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

UBSAN: runtime error: applying zero offset to null pointer in my_strnxfrm_utf8mb3_general_ci, my_uca_scanner_init_any and my_uca_scanner_next_utf8mb3

    XMLWordPrintable

Details

    Description

      SET NAMES utf8;
      DO CHAR((WEIGHT_STRING (EXTRACTVALUE ((0),('t')) LEVEL 7)) USING cp852);
      

      Leads to:

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/strings/strcoll.inl:472:54: runtime error: applying zero offset to null pointer
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/10.5_dbg_san/strings/strcoll.inl:472:54 
          #0 0x557849078606 in my_strnxfrm_utf8mb3_general_ci /test/10.5_dbg_san/strings/strcoll.inl:472:54
          #1 0x557845805bb9 in charset_info_st::strnxfrm(char*, unsigned long, unsigned int, char const*, unsigned long, unsigned int) const /test/10.5_dbg_san/include/m_ctype.h:871:12
          #2 0x557845805590 in Item_func_weight_string::val_str(String*) /test/10.5_dbg_san/sql/item_strfunc.cc:3732:19
          #3 0x557845778d61 in Item_str_func::val_int() /test/10.5_dbg_san/sql/item_strfunc.cc:154:16
          #4 0x5578457e570f in Item_func_char::val_str(String*) /test/10.5_dbg_san/sql/item_strfunc.cc:2986:32
          #5 0x557844428c22 in Type_handler_string_result::Item_update_null_value(Item*) const /test/10.5_dbg_san/sql/sql_type.cc:4286:16
          #6 0x5578424766d4 in Item::update_null_value() /test/10.5_dbg_san/sql/item.h:1911:28
          #7 0x557842b4d646 in Item_func::is_null() /test/10.5_dbg_san/sql/item_func.h:222:5
          #8 0x5578462db011 in mysql_do(THD*, List<Item>&) /test/10.5_dbg_san/sql/sql_do.cc:35:19
          #9 0x557842f389c8 in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4058:10
          #10 0x557842edf4e3 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8237:18
          #11 0x557842ebf453 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #12 0x557842ee7a19 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #13 0x557843e61f30 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #14 0x557843e606fd in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #15 0x55784235ba8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #16 0x154b2ca9ca93 in start_thread nptl/pthread_create.c:447:8
          #17 0x154b2cb29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/10.5_dbg_san/strings/strcoll.inl:472:54 
      

      In 11.7 the stack changes:

      CS 11.7.1 33907f9ec6b969528d0f3f99873c3b4d64c98b5a (Debug, UBASAN, Clang)

      /test/11.7_dbg_san/strings/ctype-uca.c:32090:22: runtime error: applying zero offset to null pointer
          #0 0x5605e65733ce in my_uca_scanner_init_any /test/11.7_dbg_san/strings/ctype-uca.c:32090:22
          #1 0x5605e658ba96 in my_uca_strnxfrm_onelevel_internal_utf8mb3 /test/11.7_dbg_san/strings/ctype-uca.inl:801:3
          #2 0x5605e658b3db in my_uca_strnxfrm_onelevel_utf8mb3 /test/11.7_dbg_san/strings/ctype-uca.inl:834:25
          #3 0x5605e65409e0 in my_uca_strnxfrm_utf8mb3 /test/11.7_dbg_san/strings/ctype-uca.inl:898:7
          #4 0x5605e2f666c6 in charset_info_st::strnxfrm(char*, unsigned long, unsigned int, char const*, unsigned long, unsigned int) const /test/11.7_dbg_san/include/m_ctype.h:1119:12
          #5 0x5605e2f66007 in Item_func_weight_string::val_str(String*) /test/11.7_dbg_san/sql/item_strfunc.cc:4201:19
          #6 0x5605e2eca524 in Item_str_func::val_int() /test/11.7_dbg_san/sql/item_strfunc.cc:169:16
          #7 0x5605e2f4559b in Item_func_char::val_str(String*) /test/11.7_dbg_san/sql/item_strfunc.cc:3405:32
          #8 0x5605e1ad1f02 in Type_handler_string_result::Item_update_null_value(Item*) const /test/11.7_dbg_san/sql/sql_type.cc:4345:16
          #9 0x5605df4308d4 in Item::update_null_value() /test/11.7_dbg_san/sql/item.h:2152:28
          #10 0x5605df5edad6 in Item_func::is_null() /test/11.7_dbg_san/sql/item_func.h:243:5
          #11 0x5605e38d6a99 in mysql_do(THD*, List<Item>&) /test/11.7_dbg_san/sql/sql_do.cc:36:19
          #12 0x5605e02301c5 in mysql_execute_command(THD*, bool) /test/11.7_dbg_san/sql/sql_parse.cc:3995:10
          #13 0x5605e01d5ec9 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.7_dbg_san/sql/sql_parse.cc:7901:18
          #14 0x5605e01b6d88 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.7_dbg_san/sql/sql_parse.cc:1903:7
          #15 0x5605e01dfe26 in do_command(THD*, bool) /test/11.7_dbg_san/sql/sql_parse.cc:1416:17
          #16 0x5605e1341db6 in do_handle_one_connection(CONNECT*, bool) /test/11.7_dbg_san/sql/sql_connect.cc:1415:11
          #17 0x5605e1340579 in handle_one_connection /test/11.7_dbg_san/sql/sql_connect.cc:1327:5
          #18 0x5605df3895cc in asan_thread_start(void*) asan_interceptors.cpp.o
          #19 0x14901769ca93 in start_thread nptl/pthread_create.c:447:8
          #20 0x149017729c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/11.7_dbg_san/strings/ctype-uca.c:32090:22 
      /test/11.7_dbg_san/strings/ctype-uca-scanner_next.inl:84:23: runtime error: applying non-zero offset 1 to null pointer
          #0 0x5605e6583f1c in my_uca_scanner_next_utf8mb3 /test/11.7_dbg_san/strings/ctype-uca-scanner_next.inl:84:23
          #1 0x5605e658baa9 in my_uca_strnxfrm_onelevel_internal_utf8mb3 /test/11.7_dbg_san/strings/ctype-uca.inl:803:18
          #2 0x5605e658b3db in my_uca_strnxfrm_onelevel_utf8mb3 /test/11.7_dbg_san/strings/ctype-uca.inl:834:25
          #3 0x5605e65409e0 in my_uca_strnxfrm_utf8mb3 /test/11.7_dbg_san/strings/ctype-uca.inl:898:7
          #4 0x5605e2f666c6 in charset_info_st::strnxfrm(char*, unsigned long, unsigned int, char const*, unsigned long, unsigned int) const /test/11.7_dbg_san/include/m_ctype.h:1119:12
          #5 0x5605e2f66007 in Item_func_weight_string::val_str(String*) /test/11.7_dbg_san/sql/item_strfunc.cc:4201:19
          #6 0x5605e2eca524 in Item_str_func::val_int() /test/11.7_dbg_san/sql/item_strfunc.cc:169:16
          #7 0x5605e2f4559b in Item_func_char::val_str(String*) /test/11.7_dbg_san/sql/item_strfunc.cc:3405:32
          #8 0x5605e1ad1f02 in Type_handler_string_result::Item_update_null_value(Item*) const /test/11.7_dbg_san/sql/sql_type.cc:4345:16
          #9 0x5605df4308d4 in Item::update_null_value() /test/11.7_dbg_san/sql/item.h:2152:28
          #10 0x5605df5edad6 in Item_func::is_null() /test/11.7_dbg_san/sql/item_func.h:243:5
          #11 0x5605e38d6a99 in mysql_do(THD*, List<Item>&) /test/11.7_dbg_san/sql/sql_do.cc:36:19
          #12 0x5605e02301c5 in mysql_execute_command(THD*, bool) /test/11.7_dbg_san/sql/sql_parse.cc:3995:10
          #13 0x5605e01d5ec9 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.7_dbg_san/sql/sql_parse.cc:7901:18
          #14 0x5605e01b6d88 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.7_dbg_san/sql/sql_parse.cc:1903:7
          #15 0x5605e01dfe26 in do_command(THD*, bool) /test/11.7_dbg_san/sql/sql_parse.cc:1416:17
          #16 0x5605e1341db6 in do_handle_one_connection(CONNECT*, bool) /test/11.7_dbg_san/sql/sql_connect.cc:1415:11
          #17 0x5605e1340579 in handle_one_connection /test/11.7_dbg_san/sql/sql_connect.cc:1327:5
          #18 0x5605df3895cc in asan_thread_start(void*) asan_interceptors.cpp.o
          #19 0x14901769ca93 in start_thread nptl/pthread_create.c:447:8
          #20 0x149017729c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /test/11.7_dbg_san/strings/ctype-uca-scanner_next.inl:84:23 
      

      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.5.28 (dbg), 10.5.28 (opt), 10.6.21 (dbg), 10.6.21 (opt), 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)

      Attachments

        Issue Links

          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:

                Git Integration

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