From bacb2f2dbe4c29fa1c9ac7d2cefe863fa52225e1 Mon Sep 17 00:00:00 2001 From: Rahul Manocha Date: Tue, 6 Jan 2026 21:27:50 +0000 Subject: [PATCH 1/2] clr: Fix segfault when running kernel compiled for different arch --- projects/clr/hipamd/src/hip_module.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/clr/hipamd/src/hip_module.cpp b/projects/clr/hipamd/src/hip_module.cpp index ad0a02ee522..28c22986b95 100644 --- a/projects/clr/hipamd/src/hip_module.cpp +++ b/projects/clr/hipamd/src/hip_module.cpp @@ -305,6 +305,10 @@ hipError_t ihipLaunchKernel_validate(hipFunction_t f, const amd::LaunchParams& l } hip::DeviceFunc* function = hip::DeviceFunc::asFunction(f); amd::Kernel* kernel = function->kernel(); + if (!kernel) { + LogPrintfError("%s", "Invalid Device function provided."); + return hipErrorInvalidValue; + } const amd::KernelSignature& signature = kernel->signature(); if ((signature.numParameters() > 0) && (kernelParams == nullptr) && (extra == nullptr)) { LogPrintfError("%s", "At least one of kernelParams or extra Params should be provided"); From e881d1974e7c046682c72a98fa2e925ef0531621 Mon Sep 17 00:00:00 2001 From: Rahul Manocha <153310294+manocharahul@users.noreply.github.com> Date: Thu, 8 Jan 2026 11:18:12 -0800 Subject: [PATCH 2/2] Update log message for the error Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- projects/clr/hipamd/src/hip_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/clr/hipamd/src/hip_module.cpp b/projects/clr/hipamd/src/hip_module.cpp index 28c22986b95..2ada6bb292d 100644 --- a/projects/clr/hipamd/src/hip_module.cpp +++ b/projects/clr/hipamd/src/hip_module.cpp @@ -306,7 +306,7 @@ hipError_t ihipLaunchKernel_validate(hipFunction_t f, const amd::LaunchParams& l hip::DeviceFunc* function = hip::DeviceFunc::asFunction(f); amd::Kernel* kernel = function->kernel(); if (!kernel) { - LogPrintfError("%s", "Invalid Device function provided."); + LogPrintfError("%s", "Kernel object is invalid or null, possibly due to architecture mismatch."); return hipErrorInvalidValue; } const amd::KernelSignature& signature = kernel->signature();