nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1From b7717446c85d08b2d7c0c60ba3ac0eff11ee6120 Mon Sep 17 00:00:00 2001
2From: Luna Nova <git@lunnova.dev>
3Date: Tue, 20 Jan 2026 12:55:45 -0800
4Subject: [PATCH 1/2] rocm-runtime: fix crash in QueueCreate due to trying to
5 free non allocated scratch
6
7if (scratch.main_queue_base != nullptr) before calling ReleaseQueueMainScratch
8because ReleaseQueueMainScratch is only valid if main_queue_base is set
9and the scope guard can fire for an error allocating the queue.
10---
11 .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 4 +++-
12 1 file changed, 3 insertions(+), 1 deletion(-)
13
14diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp
15index 01b01fe869..83db40dacc 100644
16--- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp
17+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp
18@@ -1792,7 +1792,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u
19 scratch.main_queue_base = nullptr;
20 scratch.main_queue_process_offset = 0;
21
22- MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() { ReleaseQueueMainScratch(scratch); });
23+ MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() {
24+ if (scratch.main_queue_base != nullptr) ReleaseQueueMainScratch(scratch);
25+ });
26
27 if (scratch.main_size != 0) {
28 AcquireQueueMainScratch(scratch);
29--
302.52.0
31
32
33From 9c1746cd76a703e4d2321dc2ffe85fc61bfd2f21 Mon Sep 17 00:00:00 2001
34From: Luna Nova <git@lunnova.dev>
35Date: Tue, 20 Jan 2026 13:00:32 -0800
36Subject: [PATCH 2/2] rocm-runtime: log for errors in QueueCreate
37
38---
39 .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 9 ++++++++-
40 1 file changed, 8 insertions(+), 1 deletion(-)
41
42diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp
43index 83db40dacc..ae68732eb5 100644
44--- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp
45+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp
46@@ -1799,6 +1799,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u
47 if (scratch.main_size != 0) {
48 AcquireQueueMainScratch(scratch);
49 if (scratch.main_queue_base == nullptr) {
50+ LogPrint(HSA_AMD_LOG_FLAG_INFO,
51+ "Failed to allocate scratch memory for queue, size=%zu, node=%u",
52+ scratch.main_size, node_id());
53 return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
54 }
55 }
56@@ -1827,7 +1830,11 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u
57 node_id()));
58 }
59
60- if (!shared_queue) return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
61+ if (!shared_queue) {
62+ LogPrint(HSA_AMD_LOG_FLAG_INFO,
63+ "Failed to allocate shared queue descriptor memory, node=%u", node_id());
64+ return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
65+ }
66
67 auto aql_queue = new AqlQueue(shared_queue, this, size, node_id(), scratch, event_callback, data,
68 flags);
69--
702.52.0
71