Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
2.1
-
None
-
None
Description
When a mysql connection is created and is set to not blocking, mysql_close() doesn't free the memory associate with async causing a severe memory leak.
Depending from the the speed of your CPU and your available memory, the follow code can eat all available memory in just few seconds:
#include <mysql.h>
|
#include <stdio.h>
|
int main() {
|
while(1) {
|
MYSQL *mysql=mysql_init(NULL);
|
mysql_options(mysql, MYSQL_OPT_NONBLOCK, 0); // this line triggers the bug
|
mysql_close(mysql);
|
}
|
return 0;
|
}
|
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Fix Version/s | 3.0.0 [ 18700 ] | |
Fix Version/s | 2.2.0 [ 19500 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | MariaDB connectors [ 69912 ] | MariaDB v4 [ 160991 ] |
Quick patch in mysql_close_options() :
2194a2195,2202
> {
> struct mysql_async_context *ctxt;
> if ((ctxt = mysql->options.extension->async_context) != 0)
> {
> my_context_destroy(&ctxt->async_context);
> my_free((gptr)ctxt, MYF(0));
> }
> }