-1

In the following code, when constructing the string url, the execution halts. No error, the execution doesn't stop, it just hangs there, and I can't press step over. Everything seems fine in the debugger, no nullpointers, the baseURL is set properly. RapidXML's value() function returns char*.

Am I missing something?

With Eclipse Indigo on Ubuntu 12.04

    rapidxml::xml_node<> *galleryNode = myNode->first_node("gallery");
    std::string baseURL = galleryNode->first_attribute("url")->value();
    galleryNode = galleryNode->first_node("filename");
    while ( galleryNode != NULL )
    {
        std::string url(baseURL);
        url.append(galleryNode->value());
        gallery.AddImageUrl(url);
        galleryNode = galleryNode->next_sibling();
    }
Innkeeper
  • 663
  • 1
  • 10
  • 22
  • What does "halts" mean? Does it crash, exit, just sit there "forever"? What happens if you print "baseUrl"? – Mats Petersson Apr 18 '13 at 12:50
  • @MatsPetersson sorry, I edited. It just sits there. Debugger says baseURL is correct. "http://aproperurl.com" – Innkeeper Apr 18 '13 at 12:51
  • From the code you've posted that's an infinte while loop because galleryNode is never NULL. Maybe that's what is happening. – john Apr 18 '13 at 12:52
  • So do you ever move `galleryNode` along? – BoBTFish Apr 18 '13 at 12:52
  • @john Then stepping over should just jump to the next line i believe. But it doesn't do that. In fact, the only button that does something, is "terminate". – Innkeeper Apr 18 '13 at 12:54
  • @BoBTFish The whole loop is there now. – Innkeeper Apr 18 '13 at 12:58
  • Did you try do display the value of baseURL to see if it makes sense? – Ale Apr 18 '13 at 13:08
  • @Ale yes, it's exactly what is in the xml. With changed domain and company name: `http://ab.cd.com/company/public_html/gallery/597235/` – Innkeeper Apr 18 '13 at 13:16
  • @Innkeeper The only thing I can think of is heap corruption. Unfortunately that could have happened anywhere, it doesn't have to be the code above that is wrong (nor is there anything obviously wrong with the code above). – john Apr 18 '13 at 13:31
  • @john Thanks for the suggestion. I don't know much about that. How would I confirm or deny? And would that mean that it hangs at that same statement every time? – Innkeeper Apr 18 '13 at 13:35
  • @Innkeeper Ubuntu is not my area unfortunately but you could try a tool like valgrind for detecting memory errors. – john Apr 18 '13 at 13:52
  • Hm, i tried to insert this line inside the loop, and the same thing happens: `std::string test = "test";` – Innkeeper Apr 18 '13 at 13:57
  • @Innkeeper It does suggest heap corruption. The heap is in such a state that any attempt to allocate more memory crashes/freezes the program. – john Apr 18 '13 at 13:59
  • @john I don't know if that happened or not, but if it did, the python enabled gdb lead to it. – Innkeeper Apr 18 '13 at 14:07

1 Answers1

0

The cause was the python enabled gdb in eclipse. I downloaded it with svn, then altered the gdbinit file. Viewing variables was much easier while debugging, but apparently it has quite annoying side effects.

Innkeeper
  • 663
  • 1
  • 10
  • 22