From b84f8f3349665e1a9329ec2c5a839ffc15f3766f Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Thu, 4 May 2023 17:56:06 -0400
Subject: [PATCH] Fix shutdown crash exploding image threadpools on shutdown

---
 indra/llimage/llimageworker.cpp | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index 9811f196be2..936283752e7 100644
--- a/indra/llimage/llimageworker.cpp
+++ b/indra/llimage/llimageworker.cpp
@@ -92,14 +92,21 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
 
-    // Instantiate the ImageRequest right in the lambda, why not?
-    mThreadPool->getQueue().post(
-        [req = ImageRequest(image, discard, needs_aux, responder)]
-        () mutable
-        {
-            auto done = req.processRequest();
-            req.finishRequest(done);
-        });
+	try
+	{
+		// Instantiate the ImageRequest right in the lambda, why not?
+		mThreadPool->getQueue().post(
+			[req = ImageRequest(image, discard, needs_aux, responder)]
+		() mutable
+			{
+				auto done = req.processRequest();
+				req.finishRequest(done);
+			});
+	}
+	catch (const LLThreadSafeQueueInterrupt&)
+	{
+		LL_DEBUGS() << "Tried to start decoding on shutdown" << LL_ENDL;
+	}
 
     // It's important to our consumer (LLTextureFetchWorker) that we return a
     // nonzero handle. It is NOT important that the nonzero handle be unique:
-- 
GitLab