From d2542da27dc7d3ca6fa4366c70ed5ea8cfbc05f8 Mon Sep 17 00:00:00 2001 From: Tony Tye Date: Sun, 15 Oct 2023 00:15:20 +0000 Subject: [PATCH] Make AqlPacket::string more robust AqlPacket::string should check the packet type is in range of the array used to print its name. Change-Id: I33dabbd941d086929526d842c9dbc0bd7305acd5 [ROCm/ROCR-Runtime commit: 7955fb01ecf0a6ba3e2fb33ee234f8bd18bf7724] --- projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h index 7f304d76a7..e8ac0484e4 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/queue.h @@ -99,6 +99,11 @@ struct AqlPacket { "HSA_PACKET_TYPE_KERNEL_DISPATCH", "HSA_PACKET_TYPE_BARRIER_AND", "HSA_PACKET_TYPE_AGENT_DISPATCH", "HSA_PACKET_TYPE_BARRIER_OR"}; + if (t >= sizeof(type_names) / sizeof(const char*)) { + string << "type: UNKNOWN#" << t; + return string.str(); + } + string << "type: " << type_names[t] << "\nbarrier: " << ((dispatch.header >> HSA_PACKET_HEADER_BARRIER) & ((1 << HSA_PACKET_HEADER_WIDTH_BARRIER) - 1))