You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by y_...@tsmc.com on 2008/12/09 02:41:13 UTC

MemBufInputSource core dump problem

Dear Alberto :
                  I use xerces for parsing XML String , I found some
question in my test

                 platform : IBM AIX 5.2
                 complier : IBM VA C++
                 xerces version : 2-8-0

                Q1. xerces can support multi-thread ?  ( I found answer in
xerces faq from http://xerces.apache.org/xerces-c/faq-parse-3.html#faq-6 )
                      need you double confirm

                Q2. In my function , always core dump in ( new
MemBufInputSource )
                      I use C++ while function for test xerces have memory
leak

                Q3. If I use C++ delete function delete xerces object ,
                       why xerces still have memory leak  ?

                Q4. MemBufInputSource have limit  usage ?


                attach file is my function


Source Code
=========================================================================================
try
{
    XMLPlatformUtils::Initialize();

    PPT_METHODTRACE_V1( "" , "================== Now Starting Parse XML
==================" ) ;
    string XMLString = (const char * )xmlContextInfoSeq[i].xmlContext ;
    string parseString = "";
    PPT_METHODTRACE_V2( "" , " XMLString :" , XMLString.c_str() );

    string bufferId = "prodInfo" ;
    MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager;
    MemoryManager* const manager2 = XMLPlatformUtils::fgMemoryManager;

    MemBufInputSource* memBufIS = new MemBufInputSource ((const
XMLByte*)XMLString.c_str(),

strlen(XMLString.c_str()),
                                                         bufferId.c_str(),
                                                         false,
                                                         manager2
                                                         );

    DOMInputSource * inSource = new Wrapper4InputSource(memBufIS,true,
manager);
    DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(X(""));

    DOMBuilder* parser = ((DOMImplementationLS*)impl)->
createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);

    DOMDocument* xmlDoc;
    xmlDoc =  parser->parse(*inSource);
    DOMElement * root = xmlDoc->getDocumentElement();
    DOMNodeList * list = xmlDoc->getElementsByTagName(X("ObjInfo"));

    //=============================//
    //  XMLSize_t Use Size_t       //
    //  default start from value 0 //
    //=============================//
    for ( XMLSize_t index_Attr = 0 ; index_Attr < list->getLength() ;
index_Attr++ )
    {
        DOMElement * elem =
static_cast<DOMElement*>(list->item(index_Attr)) ;
        string lot_id = "" ;
        string eqp_id = "" ;
        string value = "" ;

        objectIdentifier mem_control ;
        const XMLCh * tmpxmlch = elem->getAttribute(X("ObjType"));
        mem_control.identifier = XMLString::transcode(tmpxmlch);
        value = (const char *)mem_control.identifier ;

        PPT_METHODTRACE_V2( "" , " Objtype value :" , value.c_str() );

        if ( value == "Equipment" )
        {
            objectIdentifier mem_control2 ;
            const XMLCh * tmpxmlch2 = elem->getAttribute(X("Value"));
            mem_control2.identifier = XMLString::transcode(tmpxmlch2);
            eqp_id = (const char *)mem_control2.identifier;
            PPT_METHODTRACE_V2( "" , " eqp_id :" , eqp_id.c_str() );
            setIDLstring(strObjXMLparse_out.strXMLvalueSeq[i].eqpID ,
eqp_id ) ;
            PPT_METHODTRACE_V2( "" , "
strObjXMLparse_out.strXMLvalueSeq[i].eqpID " ,
strObjXMLparse_out.strXMLvalueSeq[i].eqpID );
        }
        else if ( value == "Lot" )
        {
            objectIdentifier mem_control3 ;
            const XMLCh * tmpxmlch3 = elem->getAttribute(X("Value")) ;
            mem_control3.identifier = XMLString::transcode(tmpxmlch3);
            lot_id = (const char *)mem_control3.identifier ;
            PPT_METHODTRACE_V2( "" , " lot_id :" , lot_id.c_str() );
            setIDLstring(strObjXMLparse_out.strXMLvalueSeq[i].lotID,lot_id)
;
            PPT_METHODTRACE_V2( "" , "
strObjXMLparse_out.strXMLvalueSeq[i].lotID " ,
strObjXMLparse_out.strXMLvalueSeq[i].lotID );
        }

    }
    delete inSource ;
    delete parser ;

}
catch (const XMLException& toCatch)
{
    char* message = XMLString::transcode(toCatch.getMessage());
    PPT_METHODTRACE_V2( "" , "Error during initialization :" , message );
    XMLString::release(&message);
    return 1;
}

XMLPlatformUtils::Terminate();

PPT_METHODTRACE_V1( "" , "================== Now Ending Parse XML
==================" ) ;

======================================================================================
Please help to check for me.
Thanks in advance.


Best Regards, Sincerely
Gervin Wu


 --------------------------------------------------------------------------- 
                                                         TSMC PROPERTY       
 This email communication (and any attachments) is proprietary information   
 for the sole use of its                                                     
 intended recipient. Any unauthorized review, use or distribution by anyone  
 other than the intended                                                     
 recipient is strictly prohibited.  If you are not the intended recipient,   
 please notify the sender by                                                 
 replying to this email, and then delete this email and any copies of it     
 immediately. Thank you.                                                     
 ---------------------------------------------------------------------------