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

Memory leak in sql_prepare.cc: Prepared_statement::execute_server_runnable()

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.0
    • Fix Version/s: 10.0
    • Component/s: None
    • Labels:
      None

      Description

      Memory leak at sql_prepare.cc:
      Prepared_statement::execute_server_runnable().

      The memory was leaked because thd->lex was restored at the end of the function.

      The fix is that the lex allocated in this function should delete its explain before the function returns, i.e. Lex's "explain" query statement has to be deleted before restoring saved variables to thd to avoid memory leak.

      Code diff:

        error= server_runnable->execute_server_code(thd);
      
      +  // Lex's "explain" query statement has to be deleted before
      +  // restoring saved variables to thd to avoid memory leak.
      +  delete_explain_query(lex);
        thd->cleanup_after_query();
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            Interesting. How did you manage to trigger that? As far as I can see this is dead code, it is never executed.

            Show
            serg Sergei Golubchik added a comment - Interesting. How did you manage to trigger that? As far as I can see this is dead code, it is never executed.
            Hide
            minli zhu Minli Zhu added a comment -

            It is triggered by calling Ed_connection::execute_direct() from our own code.

            Show
            minli zhu Minli Zhu added a comment - It is triggered by calling Ed_connection::execute_direct() from our own code.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                minli zhu Minli Zhu
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: