You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by James Fitzgerald <ji...@cisco.com> on 2005/03/01 22:23:36 UTC

GrammarPools thread safe?

I am experimenting with the GrammarPool code and
threads and am getting a crash.

I create an XMLGrammarPool object and populate it
with my schema. I lock it. I create 2 threads,
instantiate a SAX2 parser in each thread and pass each
the same pool and parse and validate a document in each
thread. It crashes with a SEGV but runs fine when run
in a single thread at a time.

(gdb) bt
#0  0xb7d053cd in 
xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>::findNext() 
(this=0x90cd348) at RefHash2KeysTableOf.c:549
#1  0xb7d0643b in 
xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>::Reset() 
(this=0x90cd348) at RefHash2KeysTableOf.c:515
#2  0xb7dd0954 in xercesc_2_6::SchemaAttDefList::Reset() (this=0x90cd320)
     at SchemaAttDefList.cpp:166
#3  0xb7d02998 in xercesc_2_6::ComplexTypeInfo::getAttDefList() const (
     this=0x90cd040) at ComplexTypeInfo.cpp:433
#4  0xb7d93100 in getAttDefList (isSchemaGrammar=true, currType=0x90cd040,
     elemDecl=0x922bf98) at IGXMLScanner2.cpp:3207
#5  0xb7d8cff5 in 
xercesc_2_6::IGXMLScanner::buildAttList(xercesc_2_6::RefVectorOf<xercesc_2_6::KVStringPair> 
const&, unsigned, xercesc_2_6::XMLElementDecl*, 
xercesc_2_6::RefVectorOf<xercesc_2_6::XMLAttr>&) (this=0x80a2b10,
     providedAttrs=@0x9a4d948, attCount=0, elemDecl=0x922bf98,
     toFill=@0x983c1e0) at IGXMLScanner2.cpp:717
#6  0xb7d9ab8a in xercesc_2_6::IGXMLScanner::scanStartTagNS(bool&) (
     this=0x80a2b10, gotData=@0xb72fd64b) at IGXMLScanner.cpp:2716
#7  0xb7d96aab in xercesc_2_6::IGXMLScanner::scanContent() (this=0x80a2b10)
     at IGXMLScanner.cpp:886
#8  0xb7d94d4a in 
xercesc_2_6::IGXMLScanner::scanDocument(xercesc_2_6::InputSource const&) 
(this=0x80a2b10, src=@0x97b9700) at IGXMLScanner.cpp:204
#9  0xb7dc6e07 in 
xercesc_2_6::SAX2XMLReaderImpl::parse(xercesc_2_6::InputSource const&) 
(this=0x83c4c50, source=@0x97b9700) at SAX2XMLReaderImpl.cpp:647
#10 0x0804f9fb in SAXProcessor::parse() (this=0x97b9700) at 
SAXProcessor.cpp:60
#11 0x08050344 in client_thread(void*) (t=0x807a208) at prox.cpp:210
#12 0xb7fc42b6 in start_thread () from /lib/tls/libpthread.so.0
(gdb) l
544         //
545         //  If there is a current element, move to its next element. 
If this
546         //  hits the end of the bucket, the next block will handle 
the rest
547         //
548         if (fCurElem)
549             fCurElem = fCurElem->fNext;
550
(gdb) p fCurElem
warning: can't find class named 
`xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 
as given by C++ RTTI
$1 = (RefHash2KeysTableBucketElem<xercesc_2_6::SchemaAttDef> *) 0x90cda48
(gdb) p *fCurElem
warning: can't find class named 
`xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 
as given by C++ RTTI
$2 = {<XMemory> = {<No data fields>}, fData = 0x90cd968, fNext = 0x90cd300,
   fKey1 = 0x90cda00, fKey2 = 6}
(gdb)
(gdb) p *fCurElem->fNext
warning: can't find class named 
`xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 
as given by C++ RTTI
$3 = {<XMemory> = {<No data fields>}, fData = 0x90cd1a8, fNext = 0x0,
   fKey1 = 0x90cd240, fKey2 = 6}
(gdb)


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: GrammarPools thread safe?

Posted by Khaled Noaman <kn...@ca.ibm.com>.
In general the grammar pool implementation in xerces-c is not thread safe 
(i,e. access/storage of grammars). However, once a grammar is fully 
validated and stored, it needs to be immutable. So, it seems that we have 
a thread safety problem with the attributes list access. I'm looking into 
the problem.

Khaled





Gareth Reakes <ga...@parthenoncomputing.com> 
03/02/2005 04:09 AM
Please respond to
xerces-c-dev


To
xerces-c-dev@xml.apache.org
cc

Subject
Re: GrammarPools thread safe?






Hey,

                 There have been a couple of bugs in Bugzilla relating to 
thread safety 
of the grammars. I have not looked at them as yet. Khaled, are you out 
there? Have you looked at the bugs?


Gareth

James Fitzgerald wrote:
> 
> I am experimenting with the GrammarPool code and
> threads and am getting a crash.
> 
> I create an XMLGrammarPool object and populate it
> with my schema. I lock it. I create 2 threads,
> instantiate a SAX2 parser in each thread and pass each
> the same pool and parse and validate a document in each
> thread. It crashes with a SEGV but runs fine when run
> in a single thread at a time.
> 
> (gdb) bt
> #0  0xb7d053cd in 
> 
xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>::findNext() 

> (this=0x90cd348) at RefHash2KeysTableOf.c:549
> #1  0xb7d0643b in 
> 
xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>::Reset() 

> (this=0x90cd348) at RefHash2KeysTableOf.c:515
> #2  0xb7dd0954 in xercesc_2_6::SchemaAttDefList::Reset() 
(this=0x90cd320)
>     at SchemaAttDefList.cpp:166
> #3  0xb7d02998 in xercesc_2_6::ComplexTypeInfo::getAttDefList() const (
>     this=0x90cd040) at ComplexTypeInfo.cpp:433
> #4  0xb7d93100 in getAttDefList (isSchemaGrammar=true, 
currType=0x90cd040,
>     elemDecl=0x922bf98) at IGXMLScanner2.cpp:3207
> #5  0xb7d8cff5 in 
> 
xercesc_2_6::IGXMLScanner::buildAttList(xercesc_2_6::RefVectorOf<xercesc_2_6::KVStringPair> 

> const&, unsigned, xercesc_2_6::XMLElementDecl*, 
> xercesc_2_6::RefVectorOf<xercesc_2_6::XMLAttr>&) (this=0x80a2b10,
>     providedAttrs=@0x9a4d948, attCount=0, elemDecl=0x922bf98,
>     toFill=@0x983c1e0) at IGXMLScanner2.cpp:717
> #6  0xb7d9ab8a in xercesc_2_6::IGXMLScanner::scanStartTagNS(bool&) (
>     this=0x80a2b10, gotData=@0xb72fd64b) at IGXMLScanner.cpp:2716
> #7  0xb7d96aab in xercesc_2_6::IGXMLScanner::scanContent() 
(this=0x80a2b10)
>     at IGXMLScanner.cpp:886
> #8  0xb7d94d4a in 
> xercesc_2_6::IGXMLScanner::scanDocument(xercesc_2_6::InputSource const&) 

> (this=0x80a2b10, src=@0x97b9700) at IGXMLScanner.cpp:204
> #9  0xb7dc6e07 in 
> xercesc_2_6::SAX2XMLReaderImpl::parse(xercesc_2_6::InputSource const&) 
> (this=0x83c4c50, source=@0x97b9700) at SAX2XMLReaderImpl.cpp:647
> #10 0x0804f9fb in SAXProcessor::parse() (this=0x97b9700) at 
> SAXProcessor.cpp:60
> #11 0x08050344 in client_thread(void*) (t=0x807a208) at prox.cpp:210
> #12 0xb7fc42b6 in start_thread () from /lib/tls/libpthread.so.0
> (gdb) l
> 544         //
> 545         //  If there is a current element, move to its next element. 

> If this
> 546         //  hits the end of the bucket, the next block will handle 
> the rest
> 547         //
> 548         if (fCurElem)
> 549             fCurElem = fCurElem->fNext;
> 550
> (gdb) p fCurElem
> warning: can't find class named 
> `xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 

> as given by C++ RTTI
> $1 = (RefHash2KeysTableBucketElem<xercesc_2_6::SchemaAttDef> *) 
0x90cda48
> (gdb) p *fCurElem
> warning: can't find class named 
> `xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 

> as given by C++ RTTI
> $2 = {<XMemory> = {<No data fields>}, fData = 0x90cd968, fNext = 
0x90cd300,
>   fKey1 = 0x90cda00, fKey2 = 6}
> (gdb)
> (gdb) p *fCurElem->fNext
> warning: can't find class named 
> `xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 

> as given by C++ RTTI
> $3 = {<XMemory> = {<No data fields>}, fData = 0x90cd1a8, fNext = 0x0,
>   fKey1 = 0x90cd240, fKey2 = 6}
> (gdb)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                  http://www.parthcomp.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org



Re: GrammarPools thread safe?

Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hey,

	There have been a couple of bugs in Bugzilla relating to thread safety 
of the grammars. I have not looked at them as yet. Khaled, are you out 
there? Have you looked at the bugs?


Gareth

James Fitzgerald wrote:
> 
> I am experimenting with the GrammarPool code and
> threads and am getting a crash.
> 
> I create an XMLGrammarPool object and populate it
> with my schema. I lock it. I create 2 threads,
> instantiate a SAX2 parser in each thread and pass each
> the same pool and parse and validate a document in each
> thread. It crashes with a SEGV but runs fine when run
> in a single thread at a time.
> 
> (gdb) bt
> #0  0xb7d053cd in 
> xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>::findNext() 
> (this=0x90cd348) at RefHash2KeysTableOf.c:549
> #1  0xb7d0643b in 
> xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>::Reset() 
> (this=0x90cd348) at RefHash2KeysTableOf.c:515
> #2  0xb7dd0954 in xercesc_2_6::SchemaAttDefList::Reset() (this=0x90cd320)
>     at SchemaAttDefList.cpp:166
> #3  0xb7d02998 in xercesc_2_6::ComplexTypeInfo::getAttDefList() const (
>     this=0x90cd040) at ComplexTypeInfo.cpp:433
> #4  0xb7d93100 in getAttDefList (isSchemaGrammar=true, currType=0x90cd040,
>     elemDecl=0x922bf98) at IGXMLScanner2.cpp:3207
> #5  0xb7d8cff5 in 
> xercesc_2_6::IGXMLScanner::buildAttList(xercesc_2_6::RefVectorOf<xercesc_2_6::KVStringPair> 
> const&, unsigned, xercesc_2_6::XMLElementDecl*, 
> xercesc_2_6::RefVectorOf<xercesc_2_6::XMLAttr>&) (this=0x80a2b10,
>     providedAttrs=@0x9a4d948, attCount=0, elemDecl=0x922bf98,
>     toFill=@0x983c1e0) at IGXMLScanner2.cpp:717
> #6  0xb7d9ab8a in xercesc_2_6::IGXMLScanner::scanStartTagNS(bool&) (
>     this=0x80a2b10, gotData=@0xb72fd64b) at IGXMLScanner.cpp:2716
> #7  0xb7d96aab in xercesc_2_6::IGXMLScanner::scanContent() (this=0x80a2b10)
>     at IGXMLScanner.cpp:886
> #8  0xb7d94d4a in 
> xercesc_2_6::IGXMLScanner::scanDocument(xercesc_2_6::InputSource const&) 
> (this=0x80a2b10, src=@0x97b9700) at IGXMLScanner.cpp:204
> #9  0xb7dc6e07 in 
> xercesc_2_6::SAX2XMLReaderImpl::parse(xercesc_2_6::InputSource const&) 
> (this=0x83c4c50, source=@0x97b9700) at SAX2XMLReaderImpl.cpp:647
> #10 0x0804f9fb in SAXProcessor::parse() (this=0x97b9700) at 
> SAXProcessor.cpp:60
> #11 0x08050344 in client_thread(void*) (t=0x807a208) at prox.cpp:210
> #12 0xb7fc42b6 in start_thread () from /lib/tls/libpthread.so.0
> (gdb) l
> 544         //
> 545         //  If there is a current element, move to its next element. 
> If this
> 546         //  hits the end of the bucket, the next block will handle 
> the rest
> 547         //
> 548         if (fCurElem)
> 549             fCurElem = fCurElem->fNext;
> 550
> (gdb) p fCurElem
> warning: can't find class named 
> `xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 
> as given by C++ RTTI
> $1 = (RefHash2KeysTableBucketElem<xercesc_2_6::SchemaAttDef> *) 0x90cda48
> (gdb) p *fCurElem
> warning: can't find class named 
> `xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 
> as given by C++ RTTI
> $2 = {<XMemory> = {<No data fields>}, fData = 0x90cd968, fNext = 0x90cd300,
>   fKey1 = 0x90cda00, fKey2 = 6}
> (gdb)
> (gdb) p *fCurElem->fNext
> warning: can't find class named 
> `xercesc_2_6::RefHash2KeysTableOfEnumerator<xercesc_2_6::SchemaAttDef>', 
> as given by C++ RTTI
> $3 = {<XMemory> = {<No data fields>}, fData = 0x90cd1a8, fNext = 0x0,
>   fKey1 = 0x90cd240, fKey2 = 6}
> (gdb)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                  http://www.parthcomp.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org