Bug #56620 Memory leak near network_mysqld_auth_response_copy
Submitted: 7 Sep 2010 15:00 Modified: 8 Sep 2010 13:37
Reporter: Diego Medina Email Updates:
Status: Verified Impact on me:
Category:MySQL Proxy: Core Severity:S3 (Non-critical)
Version:0.8.1 OS:Any
Assigned to: Jan Kneschke CPU Architecture:Any

[7 Sep 2010 15:00] Diego Medina
I was running the mysql proxy under valgrind using the  proxydb.lua script (found here 
http://forge.mysql.com/tools/tool.php?id=199 )

and I noticed a memory leak:

==8577== 111,072 (23,808 direct, 87,264 indirect) bytes in 992 blocks are definitely lost in loss record 267 of 267
==8577==    at 0x150F7: calloc (vg_replace_malloc.c:415)
==8577==    by 0x41D82F: g_malloc0 (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libglib-
==8577==    by 0x40C60: network_mysqld_auth_response_new (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libmysql-proxy.0.dylib)
==8577==    by 0x41105: network_mysqld_auth_response_copy (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libmysql-proxy.0.dylib)
==8577==    by 0x4EC0E50: ???
==8577==    by 0x36C43: plugin_call (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libmysql-proxy.0.dylib)
==8577==    by 0x37E2F: network_mysqld_con_handle (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libmysql-proxy.0.dylib)
==8577==    by 0x5A069: event_base_loop (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libevent-
==8577==    by 0x5A268: event_base_dispatch (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libevent-
==8577==    by 0x2976B: chassis_event_thread_loop (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libmysql-chassis.0.dylib)
==8577==    by 0x28F33: chassis_mainloop (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/lib/libmysql-chassis.0.dylib)
==8577==    by 0x35EC: main_cmdline (in /Users/wizard/mysql-proxy-0.8.1-osx10.5-x86/libexec/mysql-proxy)

How to repeat:
1- Download the proxydb.lus script from
2- start the proxy like this:

(adjust values where needed)

$ MYSQL_PROXY_WRAPPER="valgrind --leak-check=full  "  G_SLICE="always-malloc" ./bin/mysql-proxy --proxy-backend-addresses= --plugins=proxy --log-level=debug --proxy-lua-script=/Users/wizard/proxydb.lua

3- on another terminal run:

for x in {1..10}; do echo "INSERT \"kay$x\" = \"This is a text string not too long, not too short $x$x\"  " |   ./sandboxes/msb_5_1_32/use -P4040 ; done ;

if you increase the number of loops, the memory leak would also increase.
[8 Sep 2010 13:37] Enterprise Tools JIRA Robot
Diego Medina writes: 
Smallest lua script I could come up with to reproduce the bug.

Use query SELECT 1 instead of the INSERT I posted before, as the tokenizer is not used any more.
[8 Sep 2010 13:37] Enterprise Tools JIRA Robot

Attachment: 10440_proxydb.lua (application/octet-stream, text), 5.98 KiB.

[8 Sep 2010 13:40] Enterprise Tools JIRA Robot
Diego Medina writes: 
this is the real lua file
[8 Sep 2010 13:40] Enterprise Tools JIRA Robot

Attachment: 10441_proxydb.lua (application/octet-stream, text), 5.97 KiB.