AIDASoft / podio

PODIO
GNU General Public License v3.0
24 stars 59 forks source link

Fix leak in the buffer vectorMembers when reading SIO frames #589

Closed jmcarcell closed 4 months ago

jmcarcell commented 4 months ago

BEGINRELEASENOTES

ENDRELEASENOTES

The leak happens because at the time of this emplace_back, there is already an element in the vector with the string corresponding to that vector member. Then, the indexing will only find the first instance and this second one is leaked, so the fix is to check before and only if it isn't there add it. I think this is added for the first time in https://github.com/AIDASoft/podio/blob/master/python/templates/SIOBlock.cc.jinja2#L92

This helps with the read_frame_sio test. Before:

SUMMARY: AddressSanitizer: 12714 byte(s) leaked in 482 allocation(s).

After:

SUMMARY: AddressSanitizer: 11786 byte(s) leaked in 445 allocation(s).

I'm not sure if we need a test since read_frame_sio would be the one, once it doesn't have any leaks. Otherwise to reproduce we just have to read a frame with a collection with a vector member.

I did this one because after this I have a version of https://github.com/AIDASoft/podio/pull/583 without leaks.