[osg-users] OpenSceneGraph-3.6.5 release candidate 2 tagged, please test

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Tue Jan 28 03:51:03 PST 2020


Hi Fabian & Chris,

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.

Robert

$ git diff
diff --git a/src/OpenThreads/pthreads/PThreadMutex.cpp
b/src/OpenThreads/pthreads/PThreadMutex.cpp
index 3a3d1c338..d122fc67c 100644
--- a/src/OpenThreads/pthreads/PThreadMutex.cpp
+++ b/src/OpenThreads/pthreads/PThreadMutex.cpp
@@ -22,6 +22,8 @@
 #include <OpenThreads/Mutex>
 #include "PThreadMutexPrivateData.h"

+#include <stdio.h>
+
 using namespace OpenThreads;

 //----------------------------------------------------------------------------
@@ -33,7 +35,7 @@ using namespace OpenThreads;
 Mutex::Mutex(MutexType type):
     _mutexType(type)
 {
-
+    printf("Mutex::Mutex(%d) %p\n", type, this);
     pthread_mutexattr_t mutex_attr;
     pthread_mutexattr_init( &mutex_attr );

@@ -107,6 +109,8 @@ Mutex::Mutex(MutexType type):
 //
 Mutex::~Mutex() {

+    printf("Mutex::~Mutex() %p\n", this);
+
     PThreadMutexPrivateData *pd =
         static_cast<PThreadMutexPrivateData*>(_prvData);

diff --git a/src/osg/Referenced.cpp b/src/osg/Referenced.cpp
index 95b665c57..267bda310 100644
--- a/src/osg/Referenced.cpp
+++ b/src/osg/Referenced.cpp
@@ -79,11 +79,16 @@ struct ResetPointer
 };

 typedef ResetPointer<DeleteHandler> DeleteHandlerPointer;
+
+#if 1
+#include <stdio.h>
+
 typedef ResetPointer<OpenThreads::Mutex> GlobalMutexPointer;

 OpenThreads::Mutex* Referenced::getGlobalReferencedMutex()
 {
     static GlobalMutexPointer s_ReferencedGlobalMutext = new
OpenThreads::Mutex;
+    printf("Referenced::getGlobalReferencedMutex() %p\n",
(s_ReferencedGlobalMutext.get()));
     return s_ReferencedGlobalMutext.get();
 }

@@ -96,6 +101,17 @@ struct InitGlobalMutexes
     }
 };
 static InitGlobalMutexes s_initGlobalMutexes;
+#else
+
+#include <stdio.h>
+
+static OpenThreads::Mutex s_ReferencedGlobalMutex;
+OpenThreads::Mutex* Referenced::getGlobalReferencedMutex()
+{
+    printf("Referenced::getGlobalReferencedMutex() %p\n",
(&s_ReferencedGlobalMutex));
+    return &s_ReferencedGlobalMutex;
+}
+#endif

 // static std::auto_ptr<DeleteHandler> s_deleteHandler(0);
 static DeleteHandlerPointer s_deleteHandler(0);
diff --git a/src/osg/StateAttribute.cpp b/src/osg/StateAttribute.cpp
index e239fb3aa..c7df40894 100644
--- a/src/osg/StateAttribute.cpp
+++ b/src/osg/StateAttribute.cpp
@@ -39,6 +39,8 @@ void StateAttribute::removeParent(osg::StateSet* object)

     ParentList::iterator pitr =
std::find(_parents.begin(),_parents.end(),object);
     if (pitr!=_parents.end()) _parents.erase(pitr);
+
+    printf("StateAttribute::removeParent()\n");
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200128/bcbc50c4/attachment.html>


More information about the osg-users mailing list