fjricci created this revision. fjricci added reviewers: jingham, clayborg, andrew.w.kaylor. fjricci added subscribers: lldb-commits, sas.
The gdb-remote async thread cannot modify thread state while the main thread holds a lock on the state. Don't use locking thread iteration for bt all. Specifically, the deadlock manifests when lldb attempts to JIT code to symbolicate objective c while backtracing. As part of this code path, SetPrivateState() is called on an async thread. This async thread will block waiting for the thread_list lock held by the main thread in CommandObjectIterateOverThreads. The main thread will also block on the async thread during DoResume (although with a timeout), leading to a deadlock. Due to the timeout, the deadlock is not immediately apparent, but the inferior will be left in an invalid state after the bt all completes, and objective-c symbols will not be successfully resolved in the backtrace. http://reviews.llvm.org/D18075 Files: source/Commands/CommandObjectThread.cpp Index: source/Commands/CommandObjectThread.cpp =================================================================== --- source/Commands/CommandObjectThread.cpp +++ source/Commands/CommandObjectThread.cpp @@ -73,8 +73,13 @@ { Process *process = m_exe_ctx.GetProcessPtr(); uint32_t idx = 0; - for (ThreadSP thread_sp : process->Threads()) + + // Manually iterate to avoid locking the threadlist, + // which can cause deadlocks when JIT-ing code + ThreadList thread_list = process->GetThreadList(); + for (uint32_t i = 0; i < thread_list.GetSize(); ++i) { + ThreadSP thread_sp = thread_list.GetThreadAtIndex(i); if (idx != 0 && m_add_return) result.AppendMessage("");
Index: source/Commands/CommandObjectThread.cpp =================================================================== --- source/Commands/CommandObjectThread.cpp +++ source/Commands/CommandObjectThread.cpp @@ -73,8 +73,13 @@ { Process *process = m_exe_ctx.GetProcessPtr(); uint32_t idx = 0; - for (ThreadSP thread_sp : process->Threads()) + + // Manually iterate to avoid locking the threadlist, + // which can cause deadlocks when JIT-ing code + ThreadList thread_list = process->GetThreadList(); + for (uint32_t i = 0; i < thread_list.GetSize(); ++i) { + ThreadSP thread_sp = thread_list.GetThreadAtIndex(i); if (idx != 0 && m_add_return) result.AppendMessage("");
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits