[rocprofv3] Add check for Stream Stack Pointer before use (#465)

* Added null check for stream_stack before get_stream_id is called

* Rename function and add check for stream strack before pop

* Removed empty check for stream stack and adding error log for get_stream_id in stream.cpp

[ROCm/rocprofiler-sdk commit: 0904b6e34d]
This commit is contained in:
Trowbridge, Ian
2025-06-30 17:49:48 -05:00
zatwierdzone przez GitHub
rodzic 145944dc30
commit e2bdebcb57
4 zmienionych plików z 17 dodań i 2 usunięć
@@ -44,6 +44,12 @@ get_stream_stack()
}
} // namespace
bool
stream_stack_not_null()
{
return get_stream_stack() != nullptr;
}
void
push_stream_id(rocprofiler_stream_id_t id)
{
@@ -30,6 +30,9 @@ namespace tool
{
namespace stream
{
bool
stream_stack_not_null();
rocprofiler_stream_id_t
get_stream_id();
@@ -490,7 +490,8 @@ set_kernel_rename_and_stream_correlation_id(rocprofiler_thread_id_t thr_id,
tool::get_config().kernel_rename && thread_dispatch_rename != nullptr &&
!thread_dispatch_rename->empty();
const bool hip_stream_enabled = !tool::get_config().group_by_queue;
const bool hip_stream_enabled =
!tool::get_config().group_by_queue && rocprofiler::tool::stream::stream_stack_not_null();
if(!kernel_rename_service_enabled && !hip_stream_enabled) return 1;
@@ -109,7 +109,12 @@ auto
get_stream_id(hipStream_t stream)
{
return get_stream_map()->rlock(
[](const stream_map_t& _data, hipStream_t _stream) { return _data.at(_stream); }, stream);
[](const stream_map_t& _data, hipStream_t _stream) {
ROCP_ERROR_IF(_data.count(_stream) == 0)
<< "failed to retrieve stream ID in " << __FILE__;
return _data.at(_stream);
},
stream);
}
// Map rocprofiler_hip_stream_operation_t to respective name