0

I have a program that makes heavy use of QSharedPointer. When I execute my program it runs fine, but when I debug it with GDB it starts throwing errors. "Invalid Address specified to RtlFreeHeap" is thrown in the following code:

QSharedPointer<PersistentList> p = 
   PersistentList::createEx(wrap("abc")).dynamicCast<PersistentList>();    

QSharedPointer<IPersistentCollection> c = p->empty(); // Error thrown after this line    

QSharedPointer<IPersistentCollection> ASeq::empty()
{
    return QSharedPointer<EmptyList>(new EmptyList());
}

If I disable the p->empty() line the program runs just fine. Any ideas?

demonplus
  • 5,613
  • 12
  • 49
  • 68
Timothy Baldridge
  • 10,455
  • 1
  • 44
  • 80
  • I'm a little confused. when I read your code, as p is based on a list, then doesn't p->empty() return a bool rather than a pointer? – photo_tom Sep 23 '10 at 02:23
  • Yeah, that would make sense, but actually in this case p->empty() returns an empty list....I should probably rename the function as it's only ever used for testing. – Timothy Baldridge Sep 23 '10 at 02:26
  • What createEx does? Could you post it's body? Also more code context would be helpful. It seems that you have minor memory managment error – Kamil Klimek Sep 24 '10 at 21:43
  • Well as mentioned above if I comment the 2nd line the error doesn't occur. Since that line does not actually touch p at all, it can't really be a problem with createEx.... – Timothy Baldridge Sep 27 '10 at 13:34

1 Answers1

0

The problem is likely elsewhere in your code. Run it under Valgrind and see if you're touching any memory that's not yours, or using uninitialized data, etc.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313