Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-20-2004, 05:47 AM   #1
LQ Newbie
Registered: May 2004
Distribution: Slackware
Posts: 11

Rep: Reputation: 0
libxml++: segmentation fault when exiting program.

I'm trying to implement a simple xml-reader in c++ using libxml++. So far i've manged to open the xml-document, print the relevant parts and then exit. the problem is that i get a segmentation fault when exiting.

int main() 
   Glib::ustring file_name = "test.xml";
    xmlpp::DomParser test(file_name);
    xmlpp::Document* test_xml = test.get_document();
    xmlpp::Element*  root_node = test_xml->get_root_node();
    xmlpp::Element::NodeList children = root_node->get_children(Glib::ustring("item"));
    xmlpp::Element::NodeList::iterator i;
    i = children.begin();
    while (i != children.end())
              xmlpp::Element::NodeList item_list = (*i)->get_children(Glib::ustring("title"));
              xmlpp::Element::NodeList::iterator g;
              g = item_list.begin();
              while (g!=item_list.end())
                      if (xmlpp::Element((*g)->cobj()).has_child_text())
                          xmlpp::Element test((*g)->cobj());
                          cout << (test.get_child_text())->get_content() << endl;
Is there something missing? Do i have to close the specific document in some way? gdb outputs:

#0  0x40243eaf in _int_free () from /lib/
#1  0x40242cdf in free () from /lib/
#2  0x4017cd75 in operator delete (ptr=0x433318)
    at ../../../../gcc-3.3.3/libstdc++-v3/libsupc++/
#3  0x400ee2cf in xmlpp::NonCopyable::~NonCopyable ()
   from /usr/lib/
#4  0x400ed588 in (anonymous namespace)::on_libxml_destruct ()
   from /usr/lib/
#5  0x4037d200 in xmlFreeNodeList () from /usr/lib/./
#6  0x4037d0c1 in xmlFreeNodeList () from /usr/lib/./
#7  0x4037d0c1 in xmlFreeNodeList () from /usr/lib/./
#8  0x4037ad2d in xmlFreeDoc () from /usr/lib/./
#9  0x400ed86b in xmlpp::Document::~Document () from /usr/lib/
#10 0x0804901b in main () at test.cpp:36
so obviously there is something wrong with how the destructor works?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
why segmentation fault in this program? asahlot Programming 13 10-17-2005 12:47 PM
Wine wont start program, segmentation fault, artsdsp nontoxic Linux - Software 3 03-21-2005 06:27 AM
Program received signal SIGSEGV, Segmentation fault ims_mca Linux - Distributions 0 03-09-2005 04:16 AM
Why do i get segmentation fault upon exiting main() J-Ral Programming 5 05-28-2004 04:27 AM
"segmentation fault" when run a simple c program acer_peri Programming 11 05-28-2004 04:14 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration