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

          marko Marko Mäkelä created issue -
          marko Marko Mäkelä made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]
          marko Marko Mäkelä made changes -
          Assignee Marko Mäkelä [ marko ] Jan Lindström [ jplindst ]
          Status In Progress [ 3 ] In Review [ 10002 ]

          ok to push, consider also 10.1

          jplindst Jan Lindström (Inactive) added a comment - ok to push, consider also 10.1
          jplindst Jan Lindström (Inactive) made changes -
          Assignee Jan Lindström [ jplindst ] Marko Mäkelä [ marko ]
          Status In Review [ 10002 ] Stalled [ 10000 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Sprint 10.2.4-5 [ 125 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Rank Ranked higher

          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.
          marko Marko Mäkelä made changes -
          Status Stalled [ 10000 ] In Progress [ 3 ]
          marko Marko Mäkelä made changes -
          Summary Call sync_latch_meta_destroy() at shutdown Call mutex_free() before freeing the mutex list

          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().
          marko Marko Mäkelä made changes -
          Assignee Marko Mäkelä [ marko ] Jan Lindström [ jplindst ]
          Status In Progress [ 3 ] In Review [ 10002 ]

          ok to push also part 2.

          jplindst Jan Lindström (Inactive) added a comment - ok to push also part 2.
          jplindst Jan Lindström (Inactive) made changes -
          Assignee Jan Lindström [ jplindst ] Marko Mäkelä [ marko ]
          Status In Review [ 10002 ] Stalled [ 10000 ]
          marko Marko Mäkelä made changes -
          issue.field.resolutiondate 2016-12-22 13:29:20.0 2016-12-22 13:29:20.18
          marko Marko Mäkelä made changes -
          Fix Version/s 10.1.21 [ 22113 ]
          Resolution Fixed [ 1 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 78861 ] MariaDB v4 [ 151423 ]

          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.