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

UBSAN: member access within null pointer of type 'KEY' (aka 'st_key') in myrocks::ha_rocksdb::index_read_map_impl on CREATE SERVER

Details

    Description

      INSTALL SONAME 'ha_rocksdb';
      CREATE OR REPLACE TABLE mysql.servers (x INT) ENGINE=RocksDB;
      CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'');
      

      Leads to:

      CS 10.11.12 43c5d1303f5c7c726db276815c459436110f342f (Optimized, UBASAN, Clang) Build 15/02/2025

      /test/10.11_opt_san/storage/rocksdb/ha_rocksdb.cc:8548:7: runtime error: member access within null pointer of type 'KEY' (aka 'st_key')
          #0 0x7269db384348 in myrocks::ha_rocksdb::index_read_map_impl(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function, st_key_range const*) /test/10.11_opt_san/storage/rocksdb/ha_rocksdb.cc:8548:37
          #1 0x5cba711157b6 in handler::index_read_idx_map(unsigned char*, unsigned int, unsigned char const*, unsigned long, ha_rkey_function) /test/10.11_opt_san/sql/handler.cc:6961:12
          #2 0x5cba710f0c95 in handler::ha_index_read_idx_map(unsigned char*, unsigned int, unsigned char const*, unsigned long, ha_rkey_function) /test/10.11_opt_san/sql/handler.cc:3623:3
          #3 0x5cba709f33e9 in insert_server_record(TABLE*, st_federated_server*) /test/10.11_opt_san/sql/sql_servers.cc:648:7
          #4 0x5cba709f33e9 in insert_server(THD*, st_federated_server*) /test/10.11_opt_san/sql/sql_servers.cc:484:7
          #5 0x5cba709f33e9 in create_server(THD*, st_lex_server_options*) /test/10.11_opt_san/sql/sql_servers.cc:1140:10
          #6 0x5cba703cae5c in mysql_execute_command(THD*, bool) /test/10.11_opt_san/sql/sql_parse.cc:6096:10
          #7 0x5cba703a2dc0 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/10.11_opt_san/sql/sql_parse.cc:8188:18
          #8 0x5cba7039a0fd in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/10.11_opt_san/sql/sql_parse.cc:1905:7
          #9 0x5cba703a5086 in do_command(THD*, bool) /test/10.11_opt_san/sql/sql_parse.cc:1418:17
          #10 0x5cba70a08a9c in do_handle_one_connection(CONNECT*, bool) /test/10.11_opt_san/sql/sql_connect.cc:1386:11
          #11 0x5cba70a082ea in handle_one_connection /test/10.11_opt_san/sql/sql_connect.cc:1298:5
          #12 0x5cba6fde9dbc in asan_thread_start(void*) asan_interceptors.cpp.o
          #13 0x726ab189ca93 in start_thread nptl/pthread_create.c:447:8
          #14 0x726ab1929c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: null-pointer-use /test/10.11_opt_san/storage/rocksdb/ha_rocksdb.cc:8548:7 
      

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18. Ubuntu instructions:
        # Note: It is strongly recommended to uninstall all old Clang & LLVM packages (ref  dpkg --list | grep -iE 'clang|llvm'  and use  apt purge  and  dpkg --purge  to remove the packages), before installing Clang/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
      Compiled with: "-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C{,XX}_FLAGS='-march=native -mtune=native'" 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' in UBSAN_OPTIONS. For an example of UBSAN.filter, which includes current startup issues see: https://github.com/mariadb-corporation/mariadb-qa/blob/master/UBSAN.filter
      

      SAN Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.5   dbg  150225  c43d0a015f974c5a0142e6779332089a7a979853  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  10.5   opt  150225  c43d0a015f974c5a0142e6779332089a7a979853  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  10.6   dbg  150225  f1d7e0c17e33f77278e6226dd94aeb30fc856bf0  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  10.6   opt  150225  f1d7e0c17e33f77278e6226dd94aeb30fc856bf0  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  10.11  dbg  150225  43c5d1303f5c7c726db276815c459436110f342f  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  10.11  opt  150225  43c5d1303f5c7c726db276815c459436110f342f  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  11.4   dbg  150225  ef966af801afc2a07222b5df65dddd52c77431dd  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  11.4   opt  150225  ef966af801afc2a07222b5df65dddd52c77431dd  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  11.8   dbg  150225  33e0796e7a154e02a5e53c55cefc5d6feb4f5e6d  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  11.8   opt  150225  33e0796e7a154e02a5e53c55cefc5d6feb4f5e6d  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  12.0   dbg  150225  c92add291e636c797e6d6ddca605905541b2a441  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      CS  12.0   opt  150225  c92add291e636c797e6d6ddca605905541b2a441  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      ES  10.5   dbg  140325  6553c62369ab3606efc74295c902181f793fd6d1  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      ES  10.5   opt  140325  6553c62369ab3606efc74295c902181f793fd6d1  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      ES  10.6   dbg  140325  a99e9e4101f5d56a379577e6d81c829b7658df99  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      ES  10.6   opt  140325  a99e9e4101f5d56a379577e6d81c829b7658df99  SIGSEGV|std::__shared_ptr<myrocks::Rdb_key_def,|std::shared_ptr<myrocks::Rdb_key_def>::operator=|myrocks::ha_rocksdb::create_table|myrocks::ha_rocksdb::create
      ES  11.4   dbg  140325  26e39c99feaa4e6f9d3e1b13fd4a7d101059b7ba  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      ES  11.4   opt  140325  26e39c99feaa4e6f9d3e1b13fd4a7d101059b7ba  UBSAN|member access within null pointer of type 'KEY' (aka 'st_key')|storage/rocksdb/ha_rocksdb.cc|myrocks::ha_rocksdb::index_read_map_impl|handler::index_read_idx_map|handler::ha_index_read_idx_map|insert_server_record
      

      For the single ES 10.6 opt different stack alone, see MENT-2277. It is otherwise unrelated to this ticket.

      Attachments

        Activity

          There are no comments yet on this issue.

          People

            psergei Sergei Petrunia
            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.