From 9c1bff0ae7d67a801c479b34df8f20db56f1f464 Mon Sep 17 00:00:00 2001 From: "Xie, Pengda" Date: Wed, 2 Jul 2025 11:59:14 -0700 Subject: [PATCH] SWDEV-540576 - Abort if user request a core dump (#653) * SWDEV-539414 - Return error status from runtime handler when HIP_SKIP_ABORT_ON_GPU_ERROR is false * SWDEV-539414 - default handler when GPU core file is generated * SWDEV-540576 - Abort if user request a core dump Change-Id: I9e2c640acf559880bd13641de9103e660ef822a3 --------- Co-authored-by: Assiouras, Ioannis Co-authored-by: agunashe --- rocclr/device/rocm/rocdevice.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index 710304598a..a0a7e8987c 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -56,13 +56,14 @@ #include #include #include +#include #ifdef ROCCLR_SUPPORT_NUMA_POLICY #include #include #endif // ROCCLR_SUPPORT_NUMA_POLICY #include #include -#endif // WITHOUT_HSA_BaCKEND +#endif // WITHOUT_HSA_BACKEND #define OPENCL_VERSION_STR XSTR(OPENCL_MAJOR) "." XSTR(OPENCL_MINOR) #define OPENCL_C_VERSION_STR XSTR(OPENCL_C_MAJOR) "." XSTR(OPENCL_C_MINOR) @@ -3446,12 +3447,14 @@ hsa_status_t Device::BackendErrorCallBackHandler(const hsa_amd_event_t* event, v break; } - if (HIP_SKIP_ABORT_ON_GPU_ERROR) { - gpu_error_ = gpu_error; - } else { - abort(); + // Execute the default handler if a GPU core file should be generated ... + struct rlimit rlimit; + if ((getrlimit(RLIMIT_CORE, &rlimit) == 0 && rlimit.rlim_cur != 0) || + !HIP_SKIP_ABORT_ON_GPU_ERROR) { + return HSA_STATUS_ERROR; } + gpu_error_ = gpu_error; return HSA_STATUS_SUCCESS; } @@ -3674,11 +3677,12 @@ void callbackQueue(hsa_status_t status, hsa_queue_t* queue, void* data) { errorMsg, status); } - if (HIP_SKIP_ABORT_ON_GPU_ERROR) { - amd::Device::gpu_error_ = ConvertHSAErrorIntoCLError(status); - } else { + struct rlimit rlimit; + if ((getrlimit(RLIMIT_CORE, &rlimit) == 0 && rlimit.rlim_cur != 0) || + !HIP_SKIP_ABORT_ON_GPU_ERROR) { abort(); } + amd::Device::gpu_error_ = ConvertHSAErrorIntoCLError(status); } }