[Lldb-commits] [PATCH] Fix process attach and detach for Windows
Pavel Labath
labath at google.com
Tue Jun 16 15:17:19 PDT 2015
Hi, I have a couple of questions about the thread synchronization here. Take them with a grain of salt though, as I am looking at this code for the first time.
================
Comment at: source/Plugins/Process/Windows/DebuggerThread.cpp:374
@@ -358,1 +373,3 @@
+ if (m_pid_to_detach != 0 && m_active_exception->GetExceptionCode() == EXCEPTION_BREAKPOINT) {
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_PROCESS,
----------------
This is almost a nit, since it will generally work, but technically, this looks like a data race ( => UDB) on the `m_pid_to_detach` variable: You are accessing the variable here and in DebugDetach() and one of those accesses is write. Is there some synchronization here that I am not aware of which is preventing these accesses to occur simultaneously?
================
Comment at: source/Plugins/Process/Windows/ProcessWindows.cpp:474
@@ +473,3 @@
+
+ SetPrivateState(eStateDetached);
+
----------------
I don't know enough about ProcessWindows, but a thought comes to mind here:
You set the process state to be eStateDetached, but that is not exactly true (yet). You have merely requested detachment, which is a process that can take a while (especially if the inferior is in the middle of processing some other breakpoint). It seems likely that this activity (processing a breakpoint hit) will race with whatever happens after DoDetach() returns. I would expect some kind of synchronization here that waits for a signal from the debugger thread that the detachment was successful.
As I said, I'm not an expert, but I was wondering if you have considered this scenario.
http://reviews.llvm.org/D10404
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the lldb-commits
mailing list