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

On startup: UBSAN: applying zero offset to null pointer in my_copy_fix_mb from strings/ctype-mb.c and other locations

    XMLWordPrintable

Details

    Description

      Now that MDEV-34187 is fixed (with thanks to bar!), we see this bug on startup with clang compiled builds:

      10.5.26 736449d30ffb2ec71bd700ac84eb38ba30bb662c (Debug, UBASAN)

      2024-05-24 12:19:35 0 [Note] /test/UBASAN_MD230524-mariadb-10.5.26-linux-x86_64-dbg/bin/mariadbd: ready for connections.
      Version: '10.5.26-MariaDB-debug'  socket: '/test/UBASAN_MD230524-mariadb-10.5.26-linux-x86_64-dbg/socket.sock'  port: 11915  MariaDB Server
      /test/10.5_dbg_san/strings/ctype-mb.c:406:66: runtime error: applying zero offset to null pointer
          #0 0x55fff2ccf6b1 in my_copy_fix_mb /test/10.5_dbg_san/strings/ctype-mb.c:406:66
          #1 0x55ffed348a11 in charset_info_st::copy_fix(char*, unsigned long, char const*, unsigned long, unsigned long, MY_STRCOPY_STATUS*) const /test/10.5_dbg_san/include/m_ctype.h:839:12
          #2 0x55ffed34875e in String_copier::well_formed_copy(charset_info_st const*, char*, unsigned long, charset_info_st const*, char const*, unsigned long, unsigned long) /test/10.5_dbg_san/sql/sql_string.cc:1108:26
          #3 0x55ffec5f96f7 in THD::copy_fix(charset_info_st const*, st_mysql_lex_string*, charset_info_st const*, char const*, unsigned long, String_copier*) /test/10.5_dbg_san/sql/sql_class.cc:2488:24
          #4 0x55ffec5fa555 in THD::copy_with_error(charset_info_st const*, st_mysql_lex_string*, charset_info_st const*, char const*, unsigned long) /test/10.5_dbg_san/sql/sql_class.cc:2526:10
          #5 0x55ffec41f109 in parse_client_handshake_packet(MPVIO_EXT*, unsigned char**, unsigned long) /test/10.5_dbg_san/sql/sql_acl.cc:13802:7
          #6 0x55ffec391d7b in server_mpvio_read_packet(st_plugin_vio*, unsigned char**) /test/10.5_dbg_san/sql/sql_acl.cc:14047:14
          #7 0x55ffec43717d in native_password_authenticate(st_plugin_vio*, st_mysql_server_auth_info*) /test/10.5_dbg_san/sql/sql_acl.cc:14748:17
          #8 0x55ffec39b118 in do_auth_once(THD*, st_mysql_const_lex_string const*, MPVIO_EXT*) /test/10.5_dbg_san/sql/sql_acl.cc:14234:12
          #9 0x55ffec38572f in acl_authenticate(THD*, unsigned int) /test/10.5_dbg_san/sql/sql_acl.cc:14377:10
          #10 0x55ffeda04951 in check_connection(THD*) /test/10.5_dbg_san/sql/sql_connect.cc:1083:12
          #11 0x55ffed9ff9ff in login_connection(THD*) /test/10.5_dbg_san/sql/sql_connect.cc:1149:10
          #12 0x55ffeda10659 in thd_prepare_connection(THD*) /test/10.5_dbg_san/sql/sql_connect.cc:1333:7
          #13 0x55ffeda0eaa5 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1407:9
          #14 0x55ffeda0ce0d in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1319:5
          #15 0x14bdfba97ad9 in start_thread nptl/pthread_create.c:444:8
          #16 0x14bdfbb2847b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /test/10.5_dbg_san/strings/ctype-mb.c:406:66 in
      

      This blocks UBSAN testing using Clang-compiled builds. Likely present in other versions also.

      $ cat BUILD_CMD_CMAKE 
      cmake . -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DWITH_SSL=bundled -DBUILD_CONFIG=mysql_release -DWITH_TOKUDB=0 -DWITH_JEMALLOC=no -DFEATURE_SET=community -DDEBUG_EXTNAME=OFF -DWITH_EMBEDDED_SERVER=0 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost_011979 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DWITH_SAFEMALLOC=OFF -DPLUGIN_PERFSCHEMA=NO -DWITH_DBUG_TRACE=OFF -DWITH_ZLIB=bundled -DWITH_ROCKSDB=1 -DWITH_PAM=ON -DWITH_MARIABACKUP=0 -DFORCE_INSOURCE_BUILD=1 -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWSREP_LIB_WITH_ASAN=ON -DCMAKE_CXX_FLAGS=-fsanitize-coverage=trace-pc-guard -DMYSQL_MAINTAINER_MODE=OFF -DWARNING_AS_ERROR='' -DCMAKE_BUILD_TYPE=Debug
      

      export UBSAN_OPTIONS=print_stacktrace=1
      

      Possibly caused by MDEV-34187 or previously masked

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

                Git Integration

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