Fix failing valgrind tests due to EAGAIN error
Reference failing job: https://gitlab.cern.ch/cta/CTA/-/jobs/46623459
For some reason, valgrind has started picking up lots of EAGAIN
errors from the sem_trywait
function:
hgb: Nov 28 01:07:09 ==10126== Thread #5509's call to sem_trywait failed
hgb: Nov 28 01:07:09 ==10126== with error code 11 (EAGAIN: Try again)
hgb: Nov 28 01:07:09 ==10126== at 0x48546C9: sem_trywait_WRK (hg_intercepts.c:3224)
hgb: Nov 28 01:07:09 ==10126== by 0x4855647: sem_trywait@* (hg_intercepts.c:3240)
hgb: Nov 28 01:07:09 ==10126== by 0xD29E1EE: cta::threading::PosixSemaphore::tryAcquire() (in /usr/lib64/libctacommon.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0xCB8624D: cta::OStoreDB::delayIfNecessary(cta::log::LogContext&) (in /usr/lib64/libctascheduler.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0xCB8F922: cta::OStoreDB::queueArchive(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cta::common::dataStructures::ArchiveRequest const&, cta::common::dataStructures::ArchiveFileQueueCriteriaAndFileId const&, cta::log::LogContext&) (in /usr/lib64/libctascheduler.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x611BBB2: cta::SchedulerDatabaseDecorator::queueArchive(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cta::common::dataStructures::ArchiveRequest const&, cta::common::dataStructures::ArchiveFileQueueCriteriaAndFileId const&, cta::log::LogContext&) (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x61028A6: ??? (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x6116B5C: ??? (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x6115C0C: ??? (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x611512E: ??? (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x4AED00A: std::function<void ()>::operator()() const (in /usr/lib64/libctacommonunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614ED8F: void std::__invoke_impl<void, std::function<void ()>>(std::__invoke_other, std::function<void ()>&&) (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614ECD7: std::__invoke_result<std::function<void ()>>::type std::__invoke<std::function<void ()>>(std::function<void ()>&&) (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614EBE2: void std::thread::_Invoker<std::tuple<std::function<void ()> > >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614EA72: std::thread::_Invoker<std::tuple<std::function<void ()> > >::operator()() (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614E6CF: std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()> > >, void>::operator()() const (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614E1BB: std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter> std::__invoke_impl<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()> > >, void>&>(std::__invoke_other, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()> > >, void>&) (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614D39D: std::enable_if<is_invocable_r_v<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()> > >, void>&>, std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> >::type std::__invoke_r<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()> > >, void>&>(std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()> > >, void>&) (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x614C055: std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()> > >, void> >::_M_invoke(std::_Any_data const&) (in /usr/lib64/libctaschedulerunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x4AEC41D: std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const (in /usr/lib64/libctacommonunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x4AEB36B: std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) (in /usr/lib64/libctacommonunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x4AEE18C: void std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) (in /usr/lib64/libctacommonunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x4AED318: std::__invoke_result<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>::type std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) (in /usr/lib64/libctacommonunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x4AEC100: std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const (in /usr/lib64/libctacommonunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126== by 0x4AED36F: std::once_flag::_Prepare_execution::_Prepare_execution<std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}>(void (std::__future_base::_State_baseV2::*&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*))::{lambda()#1}::operator()() const (in /usr/lib64/libctacommonunittests.so.0.1.0)
hgb: Nov 28 01:07:09 ==10126==
hgb: Nov 28 01:07:09 {
hgb: Nov 28 01:07:09 <insert_a_suppression_name_here>
hgb: Nov 28 01:07:09 Helgrind:PthAPIerror
hgb: Nov 28 01:07:09 fun:sem_trywait_WRK
hgb: Nov 28 01:07:09 fun:sem_trywait@*
hgb: Nov 28 01:07:09 fun:_ZN3cta9threading14PosixSemaphore10tryAcquireEv
hgb: Nov 28 01:07:09 fun:_ZN3cta8OStoreDB16delayIfNecessaryERNS_3log10LogContextE
hgb: Nov 28 01:07:09 fun:_ZN3cta8OStoreDB12queueArchiveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_6common14dataStructures14ArchiveRequestERKNSA_33ArchiveFileQueueCriteriaAndFileIdERNS_3log10LogContextE
hgb: Nov 28 01:07:09 fun:_ZN3cta26SchedulerDatabaseDecorator12queueArchiveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_6common14dataStructures14ArchiveRequestERKNSA_33ArchiveFileQueueCriteriaAndFileIdERNS_3log10LogContextE
hgb: Nov 28 01:07:09 obj:/usr/lib64/libctaschedulerunittests.so.0.1.0
hgb: Nov 28 01:07:09 obj:/usr/lib64/libctaschedulerunittests.so.0.1.0
hgb: Nov 28 01:07:09 obj:/usr/lib64/libctaschedulerunittests.so.0.1.0
hgb: Nov 28 01:07:09 obj:/usr/lib64/libctaschedulerunittests.so.0.1.0
hgb: Nov 28 01:07:09 fun:_ZNKSt8functionIFvvEEclEv
hgb: Nov 28 01:07:09 fun:_ZSt13__invoke_implIvSt8functionIFvvEEJEET_St14__invoke_otherOT0_DpOT1_
hgb: Nov 28 01:07:09 fun:_ZSt8__invokeISt8functionIFvvEEJEENSt15__invoke_resultIT_JDpT0_EE4typeEOS4_DpOS5_
hgb: Nov 28 01:07:09 fun:_ZNSt6thread8_InvokerISt5tupleIJSt8functionIFvvEEEEE9_M_invokeIJLm0EEEEvSt12_Index_tupleIJXspT_EEE
hgb: Nov 28 01:07:09 fun:_ZNSt6thread8_InvokerISt5tupleIJSt8functionIFvvEEEEEclEv
hgb: Nov 28 01:07:09 fun:_ZNKSt13__future_base12_Task_setterISt10unique_ptrINS_7_ResultIvEENS_12_Result_base8_DeleterEENSt6thread8_InvokerISt5tupleIJSt8functionIFvvEEEEEEvEclEv
hgb: Nov 28 01:07:09 fun:_ZSt13__invoke_implISt10unique_ptrINSt13__future_base7_ResultIvEENS1_12_Result_base8_DeleterEERNS1_12_Task_setterIS6_NSt6thread8_InvokerISt5tupleIJSt8functionIFvvEEEEEEvEEJEET_St14__invoke_otherOT0_DpOT1_
hgb: Nov 28 01:07:09 fun:_ZSt10__invoke_rISt10unique_ptrINSt13__future_base12_Result_baseENS2_8_DeleterEERNS1_12_Task_setterIS0_INS1_7_ResultIvEES3_ENSt6thread8_InvokerISt5tupleIJSt8functionIFvvEEEEEEvEEJEENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESK_E4typeEOSL_DpOSM_
hgb: Nov 28 01:07:09 fun:_ZNSt17_Function_handlerIFSt10unique_ptrINSt13__future_base12_Result_baseENS2_8_DeleterEEvENS1_12_Task_setterIS0_INS1_7_ResultIvEES3_ENSt6thread8_InvokerISt5tupleIJSt8functionIFvvEEEEEEvEEE9_M_invokeERKSt9_Any_data
hgb: Nov 28 01:07:09 fun:_ZNKSt8functionIFSt10unique_ptrINSt13__future_base12_Result_baseENS2_8_DeleterEEvEEclEv
hgb: Nov 28 01:07:09 fun:_ZNSt13__future_base13_State_baseV29_M_do_setEPSt8functionIFSt10unique_ptrINS_12_Result_baseENS3_8_DeleterEEvEEPb
hgb: Nov 28 01:07:09 fun:_ZSt13__invoke_implIvMNSt13__future_base13_State_baseV2EFvPSt8functionIFSt10unique_ptrINS0_12_Result_baseENS4_8_DeleterEEvEEPbEPS1_JS9_SA_EET_St21__invoke_memfun_derefOT0_OT1_DpOT2_
hgb: Nov 28 01:07:09 fun:_ZSt8__invokeIMNSt13__future_base13_State_baseV2EFvPSt8functionIFSt10unique_ptrINS0_12_Result_baseENS4_8_DeleterEEvEEPbEJPS1_S9_SA_EENSt15__invoke_resultIT_JDpT0_EE4typeEOSF_DpOSG_
hgb: Nov 28 01:07:09 fun:_ZZSt9call_onceIMNSt13__future_base13_State_baseV2EFvPSt8functionIFSt10unique_ptrINS0_12_Result_baseENS4_8_DeleterEEvEEPbEJPS1_S9_SA_EEvRSt9once_flagOT_DpOT0_ENKUlvE_clEv
hgb: Nov 28 01:07:09 fun:_ZZNSt9once_flag18_Prepare_executionC4IZSt9call_onceIMNSt13__future_base13_State_baseV2EFvPSt8functionIFSt10unique_ptrINS3_12_Result_baseENS7_8_DeleterEEvEEPbEJPS4_SC_SD_EEvRS_OT_DpOT0_EUlvE_EERSI_ENKUlvE_clEv
hgb: Nov 28 01:07:09 }
hgs: Nov 28 01:07:09 [ OK ] OStoreDBPlusMockSchedulerTestVFS/SchedulerTestTriggerTapeStateChangeBehaviour.triggerTapeStateChangeValidScenarios/2 (21567 ms)
However, this is to be expected and this error is handled properly in the code:
bool PosixSemaphore::tryAcquire()
{
int ret = sem_trywait(&m_sem);
if (!ret) return true;
if (ret && EAGAIN == errno) return false;
cta::exception::Errnum::throwOnNonZero(ret,
"Error from sem_trywait in cta::threading::PosixSemaphore::tryAcquire()");
/* unreacheable, just for compiler happiness */
return false;
}
From what I can tell, there is no real error here and we should add the error to the suppression list.
Edited by Niels Alexander Buegel