From 5df86c9a6e258221440a775e229a5be25a4b7e51 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 30 Jan 2014 19:35:34 -0800
Subject: [PATCH] fix for heap corruption crash on shutdown don't set stopped
 flag until recorder object has been deleted

---
 indra/llcommon/llthread.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index cf7768c67b8..fd1f8ee0960 100755
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -143,12 +143,13 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
 
 	//LL_INFOS() << "LLThread::staticRun() Exiting: " << threadp->mName << LL_ENDL;
 	
-	// We're done with the run function, this thread is done executing now.
-	threadp->mStatus = STOPPED;
-
 	delete threadp->mRecorder;
 	threadp->mRecorder = NULL;
 
+	// We're done with the run function, this thread is done executing now.
+	//NB: we are using this flag to sync across threads...we really need memory barriers here
+	threadp->mStatus = STOPPED;
+
 	return NULL;
 }
 
-- 
GitLab