[libc-commits] [PATCH] D155005: [libc][Obvious] Check if the state hasn't already been destroyed on shutdown
Joseph Huber via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Jul 11 12:35:09 PDT 2023
jhuber6 created this revision.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, sstefan1.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155005
Files:
libc/utils/gpu/server/rpc_server.cpp
Index: libc/utils/gpu/server/rpc_server.cpp
===================================================================
--- libc/utils/gpu/server/rpc_server.cpp
+++ libc/utils/gpu/server/rpc_server.cpp
@@ -231,7 +231,7 @@
}
rpc_status_t rpc_shutdown(void) {
- if (state->reference_count-- == 1)
+ if (state && state->reference_count-- == 1)
delete state;
return RPC_STATUS_SUCCESS;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155005.539249.patch
Type: text/x-patch
Size: 390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230711/bc541259/attachment-0001.bin>
More information about the libc-commits
mailing list