Borse, Ganesh wrote:
Hi,
I recently upgraded our C++ application to Xerces-c-3.0.1 (from xerces
2.8).
This application parses the xml information using XercesDOMParser and
then gets the DOMDocument pointer using getDocument() method.
Application is aborting with "pure virtual function called" when the
(DOMNode*)doc->getDocumentElement() is called on this DOMDocument
pointer.
This cast is not necessary.
Stack traces in GDB are shown below:
#0 0x00002aeeffeb6b95 in raise () from /lib64/libc.so.6
#1 0x00002aeeffeb7f90 in abort () from /lib64/libc.so.6
#2 0x00002aeefc89fda4 in __gnu_cxx::__verbose_terminate_handler () at
../../.././libstdc++-v3/libsupc++/vterminate.cc:98
#3 0x00002aeefc89dd96 in __cxxabiv1::__terminate (handler=0x693e) at
../../.././libstdc++-v3/libsupc++/eh_terminate.cc:43
#4 0x00002aeefc89ddc3 in std::terminate () at
../../.././libstdc++-v3/libsupc++/eh_terminate.cc:53
#5 0x00002aeefc89e41f in __cxa_pure_virtual () at
../../.././libstdc++-v3/libsupc++/pure.cc:55
========================================================================
===
ECXMLMessage (this=0x7fff87ae9950, doc=0xc20080) at
./src/ecxmlmessage.cpp:35
35 : m_doc(doc)
(gdb)
42 DOM_NodeFilter::SHOW_DOCUMENT ;
(gdb)
44 rootElem_ = doc->getDocumentElement();
(gdb) print doc
$1 = (class xercesc_3_0::DOMDocument *) 0xc20080
(gdb) print *doc
$2 = {<xercesc_3_0::DOMDocumentRange> = {_vptr.DOMDocumentRange =
0x2b7d26fac7f0}, <xercesc_3_0::DOMXPathEvaluator> = {
_vptr.DOMXPathEvaluator = 0x0}, <xercesc_3_0::DOMDocumentTraversal>
= {_vptr.DOMDocumentTraversal = 0x0}, <xercesc_3_0::DOMNode> = {
_vptr.DOMNode = 0x0}, <No data fields>}
(gdb) next
pure virtual method called
terminate called without an active exception
Program received signal SIGABRT, Aborted.
0x00002b7d2691bb95 in raise () from /lib64/libc.so.6
This is quite obvious because DOMDocument, DOMNode are abstract classes.
They are abstract base classes which are implemented by DOMDocumenImpl,
which is the class you should be getting, as long as the pointer is
non-null.
What is the correct way of calling the methods of these classes?
Are there any implementation or concrete derived classes that can be
used for them?
This looks like a compiler code generation problem, or something
similar. Did you build this library yourself? If so, do the Xerces-C
sample applications work correctly?
Dave