diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-05-23 11:41:28 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-05-23 11:41:28 -0400 |
commit | 796ebd3c5491a607059d8a7db489fefb5731cb4d (patch) | |
tree | 1594caeb4c68db6e93e373196888323b28976a9e /indra | |
parent | 2c118b53e20cd9bad07407c584ca0bcf92b9af1d (diff) |
Fix test program termination crash.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/CMakeLists.txt | 27 | ||||
-rw-r--r-- | indra/llcommon/llsingleton.cpp | 13 | ||||
-rwxr-xr-x | indra/llcommon/lockstatic.cpp | 26 | ||||
-rw-r--r-- | indra/llcommon/lockstatic.h | 24 |
4 files changed, 55 insertions, 35 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index f9353baa4d..d5440d6bc8 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -18,6 +18,7 @@ include(Tracy) set(llcommon_SOURCE_FILES apply.cpp commoncontrol.cpp + hbxxh.cpp indra_constants.cpp lazyeventapi.cpp llallocator.cpp @@ -58,8 +59,8 @@ set(llcommon_SOURCE_FILES llframetimer.cpp llheartbeat.cpp llheteromap.cpp - llinitparam.cpp llinitdestroyclass.cpp + llinitparam.cpp llinstancetracker.cpp llkeybind.cpp llleap.cpp @@ -69,15 +70,15 @@ set(llcommon_SOURCE_FILES llmd5.cpp llmemory.cpp llmemorystream.cpp - llmetrics.cpp llmetricperformancetester.cpp + llmetrics.cpp llmortician.cpp llmutex.cpp - llptrto.cpp llpredicate.cpp llprocess.cpp llprocessor.cpp llprocinfo.cpp + llptrto.cpp llqueuedthread.cpp llrand.cpp llrefcount.cpp @@ -107,11 +108,11 @@ set(llcommon_SOURCE_FILES lluriparser.cpp lluuid.cpp llworkerthread.cpp + lockstatic.cpp lua_function.cpp lualistener.cpp - hbxxh.cpp - u64.cpp threadpool.cpp + u64.cpp workqueue.cpp StackWalker.cpp ) @@ -128,6 +129,7 @@ set(llcommon_HEADER_FILES fix_macros.h fsyspath.h function_types.h + hbxxh.h indra_constants.h lazyeventapi.h linden_common.h @@ -165,9 +167,9 @@ set(llcommon_HEADER_FILES lleventapi.h lleventcoro.h lleventdispatcher.h + lleventemitter.h lleventfilter.h llevents.h - lleventemitter.h llexception.h llfasttimer.h llfile.h @@ -194,13 +196,11 @@ set(llcommon_HEADER_FILES llmd5.h llmemory.h llmemorystream.h - llmetrics.h llmetricperformancetester.h + llmetrics.h llmortician.h llnametable.h llpointer.h - llprofiler.h - llprofilercategories.h llpounceable.h llpredicate.h llpreprocessor.h @@ -208,6 +208,8 @@ set(llcommon_HEADER_FILES llprocess.h llprocessor.h llprocinfo.h + llprofiler.h + llprofilercategories.h llptrto.h llqueuedthread.h llrand.h @@ -225,14 +227,14 @@ set(llcommon_HEADER_FILES llsimplehash.h llsingleton.h llstacktrace.h + llstaticstringtable.h + llstatsaccumulator.h llstl.h llstreamqueue.h llstreamtools.h llstrider.h llstring.h llstringtable.h - llstaticstringtable.h - llstatsaccumulator.h llsys.h lltempredirect.h llthread.h @@ -252,10 +254,9 @@ set(llcommon_HEADER_FILES llwin32headers.h llwin32headerslean.h llworkerthread.h + lockstatic.h lua_function.h lualistener.h - hbxxh.h - lockstatic.h stdtypes.h stringize.h threadpool.h diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp index 3049e81139..5b0990e213 100644 --- a/indra/llcommon/llsingleton.cpp +++ b/indra/llcommon/llsingleton.cpp @@ -33,7 +33,6 @@ #include "llerrorcontrol.h" #include "llexception.h" #include "llmainthreadtask.h" -#include "../test/writestr.h" #include <algorithm> #include <iostream> // std::cerr in dire emergency #include <sstream> @@ -66,12 +65,6 @@ private: mutex_t mMutex; public: - ~MasterList() - { - writestr(2, "~MasterList()"); - } - -public: // Instantiate this to both obtain a reference to MasterList::instance() // and lock its mutex for the lifespan of this Lock instance. class Lock @@ -154,7 +147,6 @@ public: private: list_t& get_initializing_() { - writestr(2, "MasterList::get_initializing_()"); LLSingletonBase::list_t* current = mInitializing.get(); if (! current) { @@ -171,7 +163,6 @@ private: // we pop the list to empty, reset() the running coroutine's local_ptr. void cleanup_initializing_() { - writestr(2, "MasterList::cleanup_initializing_()"); mInitializing.reset(nullptr); } }; @@ -300,14 +291,10 @@ void LLSingletonBase::capture_dependency(LLSingletonBase* sb) // library may have shut down, and MasterList::mInitializing.get() might // blow up. But if we're called that late, there's really no point in // trying to capture this dependency. - writestr(2, "LLSingletonBase::capture_dependency() trampoline"); if (boost::fibers::context::active()) { - writestr(2, "still active"); sb->capture_dependency(); } - else - writestr(2, "no longer active"); } void LLSingletonBase::capture_dependency() diff --git a/indra/llcommon/lockstatic.cpp b/indra/llcommon/lockstatic.cpp new file mode 100755 index 0000000000..b647208724 --- /dev/null +++ b/indra/llcommon/lockstatic.cpp @@ -0,0 +1,26 @@ +/** + * @file lockstatic.cpp + * @author Nat Goodspeed + * @date 2024-05-23 + * @brief Implementation for lockstatic. + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Copyright (c) 2024, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "linden_common.h" +// associated header +#include "lockstatic.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llerror.h" +#include "stringize.h" + +void llthread::LockStaticBase::throwDead(const char* mangled) +{ + LLTHROW(Dead(stringize(LLError::Log::demangle(mangled), " called after cleanup()"))); +} diff --git a/indra/llcommon/lockstatic.h b/indra/llcommon/lockstatic.h index 35160521a7..e83957b1fd 100644 --- a/indra/llcommon/lockstatic.h +++ b/indra/llcommon/lockstatic.h @@ -14,19 +14,14 @@ #define LL_LOCKSTATIC_H #include "mutex.h" // std::unique_lock -#include "llerror.h" #include "llexception.h" +#include <typeinfo> namespace llthread { -// Instantiate this template to obtain a pointer to the canonical static -// instance of Static while holding a lock on that instance. Use of -// Static::mMutex presumes that Static declares some suitable mMutex. -template <typename Static> -class LockStatic +class LockStaticBase { - typedef std::unique_lock<decltype(Static::mMutex)> lock_t; public: // trying to lock Static after cleanup() has been called struct Dead: public LLException @@ -34,6 +29,18 @@ public: Dead(const std::string& what): LLException(what) {} }; +protected: + static void throwDead(const char* mangled); +}; + +// Instantiate this template to obtain a pointer to the canonical static +// instance of Static while holding a lock on that instance. Use of +// Static::mMutex presumes that Static declares some suitable mMutex. +template <typename Static> +class LockStatic: public LockStaticBase +{ + typedef std::unique_lock<decltype(Static::mMutex)> lock_t; +public: LockStatic(): mData(getStatic()), mLock(getLock(mData)) @@ -81,8 +88,7 @@ private: // exceptional. if (! data) { - LLTHROW(Dead("LockStatic<" + LLError::Log::classname<LockStatic<Static>>() + - "> called after cleanup()")); + throwDead(typeid(LockStatic<Static>).name()); } // Usual case: data isn't nullptr, carry on. return lock_t(data->mMutex); |