Skip to content

Commit f0bd912

Browse files
authored
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 <[email protected]>
1 parent 129580b commit f0bd912

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

source/lib/omnitrace/library/runtime.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,16 @@ create_cpu_cid_entry(int64_t _tid)
151151
auto_lock_t _p_lk{ _p_mtx, std::defer_lock };
152152
if(!_p_lk.owns_lock()) _p_lk.lock();
153153

154-
auto&& _cid = get_cpu_cid()++;
155-
auto&& _parent_cid = get_cpu_cid_stack(_p_idx)->back();
154+
auto&& _cid = get_cpu_cid()++;
155+
// auto&& _parent_cid = get_cpu_cid_stack(_p_idx)->back();
156+
uint64_t _parent_cid = 0;
157+
auto& cid_stack = get_cpu_cid_stack(_p_idx);
158+
159+
if(!cid_stack->empty())
160+
{
161+
_parent_cid = cid_stack->back();
162+
}
163+
156164
uint32_t&& _depth = get_cpu_cid_stack(_p_idx)->size() - ((_p_idx == _tid) ? 1 : 0);
157165

158166
get_cpu_cid_parents(_tid)->emplace(_cid, std::make_tuple(_parent_cid, _depth));

0 commit comments

Comments
 (0)