[libc-commits] [libc] a608076 - [libc][Obvious] Check if the state hasn't already been destroyed on shutdown
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue Jul 11 12:35:45 PDT 2023
Author: Joseph Huber
Date: 2023-07-11T14:35:38-05:00
New Revision: a6080767268c04ab4dfcf22b12ac9f6ba6cf1a00
URL: https://github.com/llvm/llvm-project/commit/a6080767268c04ab4dfcf22b12ac9f6ba6cf1a00
DIFF: https://github.com/llvm/llvm-project/commit/a6080767268c04ab4dfcf22b12ac9f6ba6cf1a00.diff
LOG: [libc][Obvious] Check if the state hasn't already been destroyed on shutdown
This ensures that if someone calls the `rpc_shutdown` method multiple
times it will not segfault and gracefully continue. This was causing
problems in the OpenMP usage. This could point to other issues, but for
now this is a safe fix.
Differential Revision: https://reviews.llvm.org/D155005
Added:
Modified:
libc/utils/gpu/server/rpc_server.cpp
Removed:
################################################################################
diff --git a/libc/utils/gpu/server/rpc_server.cpp b/libc/utils/gpu/server/rpc_server.cpp
index 6540e38a8f7cf8..da9f50603f1181 100644
--- a/libc/utils/gpu/server/rpc_server.cpp
+++ b/libc/utils/gpu/server/rpc_server.cpp
@@ -231,7 +231,7 @@ rpc_status_t rpc_init(uint32_t num_devices) {
}
rpc_status_t rpc_shutdown(void) {
- if (state->reference_count-- == 1)
+ if (state && state->reference_count-- == 1)
delete state;
return RPC_STATUS_SUCCESS;
More information about the libc-commits
mailing list