From a61876b7715d267bd8703e52a9ab41fbbe7661c7 Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Tue, 1 Jul 2025 20:59:29 -0400 Subject: [PATCH] [LLDB][GPU] Add a comment warning the assumptions in HandleGPUActons I'm adding comments reflecting the conversation we had last week on race conditions and assumptions when executing HandleGPUActions. --- .../Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 688a815351e45..b1b3f01a854bc 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -895,7 +895,15 @@ Status ProcessGDBRemote::HandleGPUActions(const GPUActions &gpu_action) { return error; } - // Any commands below require a GPU process + // Any commands below require a GPU process and it needs to have published + // its public state as stopped, otherwise the following unwanted behaviors + // might occur: + // - if the state is running, then these actions will fail + // - if the public state is not yet stopped, then there might be race + // conditions in which the action triggered by the code below ends up + // using stale information, as the GPU target hasn't finished processing + // its internal metadata. It's worth mentioning that there are multiple + // threads operating on the GPU target. if (!(gpu_action.load_libraries || gpu_action.resume_gpu_process || gpu_action.wait_for_gpu_process_to_resume)) return error;