Skip to content

Commit 11fb835

Browse files
committed
[libc] Make LIBC_EXIT RPC code use quick exit
Summary: This RPC call does the final exiting. The callbacks were handled on the GPU side and this is only 'valid' in the pretend mode where we treat the GPU like a CPU program. Doing this keeps us from crashing and burning if people continue using the program while this is running as `exit` would tear down the offloading library in memory and lead to segfaults. This just drops everything where it is and lets the process manager clean it up for us.
1 parent c5e3430 commit 11fb835

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libc/src/__support/RPC/rpc_server.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@ LIBC_INLINE static rpc::Status handle_port_impl(rpc::Server::Port &port) {
395395
port.recv([](rpc::Buffer *buffer, uint32_t) {
396396
int status = 0;
397397
__builtin_memcpy(&status, buffer->data, sizeof(int));
398-
exit(status);
398+
// We want a quick exit to avoid conflicts with offloading library
399+
// teardowns when called from the GPU.
400+
quick_exit(status);
399401
});
400402
break;
401403
}

0 commit comments

Comments
 (0)