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

LSAN memory leak in storage/rocksdb/rocksdb/util/thread_local.cc | operator | rocksdb::ThreadLocalPtr::Instance

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      SELECT 1 FROM information_schema.all_plugins;
      INSTALL SONAME 'ha_rocksdb';
      SHUTDOWN;
      

      Leads to:

      CS 12.3.0 549628d9ccb822252b55210d922cef3d13eecd71 (Optimized, UBASAN, Clang 18.1.3-11) Build 03/02/2026

      =================================================================
      ==2069104==ERROR: LeakSanitizer: detected memory leaks
       
      Direct leak of 232 byte(s) in 1 object(s) allocated from:
          #0 0x5804dc427f71 in operator new(unsigned long) (/test/UBASAN_MD030226-mariadb-12.3.0-linux-x86_64-opt/bin/mariadbd+0x299af71) (BuildId: 65c459de73aa6e07)
          #1 0x7c1846be5ff8 in rocksdb::ThreadLocalPtr::Instance() /test/12.3_opt_san/storage/rocksdb/rocksdb/util/thread_local.cc:273:45
          #2 0x7c1846be5ff8 in rocksdb::ThreadLocalPtr::InitSingletons() /test/12.3_opt_san/storage/rocksdb/rocksdb/util/thread_local.cc:246:41
          #3 0x7c18468825d2 in rocksdb::Env::Default() /test/12.3_opt_san/storage/rocksdb/rocksdb/env/env_posix.cc:487:3
          #4 0x7c18464ecf74 in rocksdb::DBOptions::DBOptions() /test/12.3_opt_san/storage/rocksdb/rocksdb/include/rocksdb/options.h:514:14
          #5 0x7c1845ba8217 in myrocks::rdb_init_rocksdb_db_options() /test/12.3_opt_san/storage/rocksdb/ha_rocksdb.cc:744:52
          #6 0x7c1845ba8217 in __cxx_global_var_init.35 /test/12.3_opt_san/storage/rocksdb/ha_rocksdb.cc:762:5
          #7 0x7c1845ba8217 in _GLOBAL__sub_I_ha_rocksdb.cc /test/12.3_opt_san/storage/rocksdb/ha_rocksdb.cc
          #8 0x7c3ac888371e in call_init elf/dl-init.c:74:3
          #9 0x7c3ac8883823 in call_init elf/dl-init.c:120:14
          #10 0x7c3ac8883823 in _dl_init elf/dl-init.c:121:5
          #11 0x7c3ac887f5b1 in _dl_catch_exception elf/dl-catch.c:211:7
          #12 0x7c3ac888ad7b in dl_open_worker elf/dl-open.c:829:5
          #13 0x7c3ac888ad7b in dl_open_worker elf/dl-open.c:792:1
          #14 0x7c3ac887f51b in _dl_catch_exception elf/dl-catch.c:237:8
          #15 0x7c3ac888b163 in _dl_open elf/dl-open.c:905:17
          #16 0x7c3ac7e981a3 in dlopen_doit dlfcn/dlopen.c:56:15
          #17 0x7c3ac887f51b in _dl_catch_exception elf/dl-catch.c:237:8
          #18 0x7c3ac887f668 in _dl_catch_error elf/dl-catch.c:256:19
          #19 0x7c3ac7e97c82 in _dlerror_run dlfcn/dlerror.c:138:17
          #20 0x7c3ac7e9825e in dlopen_implementation dlfcn/dlopen.c:71:10
          #21 0x7c3ac7e9825e in dlopen dlfcn/dlopen.c:81:12
          #22 0x5804dc3af2f3 in dlopen (/test/UBASAN_MD030226-mariadb-12.3.0-linux-x86_64-opt/bin/mariadbd+0x29222f3) (BuildId: 65c459de73aa6e07)
          #23 0x5804dd681b1e in plugin_dl_add(st_mysql_const_lex_string const*, unsigned long) /test/12.3_opt_san/sql/sql_plugin.cc:780:27
          #24 0x5804dd681528 in plugin_dl_foreach(THD*, st_mysql_const_lex_string const*, char (*)(THD*, st_plugin_int*, void*), void*) /test/12.3_opt_san/sql/sql_plugin.cc
      :2612:30
          #25 0x5804dd8eb16a in fill_all_plugins(THD*, TABLE_LIST*, Item*) /test/12.3_opt_san/sql/sql_show.cc:431:9
          #26 0x5804dd95829e in get_schema_tables_result(JOIN*, enum_schema_table_state) /test/12.3_opt_san/sql/sql_show.cc:9844:11
          #27 0x5804dd7a9ce5 in JOIN::exec_inner() /test/12.3_opt_san/sql/sql_select.cc:5086:7
          #28 0x5804dd7a6fc0 in JOIN::exec() /test/12.3_opt_san/sql/sql_select.cc:4913:8
          #29 0x5804dd722226 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*
      , st_select_lex_unit*, st_select_lex*) /test/12.3_opt_san/sql/sql_select.cc:5439:21
          #30 0x5804dd720866 in handle_select(THD*, LEX*, select_result*, unsigned long long) /test/12.3_opt_san/sql/sql_select.cc:636:10
          #31 0x5804dd5f3c80 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/12.3_opt_san/sql/sql_parse.cc:6217:12
          #32 0x5804dd5d4080 in mysql_execute_command(THD*, bool) /test/12.3_opt_san/sql/sql_parse.cc:3967:12
          #33 0x5804dd5b6030 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/12.3_opt_san/sql/sql_parse.cc:7945:18
          #34 0x5804dd5ad375 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/12.3_opt_san/sql/sql_parse.cc:1896:7
          #35 0x5804dd5b82f6 in do_command(THD*, bool) /test/12.3_opt_san/sql/sql_parse.cc:1432:17
      

      Setup:

      Compiled with a recent version of Clang and LLVM. Ubuntu instructions for Clang/LLVM 18:
        # 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 lld-18
      Compiled with: "-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C{,XX}_FLAGS='-march=native -mtune=native'" and:
      

      SAN Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed
      CS  10.6   dbg  041125  e80998281aa1551f12a6b86cb3765796130d822d  LSAN|memory leak|plugin/ha_rocksdb.so|operator|__start_asan_globals
      CS  10.6   opt  041125  e80998281aa1551f12a6b86cb3765796130d822d  LSAN|memory leak|plugin/ha_rocksdb.so|operator|vtable|rocksdb::TransactionLogIteratorImpl::SeekToStartSequence
      CS  10.11  dbg  171025  aec79c5a7986ae9b3566cefdad429cc1dec55dea  LSAN|memory leak|storage/rocksdb/rocksdb/util/thread_local.cc|operator|rocksdb::ThreadLocalPtr::Instance|rocksdb::ThreadLocalPtr::InitSingletons|rocksdb::Env::Default
      CS  11.4   dbg  030226  ae5c8bfe764dc3a301826c15beaab49be5282263  LSAN|memory leak|plugin/ha_rocksdb.so|operator|rocksdb::kLegacyPlainTableMagicNumber|std::_Hashtable<rocksdb::ThreadStatusData
      CS  11.4   opt  030226  ae5c8bfe764dc3a301826c15beaab49be5282263  LSAN|memory leak|plugin/ha_rocksdb.so|operator|__GNU_EH_FRAME_HDR|rocksdb::BlockBasedTableBuilder::Rep::Rep
      CS  11.8   dbg  030226  9bfea48ce1214cc4470f6f6f8a4e30352cef84e7  LSAN|memory leak|storage/rocksdb/rocksdb/util/thread_local.cc|operator|rocksdb::ThreadLocalPtr::Instance|rocksdb::ThreadLocalPtr::InitSingletons|rocksdb::Env::Default
      CS  11.8   opt  030226  9bfea48ce1214cc4470f6f6f8a4e30352cef84e7  LSAN|memory leak|plugin/ha_rocksdb.so|operator|__GNU_EH_FRAME_HDR|rocksdb::BlockBasedTableBuilder::Rep::Rep
      CS  12.2   dbg  030226  de72d02bffe6639ef0b7911966a3f85e3eba052f  LSAN|memory leak|plugin/ha_rocksdb.so|operator|__PRETTY_FUNCTION__._ZNK7rocksdb8CacheKey7AsSliceEv|std::_Hashtable<rocksdb::ThreadStatusData
      CS  12.2   opt  030226  de72d02bffe6639ef0b7911966a3f85e3eba052f  LSAN|memory leak|plugin/ha_rocksdb.so|operator|__GNU_EH_FRAME_HDR|rocksdb::BlockBasedTableBuilder::Rep::Rep
      CS  12.3   dbg  030226  549628d9ccb822252b55210d922cef3d13eecd71  LSAN|memory leak|storage/rocksdb/rocksdb/util/thread_local.cc|operator|rocksdb::ThreadLocalPtr::Instance|rocksdb::ThreadLocalPtr::InitSingletons|rocksdb::Env::Default
      CS  12.3   opt  030226  549628d9ccb822252b55210d922cef3d13eecd71  LSAN|memory leak|storage/rocksdb/rocksdb/util/thread_local.cc|operator|rocksdb::ThreadLocalPtr::Instance|rocksdb::ThreadLocalPtr::InitSingletons|rocksdb::Env::Default
      ES  10.6   opt  150525  6111fbaf7bdcb6f1170f556ffd05d6e1a4159f62  LSAN|memory leak|plugin/ha_rocksdb.so|operator|__GNU_EH_FRAME_HDR|__gnu_cxx::__normal_iterator<rocksdb::FileMetaData
      ES  11.4   dbg  150525  9cd12544ebfd0d52d2158af66b5aced58121cf1f  LSAN|memory leak|plugin/ha_rocksdb.so|operator
      ES  11.4   opt  150525  9cd12544ebfd0d52d2158af66b5aced58121cf1f  LSAN|memory leak|plugin/ha_rocksdb.so|operator|__start_asan_globals
      

      Attachments

        Activity

          People

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