Bug #56382 valgrind leak warning from main.loaddata
Submitted: 30 Aug 2010 19:11 Modified: 13 Oct 2010 8:30
Reporter: Mark Callaghan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.50 OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any
Tags: Leak, loaddata, mtr, valgrind

[30 Aug 2010 19:11] Mark Callaghan
Description:
There is a leak warning from this in 5.1.50:
mtr --force --valgrind loaddata

12 bytes in 1 blocks are definitely lost in loss record 1 of 2
   at 0x4A05809: malloc (vg_replace_malloc.c:149)
   by 0x7B20B1: my_malloc (my_malloc.c:35)
   by 0x6D1EAC: READ_INFO::READ_INFO(int, unsigned, charset_info_st*, String&, String&, String&, String&, int, bool, bool) (sql_load.cc:1100)
   by 0x6D416D: mysql_load(THD*, sql_exchange*, TABLE_LIST*, List<Item>&, List<Item>&, List<Item>&, enum_duplicates, bool, bool) (sql_load.cc:374)
   by 0x5B7478: mysql_execute_command(THD*) (sql_parse.cc:3505)
   by 0x5B815E: mysql_parse(THD*, char*, unsigned, char const**) (sql_parse.cc:6032)
   by 0x5B9398: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1260)
   by 0x5BA36B: do_command(THD*) (sql_parse.cc:888)
   by 0x5A9332: handle_one_connection (sql_connect.cc:1136)
   by 0x328F8062F6: start_thread (in /lib64/libpthread-2.5.so)
   by 0x328ECD1E3C: clone (in /lib64/libc-2.5.so)

How to repeat:
Using:
gcc 4.1.2
valgrind 3.2.1
centos 5.2
64-bit x86

./configure --enable-thread-safe-client --with-plugins=partition,csv,blackhole,myisam,heap,innodb_plugin --without-plugin-innobase --with-fast-mutexes --with-extra-charsets=all --with-debug C_EXTRA_FLAGS="-fno-omit-frame-pointer -fno-strict-aliasing -DHAVE_purify -DNO_ALARM -DSIGNAL_WITH_VIO_CLOSE -Wall"

mysql-test-run.pl --force --valgrind main.loaddata
[30 Aug 2010 19:18] Sveta Smirnova
Thank you for the report.

Verified as described:

12 bytes in 1 blocks are definitely lost in loss record 1 of 3
   at 0x4A05809: malloc (vg_replace_malloc.c:149)
   by 0x7C3544: my_malloc (my_malloc.c:35)
   by 0x6DA4EB: READ_INFO::READ_INFO(int, unsigned, charset_info_st*, String&, String&, String&, String&, int, bool, bool) (sql_load.cc:1100)
   by 0x6DC655: mysql_load(THD*, sql_exchange*, TABLE_LIST*, List<Item>&, List<Item>&, List<Item>&, enum_duplicates, bool, bool) (sql_load.cc:374)
   by 0x5B8E4B: mysql_execute_command(THD*) (sql_parse.cc:3505)
   by 0x5BC1DA: mysql_parse(THD*, char*, unsigned, char const**) (sql_parse.cc:6032)
   by 0x5BC787: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1260)
   by 0x5BDCA4: do_command(THD*) (sql_parse.cc:888)
   by 0x5AD06F: handle_one_connection (sql_connect.cc:1136)
   by 0x3429E061B4: start_thread (in /lib64/libpthread-2.5.so)
   by 0x34292CD39C: clone (in /lib64/libc-2.5.so)

For compilation options see Bug #56380
[29 Sep 2010 16:14] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/119454

3519 Ramil Kalimullin	2010-09-29
      Fix for bug #56382: valgrind leak warning from main.loaddata
      
      Problem: a buffer allocated for LOAD DATA is not freed 
      under some circumstances (e.g. if an error occured).
      
      Fix: always free the buffer allocated.
     @ sql/sql_load.cc
        Fix for bug #56382: valgrind leak warning from main.loaddata
          - always free previously allocated READ_INFO::buffer 
        in its destructor.
[13 Oct 2010 8:30] Ramil Kalimullin
The issue was fixed by the patch for bug #56709: Memory leaks at running the 5.1 test suite. Closing.