Skip to content

Commit a608076

Browse files
committed
[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
1 parent 8402ad2 commit a608076

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libc/utils/gpu/server/rpc_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ rpc_status_t rpc_init(uint32_t num_devices) {
231231
}
232232

233233
rpc_status_t rpc_shutdown(void) {
234-
if (state->reference_count-- == 1)
234+
if (state && state->reference_count-- == 1)
235235
delete state;
236236

237237
return RPC_STATUS_SUCCESS;

0 commit comments

Comments
 (0)