summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-08-21 10:37:52 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-08-21 10:37:52 +0300
commit688fb6301c190a16987c91f5e14bdcc85d9b0ffa (patch)
tree5e3362d4d2dfbeae8a4495d262ac881bf2ad7751
parent2643249da51dadfe2d9b5cd1db194a89eace0e92 (diff)
downloadmariadb-git-688fb6301c190a16987c91f5e14bdcc85d9b0ffa.tar.gz
MDEV-23526 InnoDB leaks memory for some static objects
A leak of the contents of fil_system.ssd that was introduced in commit 10dd290b4b8b8b235c8cf42e100f0a4415629e79 (MDEV-17380) was caught by implementing SAFEMALLOC instrumentation of operator new. I did not try to find out how to make AddressSanitizer or Valgrind detect it. fil_system_t::close(): Clear fil_system.ssd. The leak was identified and a fix suggested by Michael Widenius and Vicențiu Ciorbaru.
-rw-r--r--storage/innobase/fil/fil0fil.cc36
1 files changed, 21 insertions, 15 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index d47e9f3f5bf..5f263611cc1 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -1610,22 +1610,28 @@ void fil_system_t::create(ulint hash_size)
void fil_system_t::close()
{
- ut_ad(this == &fil_system);
- ut_a(!UT_LIST_GET_LEN(LRU));
- ut_a(unflushed_spaces.empty());
- ut_a(!UT_LIST_GET_LEN(space_list));
- ut_ad(!sys_space);
- ut_ad(!temp_space);
-
- if (is_initialised()) {
- m_initialised = false;
- hash_table_free(spaces);
- spaces = NULL;
- mutex_free(&mutex);
- fil_space_crypt_cleanup();
- }
+ ut_ad(this == &fil_system);
+ ut_a(!UT_LIST_GET_LEN(LRU));
+ ut_a(unflushed_spaces.empty());
+ ut_a(!UT_LIST_GET_LEN(space_list));
+ ut_ad(!sys_space);
+ ut_ad(!temp_space);
+
+ if (is_initialised())
+ {
+ m_initialised= false;
+ hash_table_free(spaces);
+ spaces = nullptr;
+ mutex_free(&mutex);
+ fil_space_crypt_cleanup();
+ }
+
+ ut_ad(!spaces);
- ut_ad(!spaces);
+#ifdef UNIV_LINUX
+ ssd.clear();
+ ssd.shrink_to_fit();
+#endif /* UNIV_LINUX */
}
/*******************************************************************//**