You're right that for simple applications, this would be entirely acceptable. But what happens when the app you're talking about uses several components in-proc that use Xerces for entirely different and separate reasons. Those components do not have any knowledge of the other components and what they use Xerces for (and they _shouldn't_ have to know. It's internal to the logic of the component.). This isn't a hypothetical example. It's a situation that occurs in the software that I work on right now.
Example: Application XYZ loads lib1.dll and lib2.dll into its address space. lib1.dll and lib2.dll do entirely different tasks and do not have any direct knowledge of the other, but they both depend on Xerces (i.e. the Xerces lib is loaded into the process space). Nor do they know if or when the Xerces library is initialized or terminated, so to be sure, they both call into Initialize() and Terminate(). Because the Initialize() and Terminate() calls are not synchronized, you have a race condition. The use count variable could be set to an indeterminate value (worst case = 0), which could (and did in the bug that I worked on) lead to one thread cleaning up the global data for the library while another thread was actively doing work in Xerces that touched a deleted global value. Okay, so your argument after reading this might be, well, you just need to ensure that your application calls initialize/terminate before loading the libs. But my argument to that would be: why should my application have to know ahead of time that libs lib1.dll and lib2.dll use Xerces? To me, that defeats the whole purpose of creating component software. You're not _supposed_ to know the details of how a library works, just the interface to it. Complicating that further is the idea that lib1.dll or lib2.dll might be used by several different applications. So your argument would mean changing each and every application that uses those libs to initialize and terminate Xerces. Thanks, Brandon -----Original Message----- From: Axel Wei� [mailto:[EMAIL PROTECTED] Sent: May 19, 2005 2:23 AM To: [email protected] Subject: Re: Protect XMLPlatformUtils::Initialize and XMLPlatformUtils::Terminate Brandon White wrote: > Is there any reason why this wouldn't be acceptable? It would prevent > clients from having to worry about synchronizing requests to these > calls in Xerces. Hi Brandon, where is the problem? You just can initialize xerces right before creating any new threads, and terminate after the last thread has terminated, respectively. Or what did I miss ...? Regards, Axel -- Humboldt-Universit�t zu Berlin Institut f�r Informatik Signalverarbeitung und Mustererkennung Dipl.-Inf. Axel Wei� Rudower Chaussee 25 12489 Berlin-Adlershof +49-30-2093-3050 ** www.freesp.de ** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
