xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fredrik" <fred...@cimade.com>
Subject RE: rethrowing an exception causes assertion failure (Win32)
Date Fri, 09 Aug 2002 14:42:14 GMT
We got the same failiure using Xerces 1.5.2 C++, Borland 4.0 and Windows
2000

In the end we had to replace this exception handling and implement a windows
exception handling of this (and some more) exceptions.

-----Mensaje original-----
De: Barker, Peter [mailto:peter.barker@uk.fid-intl.com]
Enviado el: viernes 9 de agosto de 2002 16:22
Para: 'xerces-c-dev@xml.apache.org'
Asunto: rethrowing an exception causes assertion failure (Win32)


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