summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2015-05-15 13:30:59 +0000
committerPavel Labath <labath@google.com>2015-05-15 13:30:59 +0000
commit6e35163ccaad7006ed21502d0e6130a7ad5c9d39 (patch)
tree556782600b33a5b6c682fabbbc85f775ba418e62 /lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
parent6e1fd35bfe8618b2eedacfff632dc631fa80da1c (diff)
downloadbcm5719-llvm-6e35163ccaad7006ed21502d0e6130a7ad5c9d39.tar.gz
bcm5719-llvm-6e35163ccaad7006ed21502d0e6130a7ad5c9d39.zip
[NativeProcessLinux] Fix potential race during thread exit
Summary: This is the same issue as we had in D9145 for thread creation. Going through the full ThreadDidStop/RequestResume cycle can cause a deferred notification to fire, which is not correct when we are ignoring an event and resuming the thread. In this case it doesn't matter much since the thread will die after that anyway, but for correctness, we should do the same thing here. Also treating the SIGTRAP case the same way. Test Plan: Tests continue to pass. Reviewers: chaoren, ovyalov Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9696 llvm-svn: 237445
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp38
1 files changed, 7 insertions, 31 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 4bc17496d26..fd88ddf6158 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -2483,15 +2483,9 @@ NativeProcessLinux::MonitorSIGTRAP(const siginfo_t *info, lldb::pid_t pid)
case (SIGTRAP | (PTRACE_EVENT_EXIT << 8)):
{
// The inferior process or one of its threads is about to exit.
- if (! thread_sp)
- break;
-
- // This thread is currently stopped. It's not actually dead yet, just about to be.
- ThreadDidStop (pid, false);
- // The actual stop reason does not matter much, as we are going to resume the thread a
- // few lines down. If we ever want to report this state to the debugger, then we should
- // invent a new stop reason.
- std::static_pointer_cast<NativeThreadLinux>(thread_sp)->SetStoppedBySignal(LLDB_INVALID_SIGNAL_NUMBER);
+ // We don't want to do anything with the thread so we just resume it. In case we
+ // want to implement "break on thread exit" functionality, we would need to stop
+ // here.
unsigned long data = 0;
if (GetEventMessage(pid, &data).Fail())
@@ -2511,14 +2505,7 @@ NativeProcessLinux::MonitorSIGTRAP(const siginfo_t *info, lldb::pid_t pid)
SetExitStatus (convert_pid_status_to_exit_type (data), convert_pid_status_to_return_code (data), nullptr, true);
}
- const int signo = static_cast<int> (data);
- ResumeThread(pid,
- [=](lldb::tid_t tid_to_resume, bool supress_signal)
- {
- std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
- return Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
- },
- true);
+ Resume(pid, LLDB_INVALID_SIGNAL_NUMBER);
break;
}
@@ -2556,26 +2543,15 @@ NativeProcessLinux::MonitorSIGTRAP(const siginfo_t *info, lldb::pid_t pid)
if (log)
log->Printf ("NativeProcessLinux::%s() received unknown SIGTRAP system call stop event, pid %" PRIu64 "tid %" PRIu64 ", resuming", __FUNCTION__, GetID (), pid);
- // This thread is currently stopped.
- ThreadDidStop (pid, false);
- if (thread_sp)
- std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetStoppedBySignal (SIGTRAP);
-
-
// Ignore these signals until we know more about them.
- ResumeThread(pid,
- [=](lldb::tid_t tid_to_resume, bool supress_signal)
- {
- std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
- return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
- },
- true);
+ Resume(pid, LLDB_INVALID_SIGNAL_NUMBER);
break;
default:
assert(false && "Unexpected SIGTRAP code!");
if (log)
- log->Printf ("NativeProcessLinux::%s() pid %" PRIu64 "tid %" PRIu64 " received unhandled SIGTRAP code: 0x%" PRIx64, __FUNCTION__, GetID (), pid, static_cast<uint64_t> (SIGTRAP | (PTRACE_EVENT_CLONE << 8)));
+ log->Printf ("NativeProcessLinux::%s() pid %" PRIu64 "tid %" PRIu64 " received unhandled SIGTRAP code: 0x%d",
+ __FUNCTION__, GetID (), pid, info->si_code);
break;
}
OpenPOWER on IntegriCloud