Skip to content

Fix a memory leak from AbortEventListener in MinimalEventLoopMgr

Fixes a leak from MinimalEventLoopMgr::initialize() due to an instance of a private AbortEventListener type not being properly deleted. I fixed it by instead of creating it on the heap, making it a data member instead.

Leak was found by the address sanitizer in !744 (merged)

=================================================================
==20045==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7fb4efab19e0 in operator new(unsigned long) ../../../../gcc-7.3.0/libsanitizer/asan/asan_new_delete.cc:80
    #1 0x7fb4eee07d79 in MinimalEventLoopMgr::initialize() ../GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp:94
    #2 0x7fb4e92d27d8 in EventLoopMgr::initialize() ../GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp:38
    #3 0x7fb4ef3809f7 in Service::sysInitialize_imp() ../GaudiKernel/src/Lib/Service.cpp:43
    #4 0x7fb4ef387d71 in void std::__invoke_impl<void, void (Service::*)(), Service*>(std::__invoke_memfun_deref, void (Service::*&&)(), Service*&&) /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/7.3.0/x86_64-centos7/include/c++/7.3.0/bits/invoke.h:73
    #5 0x7fb4ef387d71 in std::__invoke_result<void (Service::*)(), Service*>::type std::__invoke<void (Service::*)(), Service*>(void (Service::*&&)(), Service*&&) /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/7.3.0/x86_64-centos7/include/c++/7.3.0/bits/invoke.h:95
    #6 0x7fb4ef387d71 in void std::call_once<void (Service::*)(), Service*>(std::once_flag&, void (Service::*&&)(), Service*&&)::{lambda()#1}::operator()() const /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/7.3.0/x86_64-centos7/include/c++/7.3.0/mutex:672
    #7 0x7fb4ef387d71 in void std::call_once<void (Service::*)(), Service*>(std::once_flag&, void (Service::*&&)(), Service*&&)::{lambda()#2}::operator()() const /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/7.3.0/x86_64-centos7/include/c++/7.3.0/mutex:677
    #8 0x7fb4ef387d71 in void std::call_once<void (Service::*)(), Service*>(std::once_flag&, void (Service::*&&)(), Service*&&)::{lambda()#2}::_FUN() /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/7.3.0/x86_64-centos7/include/c++/7.3.0/mutex:677
    #9 0x7fb4ee0f1e6f in pthread_once (/lib64/libpthread.so.0+0xce6f)
    #10 0x7fb4e91c9fa2 in ServiceManager::initialize() ../GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp:280
    #11 0x7fb4e9225594 in ApplicationMgr::initialize() ../GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp:474
    #12 0x7fb4e91fc9f5 in ApplicationMgr::GoToState(Gaudi::StateMachine::State, bool) ../GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp:747
    #13 0x7fb4e91fcb8d in ApplicationMgr::GoToState(Gaudi::StateMachine::State, bool) ../GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp:762
    #14 0x7fb4e92050fc in ApplicationMgr::run() ../GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp:789
    #15 0x7fb4ef2b58f5 in GaudiMain ../GaudiKernel/src/Lib/GaudiMain.cpp:38
    #16 0x40091f in main ../Gaudi/src/main.cpp:4
    #17 0x7fb4ee72f444 in __libc_start_main (/lib64/libc.so.6+0x22444)

SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).

with this fix, the most basic gaudirun.py job now runs cleanly from the sanitizer (admittedly with some suppressions for stuff from externals).

pcmf ~ > gaudirun.py 
# setting LC_ALL to "C"
# Restarting with LD_PRELOAD='libasan.so'
ApplicationMgr    SUCCESS 
====================================================================================================================================
                                                   Welcome to ApplicationMgr (GaudiCoreSvc v30r3)
                                          running on pcmf on Tue Sep 11 14:12:18 2018
====================================================================================================================================
ApplicationMgr       INFO Application Manager Configured successfully
HistogramPersis...WARNING Histograms saving not required.
ApplicationMgr       INFO Application Manager Initialized successfully
ApplicationMgr       INFO Application Manager Started successfully
EventSelector        INFO End of event input reached.
EventLoopMgr         INFO No more events in event selection 
ApplicationMgr       INFO Application Manager Stopped successfully
EventLoopMgr         INFO Histograms converted successfully according to request.
ToolSvc              INFO Removing all tools created by ToolSvc
ApplicationMgr       INFO Application Manager Finalized successfully
ApplicationMgr       INFO Application Manager Terminated successfully
pcmf ~ > 

Merge request reports