aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2023-07-11 14:30:42 -0500
committerJoseph Huber <jhuber6@vols.utk.edu>2023-07-11 14:35:38 -0500
commita6080767268c04ab4dfcf22b12ac9f6ba6cf1a00 (patch)
tree0db3530f30805ddc3aed058bbee451b966402763 /libc
parent8402ad23104b6b20f07596738b02a4ab101a8af9 (diff)
downloadllvm-a6080767268c04ab4dfcf22b12ac9f6ba6cf1a00.zip
llvm-a6080767268c04ab4dfcf22b12ac9f6ba6cf1a00.tar.gz
llvm-a6080767268c04ab4dfcf22b12ac9f6ba6cf1a00.tar.bz2
[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
Diffstat (limited to 'libc')
-rw-r--r--libc/utils/gpu/server/rpc_server.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libc/utils/gpu/server/rpc_server.cpp b/libc/utils/gpu/server/rpc_server.cpp
index 6540e38..da9f506 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;