From 3fd640a6e3dea7a3551c239323d782fb082e1dbd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 23 Dec 2012 12:27:25 -0800 Subject: SH-3468 WIP add memory tracking base class fixed crash on exit by making LLInstanceTracker iterators use atomic iterator nesting count for thread safety --- indra/llcommon/llinstancetracker.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'indra/llcommon/llinstancetracker.cpp') diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 5dc3ea5d7b..071a637cda 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -27,6 +27,8 @@ #include "linden_common.h" // associated header #include "llinstancetracker.h" +#include "llapr.h" + // STL headers // std headers // external library headers @@ -47,3 +49,19 @@ void * & LLInstanceTrackerBase::getInstances(std::type_info const & info) InstancesMap::mapped_type())) .first->second; } + +void LLInstanceTrackerBase::StaticBase::incrementDepth() +{ + apr_atomic_inc32(&sIterationNestDepth); +} + +void LLInstanceTrackerBase::StaticBase::decrementDepth() +{ + apr_atomic_dec32(&sIterationNestDepth); +} + +U32 LLInstanceTrackerBase::StaticBase::getDepth() +{ + apr_uint32_t data = apr_atomic_read32(&sIterationNestDepth); + return data; +} -- cgit v1.2.3 From cc7d92147c4a4502ec2ac04f150e94a4ac18f79e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 19 Apr 2013 20:09:00 -0700 Subject: SH-4080 WIP interesting: random crash on Mac removed unused dll support from llinstancetracker as it didn't appear to be thread safe --- indra/llcommon/llinstancetracker.cpp | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'indra/llcommon/llinstancetracker.cpp') diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 071a637cda..7ff8324fe3 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -34,22 +34,6 @@ // external library headers // other Linden headers -//static -void * & LLInstanceTrackerBase::getInstances(std::type_info const & info) -{ - typedef std::map InstancesMap; - static InstancesMap instances; - - // std::map::insert() is just what we want here. You attempt to insert a - // (key, value) pair. If the specified key doesn't yet exist, it inserts - // the pair and returns a std::pair of (iterator, true). If the specified - // key DOES exist, insert() simply returns (iterator, false). One lookup - // handles both cases. - return instances.insert(InstancesMap::value_type(info.name(), - InstancesMap::mapped_type())) - .first->second; -} - void LLInstanceTrackerBase::StaticBase::incrementDepth() { apr_atomic_inc32(&sIterationNestDepth); -- cgit v1.2.3 From 99e29b83401a1d6da9dbca03a64c0bfd7bad6298 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 18 Oct 2013 13:10:40 -0700 Subject: crash fix - bad handling of instancetracker iterators --- indra/llcommon/llinstancetracker.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcommon/llinstancetracker.cpp') diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 7ff8324fe3..11fc53f8c8 100755 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -41,6 +41,7 @@ void LLInstanceTrackerBase::StaticBase::incrementDepth() void LLInstanceTrackerBase::StaticBase::decrementDepth() { + llassert(sIterationNestDepth); apr_atomic_dec32(&sIterationNestDepth); } -- cgit v1.2.3