PDA

View Full Version : Invalid Address specified to RtlFreeHeap



abrou
15th August 2008, 22:59
Hello,

I am getting the following run-time error when I try to create a QDomDocument:


HEAP[RoboExtract.exe]: Invalid Address specified to RtlFreeHeap( 00BD0000, 00CA7EC8 )
Windows has triggered a breakpoint in RoboExtract.exe.

This may be due to a corruption of the heap, which indicates a bug in RoboExtract.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while RoboExtract.exe has focus.

The output window may have more diagnostic information.
The program '[5528] RoboExtract.exe: Native' has exited with code 0 (0x0).

I originally copied the code from another project of mine, which has no trouble compiling.

I tried different parts of the code, and I believe that it starts to occur when I create a QDomDocument:


void RoboExtract::openDocument(QString dir, QString docName) //opens and returns document
{
QDir::setCurrent(dir);
qDebug()<< QDir::currentPath();
QDomDocument doc("mydocument"); //<----If I comment all other lines but this one, I still get the error
QFile file;
file.setFileName(docName);
qDebug()<<"file name:"<<file.fileName();
qDebug()<<"directory:" << dir;
if (!file.open(QIODevice::ReadOnly)){ return doc;}
if (!doc.setContent(&file)) { file.close();
return doc;
}
file.close();

return;
}

The runtime error doesn't happen until we return to the function that originally called it:


void RoboExtract::readFiles(QDir directory, QString parameter)
{
...
openDocument(dir, docName); //function that was called (above)
return; //<--when I step through, this is where the error pops up
}

The includes are:


#include "RoboExtract.h"
#include <QApplication>
#include <QTextStream>
#include <QDir>
#include "qdom.h"
#include <QtDebug>

And if I click continue when this error pops up, it continues running without anymore trouble...

Has anyone else experienced this? Thanks!

edit: I am using Windows XP, Visual C++ 2008 express and Qt 4.4.1

abrou
15th August 2008, 23:10
It never fails, I try to find a solution for a day and a half. I post my problem, then a few minutes later I solved it. For some reason QDomDocument doesn't like to be created implicitly (right term?).

I changed:


QDomDocument doc("mydocument");
to


QDomDocument doc;

But, now I am wondering if anyone knows why it won't let me declare doc that way. I have my code working....but why? Thanks!

jacek
16th August 2008, 20:44
But, now I am wondering if anyone knows why it won't let me declare doc that way. I have my code working....but why?
It might be a bug in Qt.

BullDozers
12th September 2008, 10:44
I had a similar problem with RtlFreeHeap (completely different code/project, Qt 4.4.0). After much very frustrating debugging in attached Release mode, finally traced it to creating QDomDocument with a QString parameter.

Platform: Win XP SP3, Qt opensource 4.4.1, release multithreaded

I should try it with 4.4.1, maybe it was fixed.

mlt
23rd June 2011, 19:00
I know it is quite an old thread, but I'm having similar issue and I'm new to Qt.

I'm trying to clean up legacy code (a QGis plugin) that uses Qwt as it never deallocates malloc'ed memory as well as doesn't delete after new. I know there is a separate thread for Qwt, but I thought it is a general error and is related to memory management.

AFAIK Qt uses some kind of memory management to clean up children objects through ownership.

I tried to pin point the problem and in the essence it is the following. I don't understand why this

{
QwtPlotCurve c;
}
works while

QwtPlotCurve* tmp = new QwtPlotCurve;
delete tmp;does not and generates that exception upon delete. How can I clean up stuff from the heap as I don't provide any parent data?

Another weird thing is that if I change it to

QDialog *d = new QDialog;
delete d;
QwtPlotCurve* tmp = new QwtPlotCurve;
delete tmp;. Then I get no exception at all. I'm totally lost.

I'm using OSGeo for Windows distribution that includes Qt 4.7.1 and Qwt 5.2.1.

Ostropik
7th January 2018, 11:06
In my case it was next:

1. By mistake in my sources was used two classes with the same name
2. One class was hidden into CPP , other had normal view header and CPP implementation.
3. It was compilled without error but in some case segmentation fault signal was appeared)