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>

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

Reply via email to