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

Call mutex_free() before freeing the mutex list

Details

    • 10.2.4-5

    Description

      The call to srv_latch_meta_destroy() was disabled, because it was dereferencing some freed memory, because some calls to mutex_free() were omitted.

      Do call the function on shutdown, and ensure that all mutex_create() is paired with mutex_free().

      Attachments

        Activity

          ok to push, consider also 10.1

          jplindst Jan Lindström (Inactive) added a comment - ok to push, consider also 10.1

          In 10.1 the code is different. sync_latch_meta_destroy() was introduced in the refactoring in MySQL 5.7.

          In 10.1, it looks like forgetting the mutex_free() will leave garbage in mutex_list. While this might not be detected by memory leak tools if the mutex_list is freed at shutdown, it still is a problem to keep a lot of garbage in that list, especially if those garbage pointers can sometimes be dereferenced. So, I will try backporting the fix to 10.1 as well.

          marko Marko Mäkelä added a comment - In 10.1 the code is different. sync_latch_meta_destroy() was introduced in the refactoring in MySQL 5.7. In 10.1, it looks like forgetting the mutex_free() will leave garbage in mutex_list. While this might not be detected by memory leak tools if the mutex_list is freed at shutdown, it still is a problem to keep a lot of garbage in that list, especially if those garbage pointers can sometimes be dereferenced. So, I will try backporting the fix to 10.1 as well.

          10.1 seems to be better in this respect. fil_space_crypt_cleanup() forgot to call mutex_free() for two mutexes and fil_crypt_threads_cleanup() for one, but those are called during shutdown anyway. innobase_shutdown_for_mysql() should possibly shut down the encryption threads even when innodb_read_only_mode. I am testing those changes.

          marko Marko Mäkelä added a comment - 10.1 seems to be better in this respect. fil_space_crypt_cleanup() forgot to call mutex_free() for two mutexes and fil_crypt_threads_cleanup() for one, but those are called during shutdown anyway. innobase_shutdown_for_mysql() should possibly shut down the encryption threads even when innodb_read_only_mode. I am testing those changes.

          I made a simpler patch for 10.1. Also there we were missing some mutex_free() before sync_close() which does the equivalent of sync_latch_meta_destroy().

          marko Marko Mäkelä added a comment - I made a simpler patch for 10.1. Also there we were missing some mutex_free() before sync_close() which does the equivalent of sync_latch_meta_destroy().

          ok to push also part 2.

          jplindst Jan Lindström (Inactive) added a comment - ok to push also part 2.

          People

            marko Marko Mäkelä
            marko Marko Mäkelä
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.