Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-07 Thread Tanguy Fautre
] 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

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-07 Thread Robert Osfield
Hi Tanguy, On Fri, Aug 7, 2009 at 3:14 PM, Tanguy Fautretang...@aristechnologies.com wrote: 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. Great, a good

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-07 Thread Tanguy Fautre
...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield Sent: 07 August 2009 15:51 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Tanguy, On Fri, Aug 7, 2009 at 3:14 PM, Tanguy Fautretang

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Tanguy Fautre
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield Sent: 05 August 2009 13:26 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Tanguy, On Wed, Aug 5, 2009 at 12:55 PM, Tanguy Fautretang...@aristechnologies.com wrote

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Daniel Trstenjak
Hi Tanguy, static Mutex s_mutex; const char * getSingletonGlExtensionDisable() { ScopedLock lock(s_mutex); static const char * env = getenv(OSG_GL_EXTENSION_DISABLE); return env; } This doesn't make sense, because 'getenv' is called only once, during the initialization

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Tanguy Fautre
; return object; } Cheers, Tanguy -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Daniel Trstenjak Sent: 06 August 2009 12:24 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Robert Osfield
Hi Tanguy, I was wondering about the possibility of wrapping up the access to the sensitive C functions using a Mutex. We couldn't do it in local code, but would need to do it via a single custom getenv() etc. function implementation, otherwise we'd still end up with multiple functions

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Tanguy Fautre
: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield Sent: 06 August 2009 12:48 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Tanguy, I was wondering about the possibility

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Daniel Trstenjak
Hi Tanguy, Your proposed solution looks like a variant of the Double Checked Locking. Unfortunately, this design pattern is very subtly broken and not thread safe. See http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf for more information. It depends what you want to make thread

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Robert Osfield
Hi Tanguy, On Thu, Aug 6, 2009 at 12:53 PM, Tanguy Fautretang...@aristechnologies.com wrote: Unfortunately serializing the access to getenv() is not likely to solve the issue. The problem is not that OSG calls several getenv() in parallel, the problem is that getenv() should not be called *at

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Tanguy Fautre
...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield Sent: 06 August 2009 13:14 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Tanguy, On Thu, Aug 6, 2009 at 12:53 PM, Tanguy Fautretang

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Robert Osfield
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

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-06 Thread Tanguy Fautre
). Cheers, Tanguy -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] 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

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-05 Thread Robert Osfield
Hi Tanguy, I don't have a windows box to test against so can't do anything first hand. It does very much sound like Windows threading issue that will require a specific Windows mechanism in your application set up to avoid hitting these problems. I don't what what the solution might be, but

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-05 Thread Tanguy Fautre
: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Tanguy, I don't have a windows box to test against so can't do anything first hand. It does very much sound like Windows threading issue that will require a specific Windows mechanism in your application set up to avoid

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-05 Thread Robert Osfield
Hi Tanguy, On Wed, Aug 5, 2009 at 12:55 PM, Tanguy Fautretang...@aristechnologies.com wrote: To come back to the deadlock issue, I don't think there is any way to fix it without breaking the current OSG API compatibility. While I would favour removing the singletons (and would heavily

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-08-03 Thread Tanguy Fautre
Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Aymeric Barthe Sent: 30 July 2009 07:46 To: osg-users@lists.openscenegraph.org Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil bthrall wrote

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-07-30 Thread Aymeric Barthe
bthrall wrote: The links you posted explicitly said that creating synchronization primitives is allowed in DllMain; the problem is acquiring them when other threads are trying to acquire the loader lock (to enter some DllMain function). Are you saying that the problem is the mutex used

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-07-30 Thread Aymeric Barthe
aymericb wrote: The violation is that no C function should be called from DllMain(). Sorry. Small/Big mistake here. Forgot one important word. I meant The violation is that no C library function should be called from DllMain(). The deadlock problem is clearly similar to the one

[osg-users] Deadlock when loading osg.dll, singletons are evil

2009-07-29 Thread Tanguy Fautre
Hi, We've encountered several times a random deadlock that would happen when starting our application. After some playing around, we've identified the problem to be quite a subtle one. Here is what's happening. When osg.dll (in our case the full name is osg59-osgd.dll) gets loaded, it

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-07-29 Thread Jean-Sébastien Guay
Hi Tanguy, We've encountered several times a random deadlock that would happen when starting our application. After some playing around, we've identified the problem to be quite a subtle one. What you're describing makes sense in some way, but I have two questions: 1. Why have there not been

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-07-29 Thread Tanguy Fautre
: 29 July 2009 17:28 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll, singletons are evil Hi Tanguy, We've encountered several times a random deadlock that would happen when starting our application. After some playing around, we've identified the problem

Re: [osg-users] Deadlock when loading osg.dll, singletons are evil

2009-07-29 Thread Thrall, Bryan
be helpful, I think. -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay Sent: 29 July 2009 17:28 To: OpenSceneGraph Users Subject: Re: [osg-users] Deadlock when loading osg.dll