[ 
http://issues.apache.org/jira/browse/XERCESC-1554?page=comments#action_12363436 
] 

David Bertoni commented on XERCESC-1554:
----------------------------------------

The bugs appear to be in your code, not in Xerces-C.

You should not delete the document by called DOMDocument::release() unless you 
own the document, which you do not.  Here's the what the documentation for 
DOMBuilder::parse() looks like:

    /**
      * Parse via an input source object
      *
      * This method invokes the parsing process on the XML file specified
      * by the DOMInputSource parameter. This API is borrowed from the
      * SAX Parser interface.
      *
      * The parser owns the returned DOMDocument.  It will be deleted
      * when the parser is released.
      *
      * <p><b>"Experimental - subject to change"</b></p>
      *
      * @param source A const reference to the DOMInputSource object which
      *               points to the XML file to be parsed.
      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
      *         and populated DOMDocument is returned. If the DOMBuilder is
      *         asynchronous then <code>null</code> is returned since the
      *         document object is not yet parsed when this method returns.
      * @exception SAXException Any SAX exception, possibly
      *            wrapping another exception.
      * @exception XMLException An exception from the parser or client
      *            handler code.
      * @exception DOMException A DOM exception as per DOM spec.
      *
      * @see DOMInputSource#DOMInputSource
      * @see #setEntityResolver
      * @see #setErrorHandler
      * @see resetDocumentPool
      * @since DOM Level 3
      */

Notice especially the following text:

      * The parser owns the returned DOMDocument.  It will be deleted
      * when the parser is released.

The crash occurs when the DOMBuilder instance tries to release a DOMDocument 
instance you've already released.

The second crash with MemBufInputSource is also a bug in your code.  Take a 
look at the documentation for Wrapper4InputSource:

  /**
    * Constructor
    *
    * Wrap a SAX InputSource and pretend it to be a DOMInputSource.
    * By default, the wrapper will adopt the SAX InputSource that is wrapped.
    *
    * @param  inputSource  The SAX InputSource to be wrapped
    * @param  adoptFlag    Indicates if the wrapper should adopt the wrapped
    *                      SAX InputSource. Default is true.
    * @param manager The MemoryManager to use to allocate objects
    */

Note that you've allowed the last two parameters to be set to their defaults.  
The second one, when "true," tells the Wrapper4InputSource to adopt the 
InputSource instance you pass in.  As a result, it deletes the InputSource 
instance in its destructor, so you try to delete a MemBufInputSource instance 
that is already deleted.

Please make sure you read the documentation for the classes you are using very 
carefully, and post any questions you have to the user list.

> pure virtual function error
> ---------------------------
>
>          Key: XERCESC-1554
>          URL: http://issues.apache.org/jira/browse/XERCESC-1554
>      Project: Xerces-C++
>         Type: Bug
>   Components: DOM
>     Versions: 2.4.0
>  Environment: Windows XP SP2 
>     Reporter: Eric Swanson
>  Attachments: TestXercesProject.zip
>
> Our application is multi-threaded and com based on a win 32 platform.
> We have a function in our application that has a character string that is a 
> correctly made xml string.  When attempting to load it (xml string) into the 
> xerces dom document, as this function is called, Xerces comes up with a pure 
> virtual function error.  The service needs to have several dom documents in 
> existance at the same time on different threads.  Is this possible using 
> Xerces?  
> When we upgraded to 2_7, the problem was worse.  How can we ensure that each 
> DOM document is separate from each other and not depended on the other 
> document.
> What is the proper api calls to create a xerces dom document from a character 
> array?
> Thanks
> Eric

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to