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

UBSAN: runtime error: applying zero offset to null pointer on XA RECOVER

    XMLWordPrintable

Details

    Description

      XA RECOVER;
      

      Leads to:

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Optimized, UBASAN)

      /test/10.5_opt_san/strings/ctype.c:845:20: runtime error: applying zero offset to null pointer
      

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Optimized, UBASAN)

          #0 0x557e9ea12dec in my_string_repertoire_8bit /test/10.5_opt_san/strings/ctype.c:845:20
          #1 0x557e9ea12f49 in my_string_metadata_get /test/10.5_opt_san/strings/ctype.c:912:27
          #2 0x557e9b926e6f in Item_basic_value::Metadata::Metadata(String const*) /test/10.5_opt_san/sql/item.h:2888:7
          #3 0x557e9b926e6f in Item_string::Item_string(THD*, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, charset_info_st const*, Derivation) /test/10.5_opt_san/sql/item.h:4613:24
          #4 0x557e9c95de1b in Item_partition_func_safe_string::Item_partition_func_safe_string(THD*, st_mysql_const_lex_string const&, unsigned int, charset_info_st const*) /test/10.5_opt_san/sql/item.h:4788:5
          #5 0x557e9c95de1b in Item_empty_string::Item_empty_string(THD*, char const*, unsigned int, charset_info_st const*) /test/10.5_opt_san/sql/item.h:4816:5
          #6 0x557e9c95de1b in mysql_xa_recover(THD*) /test/10.5_opt_san/sql/xa.cc:1117:26
          #7 0x557e9be46d36 in mysql_execute_command(THD*) /test/10.5_opt_san/sql/sql_parse.cc:6072:10
          #8 0x557e9be18168 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_opt_san/sql/sql_parse.cc:8237:18
          #9 0x557e9be0b160 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_opt_san/sql/sql_parse.cc:1891:7
          #10 0x557e9be1aba9 in do_command(THD*) /test/10.5_opt_san/sql/sql_parse.cc:1375:17
          #11 0x557e9c520f72 in do_handle_one_connection(CONNECT*, bool) /test/10.5_opt_san/sql/sql_connect.cc:1386:11
          #12 0x557e9c5203d4 in handle_one_connection /test/10.5_opt_san/sql/sql_connect.cc:1298:5
          #13 0x557e9b88110c in asan_thread_start(void*) asan_interceptors.cpp.o
          #14 0x147f8009ca93 in start_thread nptl/pthread_create.c:447:8
          #15 0x147f80129c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/10.5_opt_san/strings/ctype.c:845:20 
      

      CS 11.8.0 0fabe1dc182d7186e0b42fca4b83474e5734409e (Debug, UBASAN)

      /test/11.8_dbg_san/strings/ctype.c:849:20: runtime error: applying zero offset to null pointer
      

      CS 11.8.0 0fabe1dc182d7186e0b42fca4b83474e5734409e (Debug, UBASAN)

          #0 0x558f97ffd14b in my_string_repertoire_8bit /test/11.8_dbg_san/strings/ctype.c:849:20
          #1 0x558f97ffd439 in my_string_metadata_get /test/11.8_dbg_san/strings/ctype.c:916:27
          #2 0x558f910d8407 in Item_basic_value::Metadata::Metadata(String const*) /test/11.8_dbg_san/sql/item.h:3066:7
          #3 0x558f910d714b in Item_string::Item_string(THD*, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, charset_info_st const*, Derivation) /test/11.8_dbg_san/sql/item.h:4868:24
          #4 0x558f910d6a50 in Item_partition_func_safe_string::Item_partition_func_safe_string(THD*, st_mysql_const_lex_string const&, unsigned int, charset_info_st const*) /test/11.8_dbg_san/sql/item.h:5043:5
          #5 0x558f910d28b9 in Item_empty_string::Item_empty_string(THD*, char const*, unsigned int, charset_info_st const*) /test/11.8_dbg_san/sql/item.h:5071:5
          #6 0x558f937a357b in xa_recover_get_fields(THD*, List<Item>*, char (**)(void*, void*)) /test/11.8_dbg_san/sql/xa.cc:1132:2
          #7 0x558f937a4046 in mysql_xa_recover(THD*) /test/11.8_dbg_san/sql/xa.cc:1143:3
          #8 0x558f91c2b015 in mysql_execute_command(THD*, bool) /test/11.8_dbg_san/sql/sql_parse.cc:5772:10
          #9 0x558f91b8bcf9 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_dbg_san/sql/sql_parse.cc:7901:18
          #10 0x558f91b6cbb8 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_dbg_san/sql/sql_parse.cc:1903:7
          #11 0x558f91b95c56 in do_command(THD*, bool) /test/11.8_dbg_san/sql/sql_parse.cc:1416:17
          #12 0x558f92cf7776 in do_handle_one_connection(CONNECT*, bool) /test/11.8_dbg_san/sql/sql_connect.cc:1438:11
          #13 0x558f92cf5f39 in handle_one_connection /test/11.8_dbg_san/sql/sql_connect.cc:1350:5
          #14 0x558f90d405dc in asan_thread_start(void*) asan_interceptors.cpp.o
          #15 0x14b44069ca93 in start_thread nptl/pthread_create.c:447:8
          #16 0x14b440729c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18:
      # 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
      Set before execution:
          export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
      

      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

        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.