Help... Ongoing heap corruption issue and question about main(...)

  • I have had numerous issues with heap corruption in my program all revolving around using a QTcpSocket to send login data. My most recent post regarding the matter (found "here": was resolved by using a different approach that read the data a byte at a time rather than the entire array. However, no matter how I read the object, I cannot abort or close the socket without running into the same crash that QTcpSocket.readAll() was doing. I get a "User Breakpoint" in dbgheap.c. (Method: _CrtIsValidHeapPointer(const void * pUserData)

    I am wondering if the fact that the QByteArray being sent is created in main() has anything to do with it (using the new keyword). Does the main() method, the QMainWindow, and QApplication objects all share the same heap? or does the main() method use its own heap for anything created with the new keyword? Do namespaces have anything to do with it? Do namespaces each have their own heap?

  • The above issue doesn't seem to be the problem. I moved the entire method to the mainwindow class so that no objects used are created inside main().

    Another possibility that has occurred to me is that the TcpSocket actually used to send the data is located in a separate dll. Will this have a separate heap space? I will try and see if I can make copies of the objects sent across the "boundary" to avoid this possibility works. Meanwhile... if anyone has any suggestions it would be greatly appreciated.

  • Doing the above didn't help at all. I am really frustrated at this point. I cannot figure this out. In every other way than the things I have explained above, this part of my code matches the examples in the fortune cookie server/client pair. Could this be some sort of bug?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.