Fix for crash Error: HsaRsrcFactory::SignalWait: signal_value(1), ret_value(-1)

Context::GetData() would crash when it tries to wait on the completion signal of the stop packet. The expected signal value after waiting in HsaRsrcFactory::SignalWait() is supposed to be 0 but sometimes it comes up as -1. The signal being checked has already decremented before. Profile::Finalize() was assigning the same completion signal to the read and stop packet. So those two packets have been assigned different completion signals. This fix only affects standalone profiling mode.

Change-Id: I4b16825019e58d95d70188a72b2cc5871e09dd81


[ROCm/rocprofiler commit: 34606db8c3]
This commit is contained in:
Saurabh Verma
2024-05-13 17:24:22 -05:00
parent a36338a7a6
commit 150869be6a
3 changed files with 35 additions and 3 deletions
@@ -49,6 +49,20 @@ POSSIBILITY OF SUCH DAMAGE.
namespace rocprofiler {
namespace util {
bool check_standalone_mode() {
static bool is_standalone_mode = [] {
// Checking environment variable to see if interception is enabled.
// value of zero indicates standalone mode
const char* intercept_env = getenv("ROCP_HSA_INTERCEPT");
int intercept_env_value = 0;
if (intercept_env != NULL) {
intercept_env_value = atoi(intercept_env);
}
return intercept_env_value == 0;
}();
return is_standalone_mode;
}
// Demangle C++ symbol name
static const char* cpp_demangle(const char* symname) {
size_t size = 0;
@@ -392,8 +406,8 @@ const AgentInfo* HsaRsrcFactory::AddAgentInfo(const hsa_agent_t agent) {
agent_info->vgpr_block_size = 4;
if (hsa_api_.hsa_agent_get_info(agent, static_cast<hsa_agent_info_t>(HSA_AMD_AGENT_INFO_NUM_XCC),
&agent_info->xcc_num) != HSA_STATUS_SUCCESS) {
agent_info->xcc_num = 1;
&agent_info->xcc_num) != HSA_STATUS_SUCCESS) {
agent_info->xcc_num = 1;
};
// Set GPU index
@@ -73,6 +73,7 @@ namespace util {
static const size_t MEM_PAGE_BYTES = 0x1000;
static const size_t MEM_PAGE_MASK = MEM_PAGE_BYTES - 1;
typedef decltype(hsa_agent_t::handle) hsa_agent_handle_t;
bool check_standalone_mode();
struct hsa_pfn_t {
decltype(::hsa_init)* hsa_init;