Bug #53200 Allocated memory released twice if LogHandler fails to open
Submitted: 27 Apr 2010 13:51 Modified: 6 May 2010 8:43
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:7.0.15 OS:Any
Assigned to: Magnus Blåudd CPU Architecture:Any

[27 Apr 2010 13:51] Magnus Blåudd
Description:
Double free of newly created LogHandler(coudl be SysLogHandler, FileLogHandler, ConsoleLogHandler or EventLogHandler) occurs if the LogHandler can't be opened since the pointer passed to Logger::addHandler is freed in both function and the function caller.

How to repeat:
This occurred when creating an  EventLogHandler from a process that didn't  have enough privileges to create the necessary registry keys needed to write to Windows event log and thus 'open' failed.

But this can happen also for the other supportded LogHandler types.

Suggested fix:
Free the log handler only once.
[27 Apr 2010 15:51] 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/106695
[27 Apr 2010 17:56] Bugs System
Pushed into 5.1.44-ndb-7.0.15 (revid:magnus.blaudd@sun.com-20100427162430-kd351iqnijdcxxan) (version source revid:magnus.blaudd@sun.com-20100427162430-kd351iqnijdcxxan) (merge vers: 5.1.44-ndb-7.0.15) (pib:16)
[27 Apr 2010 18:26] 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/106722

3509 Martin Skold	2010-04-27 [merge]
      Merge
      removed:
        storage/ndb/src/common/logger/listtest/
        storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.cpp
        storage/ndb/src/common/logger/listtest/LogHandlerListUnitTest.hpp
        storage/ndb/src/common/logger/listtest/Makefile
        storage/ndb/src/common/logger/loggertest/
        storage/ndb/src/common/logger/loggertest/LoggerUnitTest.cpp
        storage/ndb/src/common/logger/loggertest/LoggerUnitTest.hpp
        storage/ndb/src/common/logger/loggertest/Makefile
      modified:
        storage/ndb/include/debugger/EventLogger.hpp
        storage/ndb/include/logger/FileLogHandler.hpp
        storage/ndb/include/logger/Logger.hpp
        storage/ndb/src/common/debugger/EventLogger.cpp
        storage/ndb/src/common/logger/EventLogHandler.cpp
        storage/ndb/src/common/logger/LogHandlerList.cpp
        storage/ndb/src/common/logger/LogHandlerList.hpp
        storage/ndb/src/common/logger/Logger.cpp
        storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
        storage/ndb/src/mgmsrv/MgmtSrvr.cpp
[5 May 2010 14:36] Magnus Blåudd
Pushed to 7.0.15 and 7.1.4
[6 May 2010 8:43] Jon Stephens
Documented bugfix in the NDB-7.0.15 and 7.1.4 changelogs as follows:

      When an NDB log handler failed, the memory allocated to it was 
      freed twice.

Closed.