Computer Hater
4th May 2011, 21:16
Hi,
I seem to have a problem with the gdb debugger in combination with the QVector class.
I have Qt SDK 1.1 RC installed on my laptop with Windows Vista Home Edition.
Here is what happened:
My program crashed, so I debugged it. When it crashes during debugging, I get the attached error message. (I get a different one when I just run it.) The build configuration is set to Debug.
I traced the error back to the destructor of a custom class that has two QVector<int> member variables. Apparently, the error happens when a QVector instance is destroyed as part of the destruction of that class.
Now, when I go through the debugging step by step I get a strange behaviour. I suppose this is related to the crash:
The QVector<int> instances get set normally and their values are accessible through the watcher list. They are actually part of a larger class structure, going up a few levels. Then, when I append the topmost object of this structure (object "newsp" of class Species in the code below) to another QVector, the values of the int vectors are suddenly not accessible anymore. They are shown as 'not accessible' and when I click on them the note changes to 'unavailable synchronous data'.
This is shown both for the original object that I pass to the append routine of QVector and the newly created element of the QVector.
The segment of code in which the error happens is this:
do
{
Species newsp(chem, file, grnames); // create the Species object
if (newsp.valid) spec.append(newsp);
else break;
} while (true);
I'm assuming that QVector::append creates a copy of the object, so it shouldn't matter that the object is created only locally. Even if so, the error appears the very next line after the append command, not just when the loop is looped.
Also, the following code using a pointer causes the exact same problem:
Species* newsp;
do
{
newsp = new Species(chem, file, grnames); // create the Species object
if (newsp->valid) spec.append(*newsp);
else break;
} while (true);
The error appears in the very first iteration of the loop, so no successful instances before that.
I tried to reproduce the error in a trimmed sample program with a QVector<int> object inside another class' object that is then added to a QVector of the topmost class type, but it doesn't appear.
Now I could approach the two versions step by step, but it seemed better to ask first if someone can identify the problem from this description.
Added after 6 minutes:
This is the error I get for a regular program run.
(Edit: the runtime library error. The two posts were merged.)
Also, could it matter that I'm keeping the file open during the loop that I'm reading the Species objects from ?
I seem to have a problem with the gdb debugger in combination with the QVector class.
I have Qt SDK 1.1 RC installed on my laptop with Windows Vista Home Edition.
Here is what happened:
My program crashed, so I debugged it. When it crashes during debugging, I get the attached error message. (I get a different one when I just run it.) The build configuration is set to Debug.
I traced the error back to the destructor of a custom class that has two QVector<int> member variables. Apparently, the error happens when a QVector instance is destroyed as part of the destruction of that class.
Now, when I go through the debugging step by step I get a strange behaviour. I suppose this is related to the crash:
The QVector<int> instances get set normally and their values are accessible through the watcher list. They are actually part of a larger class structure, going up a few levels. Then, when I append the topmost object of this structure (object "newsp" of class Species in the code below) to another QVector, the values of the int vectors are suddenly not accessible anymore. They are shown as 'not accessible' and when I click on them the note changes to 'unavailable synchronous data'.
This is shown both for the original object that I pass to the append routine of QVector and the newly created element of the QVector.
The segment of code in which the error happens is this:
do
{
Species newsp(chem, file, grnames); // create the Species object
if (newsp.valid) spec.append(newsp);
else break;
} while (true);
I'm assuming that QVector::append creates a copy of the object, so it shouldn't matter that the object is created only locally. Even if so, the error appears the very next line after the append command, not just when the loop is looped.
Also, the following code using a pointer causes the exact same problem:
Species* newsp;
do
{
newsp = new Species(chem, file, grnames); // create the Species object
if (newsp->valid) spec.append(*newsp);
else break;
} while (true);
The error appears in the very first iteration of the loop, so no successful instances before that.
I tried to reproduce the error in a trimmed sample program with a QVector<int> object inside another class' object that is then added to a QVector of the topmost class type, but it doesn't appear.
Now I could approach the two versions step by step, but it seemed better to ask first if someone can identify the problem from this description.
Added after 6 minutes:
This is the error I get for a regular program run.
(Edit: the runtime library error. The two posts were merged.)
Also, could it matter that I'm keeping the file open during the loop that I'm reading the Species objects from ?