[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)
Dmitry Vasilyev via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 5 04:54:17 PDT 2024
================
@@ -150,12 +153,17 @@ static void client_handle(GDBRemoteCommunicationServerPlatform &platform,
printf("Disconnected.\n");
}
-static GDBRemoteCommunicationServerPlatform::PortMap gdbserver_portmap;
-static std::mutex gdbserver_portmap_mutex;
-
static void spawn_process_reaped(lldb::pid_t pid, int signal, int status) {
- std::lock_guard<std::mutex> guard(gdbserver_portmap_mutex);
- gdbserver_portmap.FreePortForProcess(pid);
+ if (g_single_pid != LLDB_INVALID_PROCESS_ID && g_single_pid == pid) {
+ // If not running as a server and the platform connection is closed
+ if (!g_terminate) {
+ g_terminate = true;
----------------
slydiman wrote:
There are a lot of discussions around `Detached threads accessing global or static objects` in the internet.
Detached threads are bad and the design of this callback is bad.
But if GDBRemoteCommunicationServerPlatform::g_spawned_pids is static (now) it reduces the chances of a crash to 0.(0)1%.
We have no handle of this thread. So the static global g_main_loop is the safest way and g_main_loop must be destroyed (almost) last. No 100% guarantee. But it is the better solution w/o redesigning the child process monitoring.
Ultimately we can just remove `fixes #101475` in the description because this patch improves the situation but do not fix it 100%.
https://github.com/llvm/llvm-project/pull/104238
More information about the lldb-commits
mailing list