I'm seeing a crash inside XalanTransformer.parseSource(), using an error handler that throws exceptions. My test case runs fine in debug build, but the release build crashes. Platform - linux/g++3.0, Xerces 2.2, Xalan 1.5.
Can anyone reproduce this? Any ideas/workarounds? Here is the program output, with source below - 1) Runs correctly with valid xml, debug build: $ ./crash_test "<root><hello>world</hello></root>" Compiling stylesheet... Parsing source: <root><hello>world</hello></root> Transforming.... output: <?xml version="1.0" encoding="UTF-8"?> <greetings>world</greetings> 2) Runs correctly with invalid xml, debug build: $ ./crash_test "<root<hello>world</hello></root>" Compiling stylesheet... Parsing source: <root<hello>world</hello></root> SAXFatalError! parseSource(): Unterminated start tag, 'root' exiting... 3) Fails (exception not caught) with invalid xml, release build: $ ./crash_test "<root<hello>world</hello></root>" Compiling stylesheet... Parsing source: <root<hello>world</hello></root> SAXFatalError! Aborted --- #include <xercesc/sax2/DefaultHandler.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <XalanTransformer/XalanTransformer.hpp> #include <iostream> #include <sstream> #include <stdexcept> class ExceptionErrorHandler : public xercesc::DefaultHandler { public: void warning(const xercesc::SAXParseException& e){ std::cerr<<"SAXWarning\n"; char* p = xercesc::XMLString::transcode(e.getMessage()); std::runtime_error se(p); delete []p; throw se;} void error(const xercesc::SAXParseException& e){ std::cerr<<"SAXError\n"; char* p = xercesc::XMLString::transcode(e.getMessage()); std::runtime_error se(p); delete []p; throw se;} void fatalError(const xercesc::SAXParseException& e){ std::cerr<<"SAXFatalError!\n"; char* p = xercesc::XMLString::transcode(e.getMessage()); std::runtime_error se(p); delete []p; throw se;} }; int main(int argc, char** argv) { xercesc::XMLPlatformUtils::Initialize(); xalanc::XalanTransformer::initialize(); ExceptionErrorHandler err; xalanc::XalanTransformer t; t.setErrorHandler(&err); std::istringstream xml(argv[1]); std::istringstream xsl("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/" "1999/XSL/Transform\" version =\"1.0\">\n" "<xsl:template match=\"/root\">\n" "<greetings>" "<xsl:value-of select=\"hello\"/>\n" "</greetings>" "</xsl:template>\n" "</xsl:stylesheet\n>"); const xalanc::XSLTInputSource xsl_input(&xsl); const xalanc::XalanCompiledStylesheet* compiled_xsl; std::cout<<"Compiling stylesheet..."<<std::endl; try{ t.compileStylesheet(xsl_input, compiled_xsl); } catch(const std::exception& e){ std::cerr<<"compileStylesheet(): "<<e.what()<<"\nexiting...\n"; exit(1); } const xalanc::XSLTInputSource xml_input(xml); const xalanc::XalanParsedSource* parsed_source = 0; std::cout<<"Parsing source: "<<xml.str()<<std::endl; try{ t.parseSource(xml_input, parsed_source); } catch(const std::exception& e){ std::cerr<<"parseSource(): "<<e.what()<<"\nexiting...\n"; exit(1); } std::ostringstream output; xalanc::XSLTResultTarget target(output); std::cout<<"Transforming...."<<std::endl; try{ t.transform(*parsed_source, compiled_xsl, target); } catch(const std::exception& e){ std::cerr<<"transform(): "<<e.what()<<"\nexiting...\n"; } std::cout<<"output:\n"<<output.str()<<std::endl; } --- Thanks, Steve