[MDEV-7095] Memory leak in sql_prepare.cc: Prepared_statement::execute_server_runnable() Created: 2014-11-12  Updated: 2022-11-09  Resolved: 2022-11-09

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.0
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Minli Zhu Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
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();



 Comments   
Comment by Sergei Golubchik [ 2014-11-14 ]

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

Comment by Minli Zhu [ 2014-11-14 ]

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

Comment by Sergei Golubchik [ 2022-11-09 ]

It was dead code. Now we have a service API for executing SQL statements from inside the server, please, use that

Generated at Thu Feb 08 07:16:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.