Thanks for pointing this out. I must admit I have no recollection of why or when the copy() and copyTo() methods were introduced; they are not called from anywhere, and there are no test cases as far as I can see. The methods have almost certainly not been kept up to date to copy new properties of the configuration as new properties were introduced. In the circumstances, I think the best thing is to drop these methods from the next release.

Michael Kay
Saxonica

On 14/10/2010 9:23 PM, Jason Smith wrote:

9.2.0.6 PE

 

I’m new to the list, and this is my first post. 

 

We found an interesting error during load testing today, and believe we have tracked it down to the Configuration class.  The bug manifested itself intermittently in a heavily loaded system. 

 

The Configuration class has a copy() method, and a copyTo() method.  Inside the copyTo() method, the sourceParserPool is being copied.  Note that sourceParserPool is marked as “transient,” so it’s really not supposed to be part of a copy. 

 

ArrayLists are not thread-safe unless protected by synchronization.  sourceParserPool is an ArrayList, and normally, it is protected by the synchronized sections in Configuration.  However, when you copy() or copyTo() the object, the you get a single instance of sourceParserPool copied to two instances of Configuration.  So in this case, the synchronization in Configuration is not protecting sourceParserPool at all. 

 

There are a number of transient variables in Configuration, and at least some of them are being copied by copyTo() without deep cloning.  So it looks to me like the use of copyTo() in a threaded application can be the source of numerous threading bugs.    

 

 

We fixed the bug by avoiding copyTo().  Either using a singleton Configuration instance, or creating a new Configuration on each use, appears to make the system stable again immediately.

 

Thanks!

------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help