[Lldb-commits] [lldb] r159291 - /lldb/trunk/source/Commands/CommandObjectTarget.cpp
Greg Clayton
gclayton at apple.com
Wed Jun 27 13:26:19 PDT 2012
Author: gclayton
Date: Wed Jun 27 15:26:19 2012
New Revision: 159291
URL: http://llvm.org/viewvc/llvm-project?rev=159291&view=rev
Log:
Fixed the "target modules list" to not crash in Debug builds due to an assertion where the mutex in the "module_list" local variable would assert when the lldb_private::Mutex would destruct. What was happening was the mutex in the module list was being locked by a local locker object and then "module_list" would get destroyed before the locker and the locker still had the mutex locked which would cause the pthread call to destroy the mutex to fail with "Resource busy" and it would cause a mutex leak.
Modified:
lldb/trunk/source/Commands/CommandObjectTarget.cpp
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=159291&r1=159290&r2=159291&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Jun 27 15:26:19 2012
@@ -2865,6 +2865,10 @@
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
const bool use_global_module_list = m_options.m_use_global_module_list;
+ // Define a local module list here to ensure it lives longer than any "locker"
+ // object which might lock its contents below (through the "module_list_ptr"
+ // variable).
+ ModuleList module_list;
if (target == NULL && use_global_module_list == false)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
@@ -2919,8 +2923,6 @@
Mutex::Locker locker; // This locker will be locked on the mutex in module_list_ptr if it is non-NULL.
// Otherwise it will lock the AllocationModuleCollectionMutex when accessing
// the global module list directly.
-
- ModuleList module_list;
ModuleList *module_list_ptr = NULL;
const size_t argc = command.GetArgumentCount();
if (argc == 0)
More information about the lldb-commits
mailing list