Author: abidh Date: Wed Feb 11 10:37:17 2015 New Revision: 228844 URL: http://llvm.org/viewvc/llvm-project?rev=228844&view=rev Log: Lock mutex in the same order. SBProcess uses 2 mutexex; RunLock and APILock. Apart from 2 places, RunLock is locked before API lock. I have fixed the 2 places where order was different. I observed a deadlock due to this different order in lldb-mi once. Although lldb-mi command and event thread dont run at the same time now. So it can not deadlock there but can still be problem for some other clients.
Pre-approved by Greg in http://lists.cs.uiuc.edu/pipermail/lldb-dev/2015-February/006509.html Modified: lldb/trunk/source/API/SBProcess.cpp Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=228844&r1=228843&r2=228844&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Wed Feb 11 10:37:17 2015 @@ -918,9 +918,9 @@ SBProcess::GetThreadByID (tid_t tid) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update); sb_thread.SetThread (thread_sp); } @@ -942,9 +942,9 @@ SBProcess::GetThreadByIndexID (uint32_t ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update); sb_thread.SetThread (thread_sp); } _______________________________________________ lldb-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
