[libc-commits] [libc] [libc] Move the pointer to pin off the stack to the heap (PR #74118)

via libc-commits libc-commits at lists.llvm.org
Fri Dec 1 09:48:12 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
This may be problematic to pin a stack pointer. Allocate it via the OS
allocator instead as the documentation suggests.

For some reason, if you attempt to free this pointer after the memory
region has been unlocked, it will return an invalid pointer.


---
Full diff: https://github.com/llvm/llvm-project/pull/74118.diff


1 Files Affected:

- (modified) libc/utils/gpu/loader/amdgpu/Loader.cpp (+1-1) 


``````````diff
diff --git a/libc/utils/gpu/loader/amdgpu/Loader.cpp b/libc/utils/gpu/loader/amdgpu/Loader.cpp
index a9a687656efcb39..d3d2c2b42080837 100644
--- a/libc/utils/gpu/loader/amdgpu/Loader.cpp
+++ b/libc/utils/gpu/loader/amdgpu/Loader.cpp
@@ -471,7 +471,7 @@ int load(int argc, char **argv, char **envp, void *image, size_t size,
     handle_error(err);
 
   // Pin some memory we can use to obtain the address of the rpc client.
-  void *rpc_client_storage = nullptr;
+  void **rpc_client_storage = new void *;
   void *rpc_client_host = nullptr;
   if (hsa_status_t err =
           hsa_amd_memory_lock(&rpc_client_storage, sizeof(void *),

``````````

</details>


https://github.com/llvm/llvm-project/pull/74118


More information about the libc-commits mailing list