aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-06-27 00:23:57 +0000
committerGreg Clayton <gclayton@apple.com>2013-06-27 00:23:57 +0000
commit58274a3c8d618e5aac2b738aa1d11bce423208ab (patch)
tree302bb57a9cbe84704384c94049a29b5c399c9959
parente46dd5bb968f0c269ead5cbf3d05511fd2ebcf92 (diff)
downloadlldb-58274a3c8d618e5aac2b738aa1d11bce423208ab.tar.gz
<rdar://problem/14195566>
Found a race condition when killing an application where the state could be set to exited by the waitpid_thread() _before_ we call task resume (via MachProcess::PrivateResume()) in MachProcess::Kill(). git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@185048 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/debugserver/source/DNB.cpp6
-rw-r--r--tools/debugserver/source/MacOSX/MachProcess.cpp16
2 files changed, 13 insertions, 9 deletions
diff --git a/tools/debugserver/source/DNB.cpp b/tools/debugserver/source/DNB.cpp
index bcbcf983f..d7955541f 100644
--- a/tools/debugserver/source/DNB.cpp
+++ b/tools/debugserver/source/DNB.cpp
@@ -132,7 +132,7 @@ waitpid_thread (void *arg)
while (1)
{
pid_t child_pid = waitpid(pid, &status, 0);
- DNBLogThreadedIf(LOG_PROCESS, "waitpid_process_thread (): waitpid (pid = %i, &status, 0) => %i, status = %i, errno = %i", pid, child_pid, status, errno);
+ DNBLogThreadedIf(LOG_PROCESS, "waitpid_thread (): waitpid (pid = %i, &status, 0) => %i, status = %i, errno = %i", pid, child_pid, status, errno);
if (child_pid < 0)
{
@@ -148,7 +148,7 @@ waitpid_thread (void *arg)
}
else// if (WIFEXITED(status) || WIFSIGNALED(status))
{
- DNBLogThreadedIf(LOG_PROCESS, "waitpid_process_thread (): setting exit status for pid = %i to %i", child_pid, status);
+ DNBLogThreadedIf(LOG_PROCESS, "waitpid_thread (): setting exit status for pid = %i to %i", child_pid, status);
DNBProcessSetExitStatus (child_pid, status);
return NULL;
}
@@ -157,7 +157,7 @@ waitpid_thread (void *arg)
// We should never exit as long as our child process is alive, so if we
// do something else went wrong and we should exit...
- DNBLogThreadedIf(LOG_PROCESS, "waitpid_process_thread (): main loop exited, setting exit status to an invalid value (-1) for pid %i", pid);
+ DNBLogThreadedIf(LOG_PROCESS, "waitpid_thread (): main loop exited, setting exit status to an invalid value (-1) for pid %i", pid);
DNBProcessSetExitStatus (pid, -1);
return NULL;
}
diff --git a/tools/debugserver/source/MacOSX/MachProcess.cpp b/tools/debugserver/source/MacOSX/MachProcess.cpp
index 2eab3784e..f6537bfb3 100644
--- a/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -268,23 +268,27 @@ MachProcess::SetState(nub_state_t new_state)
PTHREAD_MUTEX_LOCKER(locker, m_state_mutex);
const nub_state_t old_state = m_state;
- if (old_state != new_state)
+ if (old_state == eStateExited)
+ {
+ DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState(%s) ignoring new state since current state is exited", DNBStateAsString(new_state));
+ }
+ else if (old_state == new_state)
+ {
+ DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState(%s) ignoring redundant state change...", DNBStateAsString(new_state));
+ }
+ else
{
if (NUB_STATE_IS_STOPPED(new_state))
event_mask = eEventProcessStoppedStateChanged;
else
event_mask = eEventProcessRunningStateChanged;
- DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState ( old = %s, new = %s ) updating state, event_mask = 0x%8.8x", DNBStateAsString(old_state), DNBStateAsString(new_state), event_mask);
+ DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState(%s) upating state (previous state was %s), event_mask = 0x%8.8x", DNBStateAsString(new_state), DNBStateAsString(old_state), event_mask);
m_state = new_state;
if (new_state == eStateStopped)
m_stop_count++;
}
- else
- {
- DNBLogThreadedIf(LOG_PROCESS, "MachProcess::SetState ( old = %s, new = %s ) ignoring state...", DNBStateAsString(old_state), DNBStateAsString(new_state));
- }
}
if (event_mask != 0)