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

UBSAN: runtime error: applying zero offset to null pointer in my_uca_contraction_find on SET SESSION collation_connection

    XMLWordPrintable

Details

    Description

      Possibly some connection with MDEV-35621, though no WEIGHT_STRING is used here etc.

      SET SESSION collation_connection=utf8_german2_ci;
      

      Leads to:

      CS 10.5.28 a226f12675c6312ca7632b90261397e313e6a7ae (Optimized, UBASAN, Clang)

      /test/10.5_opt_san/strings/ctype-uca.c:31493:31: runtime error: applying zero offset to null pointer
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/10.5_opt_san/strings/ctype-uca.c:31493:31 
          #0 0x559d9ea8d742 in my_uca_contraction_find /test/10.5_opt_san/strings/ctype-uca.c:31493:31
          #1 0x559d9ea8ce80 in my_char_weight_put /test/10.5_opt_san/strings/ctype-uca.c:33243:17
          #2 0x559d9ea85bdb in apply_one_rule /test/10.5_opt_san/strings/ctype-uca.c:33515:9
          #3 0x559d9ea85bdb in init_weight_level /test/10.5_opt_san/strings/ctype-uca.c:33719:9
          #4 0x559d9ea85bdb in create_tailoring /test/10.5_opt_san/strings/ctype-uca.c:33888:14
          #5 0x559d9ea6e3a9 in my_coll_init_uca /test/10.5_opt_san/strings/ctype-uca.c:33755:10
          #6 0x559d9ea6e3a9 in my_uca_coll_init_utf8mb3 /test/10.5_opt_san/strings/ctype-uca.c:34897:7
          #7 0x559d9e92d202 in my_ci_init_collation /test/10.5_opt_san/include/m_ctype.h:1121:10
          #8 0x559d9e92d202 in get_internal_charset /test/10.5_opt_san/mysys/charset.c:885:13
          #9 0x559d9e92dfa8 in my_collation_get_by_name /test/10.5_opt_san/mysys/charset.c:950:19
          #10 0x559d9e92dfa8 in get_charset_by_name /test/10.5_opt_san/mysys/charset.c:966:10
          #11 0x559d9c678bdb in check_collation_not_null(sys_var*, THD*, set_var*) /test/10.5_opt_san/sql/sys_vars.cc:887:35
          #12 0x559d9ba28529 in sys_var::check(THD*, set_var*) /test/10.5_opt_san/sql/set_var.cc:248:7
          #13 0x559d9ba30c29 in set_var::check(THD*) /test/10.5_opt_san/sql/set_var.cc:815:15
          #14 0x559d9ba2f51a in sql_set_variables(THD*, List<set_var_base>*, bool) /test/10.5_opt_san/sql/set_var.cc:743:9
          #15 0x559d9bf329b4 in mysql_execute_command(THD*) /test/10.5_opt_san/sql/sql_parse.cc:5186:9
          #16 0x559d9befee98 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_opt_san/sql/sql_parse.cc:8251:18
          #17 0x559d9bef19d0 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_opt_san/sql/sql_parse.cc:1891:7
          #18 0x559d9bf018d9 in do_command(THD*) /test/10.5_opt_san/sql/sql_parse.cc:1375:17
          #19 0x559d9c6095c2 in do_handle_one_connection(CONNECT*, bool) /test/10.5_opt_san/sql/sql_connect.cc:1386:11
          #20 0x559d9c608a24 in handle_one_connection /test/10.5_opt_san/sql/sql_connect.cc:1298:5
          #21 0x559d9b96910c in asan_thread_start(void*) asan_interceptors.cpp.o
          #22 0x15223fa9ca93 in start_thread nptl/pthread_create.c:447:8
          #23 0x15223fb29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/10.5_opt_san/strings/ctype-uca.c:31493:31 
      

      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:
              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.