Bug #38468 Memory leak detected when using mysqlbinlog utility.
Submitted: 30 Jul 2008 18:03 Modified: 17 Jun 2010 22:54
Reporter: Hema Sridharan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:mysql-6.0-backup,mysql-6.0,5.4 OS:Linux (64 bit)
Assigned to: Zhenxing He CPU Architecture:Any

[30 Jul 2008 18:03] Hema Sridharan
Description:
Memory leak is detected when using mysqlbinlog utility in test framework.
This is observed only in 64 bit and not 32bit linux.

How to repeat:
--source include/have_binlog_format_mixed_or_statement.inc
--source include/have_log_bin.inc
CREATE DATABASE IF NOT EXISTS backup;
USE backup;
CREATE TABLE t1 SELECT 1;
DROP TABLE t1;
FLUSH LOGS;
--exec $MYSQL_BINLOG --stop-position=295 $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
SELECT * FROM t1;

Result 
======

Warning: Not freed memory segments: 2
Warning: Memory that was not free'ed (548 bytes):
           104 bytes at 0x00d8fbbb8, allocated at line 1019 in 'log_event.cc'
           444 bytes at 0x00d8d7078, allocated at line  201 in 'my_alloc.c'
mysqltest: The specified result file does not exist: '/export/home/tmp/hema/main/mysql-6.0/mysql-test/r/backup_leak.result'

The result from queries just before the failure was:
CREATE DATABASE IF NOT EXISTS backup;
USE backup;
CREATE TABLE t1 SELECT 1;
DROP TABLE t1;
FLUSH LOGS;
SELECT * FROM t1;
1
1
[14 Apr 2009 9:57] 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/71985

2841 He Zhenxing	2009-04-14
      BUG#38468 Memory leak detected when using mysqlbinlog utility
      
      There were two memory leaks in mysqlbinlog command, one was already
      fixed by previous patches, another one was that defaults_argv was
      set to the value of argv after parse_args, in which called
      handle_options after calling load_defaults and changed the value
      of argv, and caused the memory allocated for defaults arguments
      not freed.
      
      Fixed the problem by setting defaults_argv right after calling
      load_defaults.
     @ client/mysqlbinlog.cc
        change defaults_argv to global, and set its value right after load_defaults
[15 Apr 2009 3:35] 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/72097

2841 He Zhenxing	2009-04-15
      BUG#38468 Memory leak detected when using mysqlbinlog utility
      
      There were two memory leaks in mysqlbinlog command, one was already
      fixed by previous patches, another one was that defaults_argv was
      set to the value of argv after parse_args, in which called
      handle_options after calling load_defaults and changed the value
      of argv, and caused the memory allocated for defaults arguments
      not freed.
      
      Fixed the problem by setting defaults_argv right after calling
      load_defaults.
     @ client/mysqlbinlog.cc
        Move load_defaults out of parse_args to main, set defaults_argv right after load_defaults
[15 Apr 2009 6:53] Rafal Somla
Good to push.
[20 Apr 2009 9:22] 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/72489

2841 He Zhenxing	2009-04-20
      BUG#38468 Memory leak detected when using mysqlbinlog utility
      
      There were two memory leaks in mysqlbinlog command, one was already
      fixed by previous patches, another one was that defaults_argv was
      set to the value of argv after parse_args, in which called
      handle_options after calling load_defaults and changed the value
      of argv, and caused the memory allocated for defaults arguments
      not freed.
      
      Fixed the problem by setting defaults_argv right after calling
      load_defaults.
     @ client/mysqlbinlog.cc
        Move load_defaults out of parse_args to main, set defaults_argv right after load_defaults
[21 Apr 2009 9:29] 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/72553

2845 He Zhenxing	2009-04-21
      BUG#38468 Memory leak detected when using mysqlbinlog utility
      
      There were two memory leaks in mysqlbinlog command, one was already
      fixed by previous patches, another one was that defaults_argv was
      set to the value of argv after parse_args, in which called
      handle_options after calling load_defaults and changed the value
      of argv, and caused the memory allocated for defaults arguments
      not freed.
      
      Fixed the problem by setting defaults_argv right after calling
      load_defaults.
     @ client/mysqlbinlog.cc
        Move load_defaults out of parse_args to main, set defaults_argv right after load_defaults
[21 Apr 2009 12:22] Zhenxing He
pushed to 6.0-rpl
[13 May 2009 3:31] Bugs System
Pushed into 6.0.12-alpha (revid:alik@sun.com-20090513032549-rxa73jbxd1qv09xc) (version source revid:aelkin@mysql.com-20090429125820-vu261kl1z4z5f0iv) (merge vers: 6.0.12-alpha) (pib:6)
[13 May 2009 16:32] Paul DuBois
Noted in 6.0.12 changelog.

mysqlbinlog had a memory leak in its option-processing code.

Setting report to NDI ending push into 5.4.x.
[14 Aug 2009 5:21] Zhenxing He
patch already in azalea, set status to Documenting
[15 Aug 2009 2:32] Paul DuBois
Noted in 5.4.4 changelog.
[2 Oct 2009 8:18] 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/85477

3118 He Zhenxing	2009-10-02
      Backport BUG#38468 Memory leak detected when using mysqlbinlog utility
      
      There were two memory leaks in mysqlbinlog command, one was already
      fixed by previous patches, another one was that defaults_argv was
      set to the value of argv after parse_args, in which called
      handle_options after calling load_defaults and changed the value
      of argv, and caused the memory allocated for defaults arguments
      not freed.
      
      Fixed the problem by setting defaults_argv right after calling
      load_defaults.
[27 Oct 2009 9:50] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091027094604-9p7kplu1vd2cvcju) (version source revid:zhenxing.he@sun.com-20091026140226-uhnqejkyqx1aeilc) (merge vers: 6.0.14-alpha) (pib:13)
[27 Oct 2009 18:19] Paul DuBois
Already fixed in 6.0.12.
[12 Nov 2009 8:16] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091110093229-0bh5hix780cyeicl) (version source revid:alik@sun.com-20091027095744-rf45u3x3q5d1f5y0) (merge vers: 5.5.0-beta) (pib:13)
[12 Nov 2009 18:45] Paul DuBois
Noted in 5.5.0 changelog.
[26 Mar 2010 8:20] Bugs System
Pushed into 5.5.4-m3 (revid:alik@sun.com-20100326080914-2pz8ns984e0spu03) (version source revid:alexey.kopytov@sun.com-20100312095153-t4rtoqc7p96lmxvh) (merge vers: 5.5.3-m2) (pib:16)
[26 Mar 2010 8:25] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100326081116-m3v4l34yhr43mtsv) (version source revid:alik@sun.com-20100325072612-4sds00ix8ajo1e84) (pib:16)
[26 Mar 2010 8:29] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100326081944-qja07qklw1p2w7jb) (version source revid:alik@sun.com-20100325073410-4t4i9gu2u1pge7xb) (merge vers: 6.0.14-alpha) (pib:16)
[6 Apr 2010 7:56] Bugs System
Pushed into 5.1.46 (revid:sergey.glukhov@sun.com-20100405111026-7kz1p8qlzglqgfmu) (version source revid:luis.soares@sun.com-20100308235519-dyijxl1xhf3ln7mv) (merge vers: 5.1.45) (pib:16)
[6 Apr 2010 11:50] Jon Stephens
Also documented bugfix in the 5.1.46 changelog. Closed.
[17 Jun 2010 11:53] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:31] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:martin.skold@mysql.com-20100609211156-tsac5qhw951miwtt) (merge vers: 5.1.46-ndb-6.2.19) (pib:16)
[17 Jun 2010 13:19] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)