forked from OSchip/llvm-project
[lldb] Fix CommandInterpreter::DidProcessStopAbnormally() with multiple threads
If a process has multiple threads, the thread with the stop info might not be the first one in the thread list. On Windows, under certain circumstances, processes seem to have one or more extra threads that haven't been launched by the executable itself, waiting in NtWaitForWorkViaWorkerFactory. If the main (stopped) thread isn't the first one in the list (the order seems nondeterministic), DidProcessStopAbnormally() would return false prematurely, instead of inspecting later threads. The main observable effect of DidProcessStopAbnormally() erroneously returning false, is when running lldb with multiple "-o" parameters to specify multiple commands to execute on the command line. After an abnormal stop, lldb would stop executing "-o" parameters and execute "-k" parameters instead - but due to this issue, it would instead keep executing "-o" parameters as if there was no abnormal stop. (If multiple parameters are specified via a script file via the "-s" option, all of the commands in that file are executed regardless of whether there's an abnormal stop inbetween.) Differential Revision: https://reviews.llvm.org/D134037
This commit is contained in:
parent
be5582981a
commit
8a3597d73c
|
@ -2471,8 +2471,12 @@ bool CommandInterpreter::DidProcessStopAbnormally() const {
|
|||
|
||||
for (const auto &thread_sp : process_sp->GetThreadList().Threads()) {
|
||||
StopInfoSP stop_info = thread_sp->GetStopInfo();
|
||||
if (!stop_info)
|
||||
return false;
|
||||
if (!stop_info) {
|
||||
// If there's no stop_info, keep iterating through the other threads;
|
||||
// it's enough that any thread has got a stop_info that indicates
|
||||
// an abnormal stop, to consider the process to be stopped abnormally.
|
||||
continue;
|
||||
}
|
||||
|
||||
const StopReason reason = stop_info->GetStopReason();
|
||||
if (reason == eStopReasonException ||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# REQUIRES: native && (target-x86 || target-x86_64)
|
||||
# RUN: %clangxx_host %p/Inputs/CommandOnCrashMultiThreaded.cpp -o %t -pthread
|
||||
# RUN: %lldb -b -o "process launch" -k "process continue" -k "exit" %t | FileCheck %s
|
||||
|
||||
# CHECK: Process {{[0-9]+}} exited with status = 0
|
|
@ -0,0 +1,13 @@
|
|||
#include <thread>
|
||||
|
||||
void t_func() {
|
||||
asm volatile(
|
||||
"int3\n\t"
|
||||
);
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::thread t(t_func);
|
||||
t.join();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue