Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-11

XML DOM thread safety

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Inoussa OUEDRAOGO

Hi

I would like to point out ( again, the third time ) that up to now ( I just checked out 2.4-rc1 and trunk ) there is _no safe_ way to use the "fcl-xml" package in a multi threaded environment. I mean, even if your xml DOM instances are private to
their thread, _not accessed_ by other threads, used independently, still you are not safe.

This situation is due to the dependency
of the DOM implementation, specifically the "TDOMNode_WithChildren", upon the "TAVLTree" class ( see fcl-base\avl_tree.pp ). "TAVLTree" _by default_ uses a _shared not protected_ node manager and that has the consequence that every code
that depend on this class is fundamentally not thread safe.

Because of this, one cannot do serious enterprise server side development with FPC 2.2.x without patching
the base packages, and this is causing serious threats to FPC. Please consider removing the TAVLTree dependency as
proposed by Sergei Gorelkin or use, by default, a thread safe node manager. I can provide a patch( as I already did ) for a default thread safe node manager that does not pooled the objects. Note that Marco van de Voort provided and applied a patch that allow the change of an instance node manager, but that does not address the base problem of the default usage.

I do think that an implementation optimization does not have to make a _default_ usage of a class not safe. More over a
basic data structure that is used by other base classes in the _default_ way.

It will be very disappointing and sad to see another FPC release with this problem.

PS : More infos about the thread safety
Given :
* 2 threads , ThreadA and ThreadB, each thread having an instance of TDOMDocument
* The threads does not communicate
* The treads are not aware one about the other
* each thread access _only_ its _own_ instance of TDOMDocument still, you are not safe. The problem is present even if no instance is shared.

Best regards.

Inoussa O.

Reply by email

Inoussa OUEDRAOGO
to Sergei Gorelkin

2009/11/11 Sergei Gorelkin :

Show quoted text 6 lines
Inoussa OUEDRAOGO пишет: (a long message skipped) Rather that writing that much, you'd better simply bug me to speed it up :-) Anyway, done in r14145.

Thank you very much !
I will now call for a merge for FPC 2.4.

Again, Thank you very much !

Inoussa O.

Reply by email