Undefined behaviour in Gaudi persistency / ROOT
When running with the UndefinedBehaviorSanitizer enabled, we see runtime error: reference binding to null pointer of type 'int'
in 12 Gaudi tests. All stack traces are very similar and one example is here (also copied below). The full list of affected tests is
GaudiExamples.bug_101513.with_error
GaudiExamples.bug_101513.without_error
GaudiExamples.conditional_output.read
GaudiExamples.evtcolsex.write
GaudiExamples.functional_algorithms.select_tracks
GaudiExamples.jira.gaudi_971
GaudiExamples.multi_input.read
GaudiExamples.return_codes.corrupted_input
GaudiExamples.root_io.coll.write
GaudiExamples.root_io.newinputwrite
GaudiExamples.root_io.read
GaudiHive.whiteboard.read
I don't know if we can fix this so I tried to suppress the issue but I can't manage by extending our suppression list with lines such as
null:TStreamerInfoActions::VectorLooper::ReadCollectionBasicType<int>
null:TStreamerInfoActions::VectorLooper::ReadCollectionBasicType
null:TStreamerInfoActions.cxx
GaudiHive.whiteboard.read
test
Stack trace from /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/10.1.0/x86_64-centos7/include/c++/10.1.0/bits/stl_iterator.h:969:17: runtime error: reference binding to null pointer of type 'int'
#0 0x7f962c26e917 in __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::operator*() const /cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/10.1.0/x86_64-centos7/include/c++/10.1.0/bits/stl_iterator.h:969
#1 0x7f9621190f50 in int TStreamerInfoActions::VectorLooper::ReadCollectionBasicType<int>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) /build/jenkins/workspace/lcg_release_pipeline/build/projects/ROOT-v6.24.00/src/ROOT/v6.24.00/io/io/src/TStreamerInfoActions.cxx:1900
#2 0x7f962107f3ca in TStreamerInfoActions::TConfiguredAction::operator()(TBuffer&, void*) const /build/jenkins/workspace/lcg_release_pipeline/build/projects/ROOT-v6.24.00/src/ROOT/v6.24.00/io/io/inc/TStreamerInfoActions.h:123
#3 0x7f962107d146 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) /build/jenkins/workspace/lcg_release_pipeline/build/projects/ROOT-v6.24.00/src/ROOT/v6.24.00/io/io/src/TBufferFile.cxx:3572
#4 0x7f960e867bf5 in TBranchElement::ReadLeavesMember(TBuffer&) /build/jenkins/workspace/lcg_release_pipeline/build/projects/ROOT-v6.24.00/src/ROOT/v6.24.00/tree/tree/src/TBranchElement.cxx:4495
#5 0x7f960e84e10b in TBranch::GetEntry(long long, int) /build/jenkins/workspace/lcg_release_pipeline/build/projects/ROOT-v6.24.00/src/ROOT/v6.24.00/tree/tree/src/TBranch.cxx:1693
#6 0x7f960e860d1c in TBranchElement::GetEntry(long long, int) /build/jenkins/workspace/lcg_release_pipeline/build/projects/ROOT-v6.24.00/src/ROOT/v6.24.00/tree/tree/src/TBranchElement.cxx:2709
#7 0x7f960e0add2e in Gaudi::RootTool::loadRefs(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >, unsigned long, Gaudi::RootObjectRefs&) ../RootCnv/src/RootTool.h:48
#8 0x7f960e0938ac in Gaudi::RootDataConnection::loadRefs(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >, unsigned long, Gaudi::RootObjectRefs&) ../RootCnv/src/RootDataConnection.cpp:559
#9 0x7f960e000225 in Gaudi::RootCnvSvc::i__fillObjRefs(IOpaqueAddress*, DataObject*) ../RootCnv/src/RootCnvSvc.cpp:485
#10 0x7f960e01176c in Gaudi::RootConverter::fillObjRefs(IOpaqueAddress*, DataObject*) ../RootCnv/include/RootCnv/RootConverter.h:80
#11 0x7f962bd310aa in ConversionSvc::makeCall(int, bool, bool, bool, IOpaqueAddress*&, DataObject*&) ../GaudiKernel/src/Lib/ConversionSvc.cpp:59
#12 0x7f962bd32983 in ConversionSvc::fillObjRefs(IOpaqueAddress*, DataObject*) ../GaudiKernel/src/Lib/ConversionSvc.cpp:105
#13 0x7f961e673499 in PersistencySvc::makeCall(int, IOpaqueAddress*&, DataObject*&) ../GaudiCommonSvc/src/PersistencySvc/PersistencySvc.cpp:84
#14 0x7f961e674c81 in PersistencySvc::fillObjRefs(IOpaqueAddress*, DataObject*) ../GaudiCommonSvc/src/PersistencySvc/PersistencySvc.cpp:121
#15 0x7f962be69283 in DataSvc::loadObject(IConversionSvc*, IRegistry*) ../GaudiKernel/src/Lib/DataSvc.cpp:512
#16 0x7f962be66940 in DataSvc::loadObject(IRegistry*) ../GaudiKernel/src/Lib/DataSvc.cpp:471
#17 0x7f962be6d35e in DataSvc::i_retrieveEntry(DataSvcHelpers::RegistryEntry*, std::basic_string_view<char, std::char_traits<char> >, DataSvcHelpers::RegistryEntry*&) ../GaudiKernel/src/Lib/DataSvc.cpp:612
#18 0x7f962be6d684 in DataSvc::retrieveObject(IRegistry*, std::basic_string_view<char, std::char_traits<char> >, DataObject*&) ../GaudiKernel/src/Lib/DataSvc.cpp:630
#19 0x7f96252d3afb in HiveWhiteBoard::retrieveObject(IRegistry*, std::basic_string_view<char, std::char_traits<char> >, DataObject*&)::{lambda(IDataProviderSvc&)#1}::operator()(IDataProviderSvc&) const ../GaudiHive/src/HiveWhiteBoard.cpp:302
#20 0x7f96252c6721 in operator() ../GaudiHive/src/HiveWhiteBoard.cpp:111
#21 0x7f96252c6860 in with_lock<(anonymous namespace)::fwd<HiveWhiteBoard::retrieveObject(IRegistry*, std::string_view, DataObject*&)::<lambda(IDataProviderSvc&)> >::<lambda((anonymous namespace)::Partition&)> > ../GaudiHive/src/HiveWhiteBoard.cpp:76
#22 0x7f96252c694c in fwd<HiveWhiteBoard::retrieveObject(IRegistry*, std::string_view, DataObject*&)::<lambda(IDataProviderSvc&)> > ../GaudiHive/src/HiveWhiteBoard.cpp:109
#23 0x7f96252d3b4f in HiveWhiteBoard::retrieveObject(IRegistry*, std::basic_string_view<char, std::char_traits<char> >, DataObject*&) ../GaudiHive/src/HiveWhiteBoard.cpp:302
#24 0x7f962bd7a444 in IDataProviderSvc::retrieveObject(std::basic_string_view<char, std::char_traits<char> >, DataObject*&) ../GaudiKernel/include/GaudiKernel/IDataProviderSvc.h:244
#25 0x7f962c785bff in SmartDataObjectPtr::retrieve(std::basic_string_view<char, std::char_traits<char> >, DataObject*&) ../GaudiKernel/src/Lib/SmartDataObjectPtr.cpp:47
#26 0x7f962c787248 in SmartDataObjectPtr::retrieveObject() ../GaudiKernel/src/Lib/SmartDataObjectPtr.cpp:79
#27 0x7f962c788f46 in SmartDataObjectPtr::retrieve(SmartDataObjectPtr*) ../GaudiKernel/include/GaudiKernel/SmartDataObjectPtr.h:99
#28 0x7f962c788e68 in SmartDataObjectPtr::accessData() ../GaudiKernel/include/GaudiKernel/SmartDataObjectPtr.h:96
#29 0x7f961e542af1 in SmartDataStorePtr<DataObject, SmartDataObjectPtr::ObjectLoader>::accessTypeSafeData() ../GaudiKernel/include/GaudiKernel/SmartDataStorePtr.h:122
#30 0x7f961e53f97e in SmartDataStorePtr<DataObject, SmartDataObjectPtr::ObjectLoader>::operator int() ../GaudiKernel/include/GaudiKernel/SmartDataStorePtr.h:115
#31 0x7f961e559ab5 in StoreSnifferAlg::execute() ../GaudiCommonSvc/src/DataSvc/StoreSnifferAlg.cpp:139
#32 0x7f96250fd997 in Gaudi::details::LegacyAlgorithmAdapter::execute(EventContext const&) const ../GaudiKernel/include/GaudiKernel/Algorithm.h:48
#33 0x7f962bb9fbbf in Gaudi::Algorithm::sysExecute(EventContext const&) ../GaudiKernel/src/Lib/Algorithm.cpp:366
#34 0x7f9625065fa2 in AlgTask::operator()() const ../GaudiHive/src/AlgTask.h:81
#35 0x7f96250d338b in tbb::internal::function_task<AlgTask>::execute() (/workspace/build/Gaudi/build/.plugins/libGaudiHive.so+0xf8738b)
#36 0x7f962686f914 in tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::process_bypass_loop(tbb::internal::context_guard_helper<false>&, tbb::task*, long) ../../src/tbb/custom_scheduler.h:474
#37 0x7f962686fc3a in tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::local_wait_for_all(tbb::task&, tbb::task*) ../../src/tbb/custom_scheduler.h:636
#38 0x7f96268698f6 in tbb::internal::arena::process(tbb::internal::generic_scheduler&) ../../src/tbb/arena.cpp:196
#39 0x7f962686808f in tbb::internal::market::process(rml::job&) ../../src/tbb/market.cpp:667
#40 0x7f96268647db in tbb::internal::rml::private_worker::run() ../../src/tbb/private_server.cpp:266
#41 0x7f9626864a18 in tbb::internal::rml::private_worker::thread_routine(void*) ../../src/tbb/private_server.cpp:219
#42 0x7f962fe2aea4 in start_thread (/lib64/libpthread.so.0+0x7ea4)
#43 0x7f962f44a8dc in __clone (/lib64/libc.so.6+0xfe8dc)