xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David N Bertoni/Cambridge/IBM <david_n_bert...@us.ibm.com>
Subject Re: rethrowing an exception causes assertion failure (Win32)
Date Fri, 09 Aug 2002 15:13:26 GMT




It's likely you're mixing run-time libraries.  See the FAQ:

   http://xml.apache.org/xerces-c/faq-build.html#faq-11

Dave



                                                                                         
                                               
                      "Barker, Peter"                                                    
                                               
                      <peter.barker@uk.           To:      "'xerces-c-dev@xml.apache.org'"
<xerces-c-dev@xml.apache.org>                 
                      fid-intl.com>               cc:      (bcc: David N Bertoni/Cambridge/IBM)
                                         
                                                  Subject: rethrowing an exception causes
assertion failure (Win32)                      
                      08/09/2002 07:22 AM                                                
                                               
                      Please respond to                                                  
                                               
                      xerces-c-dev                                                       
                                               
                                                                                         
                                               
                                                                                         
                                               



Hello,

I have a problem in my program which I've narrowed down and extracted into
a
small test program below (VC++ console program).

I get the program to cause a parsing exception by creating non XML
compliant
input.
I catch this exception in an ellipsis handler, then call a function which
re-throws it to determine it's correct type. After this completes, I get a
assertion failure BLOCK_TYPE_IS_VALID(pHead->nBlockUse).

I am compiling in DEBUG mode and using the DEBUG version of the Xerces
library. The error doesn't happen if I don't re-throw the exception.

Regards,

Peter Barker

// XercesExceptionTest.cpp : Defines the entry point for the console
application.
//

#include "stdafx.h"
#include "XercesExceptionTest.h"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/DOMParser.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
#include <xercesc/util/XMLException.hpp>         // Required to catch
XMLException
#include <xercesc/dom/DOM_DOMException.hpp>            // Required to catch
DOM_DOMException
#include <xercesc/sax/SAXException.hpp>                      // Required to
catch
SAXException

CWinApp theApp;

void ShowException()
{
             try
             {
                         throw;
             }
             catch(const SAXException& e)
             {
                         char* xCodedMess = XMLString::transcode(e.
getMessage());
                         std::cout << "SAXException: " << xCodedMess <<
std::endl;
                         delete[] xCodedMess;
             }
             catch(const XMLException& e)
             {
                         char* xCodedMess = XMLString::transcode(e.
getMessage());
                         std::cout << "XMLException: " << xCodedMess <<
std::endl;
                         delete[] xCodedMess;
             }
             catch(const DOM_DOMException& e)
             {
                         char* xCodedMess = e.msg.transcode();
                         std::cout << "DOM_DOMException: " << xCodedMess <<
std::endl;
                         delete[] xCodedMess;
             }
}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
             int nRetCode = 0;

             XMLPlatformUtils::Initialize();
             {
                         try
                         {
                                     MemBufInputSource
is(reinterpret_cast<const unsigned
char*>("<fred></freda>"),14,"");

                                     DOMParser parser;
                                     DefaultHandler handler;
                                     parser.setErrorHandler(&handler);
                                     parser.parse(is);
                         }
                         catch(...)
                         {
                                     ShowException();
                         }
             }
             XMLPlatformUtils::Terminate();


             return nRetCode;
}



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





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


Mime
View raw message