From d081df14ef4c19395b6c0f6e826764d91d4e034f Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Wed, 29 May 2019 19:28:52 +0300
Subject: [PATCH] SL-11309 Crash on attempt to costruct singletone

---
 indra/newview/llstartup.cpp      | 2 ++
 indra/newview/lltexturefetch.cpp | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 9397356d407..e9d3cfa993c 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -162,6 +162,7 @@
 #include "llviewerparcelmgr.h"
 #include "llviewerregion.h"
 #include "llviewerstats.h"
+#include "llviewerstatsrecorder.h"
 #include "llviewerthrottle.h"
 #include "llviewerwindow.h"
 #include "llvoavatar.h"
@@ -1228,6 +1229,7 @@ bool idle_startup()
 		//
 		// Initialize classes w/graphics stuff.
 		//
+		LLViewerStatsRecorder::instance(); // Since textures work in threads
 		gTextureList.doPrefetchImages();		
 		display_startup();
 
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index f6cb787156c..fe058024f69 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2409,7 +2409,11 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
 	mLoaded = TRUE;
 	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
 
-	LLViewerStatsRecorder::instance().log(0.2f);
+	if (LLViewerStatsRecorder::instanceExists())
+	{
+		// Do not create this instance inside thread
+		LLViewerStatsRecorder::instance().log(0.2f);
+	}
 	return data_size ;
 }
 
-- 
GitLab