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

ASAN: RockDB doesn't free ThreadLocalPtr::StaticMeta instance

    XMLWordPrintable

    Details

      Description

      ThreadLocalPtr::StaticMeta instance is a singleton.
      It is created once, immediately when ha_rocksdb.so is dlopened [1] and it doesn't seem to be freed anywhere. This triggers leak sanitizer in ASAN builds. It can perhaps exhaust memory if one installs/uninstalls (or runs show plugin soname) in a loop.

      [1] static variable rocksdb_db_options initialized by calling rdb_init_rocksdb_db_options() that calls DBOptions::DBOptions(), Env::Default(), ThreadLocalPtr::InitSingletons(), ThreadLocalPtr::Instance().

      Explicit delete seems to help:

      diff --git a/util/thread_local.cc b/util/thread_local.cc
      --- a/util/thread_local.cc
      +++ b/util/thread_local.cc
      @@ -335,6 +335,7 @@ ThreadLocalPtr::StaticMeta::StaticMeta()
             if (tls_) {
               OnThreadExit(tls_);
             }
      +      delete Instance();
           }
         } a;
       #endif  // !defined(OS_WIN)
      

        Attachments

          Activity

            People

            Assignee:
            psergei Sergei Petrunia
            Reporter:
            serg Sergei Golubchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: