Hi Robert, I had the chance to test your patch. As expected, it fixes the problem. The debugger shows the singleton is only initialized well after DllMain has been called. No deadlock to report.
As you stated, we need to fix all the getenv() that can be called from constructing a global singleton. We've seen our app deadlocking on them before. Not sure if you want to apply the patch as it stands though, as thread-safety is quite important to us. Cheers, T -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Tanguy Fautre Sent: 06 August 2009 13:59 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Robert, We've got a custom build of OSG where we've commented out all the unsafe getenv (we do not use env variables in our application anyway). I'm gonna give your patch a few runs. In theory, it should not deadlock (considering all the other unsafe getenv are already commented out). Cheers, Tanguy -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Robert Osfield Sent: 06 August 2009 13:28 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Tanguy, As a first step I've just moved the GLExtension.cpp code that does the static getenv() into the osg::getGLExtensionDisableString() method so it now reads: std::string& osg::getGLExtensionDisableString() { static const char* envVar = getenv("OSG_GL_EXTENSION_DISABLE"); static std::string s_GLExtensionDisableString(envVar?envVar:"Nothing defined"); return s_GLExtensionDisableString; } This isn't yet thread safe, but since the problem in hand isn't directly a threading one this should be at least a little step towards helping solve the problem. Modified file attached. Could you try this modification out at your end to see if it is appropriate step forward. A quick search shows other places where there is static getenv in the global scope so I don't expect this one tweak to be a complete solution, but if it does look like a way forward then we can start rolling the fix out more generally. Cheers, Robert. _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

