Skip to content

Commit 8c6a6f1

Browse files
committed
[libc] Make RPC malloc implementation return 'nullptr' on alloc failure
Summary: `malloc` is supposed to return `nullptr` if it fails, not exit with an error code.
1 parent 2336ef9 commit 8c6a6f1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libc/utils/gpu/loader/amdgpu/amdhsa-loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ hsa_status_t launch_kernel(hsa_agent_t dev_agent, hsa_executable_t executable,
180180
if (hsa_status_t err =
181181
hsa_amd_memory_pool_allocate(pool, size,
182182
/*flags=*/0, &dev_ptr))
183-
handle_error(err);
183+
dev_ptr = nullptr;
184184
hsa_amd_agents_allow_access(1, &dev_agent, nullptr, dev_ptr);
185185
buffer->data[0] = reinterpret_cast<uintptr_t>(dev_ptr);
186186
};

libc/utils/gpu/loader/nvptx/nvptx-loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ CUresult launch_kernel(CUmodule binary, CUstream stream,
198198
uint64_t size = buffer->data[0];
199199
CUdeviceptr dev_ptr;
200200
if (CUresult err = cuMemAllocAsync(&dev_ptr, size, memory_stream))
201-
handle_error(err);
201+
dev_ptr = 0UL;
202202

203203
// Wait until the memory allocation is complete.
204204
while (cuStreamQuery(memory_stream) == CUDA_ERROR_NOT_READY)

0 commit comments

Comments
 (0)