zhaopuming / quickfast

Automatically exported from code.google.com/p/quickfast
Other
1 stars 0 forks source link

Default copy constructor of XMLTemplateParser not calling XMLPlatformUtils::Initialize() #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As designed, the constructor for XMLTemplateParser calls 
XMLPlatformUtils::Initialize().  However, no copy constructor has been defined 
for XMLTemplateParser.  This becomes an issue in boost::thread, for example, 
where the copy constructor is used to pass a parameter to a new thread.  In 
this case, when the thread terminates, the parser destructor will call 
::Terminate() without having called ::Initialize(), and you get a crash.

The copy constructor for XMLTemplateParser should also call 
XMLPlatformUtils::Initialize(), I believe.

Original issue reported on code.google.com by da...@optionmetrics.com on 5 Oct 2010 at 4:17

GoogleCodeExporter commented 9 years ago
You shouldn't need to copy an XMLTemplateParser.  The design intent is to parse 
the templates once into a template registry and share them among all threads 
that need them.   The TemplateRegistryPtr can be safely copied and used by 
multiple threads.

With that in mind, I am considering addressing this issue by defining a private 
copy construction and a private assignment operator for XMLTemplateParser to 
disallow copying, but before I do so, I want to let you make a case for 
supporting copying of the parser.

PS: I haven't checked to see if Xerces is thread-safe.  Parsing templates in 
multiple threads simultaneously could be iffy.

Dale

Original comment by dale.wil...@gmail.com on 5 Oct 2010 at 3:01

GoogleCodeExporter commented 9 years ago
Disabling copy construction sounds like a reasonable way to go, along with a 
note in the docs about the dangers of multithreaded template parsing.

Original comment by da...@optionmetrics.com on 5 Oct 2010 at 3:29

GoogleCodeExporter commented 9 years ago
Done:  R447

Original comment by dale.wil...@gmail.com on 5 Oct 2010 at 6:51