<div dir="ltr"><div dir="ltr">Hi Fabian & Chris,<br></div><div><br></div><div>I was curious about the clean up of the global getGlobalReferencedMutex() so I added some debug messages to OpenThreads and to relevant calls in the OSG to track the creation and clean up of mutexes.  I tried an alternative means of static initialization of the static getGlobalReferencedMutex() and got the same behavior for before and after results so I don't think the version in the 3.6 branch is likley to be be a source of problem, even if it's not particular clean.  Below is diff of the changes I made.</div><div><br></div><div>Robert<br></div><div><br></div><div>$ git diff<br>diff --git a/src/OpenThreads/pthreads/PThreadMutex.cpp b/src/OpenThreads/pthreads/PThreadMutex.cpp<br>index 3a3d1c338..d122fc67c 100644<br>--- a/src/OpenThreads/pthreads/PThreadMutex.cpp<br>+++ b/src/OpenThreads/pthreads/PThreadMutex.cpp<br>@@ -22,6 +22,8 @@<br> #include <OpenThreads/Mutex><br> #include "PThreadMutexPrivateData.h"<br> <br>+#include <stdio.h><br>+<br> using namespace OpenThreads;<br> <br> //----------------------------------------------------------------------------<br>@@ -33,7 +35,7 @@ using namespace OpenThreads;<br> Mutex::Mutex(MutexType type):<br>     _mutexType(type)<br> {<br>-<br>+    printf("Mutex::Mutex(%d) %p\n", type, this);<br>     pthread_mutexattr_t mutex_attr;<br>     pthread_mutexattr_init( &mutex_attr );<br>     <br>@@ -107,6 +109,8 @@ Mutex::Mutex(MutexType type):<br> //<br> Mutex::~Mutex() {<br> <br>+    printf("Mutex::~Mutex() %p\n", this);<br>+<br>     PThreadMutexPrivateData *pd =<br>         static_cast<PThreadMutexPrivateData*>(_prvData);<br> <br>diff --git a/src/osg/Referenced.cpp b/src/osg/Referenced.cpp<br>index 95b665c57..267bda310 100644<br>--- a/src/osg/Referenced.cpp<br>+++ b/src/osg/Referenced.cpp<br>@@ -79,11 +79,16 @@ struct ResetPointer<br> };<br> <br> typedef ResetPointer<DeleteHandler> DeleteHandlerPointer;<br>+<br>+#if 1<br>+#include <stdio.h><br>+<br> typedef ResetPointer<OpenThreads::Mutex> GlobalMutexPointer;<br> <br> OpenThreads::Mutex* Referenced::getGlobalReferencedMutex()<br> {<br>     static GlobalMutexPointer s_ReferencedGlobalMutext = new OpenThreads::Mutex;<br>+    printf("Referenced::getGlobalReferencedMutex() %p\n", (s_ReferencedGlobalMutext.get()));<br>     return s_ReferencedGlobalMutext.get();<br> }<br> <br>@@ -96,6 +101,17 @@ struct InitGlobalMutexes<br>     }<br> };<br> static InitGlobalMutexes s_initGlobalMutexes;<br>+#else<br>+<br>+#include <stdio.h><br>+<br>+static OpenThreads::Mutex s_ReferencedGlobalMutex;<br>+OpenThreads::Mutex* Referenced::getGlobalReferencedMutex()<br>+{<br>+    printf("Referenced::getGlobalReferencedMutex() %p\n", (&s_ReferencedGlobalMutex));<br>+    return &s_ReferencedGlobalMutex;<br>+}<br>+#endif<br> <br> // static std::auto_ptr<DeleteHandler> s_deleteHandler(0);<br> static DeleteHandlerPointer s_deleteHandler(0);<br>diff --git a/src/osg/StateAttribute.cpp b/src/osg/StateAttribute.cpp<br>index e239fb3aa..c7df40894 100644<br>--- a/src/osg/StateAttribute.cpp<br>+++ b/src/osg/StateAttribute.cpp<br>@@ -39,6 +39,8 @@ void StateAttribute::removeParent(osg::StateSet* object)<br> <br>     ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),object);<br>     if (pitr!=_parents.end()) _parents.erase(pitr);<br>+<br>+    printf("StateAttribute::removeParent()\n");<br> }<br> <br> </div><div><br></div><div><br></div></div>