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 "AESYS S.p.A. [Enzo Arlati]" <en...@aesys.it> on 2005/09/14 16:38:06 UTC

DOMPrintErrorHandler cause SIGSEGV

In my application when the parser found an error and call the error handler
a SIGSEGV occur.
Belowe I copy the piece of code which can cause the problem.
I'm new on using xerces-c so mybe I forget something.
Can someone help me ?
Regards, Enzo Arlati
enzo.arlati@aesys.it


    XercesDOMParser * domParser;
    DOMPrintErrorHandler * errReporter;
    // -------------------------------------------------------
    domParser = new XercesDOMParser;
    domParser->setValidationScheme( XercesDOMParser::Val_Auto );
    domParser->setDoNamespaces( false );
    domParser->setDoSchema( false );
    domParser->setValidationSchemaFullChecking( false );
    domParser->setCreateEntityReferenceNodes( true );

    errReporter = new DOMPrintErrorHandler();
    domParser->setErrorHandler( (ErrorHandler*)  errReporter );

    string sfile( "/home/enzo/test1.xml" );
    domParser->parse( sfile.c_str() );



where DOMPrintErrorHandler is defined as show belowe:

#ifndef DOMPRINTERRORHANDLER_H
#define DOMPRINTERRORHANDLER_H

#include <xercesc/dom/DOMErrorHandler.hpp>

XERCES_CPP_NAMESPACE_USE

class DOMPrintErrorHandler : public DOMErrorHandler
{

public:
    DOMPrintErrorHandler();
    ~DOMPrintErrorHandler();

    /** @name The error handler interface */
    bool handleError(const DOMError& domError);
    void resetErrors(){};

private :
    /* Unimplemented constructors and operators */
    DOMPrintErrorHandler(const DOMErrorHandler&);
    void operator=(const DOMErrorHandler&);
};

#endif

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

#include "domprinterrorhandler.h"

#include <xercesc/util/XMLString.hpp>
#include <xercesc/dom/DOMError.hpp>
#include <xercesc/dom/DOMLocator.hpp>
#include <xercesc/dom/DOMNode.hpp>
#include <iostream>

#include "ae_util.h"


DOMPrintErrorHandler::DOMPrintErrorHandler()
{
}

DOMPrintErrorHandler::~DOMPrintErrorHandler()
{
}


bool DOMPrintErrorHandler::handleError(const DOMError &domError)
{
    string stmp;
    char buffer[1024];
    char buffer2[1024];
    bool rc;

    MYLOG( "----------------------------------------------------" );

    switch( domError.getSeverity() )
    {
      case DOMError::DOM_SEVERITY_WARNING :
        MYLOG( " [DOMPrintErrorHandler::handleError] warning " );
        rc = true;
        break;

      case DOMError::DOM_SEVERITY_ERROR:
        MYLOG( " [DOMPrintErrorHandler::handleError] error " );
        rc = true;
        break;

      case DOMError::DOM_SEVERITY_FATAL_ERROR:
        MYLOG( " [DOMPrintErrorHandler::handleError] fatal error" );
        rc = false;
        break;

      default:
        MYLOG( " [DOMPrintErrorHandler::handleError] unknown error " );
        rc = false;
    }

    DOMLocator *pLocation = domError.getLocation();

    stmp = ae_util::format_string( "[DOMPrintErrorHandler::handleError]
Location line=%d column=%d ooffset=%d",
                                    pLocation->getLineNumber(),
                                    pLocation->getColumnNumber(),
                                    pLocation->getOffset());
    MYLOG( stmp );

    DOMNode *pDomNode = pLocation->getErrorNode();
    XMLString::transcode(pDomNode->getNodeName(), buffer, 1023);
    XMLString::transcode(pLocation->getURI(), buffer2, 1023);
    stmp = ae_util::format_string( "[DOMPrintErrorHandler::handleError]
Nodo=%s  URI=%s",
                                    buffer, buffer2 );
    MYLOG( stmp );
    MYLOG( "----------------------------------------------------" );

    return rc;

}   // ____________  DOMPrintErrorHandler::handleError



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


R: DOMPrintErrorHandler cause SIGSEGV

Posted by "AESYS S.p.A. [Enzo Arlati]" <en...@aesys.it>.
I have also try with an empty function, but the sigsev still persist.
bool DOMPrintErrorHandler::handleError(const DOMError &domError)
{
    return true;
}

It seems that it is generated before or during the function call.

I check the standard example DOMPrint and I see it uses two errorHandler.
"class DOMTreeErrorReporter : public ErrorHandler" are used while parsing a
file
    XercesDOMParser *parser = new XercesDOMParser;
    ............
    DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
    parser->setErrorHandler(errReporter);
and
"class DOMPrintErrorHandler : public DOMErrorHandler" are used while writing
a file
            DOMErrorHandler *myErrorHandler = new DOMPrintErrorHandler();
            theSerializer->setErrorHandler(myErrorHandler);

mybe taht my mystake were to use the wrong error handler , I used
DOMPrintErrorHandler also for parsing a file.

BTW: there are somewhere more deeper documentation on xerces-c, the ones on
the apache site is really poor.

-----Messaggio originale-----
Da: Axel Weiß [mailto:aweiss@informatik.hu-berlin.de]
Inviato: mercoledì 14 settembre 2005 18.04
A: c-dev@xerces.apache.org
Oggetto: Re: DOMPrintErrorHandler cause SIGSEGV


AESYS S.p.A. [Enzo Arlati] schrieb:
> In my application when the parser found an error and call the error
> handler a SIGSEGV occur.
> Belowe I copy the piece of code which can cause the problem.
> I'm new on using xerces-c so mybe I forget something.
> Can someone help me ?

Hi Enzo,

your code looks rather sane - the only thing I'd mention here is to check
the return value of domError.getLocation() against NULL, e.g.

>     DOMLocator *pLocation = domError.getLocation();
      if (pLocation != NULL){
>
>     stmp = ae_util::format_string(
> "[DOMPrintErrorHandler::handleError] Location line=%d column=%d
> ooffset=%d",
>                                     pLocation->getLineNumber(),
>                                     pLocation->getColumnNumber(),
>                                     pLocation->getOffset());
>     MYLOG( stmp );
>
>     DOMNode *pDomNode = pLocation->getErrorNode();
>     XMLString::transcode(pDomNode->getNodeName(), buffer, 1023);
>     XMLString::transcode(pLocation->getURI(), buffer2, 1023);
      }
      else{
         MYLOG( "(sorry, no location object)" );
      }

Does this help?
			Axel

--
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **

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



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


Re: DOMPrintErrorHandler cause SIGSEGV

Posted by Axel Weiß <aw...@informatik.hu-berlin.de>.
AESYS S.p.A. [Enzo Arlati] schrieb:
> In my application when the parser found an error and call the error
> handler a SIGSEGV occur.
> Belowe I copy the piece of code which can cause the problem.
> I'm new on using xerces-c so mybe I forget something.
> Can someone help me ?

Hi Enzo,

your code looks rather sane - the only thing I'd mention here is to check 
the return value of domError.getLocation() against NULL, e.g.

>     DOMLocator *pLocation = domError.getLocation();
      if (pLocation != NULL){
>
>     stmp = ae_util::format_string(
> "[DOMPrintErrorHandler::handleError] Location line=%d column=%d
> ooffset=%d",
>                                     pLocation->getLineNumber(),
>                                     pLocation->getColumnNumber(),
>                                     pLocation->getOffset());
>     MYLOG( stmp );
>
>     DOMNode *pDomNode = pLocation->getErrorNode();
>     XMLString::transcode(pDomNode->getNodeName(), buffer, 1023);
>     XMLString::transcode(pLocation->getURI(), buffer2, 1023);
      }
      else{
         MYLOG( "(sorry, no location object)" );
      }

Does this help?
			Axel

-- 
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **

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


Re: DOMPrintErrorHandler cause SIGSEGV

Posted by "Jeroen N. Witmond" <jn...@xs4all.nl>.
>
> In my application when the parser found an error and call the error
> handler
> a SIGSEGV occur.
> Belowe I copy the piece of code which can cause the problem.
> I'm new on using xerces-c so mybe I forget something.
> Can someone help me ?

You can
- tell us on what platform (hardware, OS, etc.) you are running xerces.
The following assumes you are running GNU/Linux, as you mentioned SIGSEGV.
- reduce your program, xml and schema to the minimum needed to reproduce
the problem.
- compile your code and xerces with production of debugging information
using the gcc -g flag.
- use a debugger (e.g. gdb) to determine (while running or from a core
dump) on what source line the error occurs.
- copy or attach the output of the program to your next email.

Jeroen.



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