xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Ramponi" <aramp...@astrocenter.com>
Subject Re: cloneNode Bug ?
Date Mon, 05 Feb 2001 15:05:44 GMT

Hi,
It seems that my problem had nothing to do with multithreading.
For example, the following program craches (Win2K + Xerces 1.4 + VC++ 6) after
the 798 th call to cloneNode, just after printing "growing... " on stderr.

NodeIDMap::add(AttrImpl * 0x00a00d10) line 117 + 12 bytes
NodeIDMap::growTable() line 263
NodeIDMap::add(AttrImpl * 0x00a00eb8) line 110
AttrImpl::AttrImpl(const AttrImpl & {...}, unsigned char 0x01) line 119
AttrImpl::cloneNode(unsigned char 0x01) line 170 + 44 bytes
NamedNodeMapImpl::cloneContent(NamedNodeMapImpl * 0x00a21b60) line 446 + 13
bytes
AttrMapImpl::cloneAttrMap(NodeImpl * 0x00a24eb8) line 95
ElementImpl::ElementImpl(const ElementImpl & {...}, unsigned char 0x01) line 90
+ 21 bytes
ElementImpl::cloneNode(unsigned char 0x01) line 106 + 44 bytes
DOM_Node::cloneNode(unsigned char 0x01) line 185 + 21 bytes
main(int 0x00000002, char * * 0x00794478) line 38 + 68 bytes
mainCRTStartup() line 338 + 17 bytes
KERNEL32! 77e87903()

I don't understand why the symbol table is growing, simply by calling the
cloneNode function.
That problem does not occure whithout dtd.


Can anyone help ?
Thanks

Antoine

clonetest.cpp
-----------------------------------------------

#include <stdio.h>
#include <parsers/DOMParser.hpp>
#include <util/PlatformUtils.hpp>

#include <dom/DOM.hpp>

int main (int argc, char **argv)
{
	if (argc < 2) {
		fprintf(stderr, "usage clonetest xmlfile");
		return 1;
	}
    char *fileName = argv[1];
    try
    {
         XMLPlatformUtils::Initialize();
    }
    catch (...)
    {
        fprintf(stderr, "Exception from XMLPlatfromUtils::Initialize.\n");
        return 1;
    }
	DOM_Document doc;
	DOMParser parser;
    parser.parse(fileName);
    doc = parser.getDocument();

	while(1) {
		DOM_NodeList nodes = doc.getElementsByTagName("question_group");
		for (unsigned int i = 0; i < nodes.getLength(); i++) {
			nodes.item(i).cloneNode(true);
		}
	}

    return 0;
}

test.xml
-------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE document [
	<!ELEMENT answer (item+)>
	<!ELEMENT document (question_list*)>
	<!ELEMENT item (#PCDATA)>
	<!ELEMENT question (answer*)>
	<!ATTLIST question
	id ID #REQUIRED
>
	<!ELEMENT question_group (question+)>
	<!ATTLIST question_group
	id ID #REQUIRED
>
	<!ELEMENT question_list (question_group+)>
]>
<!-- <!DOCTYPE document SYSTEM "test.dtd"> -->
<document>
	<question_list>
		<question_group id="qg1">
			<question id="q1">
				<answer>
					<item>item</item>
				</answer>
			</question>
		</question_group>
	</question_list>
</document>






> Antoine Ramponi wrote:
>
> > Hi,
> >
> > The problem : an "Access Violation", occures during a cloneNode on the
> same DOM_Document  shared by multiple threads.
>
>
> Are those multiple threads trying to access the same DOM_Document at the
> same time?  The parser has the following restriction:
>
>   Multiple document instances may be concurrently accessed from different
>   threads, but any given document instance can only be accessed by one
>   thread at a time.
>
> See http://xml.apache.org/xerces-c/faq-parse.html#faq-5 for more
> multi-thread details.
>
> Tinny


Mime
View raw message