From 9d5b897600a8f9405ec37a141b9417f34a11c557 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 2 Dec 2019 14:39:24 -0500 Subject: DRTVWR-494: Defend LLInstanceTracker against multi-thread usage. The previous implementation went to some effort to crash if anyone attempted to create or destroy an LLInstanceTracker subclass instance during traversal. That restriction is manageable within a single thread, but becomes unworkable if it's possible that a given subclass might be used on more than one thread. Remove LLInstanceTracker::instance_iter, beginInstances(), endInstances(), also key_iter, beginKeys() and endKeys(). Instead, introduce key_snapshot() and instance_snapshot(), the only means of iterating over LLInstanceTracker instances. (These are intended to resemble functions, but in fact the current implementation simply presents the classes.) Iterating over a captured snapshot defends against container modifications during traversal. The term 'snapshot' reminds the coder that a new instance created during traversal will not be considered. To defend against instance deletion during traversal, a snapshot stores std::weak_ptrs which it lazily dereferences, skipping on the fly any that have expired. Dereferencing instance_snapshot::iterator gets you a reference rather than a pointer. Because some use cases want to delete all existing instances, add an instance_snapshot::deleteAll() method that extracts the pointer. Those cases used to require explicitly copying instance pointers into a separate container; instance_snapshot() now takes care of that. It remains the caller's responsibility to ensure that all instances of that LLInstanceTracker subclass were allocated on the heap. Replace unkeyed static LLInstanceTracker::getInstance(T*) -- which returned nullptr if that instance had been destroyed -- with new getWeak() method returning std::weak_ptr. Caller must detect expiration of that weak_ptr. Adjust tests accordingly. Use of std::weak_ptr to detect expired instances requires engaging std::shared_ptr in the constructor. We now store shared_ptrs in the static containers (std::map for keyed, std::set for unkeyed). Make LLInstanceTrackerBase a template parameterized on the type of the static data it manages. For that reason, hoist static data class declarations out of the class definitions to an LLInstanceTrackerStuff namespace. Remove the static atomic sIterationNestDepth and its methods incrementDepth(), decrementDepth() and getDepth(), since they were used only to forbid creation and destruction during traversal. Add a std::mutex to static data. Introduce an internal LockStatic class that locks the mutex while providing a pointer to static data, making that the only way to access the static data. The LLINSTANCETRACKER_DTOR_NOEXCEPT macro goes away because we no longer expect ~LLInstanceTracker() to throw an exception in test programs. That affects LLTrace::StatBase as well as LLInstanceTracker itself. Adapt consumers to the new LLInstanceTracker API. --- indra/llwindow/llwindow.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 1b24250618..40e297bac1 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -457,9 +457,9 @@ LLCoordCommon LL_COORD_TYPE_WINDOW::convertToCommon() const { const LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); - LLWindow* windowp = &(*LLWindow::beginInstances()); + auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL out; - windowp->convertCoords(self, &out); + windowit->convertCoords(self, &out); return out.convert(); } @@ -467,18 +467,18 @@ void LL_COORD_TYPE_WINDOW::convertFromCommon(const LLCoordCommon& from) { LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); - LLWindow* windowp = &(*LLWindow::beginInstances()); + auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL from_gl(from); - windowp->convertCoords(from_gl, &self); + windowit->convertCoords(from_gl, &self); } LLCoordCommon LL_COORD_TYPE_SCREEN::convertToCommon() const { const LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); - LLWindow* windowp = &(*LLWindow::beginInstances()); + auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL out; - windowp->convertCoords(self, &out); + windowit->convertCoords(self, &out); return out.convert(); } @@ -486,7 +486,7 @@ void LL_COORD_TYPE_SCREEN::convertFromCommon(const LLCoordCommon& from) { LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); - LLWindow* windowp = &(*LLWindow::beginInstances()); + auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL from_gl(from); - windowp->convertCoords(from_gl, &self); + windowit->convertCoords(from_gl, &self); } -- cgit v1.2.3 From de4a0b8f5b28799bf1c55976dcd8653d8a642a02 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 18 Dec 2019 12:27:05 -0500 Subject: DRTVWR-494: Avoid keeping iterator to destroyed temporary container. --- indra/llwindow/llwindow.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 40e297bac1..d77997a928 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -457,9 +457,8 @@ LLCoordCommon LL_COORD_TYPE_WINDOW::convertToCommon() const { const LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); - auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL out; - windowit->convertCoords(self, &out); + LLWindow::instance_snapshot().begin()->convertCoords(self, &out); return out.convert(); } @@ -467,18 +466,16 @@ void LL_COORD_TYPE_WINDOW::convertFromCommon(const LLCoordCommon& from) { LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); - auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL from_gl(from); - windowit->convertCoords(from_gl, &self); + LLWindow::instance_snapshot().begin()->convertCoords(from_gl, &self); } LLCoordCommon LL_COORD_TYPE_SCREEN::convertToCommon() const { const LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); - auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL out; - windowit->convertCoords(self, &out); + LLWindow::instance_snapshot().begin()->convertCoords(self, &out); return out.convert(); } @@ -486,7 +483,6 @@ void LL_COORD_TYPE_SCREEN::convertFromCommon(const LLCoordCommon& from) { LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); - auto windowit = LLWindow::instance_snapshot().begin(); LLCoordGL from_gl(from); - windowit->convertCoords(from_gl, &self); + LLWindow::instance_snapshot().begin()->convertCoords(from_gl, &self); } -- cgit v1.2.3 From df8e30b6708d94be89be324000e73ab70a3e2ecb Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 7 May 2020 19:26:52 -0400 Subject: DRTVWR-476: Diagnostically /showIncludes for Windows SDK errors --- indra/llwindow/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 0743fd899f..726147e866 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -148,6 +148,11 @@ if (WINDOWS) comdlg32 # Common Dialogs for ChooseColor ole32 ) + set_source_files_properties( + llwindowwin32.cpp + PROPERTIES + COMPILE_FLAGS "/showIncludes" + ) endif (WINDOWS) if (SOLARIS) -- cgit v1.2.3 From 7766689f21af922278b12abe7ee61996eecb0a1c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 7 May 2020 20:01:11 -0400 Subject: DRTVWR-476: Add /showIncludes to additional source files. Having it on just one source file was frustrating because the project build failed before it reached the one source file with the switch. --- indra/llwindow/CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 726147e866..9322a69eea 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -138,6 +138,14 @@ if (WINDOWS) llkeyboardwin32.cpp lldragdropwin32.cpp ) + set_source_files_properties( + llwindowwin32.cpp + lldxhardware.cpp + llkeyboardwin32.cpp + lldragdropwin32.cpp + PROPERTIES + COMPILE_FLAGS "/showIncludes" + ) list(APPEND llwindow_HEADER_FILES llwindowwin32.h lldxhardware.h @@ -148,11 +156,6 @@ if (WINDOWS) comdlg32 # Common Dialogs for ChooseColor ole32 ) - set_source_files_properties( - llwindowwin32.cpp - PROPERTIES - COMPILE_FLAGS "/showIncludes" - ) endif (WINDOWS) if (SOLARIS) -- cgit v1.2.3 From 89452cecebab69159278fce5ca916a55090aaf29 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 7 May 2020 20:25:23 -0400 Subject: DRTVWR-476: Whack-A-Mole not working, put switch on ALL llwindow --- indra/llwindow/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 9322a69eea..cdd6690e6c 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -139,10 +139,7 @@ if (WINDOWS) lldragdropwin32.cpp ) set_source_files_properties( - llwindowwin32.cpp - lldxhardware.cpp - llkeyboardwin32.cpp - lldragdropwin32.cpp + ${llwindow_SOURCE_FILES} PROPERTIES COMPILE_FLAGS "/showIncludes" ) -- cgit v1.2.3 From 2ccb6422ea263a5bb6aadc7f8ba11048bd14ed87 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 11 May 2020 11:47:53 -0400 Subject: DRTVWR-476: Remove /showIncludes from llwindow project. --- indra/llwindow/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index cdd6690e6c..0743fd899f 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -138,11 +138,6 @@ if (WINDOWS) llkeyboardwin32.cpp lldragdropwin32.cpp ) - set_source_files_properties( - ${llwindow_SOURCE_FILES} - PROPERTIES - COMPILE_FLAGS "/showIncludes" - ) list(APPEND llwindow_HEADER_FILES llwindowwin32.h lldxhardware.h -- cgit v1.2.3 From 6148a6443af886f9b71b4c88084db943950e146c Mon Sep 17 00:00:00 2001 From: Nicky Dasmijn Date: Tue, 19 May 2020 00:03:19 +0200 Subject: Remove DirectX.cmake. With recent SDKs (dating back to at least VS 2013 and the 8.1 SDK) DirectX is included in the SDK and does not need any special detection logic. --- indra/llwindow/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 0743fd899f..5476dc324c 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -11,7 +11,6 @@ project(llwindow) include(00-Common) -include(DirectX) include(DragDrop) include(LLCommon) include(LLImage) -- cgit v1.2.3 From 0c520c7a896a27880a9ddaf0d219e5ae1a084047 Mon Sep 17 00:00:00 2001 From: Nicky Dasmijn Date: Tue, 19 May 2020 19:21:52 +0200 Subject: Remove last occurence of DIRECTX_INCLUDE_DIR. --- indra/llwindow/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 5476dc324c..8bfb23ed64 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -29,7 +29,6 @@ include_directories( ${LLVFS_INCLUDE_DIRS} ${LLWINDOW_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} - ${DIRECTX_INCLUDE_DIR} ) include_directories(SYSTEM ${LLCOMMON_SYSTEM_INCLUDE_DIRS} -- cgit v1.2.3