Bug #21671 memory leak for mgmapi event listeners
Submitted: 16 Aug 2006 6:36 Modified: 2 Sep 2006 6:36
Reporter: Stewart Smith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: NDB API Severity:S3 (Non-critical)
Version:5.0.25 OS:
Assigned to: Stewart Smith CPU Architecture:Any

[16 Aug 2006 6:36] Stewart Smith
Description:
mgmapi users who listen to events have a memory leak every time they call ndb_mgm_listen_event (usually once, after they connect).

for long time listeners who have to reconnect to mgmd, this could add up....

==23291== 190 (20 direct, 170 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 22
==23291==    at 0x401C895: operator new(unsigned) (vg_replace_malloc.c:163)
==23291==    by 0x8075300: ParserImpl::run(Parser<ParserImpl::Dummy>::Context*, Properties const**, bool volatile*) const (Parser.cpp:178)
==23291==    by 0x806D09B: Parser<ParserDummy>::parse(Parser<ParserDummy>::Context&, ParserDummy&) (Parser.hpp:219)
==23291==    by 0x80671C4: ndb_mgm_call(ndb_mgm_handle*, ParserRow<ParserDummy> const*, char const*, Properties const*) (mgmapi.cpp:355)
==23291==    by 0x806AB79: ndb_mgm_listen_event_internal(ndb_mgm_handle*, int const*, int) (mgmapi.cpp:1419)
==23291==    by 0x806AC1F: ndb_mgm_listen_event (mgmapi.cpp:1434)
==23291==    by 0x805EB5D: event_thread_run(void*) (CommandInterpreter.cpp:467)
==23291==    by 0x806F70A: ndb_thread_wrapper (NdbThread.c:68)
==23291==    by 0x4042340: start_thread (in /lib/tls/i686/cmov/libpthread-2.3.6.so)
==23291==    by 0x429D4ED: clone (in /lib/tls/i686/cmov/libc-2.3.6.so)

How to repeat:
run ndb_mgm under valgrind, notice leak.

Suggested fix:
add 'delete reply' to ndb_mgm_listen_event_internal in mgmapi.cpp
[16 Aug 2006 6:40] 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/10523

ChangeSet@1.2249, 2006-08-16 14:39:27+08:00, stewart@willster.(none) +1 -0
  BUG#21671 memory leak for mgmapi event listeners
  
  fixes the following valgrind warning (when running ndb_mgm under valgrind,
  or, indeed any other mgmapi program listening to events):
  
  ==23291== 190 (20 direct, 170 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 22
  ==23291==    at 0x401C895: operator new(unsigned) (vg_replace_malloc.c:163)
  ==23291==    by 0x8075300: ParserImpl::run(Parser<ParserImpl::Dummy>::Context*, Properties const**, bool volatile*) const (Parser.cpp:178)
  ==23291==    by 0x806D09B: Parser<ParserDummy>::parse(Parser<ParserDummy>::Context&, ParserDummy&) (Parser.hpp:219)
  ==23291==    by 0x80671C4: ndb_mgm_call(ndb_mgm_handle*, ParserRow<ParserDummy> const*, char const*, Properties const*) (mgmapi.cpp:355)
  ==23291==    by 0x806AB79: ndb_mgm_listen_event_internal(ndb_mgm_handle*, int const*, int) (mgmapi.cpp:1419)
  ==23291==    by 0x806AC1F: ndb_mgm_listen_event (mgmapi.cpp:1434)
  ==23291==    by 0x805EB5D: event_thread_run(void*) (CommandInterpreter.cpp:467)
  ==23291==    by 0x806F70A: ndb_thread_wrapper (NdbThread.c:68)
  ==23291==    by 0x4042340: start_thread (in /lib/tls/i686/cmov/libpthread-2.3.6.so)
  ==23291==    by 0x429D4ED: clone (in /lib/tls/i686/cmov/libc-2.3.6.so)
[16 Aug 2006 7:39] Stewart Smith
pushed to 5.0-ndb and 5.1-ndb team trees.
[1 Sep 2006 8:11] Jonas Oreland
pushed to 5.1.12
[1 Sep 2006 19:34] Jonas Oreland
pushed to 5.0.25
[2 Sep 2006 6:36] Jon Stephens
Documented bugfix in 5.0.25 and 5.1.12 changelogs.