Tanguy Fautre wrote on Wednesday, July 29, 2009 12:37 PM:
> The DllMain problem is quite well documented (cf. the MSDN links from my
> previous post). The thing is that an illegal use of DllMain is quite similar
> to a race condition. Most of the time, everything just seems to work. Our
> application has already about 10 threads up and running before osg.dll is
> being loaded, significantly increasing the chance of a deadlock. I would
> expect most OSG-based applications to do just fine as they start using OSG
> (and therefore osg.dll) when still single threaded.      
> 
> Because our application is quite multithreaded, it's not the first time we've
> uncovered thread-safety bugs in what are supposed to be quite stable
> libraries. Recently, we've just found a couple of thread-safety issues with
> LibCurl and OpenSSL (their developers have accepted these as genuine defects
> and are fixing these issues). Google found a few (not many) posts related to
> these issues, but due to the lack of proper investigations they often got
> dismissed.      

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 in creating the singletons, or is 
there some other limitation of DllMain that you think OSG is violating?

A simple test case demonstrating the problem you're describing would 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, 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 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 more discussions about random deadlocks in
> the recent past? For example, we have not experienced anything
> resembling what you describe. I am not an expert in Win32 programming,
> so what you describe may well be true, but we haven't encountered this,
> and I'm pretty sure if it were such a widespread problem we'd have heard
> of it on this list before. Of course, that's not proof in itself that
> the issue is not there, but it's an indication that it might be
> something on your side rather than a widespread problem.
> 
> 2. If singletons are bad practice as you say, what do you propose to
> replace them? I'm always a bit skeptical of sentences like "Google is
> full of papers [saying that singletons are broken]". People have a
> tendency to be extreme in their judgements, and if someone finds an
> instance where singletons give bad results, they will often start saying
> that they are bad in all cases (and inevitably post to their blog about
> it). It's a tool for a job, and the developer has to know when to use it
> and when not to. That's the developer's responsibility, not the tool's.
> 
> I'm not saying that all uses of singletons in OSG are good ones (most
> obviously because I've probably not personally seen all of them) but
> singletons are useful (they give a single point of access to something -
> data, functionality) and that has to be replaced by something else if
> singletons have a downside in some/most/all(?) situations.
> 
> J-S



-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to