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

UBSAN: runtime errors: applying zero offset to null pointer in my_strnncoll_utf8mb3_general1400_as_ci, and applying non-zero offset 4 to null pointer in my_strcoll_ascii_4bytes_found

    XMLWordPrintable

Details

    Description

      CREATE TABLE t (c INT,c2 CHAR,c3 DATE,CHECK (c>0));
      ALTER TABLE t ADD INDEX (c2) USING HASH;
      

      or

      --error ER_PARSE_ERROR
      WITH a AS (SELECT * FROM a FOR TIME ALL;
      

      or

      --error ER_PARSE_ERROR
      WITH c AS(SELECT * FROM (SELECT * FROM t1) SELECT * FROM DUAL;
      

      Lead to:

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Optimized, UBASAN, Clang)

      /test/11.8_opt_san/strings/strcoll.inl:230:25: runtime error: applying zero offset to null pointer
          #0 0x56158a789512 in my_strnncoll_utf8mb3_general1400_as_ci /test/11.8_opt_san/strings/strcoll.inl:230:25
          #1 0x561587af53ea in charset_info_st::strnncoll(st_mysql_const_lex_string, st_mysql_const_lex_string, char) const /test/11.8_opt_san/include/m_ctype.h:1081:12
          #2 0x561587af53ea in charset_info_st::streq(st_mysql_const_lex_string, st_mysql_const_lex_string) const /test/11.8_opt_san/include/m_ctype.h:1073:17
          #3 0x561587af53ea in Lex_ident<Compare_ident_ci>::streq(st_mysql_const_lex_string const&) const /test/11.8_opt_san/sql/lex_ident.h:119:38
          #4 0x561587af53ea in is_infoschema_db(st_mysql_const_lex_string const*) /test/11.8_opt_san/sql/table.h:3583:34
          #5 0x561587af53ea in st_select_lex::add_table_to_list(THD*, Table_ident*, st_mysql_const_lex_string const*, unsigned long, thr_lock_type, enum_mdl_type, List<Index_hint>*, List<String>*, st_mysql_lex_string*) /test/11.8_opt_san/sql/sql_parse.cc:8100:21
          #6 0x561588870fcd in MYSQLparse(THD*) /test/11.8_opt_san/sql/sql_yacc.yy:12150:47
          #7 0x561587b44284 in parse_sql(THD*, Parser_state*, Object_creation_ctx*, bool) /test/11.8_opt_san/sql/sql_parse.cc:10314:46
          #8 0x561587adcef1 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_opt_san/sql/sql_parse.cc:7853:15
          #9 0x561587ad2b9e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_opt_san/sql/sql_parse.cc:1903:7
          #10 0x561587ae0a6e in do_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:1416:17
          #11 0x5615882c1e38 in do_handle_one_connection(CONNECT*, bool) /test/11.8_opt_san/sql/sql_connect.cc:1415:11
          #12 0x5615882c1280 in handle_one_connection /test/11.8_opt_san/sql/sql_connect.cc:1327:5
          #13 0x561587409b0c in asan_thread_start(void*) asan_interceptors.cpp.o
          #14 0x151f1549ca93 in start_thread nptl/pthread_create.c:447:8
          #15 0x151f15529c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-offset /test/11.8_opt_san/strings/strcoll.inl:230:25 
      

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Optimized, UBASAN, Clang)

      /test/11.8_opt_san/strings/ctype-ascii.h:110:27: runtime error: applying non-zero offset 4 to null pointer
          #0 0x56158a7842e6 in my_strcoll_ascii_4bytes_found /test/11.8_opt_san/strings/ctype-ascii.h:110:27
          #1 0x56158a789227 in my_strnncoll_utf8mb3_general1400_as_ci /test/11.8_opt_san/strings/strcoll.inl:238:24
          #2 0x561587af53ea in charset_info_st::strnncoll(st_mysql_const_lex_string, st_mysql_const_lex_string, char) const /test/11.8_opt_san/include/m_ctype.h:1081:12
          #3 0x561587af53ea in charset_info_st::streq(st_mysql_const_lex_string, st_mysql_const_lex_string) const /test/11.8_opt_san/include/m_ctype.h:1073:17
          #4 0x561587af53ea in Lex_ident<Compare_ident_ci>::streq(st_mysql_const_lex_string const&) const /test/11.8_opt_san/sql/lex_ident.h:119:38
          #5 0x561587af53ea in is_infoschema_db(st_mysql_const_lex_string const*) /test/11.8_opt_san/sql/table.h:3583:34
          #6 0x561587af53ea in st_select_lex::add_table_to_list(THD*, Table_ident*, st_mysql_const_lex_string const*, unsigned long, thr_lock_type, enum_mdl_type, List<Index_hint>*, List<String>*, st_mysql_lex_string*) /test/11.8_opt_san/sql/sql_parse.cc:8100:21
          #7 0x561588870fcd in MYSQLparse(THD*) /test/11.8_opt_san/sql/sql_yacc.yy:12150:47
          #8 0x561587b44284 in parse_sql(THD*, Parser_state*, Object_creation_ctx*, bool) /test/11.8_opt_san/sql/sql_parse.cc:10314:46
          #9 0x561587adcef1 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_opt_san/sql/sql_parse.cc:7853:15
          #10 0x561587ad2b9e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_opt_san/sql/sql_parse.cc:1903:7
          #11 0x561587ae0a6e in do_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:1416:17
          #12 0x5615882c1e38 in do_handle_one_connection(CONNECT*, bool) /test/11.8_opt_san/sql/sql_connect.cc:1415:11
          #13 0x5615882c1280 in handle_one_connection /test/11.8_opt_san/sql/sql_connect.cc:1327:5
          #14 0x561587409b0c in asan_thread_start(void*) asan_interceptors.cpp.o
          #15 0x151f1549ca93 in start_thread nptl/pthread_create.c:447:8
          #16 0x151f15529c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /test/11.8_opt_san/strings/ctype-ascii.h:110:27 
      

      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: 11.5-11.8 (opt+dbg)

      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.