Bug #78205 Event-API memory leak of gci_op(s)
Submitted: 25 Aug 2015 10:41 Modified: 27 Aug 2015 10:33
Reporter: Ole John Aske Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: NDB API Severity:S3 (Non-critical)
Version:7.4.7 OS:Any
Assigned to: CPU Architecture:Any

[25 Aug 2015 10:41] Ole John Aske
Description:
The NdbEvent-API has an internal list relating GCIs to event operations
which has event data for each GCI. (The gci_op / gci_ops list)

This structure is part of the EventBufData_list structure, which also 
manage a list of EventBufData to be delivered.

There are several placed where we empties the EventBufData_list by
freeing all EventBufData from it. *iff* the EventBufData_list 
is non-empty ::free_list() will be called to recycle the EventBufData
objects *and* their gci_op(s). (No leaks)

However, there can be remaining gci_op(s) in the EventBufData_list,
referring the last consumed EventBufData item, even if the list
of EventBufData items is empty. As ::free_list is not called for
empty list, these gci_op(s) leaked if not explicitly handled.

The code for handling these dangling gci_op(s) is missing from 

-  NdbEventBuffer::~NdbEventBuffer()
-  NdbEventBuffer::remove_op()
-  NdbEventBuffer::move_data()

Where it *is* handled, the implementation is just cluttered by first
freeing the EventDataList, then freeing gci_op(s) which was not handled 
by free_list() (Which actually *is* part of the list)

How to repeat:

Run Valgrind with some of the ATR test_event testcases.
.. or inspect code..
[27 Aug 2015 10:33] Jon Stephens
Documented fix in the NDB 7.4.8 changelog, as follows:

    Operations relating to global checkpoints in the NDB internal
    event data buffer could sometimes leak memory.

    See also BUG#76165.

Closed.