You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Gilles FILIPPINI <Gi...@edf.fr> on 2000/02/17 09:57:18 UTC

Xerces-C 1.0.1 - Solaris 2.6 - Bus error

Hello,

I encountered a strange Bus Error problem while using Xerces C++ 1.0.1 lib with Solaris 2.6.
It depends on where I put the DOM object declarations into my source code :
- if all the DOM objects a function uses are declared at the beginning of the function => no problem.
- if the DOM objects are declared at the place they are first used in the function, the bus error is very easy to obtain.

With the dbx debugger, the error message is a kind of "signal bus (invalid address aligment)" while in a destructor.
Occasionnaly, it can be a SEGV error.

Here are a source (testxml.cpp) and a xml file (foo.xml) I use to reproduce the problem.
The command line to execute is simply "testxml foo.xml".

Any help appreciated.
Thanks in advance.

- Gilles FILIPPINI.

// ================================================
// testxml.cpp
// Produces a bus error.
// ================================================

#include <util/PlatformUtils.hpp>
#include <dom/DOM.hpp>
#include <parsers/DOMParser.hpp>

#include <iostream.h>

void ReadLevel2(DOM_Node elt);

int main(int argc, char ** argv)
{
	// No bus error if doc (DOM_Document) and nl (DOM_NodeList) are first declared here

	if (argc < 2)
		return 1;
	
	XMLPlatformUtils::Initialize();

	DOMParser       parser;
	parser.parse(argv[1]);
	
	// No bus error if the following statement is commented
	cout << "Hello World\n" << flush;

	DOM_Document    doc     = parser.getDocument();
	if (doc == 0)
		return 2;

	DOM_NodeList    nl      =
		doc.getDocumentElement().getElementsByTagName("Level2");
	for (unsigned int i = 0; i < nl.getLength(); i++) {
		ReadLevel2(nl.item(i));
	}

	return 0;
}

void ReadLevel2(DOM_Node elt)
{
	DOM_TreeWalker  tw      =
		elt.getOwnerDocument().createTreeWalker(elt, DOM_TreeWalker::SHOW_ELEMENT, 0);
}

// ================================================

=======================
foo.xml
=======================

<?xml version='1.0'?>
<Level1>
<Level2/>
</Level1>

=======================

Re: Xerces-C 1.0.1 - Solaris 2.6 - Bus error

Posted by Arundhati Bhowmick <ar...@hyperreal.org>.
I just now tried your sample and it works fine with the latest codebase. I didn't change any of your code except the
parameters of TreeWalker.  Infact there had been lot of changes in TreeWalker and NodeIterator stuff so in case you're using
any of those it'd be advisable to extract the source from cvs and rebuilt it.

Thanks,
Arundhati

Gilles FILIPPINI wrote:

> Hello,
>
> I encountered a strange Bus Error problem while using Xerces C++ 1.0.1 lib with Solaris 2.6.
> It depends on where I put the DOM object declarations into my source code :
> - if all the DOM objects a function uses are declared at the beginning of the function => no problem.
> - if the DOM objects are declared at the place they are first used in the function, the bus error is very easy to obtain.
>
> With the dbx debugger, the error message is a kind of "signal bus (invalid address aligment)" while in a destructor.
> Occasionnaly, it can be a SEGV error.
>
> Here are a source (testxml.cpp) and a xml file (foo.xml) I use to reproduce the problem.
> The command line to execute is simply "testxml foo.xml".
>
> Any help appreciated.
> Thanks in advance.
>
> - Gilles FILIPPINI.
>
> // ================================================
> // testxml.cpp
> // Produces a bus error.
> // ================================================
>
> #include <util/PlatformUtils.hpp>
> #include <dom/DOM.hpp>
> #include <parsers/DOMParser.hpp>
>
> #include <iostream.h>
>
> void ReadLevel2(DOM_Node elt);
>
> int main(int argc, char ** argv)
> {
>         // No bus error if doc (DOM_Document) and nl (DOM_NodeList) are first declared here
>
>         if (argc < 2)
>                 return 1;
>
>         XMLPlatformUtils::Initialize();
>
>         DOMParser       parser;
>         parser.parse(argv[1]);
>
>         // No bus error if the following statement is commented
>         cout << "Hello World\n" << flush;
>
>         DOM_Document    doc     = parser.getDocument();
>         if (doc == 0)
>                 return 2;
>
>         DOM_NodeList    nl      =
>                 doc.getDocumentElement().getElementsByTagName("Level2");
>         for (unsigned int i = 0; i < nl.getLength(); i++) {
>                 ReadLevel2(nl.item(i));
>         }
>
>         return 0;
> }
>
> void ReadLevel2(DOM_Node elt)
> {
>         DOM_TreeWalker  tw      =
>                 elt.getOwnerDocument().createTreeWalker(elt, DOM_TreeWalker::SHOW_ELEMENT, 0);
> }
>
> // ================================================
>
> =======================
> foo.xml
> =======================
>
> <?xml version='1.0'?>
> <Level1>
> <Level2/>
> </Level1>
>
> =======================