Xalan 1.5
Xerces 2.3.0
WinXP
VC6 (so service packs I believe).

I built a DLL and under a debug compile I can run it for extended
periods without problems.
As soon as I build a Release version, it always crashes after 5 or 6
runs.
The DLL was also using an API that my company provides.
So I have tried to narrow down the problem into a simple program that
was copied (initially) from the StreamTransform sample.

Now, when I run this with the following XML and XSL:
    char * xml_str =  "<?xml version=\"1.0\"?>\
        <doc>Hello</doc>";

    char * xsl_str = "<?xml version=\"1.0\"?>\
        <xsl:stylesheet
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"; version=\"1.0\">\
        <xsl:template match=\"doc\">\
        <out><xsl:value-of select=\".\"/></out>\
        </xsl:template>\
        </xsl:stylesheet>";

I get the following:
C:\>XalanTransform.exe
xalan_transformGot both input parameters
xalan_transformCreating inputSource
xalan_transformXalanDOMString
xalan_transformx
xalan_transformsetting system id to http://localhost
xalan_transformCreating theXalanTransformer
Assertion failed: manager != 0, file
C:\OpenSrc\xalan\C\xerces-c-src_2_3_0\src\xercesc\util\XMemory.cpp, line
88


Some points to note:
1.  I have compiled both Xalan and Xerces on my machine using VC6 no
service packs.
2.  I had to recompile Xerces, since I was getting compiler errors when
I tried to build Xalan.
3.  This is the FIRST time I am actually getting an assertion, the
behaviour up and to this point was:
            try
            {
                ret = theXalanTransformer.transform(
                        theXMLStream,
                        inputSource,
                        cout
                        );
            }
            catch (exception* e) 
            { 
                if( e->what() != NULL )
                {
                    cerr << "xalan_transform" << e->what() << endl;
                } else {
                    cerr << "xalan_transform" << "Exception text is
empty" << endl;
                }
            }
            catch(...)
            {
                error_msg.append("Error: XalanTransformer threw an
exception - ");
                error_msg.append(theXalanTransformer.getLastError());
                error_msg.append(" - ");
                error_msg.append(xsl);

                cerr << "xalan_transform" << error_msg.c_str() << endl; 

            }

I would fall into the catch(...) block and the
theXalanTransformer.getLastError() would always return a blank string
(very unhelpful).


If anyone can provide some guidance I would really appreciate this.  I
have been trying to debug the release stuff for a month now (on and off)
without success.  My C/C++ skill are novice, but the code is quite
simple.

Here is the cpp and header, this demonstrates the Memory error when
compiled with debug on.

***********************
#ifndef XP_XALANTRANSFORM_H_INCLUDED
#define XP_XALANTRANSFORM_H_INCLUDED

#include <xalanc/XSLT/XSLTInputSource.hpp>
#include <xalanc/XSLT/XSLTResultTarget.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>


#include <string>
#include <iostream>
#include "extfnapi.h"
using namespace std;

int xalan_transform_test( const char *xml, const char *xsl, char *result
);

#endif  // XP_XALANTRANSFORM_H_INCLUDED
***********************

***********************

#include "XalanTransform.hpp"
#include "DLL Debug/extXalandll.h"

#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>

#include <string>
#include <iostream>
#include <strstream>

using namespace std;


int
main(
        int                              argc,
        const char*              argv[])
{
    XALAN_USING_STD(cerr);
    XALAN_USING_STD(cout);
    XALAN_USING_STD(endl);

    char* temp_fname = NULL;
    int             ret        = -1;
    int             msg_level  = 0;
    char           *result = NULL;

    char * xml_str =  "<?xml version=\"1.0\"?>\
        <doc>Hello</doc>";

    char * xsl_str = "<?xml version=\"1.0\"?>\
        <xsl:stylesheet
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"; version=\"1.0\">\
        <xsl:template match=\"doc\">\
        <out><xsl:value-of select=\".\"/></out>\
        </xsl:template>\
        </xsl:stylesheet>";

    ret = xalan_transform_test( xml_str, xsl_str, result );

    if(ret != 0) 
    {
        cerr << "Error: " << endl;
    }

    if( result != NULL ) {
        cout << "Result:\n" << result << endl;
    }

    return ret;

}

int xalan_transform_test( const char *xml, const char *xsl, char *result
)
    /**************************************************/
{
    string          error_msg;
    char        *temp_fname = NULL;
    int         ret = -1;

    XALAN_USING_STD(istrstream);
    XALAN_USING_STD(ofstream);
    XALAN_USING_STD(cerr);
    XALAN_USING_STD(cout);
    XALAN_USING_STD(endl);

    cout << "xalan_transform" << "Got both input parameters" << endl;

    istrstream  theXMLStream(xml, strlen(xml) );
    istrstream  theXSLStream(xsl, strlen(xsl) );

    try
    {
        XALAN_USING_XALAN(XalanDOMString);
        XALAN_USING_XALAN(XSLTInputSource);
        XALAN_USING_XALAN(XalanTransformer);
        XALAN_USING_XERCES(XMLPlatformUtils);

        cout << "xalan_transform" << "Creating inputSource" << endl;

        XSLTInputSource         inputSource(&theXSLStream);

        cout << "xalan_transform" << "XalanDOMString" << endl;
        cout << "xalan_transform" << (char
*)XalanDOMString("xsl").c_str() << endl;

        cout << "xalan_transform" << "setting system id to
http://localhost"; << endl;

        //inputSource.setSystemId(XalanDOMString("xsl").c_str());
 
//inputSource.setSystemId(XalanDOMString("http://localhost";).c_str());

        {
            cout << "xalan_transform" << "Creating theXalanTransformer"
<< endl;
            // Create a XalanTransformer.
            XalanTransformer theXalanTransformer;

            try
            {



                ret = theXalanTransformer.transform(
                        theXMLStream,
                        inputSource,
                        cout
                        //temp_fname
                        //theResultStream
                        );

                cout << "xalan_transform - ret = " << ret << endl;

                if(ret != 0)
                {
                    char ret_str[10];
                    sprintf( ret_str, "%ld", ret );

                    error_msg.append("Error: ret = ");
                    error_msg.append(ret_str);
                    error_msg.append(" - ");
 
error_msg.append(theXalanTransformer.getLastError());
                    error_msg.append(" - ");
                    error_msg.append(xsl);
                    strcpy( result, error_msg.c_str() );

                    cerr << "xalan_transform" << result << endl;

                }

                if(ret == 0)
                {
                    error_msg.append("Temporary file name: ");
                    error_msg.append(temp_fname);
                    cout << "xalan_transform" << error_msg.c_str() <<
endl;
                    strcpy( result, error_msg.c_str() );

                }
            }
            catch (exception* e) 
            { 
                if( e->what() != NULL )
                {
                    cerr << "xalan_transform" << e->what() << endl;
                } else {
                    cerr << "xalan_transform" << "Exception text is
empty" << endl;
                }
            }
            catch(...)
            {
                error_msg.append("Error: XalanTransformer threw an
exception - ");
                error_msg.append(theXalanTransformer.getLastError());
                error_msg.append(" - ");
                error_msg.append(xsl);

                cerr << "xalan_transform" << error_msg.c_str() << endl; 

            }
        }

    }
    catch(...)
    {
        //cerr << "An unknown error occurred!" << endl;
        result      = NULL;
        cerr << "xalan_transform - Error setting Xalan Input Source" <<
endl;
    }



    if( result != NULL )
    {
        cout << "xalan_transform -  Returning" << endl;
    } else {
        cout << "xalan_transform - Returning NULL" << endl;
    }

    return ret;

}
***********************
-- 
David Fishburn
Solutions Architect
Certified Sybase ASA Developer Version 8
iAnywhere Solutions - Sybase

Reply via email to