diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-21 11:54:16 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-21 11:54:16 +0300 |
commit | d98ccbe1e1a8190d295fe91942ba739a12d9e245 (patch) | |
tree | c500d0b5be023530260ffaf1f85c51580b766403 /storage/innobase/log | |
parent | f2739e2a96d6e73922577cd2dc8611aab81e6024 (diff) | |
download | mariadb-git-d98ccbe1e1a8190d295fe91942ba739a12d9e245.tar.gz |
MDEV-23526 InnoDB leaks memory for some static objects
Leaks of some members of statically allocated objects are
not being reported by AddressSanitizer or Valgrind, but they
can be reported by implementing SAFEMALLOC instrumentation.
These leaks were identified and original fixes provided
by Michael Widenius and Vicențiu Ciorbaru.
Diffstat (limited to 'storage/innobase/log')
-rw-r--r-- | storage/innobase/log/log0log.cc | 11 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 76 |
2 files changed, 43 insertions, 44 deletions
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 62de68790ed..3e2a64a3902 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -823,11 +823,12 @@ void log_t::file::flush() void log_t::file::close_file() { - if (!fd.is_opened()) - return; - - if (const dberr_t err= fd.close()) - ib::fatal() << "close(" << fd.get_path() << ") returned " << err; + if (fd.is_opened()) + { + if (const dberr_t err= fd.close()) + ib::fatal() << "close(" << fd.get_path() << ") returned " << err; + } + fd.free(); // Free path } /** Initialize the redo log. */ diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 791e13e014e..46830db1323 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -907,37 +907,34 @@ fil_name_process(char* name, ulint len, ulint space_id, bool deleted) /** Clean up after recv_sys_t::create() */ void recv_sys_t::close() { - ut_ad(this == &recv_sys); - ut_ad(!recv_writer_thread_active); - - if (is_initialised()) { - dblwr.pages.clear(); - ut_d(mutex_enter(&mutex)); - clear(); - ut_d(mutex_exit(&mutex)); + ut_ad(this == &recv_sys); + ut_ad(!recv_writer_thread_active); - if (flush_start) { - os_event_destroy(flush_start); - } + if (is_initialised()) + { + dblwr.pages.clear(); + ut_d(mutex_enter(&mutex)); + clear(); + ut_d(mutex_exit(&mutex)); - if (flush_end) { - os_event_destroy(flush_end); - } + os_event_destroy(flush_start); + os_event_destroy(flush_end); - if (buf) { - ut_free_dodump(buf, RECV_PARSING_BUF_SIZE); - buf = NULL; - } + if (buf) + { + ut_free_dodump(buf, RECV_PARSING_BUF_SIZE); + buf= nullptr; + } - last_stored_lsn = 0; - mutex_free(&writer_mutex); - mutex_free(&mutex); - } + last_stored_lsn= 0; + mutex_free(&writer_mutex); + mutex_free(&mutex); + } - recv_spaces.clear(); - mlog_init.clear(); + recv_spaces.clear(); + mlog_init.clear(); - files.clear(); + close_files(); } /******************************************************************//** @@ -1060,24 +1057,25 @@ inline void recv_sys_t::clear() /** Free most recovery data structures. */ void recv_sys_t::debug_free() { - ut_ad(this == &recv_sys); - ut_ad(is_initialised()); - mutex_enter(&mutex); + ut_ad(this == &recv_sys); + ut_ad(is_initialised()); + mutex_enter(&mutex); - pages.clear(); - ut_free_dodump(buf, RECV_PARSING_BUF_SIZE); + pages.clear(); + ut_free_dodump(buf, RECV_PARSING_BUF_SIZE); - buf = NULL; + buf= nullptr; - /* wake page cleaner up to progress */ - if (!srv_read_only_mode) { - ut_ad(!recv_recovery_is_on()); - ut_ad(!recv_writer_thread_active); - os_event_reset(buf_flush_event); - os_event_set(flush_start); - } + /* wake page cleaner up to progress */ + if (!srv_read_only_mode) + { + ut_ad(!recv_recovery_is_on()); + ut_ad(!recv_writer_thread_active); + os_event_reset(buf_flush_event); + os_event_set(flush_start); + } - mutex_exit(&mutex); + mutex_exit(&mutex); } inline void *recv_sys_t::alloc(size_t len) |