From f0bd9126a5456eb9e511d13261af262d17d9b61b Mon Sep 17 00:00:00 2001 From: ajanicijamd Date: Fri, 7 Jun 2024 15:23:18 -0400 Subject: [PATCH] Patch for omnitrace-sample crash with HIP API. (#344) Fix HIP-API CTest failure Check if stack is empty before popping data off of it. Signed-off-by: Aleksandar Janicijevic --- source/lib/omnitrace/library/runtime.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/lib/omnitrace/library/runtime.cpp b/source/lib/omnitrace/library/runtime.cpp index d3ae7a70a..66cb12eb3 100644 --- a/source/lib/omnitrace/library/runtime.cpp +++ b/source/lib/omnitrace/library/runtime.cpp @@ -151,8 +151,16 @@ create_cpu_cid_entry(int64_t _tid) auto_lock_t _p_lk{ _p_mtx, std::defer_lock }; if(!_p_lk.owns_lock()) _p_lk.lock(); - auto&& _cid = get_cpu_cid()++; - auto&& _parent_cid = get_cpu_cid_stack(_p_idx)->back(); + auto&& _cid = get_cpu_cid()++; + // auto&& _parent_cid = get_cpu_cid_stack(_p_idx)->back(); + uint64_t _parent_cid = 0; + auto& cid_stack = get_cpu_cid_stack(_p_idx); + + if(!cid_stack->empty()) + { + _parent_cid = cid_stack->back(); + } + uint32_t&& _depth = get_cpu_cid_stack(_p_idx)->size() - ((_p_idx == _tid) ? 1 : 0); get_cpu_cid_parents(_tid)->emplace(_cid, std::make_tuple(_parent_cid, _depth));